:root {
  --bg: #0f1013; --panel: #17191d; --panel2: #1e2126; --line: #2a2e35; --fg: #e9e7e1; --muted: #9298a0;
  --accent: #e8743b; --ok: #6cc28a; --bad: #e0675b;
}
/* tema chiaro (pulsante ☀/🌙 nella barra dei menu): le viste tecniche (PCB, 3D, simulatore, codice) restano scure */
:root[data-theme="light"] {
  --bg: #f4f3ef; --panel: #ffffff; --panel2: #eceae4; --line: #d9d6cd; --fg: #1d1f23; --muted: #6b7079;
  --ok: #2f8a5b; --bad: #c94a3e;
}
:root[data-theme="light"] .m-user { background: #e7e4dc; }
:root[data-theme="light"] .m-ai code { background: #0000000f; }
:root[data-theme="light"] .ask { border-color: #e8c9b4; background: #fdf1e8; }
:root[data-theme="light"] .ask button { background: #ffffffb0; }
:root[data-theme="light"] #nokey { border-color: #e6b5ad; background: #fbe9e6; }
:root[data-theme="light"] #input:focus { border-color: #b9b5ab; }
:root[data-theme="light"] .mdrop .danger { color: #c94a3e; }
:root[data-theme="light"] .mdrop { box-shadow: 0 14px 40px -8px #0003; }
:root[data-theme="light"] .badge.ok { background: #dff1e6; } :root[data-theme="light"] .badge.bad { background: #f8e0dd; }
:root[data-theme="light"] .badge.run { background: #f7efd2; color: #9a7a10; }
:root[data-theme="light"] #opendlg::backdrop, :root[data-theme="light"] #consentdlg::backdrop { background: #0005; }
/* comandi che galleggiano sulle viste scure: restano col tema scuro */
:root[data-theme="light"] :is(.pcbmenu, .simsel, .viewsel, .probebar, .insttoggle) {
  --fg: #e9e7e1; --panel: #17191d; --panel2: #1e2126; --line: #2a2e35; --muted: #9298a0; color: var(--fg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; grid-template-rows: 40px minmax(0, 1fr); background: var(--bg); color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* barra dei menu (File, Schede) */
#menubar { grid-column: 1 / -1; display: flex; align-items: center; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: relative; z-index: 30; }
#menubar .brand { display: flex; align-items: center; gap: 7px; margin-right: 12px; font-size: 14.5px; }
#menubar .acc { color: var(--accent); }
.logo { width: 24px; height: 24px; display: block; }
.menu { position: relative; }
.mtop { background: none; border: 0; padding: 5px 10px; border-radius: 6px; color: var(--fg); }
.menu.open > .mtop, .mtop:hover { background: var(--panel2); }
.mdrop { display: none; position: absolute; left: 0; top: calc(100% + 4px); min-width: 230px; padding: 5px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 14px 40px -8px #000c; }
.menu.open > .mdrop { display: block; }
.mdrop button, .mdrop a { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0;
  padding: 6px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; font-size: 13.5px; white-space: nowrap; }
.mdrop button:hover:not(:disabled), .mdrop a:hover, .msub.open > .mhas { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.mdrop button:disabled { color: var(--muted); cursor: default; }
.mdrop kbd { margin-left: auto; font: 11.5px system-ui, sans-serif; color: var(--muted); }
.mdrop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.mdrop .danger { color: #f2a197; }
.mdrop .note { padding: 6px 10px 4px; font-size: 11.5px; color: var(--muted); white-space: normal; max-width: 300px; }
.msub { position: relative; }
.mhas::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 15px; }
.mdrop.side { left: calc(100% + 3px); top: -6px; }
/* liste lunghe (es. Moduli > Sensori): scorrono dentro la finestra */
#m-mods .mdrop.side { max-height: calc(100vh - 90px); overflow-y: auto; }
/* Schede: il sottomenu parte dall'alto della tendina delle marche (Elecrow in basso aveva le ultime schede fuori) */
#m-brands .msub { position: static; }
#m-brands .mdrop.side { top: 0; max-height: calc(100vh - 70px); overflow-y: auto; }
/* ricerca in cima ai menu Schede e Moduli, etichette dei gruppi */
.msearch { padding: 3px 3px 6px; }
.msearch input { width: 100%; box-sizing: border-box; background: var(--panel); border: 1px solid var(--line); color: var(--fg);
                 border-radius: 6px; padding: 6px 9px; font: inherit; font-size: 13px; }
.mres { max-height: calc(100vh - 150px); overflow-y: auto; margin-top: 4px; }
.mlabel { padding: 6px 10px 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
/* miniatura della voce sotto il mouse: foto del prodotto o modello 3D */
#mthumb { position: fixed; z-index: 1000; width: 240px; height: 180px; padding: 6px; background: #fff; border-radius: 10px;
          box-shadow: 0 14px 40px -8px #000a; pointer-events: none; opacity: 0; transition: opacity .12s; }
#mthumb.on { opacity: 1; }
#mthumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.msub.open > .mdrop.side { display: block; }
.mhas .soon { margin-left: 4px; font-size: 11px; color: var(--muted); }
.bd { display: grid !important; grid-template-columns: 1fr auto; gap: 0 14px; }
.bd small { grid-column: 1; color: var(--muted); font-size: 11.5px; white-space: normal; max-width: 260px; }
.bd .chip { color: var(--muted); font-size: 11.5px; }
/* negozio ufficiale della scheda, nella distinta */
.bom a.buy { white-space: nowrap; font-size: 12.5px; color: var(--accent); text-decoration: none; }
.bom a.buy:hover { text-decoration: underline; }
.mspace { flex: 1; }
#savestate { font-size: 12px; margin-right: 10px; }
#credbar { display: flex; flex-direction: column; gap: 3px; align-items: stretch; min-width: 92px; margin: 0 8px 0 4px;
  color: var(--muted); text-decoration: none; font-size: 11px; line-height: 1; }
#credbar:hover { color: var(--fg); }
#credbar .cbt { text-align: right; white-space: nowrap; }
#credbar .cbb { height: 5px; border-radius: 3px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; }
#credbar .cbb i { display: block; height: 100%; width: 100%; border-radius: 3px; transition: width .4s, background .4s; }
@media (max-width: 700px) { #credbar { min-width: 60px; margin: 0 4px; } #credbar .cbt { font-size: 10px; } }
#account { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); font-size: 13px; font-weight: 600; padding: 0; }

/* finestra Apri */
#opendlg, #consentdlg { padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--fg); width: min(560px, 94vw); }
#opendlg::backdrop, #consentdlg::backdrop { background: #000a; }
.dlg header { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dlg header .x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 15px; }
#opensearch { display: block; width: calc(100% - 28px); margin: 12px 14px 6px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font: inherit; }
#openlist { max-height: min(60vh, 520px); overflow-y: auto; padding: 4px 8px 10px; }
#openlist button { display: flex; gap: 12px; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; }
#openlist button:hover, #openlist button:focus { background: var(--panel2); outline: none; }
#openlist button.on b::after { content: " · aperto"; color: var(--accent); font-weight: 400; font-size: 12px; }
#openlist b { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#openlist span { color: var(--muted); font-size: 12px; white-space: nowrap; }
#welcome .hint { margin-top: 14px; }

/* chat */
#chatcol { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; min-height: 0; overflow: hidden; }
#chatcol header { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; }
#title { flex: 1; min-width: 0; background: none; border: 0; color: var(--fg); font-weight: 600; font-size: 15px; }
#model, #vmodel, #reason { max-width: 170px; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
#msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.m-user { align-self: flex-end; background: #f3f1ec; color: #1a1a1a; padding: 8px 12px; border-radius: 12px; max-width: 88%; white-space: pre-wrap; }
.m-ai { background: var(--panel); border: 1px solid var(--line); padding: 8px 12px; border-radius: 12px; max-width: 100%; overflow-x: auto; }
.m-ai p { margin: .35em 0; } .m-ai ul, .m-ai ol { margin: .3em 0; padding-left: 1.3em; }
.m-ai table { border-collapse: collapse; font-size: 12.5px; margin: 6px 0; }
.m-ai td, .m-ai th { border: 1px solid var(--line); padding: 3px 6px; }
.m-ai code { background: #0006; padding: 0 4px; border-radius: 4px; }
.steps { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; }
.step { display: flex; gap: 7px; align-items: baseline; color: var(--muted); }
.step .ic { width: 14px; flex: none; text-align: center; }
.step.ok .ic { color: var(--ok); } .step.bad .ic { color: var(--bad); }
.step .sum { color: #6f757c; margin-left: auto; padding-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: r 0.8s linear infinite; }
@keyframes r { to { transform: rotate(360deg); } }
.progress { font: 12px ui-monospace, Consolas, monospace; color: #6f757c; padding-left: 21px; }
.ask { border: 1px solid #5a3a28; background: #22170f; border-radius: 12px; padding: 10px; }
.ask .q { margin-bottom: 8px; }
.ask button { display: block; width: 100%; text-align: left; background: #0003; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 5px 0; }
.ask button:hover:not(:disabled) { border-color: var(--accent); }
.ask button small { display: block; color: var(--muted); }
.ask button:disabled { opacity: .55; cursor: default; }
.err { color: var(--bad); font-size: 13px; }
#welcome { padding: 18px 16px; overflow-y: auto; }
#welcome h2 { margin: 0 0 6px; font-size: 19px; }
#welcome p { color: var(--muted); margin: 0 0 12px; }
.examples button { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.examples button:hover { color: var(--fg); border-color: var(--accent); }
#nokey { margin: 0 12px 8px; padding: 8px 10px; border: 1px solid #6b3b35; background: #2a1715; border-radius: 8px; font-size: 13px; }
#form { position: relative; margin: 8px 12px 12px; }
#input { width: 100%; resize: none; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 46px 10px 12px; font: inherit; }
#input:focus { outline: none; border-color: #4a4f57; }
#send { position: absolute; right: 8px; bottom: 9px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 16px; }
#send:disabled { opacity: .4; }
#attach { position: absolute; right: 44px; bottom: 9px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); font-size: 14px; }
#attach:hover { border-color: var(--accent); }
#input { padding-right: 84px; }
#thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
#thumbs:not(:empty) { margin-bottom: 6px; }
#thumbs .th { position: relative; }
#thumbs img { height: 54px; border-radius: 6px; border: 1px solid var(--line); display: block; }
#thumbs button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; padding: 0; }
#chatcol.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.m-user .pics { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.m-user .pics img { max-height: 120px; max-width: 100%; border-radius: 8px; cursor: zoom-in; }

/* area di lavoro */
#work { display: flex; flex-direction: column; min-width: 0; }
#tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
#tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; color: var(--muted); }
#tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
#tabs button.new::after { content: " •"; color: var(--accent); }
#panes { flex: 1; position: relative; min-height: 0; }
.pane { position: absolute; inset: 0; display: none; }
.pane.on { display: block; }
.pane.scroll { overflow: auto; padding: 16px 20px; }
.zoom { position: absolute; inset: 12px; overflow: hidden; border-radius: 10px; cursor: grab; }
.zoom.white { background: #f5f4ee; }
.zoom.pcbbg { background: #0c1a12; }
.zoom img { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.zoom img:not([src]) { display: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: #555b62; pointer-events: none; }
.pcbsel { position: absolute; z-index: 2; right: 22px; top: 22px; display: flex; gap: 4px; }
.pcbsel button { background: #000a; border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; font-size: 12px; }
.pcbsel button.on { border-color: var(--accent); }
#p-display iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
#p-3d iframe { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); border: 0; border-radius: 10px; background: #14161a; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; margin-left: 6px; }
.badge.ok { background: #1d3a27; color: var(--ok); } .badge.bad { background: #3a1d1d; color: var(--bad); } .badge.na { background: var(--panel2); color: var(--muted); }
.badge.run { background: #3a331d; color: #f2c94c; }
.card ul { margin: 4px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
table.bom { border-collapse: collapse; width: 100%; font-size: 13px; }
table.bom th, table.bom td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; }
table.bom th { color: var(--muted); font-weight: 500; }
table.bom td.why { color: var(--muted); font-size: 12px; max-width: 360px; }
a.dl { display: inline-block; margin: 4px 8px 4px 0; padding: 7px 12px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--fg); text-decoration: none; }
a.dl:hover { border-color: var(--accent); }
/* scheda File: documento con la copertina e file in colonna */
.fdoc { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.fcover { position: relative; width: 190px; aspect-ratio: 210 / 297; padding: 0; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: #f4efe6; cursor: zoom-in; box-shadow: 0 10px 28px -12px #0009; transition: transform .15s; flex: none; }
.fcover:hover { transform: translateY(-2px) scale(1.02); }
.fcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fcover .fzoom { position: absolute; left: 0; right: 0; bottom: 0; padding: 7px; background: #000a; color: #fff; font-size: 13px; opacity: 0; transition: opacity .15s; }
.fcover:hover .fzoom { opacity: 1; }
.fcover .fwait { display: none; position: absolute; inset: 0; place-items: center; color: #6f757c; font-size: 13px; }
.fcover.wait img { display: none; } .fcover.wait .fwait { display: grid; }
.fdesc { flex: 1; min-width: 220px; } .fdesc p { color: var(--muted); margin: 6px 0 14px; }
.fbtns { display: flex; gap: 10px; flex-wrap: wrap; }
.fbtn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--fg); text-decoration: none; font: inherit; cursor: pointer; white-space: nowrap; }
.fbtn:hover { border-color: var(--accent); } .fbtn.main { background: var(--accent); border-color: var(--accent); color: #fff; }
.flist .frow { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-top: 1px solid var(--line); }
.flist h3 + .frow { border-top: 0; }
.fico { font-size: 26px; width: 36px; text-align: center; flex: none; }
.ftxt { flex: 1; min-width: 0; display: flex; flex-direction: column; } .ftxt small { color: var(--muted); }
#docprev { width: min(960px, 96vw); height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--fg); }
#docprev::backdrop { background: #000a; }
.dphead { position: sticky; top: 0; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel2); border-bottom: 1px solid var(--line); }
.dphead b { flex: 1; } .dphead .x { background: none; border: 0; color: var(--fg); font-size: 18px; cursor: pointer; }
.dppages { height: calc(92vh - 58px); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 14px; background: #2a2d31; }
.dppages img { width: 100%; max-width: 860px; background: #fff; box-shadow: 0 6px 20px -8px #000; border-radius: 2px; }
@media (max-width: 600px) { .fcover { width: 140px; } .flist .frow { flex-wrap: wrap; } .flist .fbtn { margin-left: 50px; } }

@media (max-width: 700px) {
  body { grid-template-columns: 1fr; grid-template-rows: 40px 60vh 70vh; overflow-x: hidden; overflow-y: auto; height: auto; }
  /* le schede (Schema, PCB, 3D...) scorrono di lato da sole: prima allargavano tutta la pagina */
  #tabs { overflow-x: auto; scrollbar-width: none; padding: 6px 8px; }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button { flex: 0 0 auto; white-space: nowrap; }
  #work, #chatcol { min-width: 0; max-width: 100vw; }
  #p-3d iframe, #p-sim iframe { inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
  .zoom, .wiring { inset: 6px; }
  .pane.scroll { padding: 12px; }
  #menubar { position: sticky; top: 0; }
  #menubar .brand b { display: none; }
  .mdrop.side { position: static; box-shadow: none; border: 0; padding: 0 0 0 10px; background: none; }
}
.usage { align-self: flex-end; font-size: 11.5px; color: #6f757c; }
#msgs > * { flex-shrink: 0; }
#mount { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }

/* progetti a moduli */
body:not(.has-mcu) #tabs button.mcu { display: none; }
body.is-mcu #tabs button.pcb { display: none; }
body.is-mcu #tabs button[data-t="bom"] { display: none; }
.simsel { position: absolute; z-index: 2; top: 18px; right: 26px; display: flex; gap: 2px; background: #000a; border: 1px solid var(--line); border-radius: 20px; padding: 3px; }
.simsel button { background: none; border: 0; border-radius: 16px; padding: 3px 12px; color: var(--muted); font-size: 12.5px; }
.simsel button.on { background: var(--fg); color: #111; }
.simsel { transition: opacity .2s; } .simsel.hid { opacity: 0; pointer-events: none; }
.simsel button:disabled { opacity: .35; cursor: default; }
#p-sim iframe { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); border: 0; border-radius: 10px; background: #14161a; }
.wiring { position: absolute; inset: 12px; overflow: auto; border-radius: 10px; background: #101215; }
.wiring svg { display: block; margin: 0 auto; }
.wiring .wire { fill: none; stroke-width: 2.6; opacity: .9; }
.wiring .wire:hover { stroke-width: 4.5; opacity: 1; }
pre.code { background: #0b0c0e; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font: 12.5px/1.5 ui-monospace, Consolas, monospace; overflow: auto; margin: 0; }
pre.code .c { color: #6f8a6f; } pre.code .s { color: #d7b46a; } pre.code .k { color: #e8743b; } pre.code .p { color: #9cc3ff; }
table.pins { border-collapse: collapse; font-size: 13px; margin: 6px 0 12px; }
table.pins th, table.pins td { border-bottom: 1px solid var(--line); padding: 4px 10px; text-align: left; }
table.pins th { color: var(--muted); font-weight: 500; }
#send.stop { background: #3a3f47; font-size: 13px; }
#send.stop:hover { background: var(--bad); }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.usbbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
#usbprog { font-size: 13px; color: var(--muted); }
pre.usblog { background: #0b0c0e; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 12px/1.45 ui-monospace, Consolas, monospace;
  color: #b8f5c8; height: 170px; overflow: auto; margin: 8px 0 4px; white-space: pre-wrap; }
.usbsend { display: flex; gap: 6px; } .usbsend input { flex: 1; background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: 12.5px ui-monospace, Consolas, monospace; }
.hint { color: #6f757c; font-size: 12.5px; margin: 6px 0 0; }
textarea.code { width: 100%; min-height: 420px; resize: vertical; background: #0b0c0e; color: #e6e2d8; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font: 12.5px/1.5 ui-monospace, Consolas, monospace; tab-size: 2; margin-top: 8px; }
.viewsel { position: absolute; z-index: 2; top: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; background: #000a; border: 1px solid var(--line); border-radius: 20px; padding: 3px; }
.viewsel button { background: none; border: 0; border-radius: 16px; padding: 4px 14px; color: var(--muted); font-size: 13px; }
.viewsel button.on { background: var(--fg); color: #111; }
body:not(.has-mcu) .viewsel { display: none; }
.wiring { padding-top: 40px; }
body.has-spice #tabs button[data-t="sim"] { display: revert; }
/* sonde sullo schema */
.zoom .ovl { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; overflow: visible; }
#p-sch .leads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.probebar { position: absolute; z-index: 3; left: 22px; top: 22px; display: flex; gap: 4px; align-items: center; background: #000c; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
.probebar span { color: var(--muted); font-size: 12px; margin-right: 4px; }
.probebar button { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--c, #888); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.probebar button.on { background: var(--c, #555); color: #fff; }
.insttoggle { position: absolute; z-index: 3; right: 22px; top: 22px; background: #000c; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.insttoggle.on { color: #fff; border-color: var(--accent); }
.probebar .regen { display: none; border-left-color: var(--accent); }
.probebar.nomap .regen { display: inline-block; }
.probebar.nomap button[data-p] { display: none; }
.card.history { margin-top: 18px; }
.card.history button.restore { font-size: 12px; padding: 3px 10px; cursor: pointer; background: var(--panel2);
  color: var(--fg); border: 1px solid var(--line); border-radius: 6px; }
.card.history button.restore:hover { border-color: var(--accent); color: var(--accent); }

/* pallino di stato del pulsante Compila: grigio = da compilare, giallo lampeggiante = in corso, verde = ok, rosso = errori */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 5px var(--ok); }
.dot.bad { background: var(--bad); box-shadow: 0 0 5px var(--bad); }
.dot.run { background: #f2c94c; box-shadow: 0 0 6px #f2c94c; animation: lampeggia .8s ease-in-out infinite; }
@keyframes lampeggia { 50% { opacity: .2; } }

/* ---- cantiere: tappe, componenti per blocco e piste animate mentre lo schema non c'e' ancora ---- */
/* banco da maker: carta a quadretti (5 mm, con la riga piu' scura ogni 5), scritte a mano, piste a matita */
.cantiere { --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Neue", cursive;
  position: absolute; inset: 0; z-index: 10; overflow: auto; padding: 18px 22px; color: #2c3440;
  background-color: #fdfdfa;
  background-image: linear-gradient(#c9d9ec 1px, transparent 1px), linear-gradient(90deg, #c9d9ec 1px, transparent 1px),
    linear-gradient(#e4ecf5 1px, transparent 1px), linear-gradient(90deg, #e4ecf5 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; background-position: -1px -1px; }
.cantiere .traces { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cantiere .traces path { fill: none; stroke: #3d5f8f; opacity: .16; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 2400; stroke-dashoffset: 2400; animation: traccia 12s ease-in-out infinite; }
.cantiere .traces circle { fill: none; stroke: #3d5f8f; stroke-width: 2; opacity: .18; }
@keyframes traccia { 0% { stroke-dashoffset: 2400; } 55%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -2400; } }
.c-head, .c-blocks { position: relative; }
.c-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 0; padding: 0; margin: 0 0 6px; }
.c-steps li { display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; font-size: 13px; color: #8a8f98; position: relative; }
.c-steps li + li::before { content: ""; width: 18px; height: 2px; background: #d6d3ca; margin-right: 6px; }
.c-steps .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c9c6bd; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.c-steps li.run { color: #2a2f37; font-weight: 600; }
.c-steps li.run .dot { border-color: var(--accent); background: var(--accent); animation: pulsa 1.2s ease-in-out infinite; }
.c-steps li.ok { color: #3c4048; } .c-steps li.ok .dot { border-color: #3f9a62; background: #3f9a62; }
.c-steps li.bad .dot { border-color: #d0574b; background: #d0574b; }
.c-steps .nt { font-size: 11.5px; font-weight: 400; color: #6b7079; background: #ffffffb0; border-radius: 10px; padding: 1px 8px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulsa { 50% { box-shadow: 0 0 0 6px #e8743b33; } }
.c-meta { font-size: 12px; color: #8a8f98; margin: 0 0 18px 8px; }
.c-blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.c-blocks section { background: #ffffffc8; border: 1px solid #e3e0d6; border-radius: 12px; padding: 10px 12px 12px;
  box-shadow: 0 2px 10px #0000000a; backdrop-filter: blur(2px); }
.c-blocks h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; color: #3c4048; }
.c-blocks h4 small { color: #9a9ea6; font-weight: 400; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { width: 78px; display: flex; flex-direction: column; align-items: center; font-size: 11.5px; line-height: 1.25; }
.tile .bed { position: relative; width: 74px; height: 52px; border-radius: 8px; background: #f7f6f2; border: 1px solid #e6e3da;
  display: grid; place-items: center; overflow: hidden; }
.tile .art { width: 64px; height: 44px; }
.tile b { margin-top: 3px; color: #3c4048; } .tile em { font-style: normal; color: #7a7f88; max-width: 76px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.tile.off .bed { border-style: dashed; } .tile.off .art { opacity: .6; }
.tile .head { display: none; }
/* stampa: il disegno compare dal basso a strati mentre la testina va avanti e indietro, poi un piccolo assestamento */
.tile.new .art { animation: stampa 1.2s steps(12) var(--d) both, assesta .35s ease-out calc(var(--d) + 1.2s) both; }
.tile.new .head { display: block; position: absolute; left: 0; top: 0; width: 12px; height: 9px; background: #4a4f57;
  clip-path: polygon(0 0, 100% 0, 100% 55%, 62% 55%, 50% 100%, 38% 55%, 0 55%); opacity: 0;
  animation: testina 1.2s linear var(--d) both; }
.tile.new .head::after { content: ""; position: absolute; left: 5px; top: 8px; width: 2px; height: 2px; background: #e8743b; }
.tile.new b, .tile.new em { animation: compare .4s ease-out calc(var(--d) + 1.1s) both; }
@keyframes stampa { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes assesta { 0% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes compare { from { opacity: 0; } }
@keyframes testina {
  0% { opacity: 1; transform: translate(4px, 42px); } 8% { transform: translate(58px, 39px); } 17% { transform: translate(4px, 35px); }
  25% { transform: translate(58px, 31px); } 33% { transform: translate(4px, 27px); } 42% { transform: translate(58px, 23px); }
  50% { transform: translate(4px, 19px); } 58% { transform: translate(58px, 15px); } 67% { transform: translate(4px, 11px); }
  75% { transform: translate(58px, 7px); } 83% { transform: translate(4px, 3px); } 92% { opacity: 1; transform: translate(58px, -1px); }
  100% { opacity: 0; transform: translate(31px, -12px); } }
.tile .glow { opacity: .18; animation: brilla 1.8s ease-in-out infinite alternate; }
@keyframes brilla { to { opacity: .45; } }
.k-mcu { --kc: #6a4bc4; } .k-r { --kc: #b07a3a; } .k-c { --kc: #3a7bb0; } .k-led { --kc: #d0574b; } .k-d { --kc: #555; }
.k-q { --kc: #2f8a5b; } .k-l { --kc: #8a5a2f; } .k-f { --kc: #c4a020; } .k-j { --kc: #4a4f57; } .k-sw { --kc: #7a6a50; }
.k-u { --kc: #2a6f8a; } .k-s { --kc: #c46a9a; } .k-pot { --kc: #b07a3a; } .k-m { --kc: #aaa; }
/* riquadro "al lavoro" */
.cantiere { display: flex; flex-direction: column; }
.cantiere .c-steps li { font-family: var(--hand); font-size: 13.5px; }
.cantiere .c-meta { font-family: var(--hand); }
/* foglio con l'animazione (fissato con lo scotch) e diario del banco accanto */
.c-main { position: relative; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 340px); gap: 22px;
  align-items: start; min-height: 0; }
.c-stage { position: relative; background: #fffef9; border: 1px solid #ddd8c8; border-radius: 4px; padding: 18px 22px 20px;
  box-shadow: 2px 4px 0 #00000010, 0 10px 30px #0000000f; transform: rotate(-.4deg); }
.c-stage::before, .c-stage::after { content: ""; position: absolute; top: -10px; width: 86px; height: 22px;
  background: #f6e7a6b8; box-shadow: 0 1px 2px #0000001a; }
.c-stage::before { left: 18px; transform: rotate(-4deg); } .c-stage::after { right: 18px; transform: rotate(3deg); }
.c-stage-t { font-family: var(--hand); font-size: 19px; color: #2c3440; margin-bottom: 12px; }
.c-log { position: relative; max-height: calc(100vh - 210px); overflow: auto; background: #fffef9; border: 1px solid #ddd8c8;
  border-radius: 4px; padding: 10px 12px 12px 34px; transform: rotate(.5deg); box-shadow: 2px 4px 0 #00000010;
  background-image: linear-gradient(90deg, transparent 26px, #f0a8a0 26px, #f0a8a0 27px, transparent 27px),
    repeating-linear-gradient(transparent 0 23px, #d6e2f0 23px 24px); background-attachment: local; }
.c-log h4 { margin: 0 0 6px; font-family: var(--hand); font-size: 16px; font-weight: 400; color: #3d5f8f; }
.c-log ol { list-style: none; margin: 0; padding: 0; }
.c-log li { display: flex; gap: 8px; font-family: var(--hand); font-size: 12.5px; line-height: 24px; color: #2c3440;
  animation: riga .3s ease-out both; }
.c-log li time { flex: none; width: 34px; color: #9aa3ae; font-size: 11px; }
.c-log li span { min-width: 0; overflow-wrap: anywhere; line-height: 1.5; padding-top: 3px; }
.c-log .l-run { color: #b85f22; } .c-log .l-ok { color: #2f7a4d; } .c-log .l-bad { color: #c0443a; }
.c-log .l-progress { color: #7d8794; font-size: 11.5px; } .c-log .l-say { color: #3d5f8f; } .c-log .l-wait { color: #a8780f; }
.c-log .l-unlock { color: #6a4bc4; } .c-log .l-unlock span::before { content: "🔓 "; }
.c-log .l-start, .c-log .l-parts { color: #4a5563; }
@media (max-width: 900px) { .c-main { grid-template-columns: 1fr; } .c-log { max-height: 260px; } }
/* schede non ancora pronte durante il cantiere */
#tabs button.locked { opacity: .35; cursor: not-allowed; }
#tabs button.locked::before { content: "🔒 "; font-size: 10px; }
.c-stage-t::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  margin-right: 7px; animation: pulsa 1.2s ease-in-out infinite; }
.c-stage-a { height: min(400px, 55vh); }
.c-stage.fin .c-stage-t { font-size: 20px; }
.c-stage.fin .c-stage-t::before { background: #3f9a62; animation: none; }
.c-stage.fin.bad .c-stage-t::before { background: #d0543c; }
.c-stage.fin.wait .c-stage-t::before { background: #e0a030; }
.c-stage.fin.wait .c-stage-a, .c-stage.fin.bad .c-stage-a { display: none; }
.c-done { font-size: 15px; color: #4a4f57; margin: -4px 0 10px 16px; }
.c-done.hidden { display: none; }
/* progetto completato: conto alla rovescia prima di aprire il 3D, che intanto si carica impaginato ma invisibile */
.pane.preload:not(.on) { display: block; visibility: hidden; pointer-events: none; }
.c-count { display: flex; align-items: center; gap: 12px; margin: 0 0 12px 16px; font-size: 14px; color: #4a4f57; }
.c-count-t { min-width: 210px; }
.c-count-bar { flex: 1; max-width: 320px; height: 6px; border-radius: 3px; background: #e3e0d6; overflow: hidden; }
.c-count-bar i { display: block; height: 100%; width: 0; background: #3f9a62; transition: width .1s linear; }
.c-count-x { font: inherit; font-size: 13px; padding: 3px 10px; border-radius: 6px; border: 1px solid #c9c4b6;
  background: #fff; color: #4a4f57; cursor: pointer; }
.c-count-x:hover { background: #f3f0e8; }
@media (max-width: 600px) { .c-count { flex-wrap: wrap; } .c-count-t { min-width: 0; } }
.sc { width: 100%; height: 100%; display: block; }
/* libreria: finestra come il selettore dei componenti di KiCad (ricerca vera, risultati, anteprima o foto) */
.sc-lib { display: grid; grid-template-columns: minmax(0, 1fr) 260px; height: 100%; background: #fbfaf7; border: 1px solid #d8d4c8;
  border-radius: 8px; overflow: hidden; font: 13px system-ui, sans-serif; color: #2b2e33; }
.sc-lib-l { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid #e2ded3; }
.sc-q { margin: 10px; padding: 7px 10px; background: #fff; border: 1px solid #c9c4b6; border-radius: 6px; font: 13px ui-monospace, Consolas, monospace; }
.sc-q::before { content: "⌕ "; color: #8a8f98; }
.sc-q i { display: inline-block; width: 1px; height: 14px; background: #2b2e33; vertical-align: -2px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.sc-res { list-style: none; margin: 0; padding: 0 6px 8px; overflow: hidden; }
.sc-res li { display: flex; gap: 10px; align-items: baseline; padding: 5px 8px; border-radius: 4px; animation: riga .25s ease-out both; white-space: nowrap; }
.sc-res li b { font: 500 12.5px ui-monospace, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; }
.sc-res li span { color: #8a8f98; font-size: 11.5px; }
.sc-res li.on { background: #2f6fd6; color: #fff; } .sc-res li.on span { color: #dce6f8; }
.sc-lib-r { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px; background: #f3f1ec; }
.sc-pv { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.sc-pv svg { width: 100%; height: 92px; border-radius: 4px; }
.sc-sym { background: #f5f4ef; border: 1px solid #e2ded3; } .sc-sym g { fill: none; stroke: #8a2e2e; stroke-width: 2.2; stroke-linejoin: round; }
.sc-fp { background: #1b1d22; } .sc-fp g { fill: #c8a24a; stroke: none; }
.sc-photo { max-width: 100%; max-height: 190px; object-fit: contain; border-radius: 4px; }
.sc-pn { color: #6b7079; font: 11px ui-monospace, Consolas, monospace; text-align: center; overflow-wrap: anywhere; }
@media (max-width: 640px) { .sc-lib { grid-template-columns: 1fr; } .sc-lib-r { display: none; } }
.sc-pop { animation: popin .5s cubic-bezier(.2,.8,.3,1.3) var(--d, 0s) both; transform-box: fill-box; transform-origin: center; }
@keyframes popin { from { opacity: 0; transform: scale(.4); } }
.sc-wire { stroke-dasharray: 100; animation: filo 1.6s ease-in-out var(--d, 0s) both; }
@keyframes filo { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.sc-sch .sc-pop, .sc-sch .sc-wire, .sc-end .sc-pop { animation-iteration-count: 1; }
.sc-trace { stroke-dasharray: 100; animation: traccia2 3.2s linear var(--d, 0s) infinite; }
@keyframes traccia2 { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.sc-fly { animation: vola .9s cubic-bezier(.2,.9,.3,1.15) var(--d) both; }
@keyframes vola { from { opacity: 0; transform: translate(var(--fx), var(--fy)) rotate(25deg) scale(.6); } }
.sc-fw { display: grid; grid-template-columns: 1fr 220px; gap: 16px; height: 100%; }
.sc-code { margin: 0; background: #14161b; color: #d6d9de; border-radius: 10px; padding: 12px 14px; font: 13px/1.5 ui-monospace, Consolas, monospace;
  overflow: hidden; white-space: pre; }
.sc-code div { animation: riga .25s ease-out both; } .sc-code .cm { color: #7c8a6a; } .sc-code .pp { color: #c792ea; }
@keyframes riga { from { opacity: 0; transform: translateX(-6px); } }
.sc-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #6b7079; }
.sc-die { width: 110px; height: 110px; border-radius: 6px; background: #2f2f36; position: relative;
  box-shadow: 0 0 0 4px #c8ced6, 0 0 18px #e8743b55; animation: caldo 1.4s ease-in-out infinite alternate; }
.sc-die::after { content: ""; position: absolute; inset: 30px; border: 2px solid #55555f; border-radius: 3px; }
@keyframes caldo { to { box-shadow: 0 0 0 4px #c8ced6, 0 0 28px #e8743baa; } }
.sc-bar { width: 180px; height: 6px; border-radius: 3px; background: #e3e0d6; overflow: hidden; }
.sc-bar i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 3px; animation: barra 1.6s ease-in-out infinite; }
@keyframes barra { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .c-stage *, .c-stage *::before { animation: none !important; } .cantiere .traces path, .tile.new .art, .tile.new .head, .tile .glow, .c-steps li.run .dot { animation: none; } .tile.new .head { display: none; } .cantiere .traces path { stroke-dashoffset: 0; } }

/* ---- cablaggio (diagramma e breadboard dal design completo) ---- */
svg.bb2 [data-net], svg.dg2 [data-net] { transition: opacity .15s; }
svg.bb2.dim [data-net]:not(.hl), svg.dg2.dim [data-net]:not(.hl) { opacity: .18; }
svg.bb2 .jw:hover path, svg.dg2 .wire:hover { stroke-width: 4.5; }

/* ---- pannello Wi-Fi (scheda Codice) ---- */
.wifibox { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.wifibox .qr { width: 190px; height: 190px; background: #fff; border-radius: 10px; padding: 6px; flex: none; color: #333; font-size: 12px; }
.wifibox .qr svg { width: 100%; height: 100%; display: block; }
.wifibox > div:last-child { flex: 1; min-width: 240px; }
.wifibox p { margin: 0 0 10px; }

/* ---- impostazioni dei fori di fissaggio (scheda PCB) ---- */
/* comandi del PCB in un menu a scomparsa: chiuso resta solo un pulsante piccolo sopra la scheda */
.pcbmenu { position: absolute; z-index: 3; left: 22px; top: 22px; }
#pcbmenubtn { background: #000a; border: 1px solid var(--line); border-radius: 6px; width: 30px; height: 28px; padding: 0;
  font-size: 16px; line-height: 1; opacity: .75; }
#pcbmenubtn:hover, .pcbmenu.open #pcbmenubtn { opacity: 1; border-color: var(--accent); }
#pcbmenubox { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  background: #000c; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
#pcbmenubox.hidden { display: none; }
.pcbmenu .pcbsel { position: static; }
.pcbopt { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pcbopt > button { background: #000a; border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; font-size: 12px; }
/* finestra Impostazioni: schede a sinistra, una riga per scelta (etichetta | controllo) */
#setdlg { padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--fg);
  width: min(620px, 96vw); }
#setdlg::backdrop { background: #000a; }
:root[data-theme="light"] #setdlg::backdrop { background: #0005; }
.setbody { display: flex; min-height: 300px; }
.settabs { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-right: 1px solid var(--line); min-width: 130px; }
.settabs button { text-align: left; background: none; border: 0; color: var(--muted); padding: 7px 10px; border-radius: 7px; font-size: 13.5px; }
.settabs button:hover { color: var(--fg); background: var(--panel2); }
.settabs button.on { color: var(--fg); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.setpanes { flex: 1; padding: 12px 18px 16px; font-size: 13.5px; }
.setpanes section { display: none; }
.setpanes section.on { display: block; }
.setpanes h4 { margin: 2px 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setpanes .when { font-weight: 400; font-size: 11.5px; color: var(--muted); margin-left: auto; }
.srow { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; margin: 8px 0; }
.srow > span { color: var(--muted); }
.srow.sub > span { padding-left: 14px; }
.srow select, .srow input:not([type]) { width: 100%; max-width: 280px; }
.srow .sw { display: flex; align-items: center; gap: 7px; }
.setpanes .hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.setpanes .btn { margin-top: 10px; }
.setpanes .badge { font-size: 10.5px; font-weight: 400; padding: 1px 7px; border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 25%, transparent); }
.setpanes .badge.hidden { display: none; }
@media (max-width: 560px) {
  .setbody { flex-direction: column; }
  .settabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .srow { grid-template-columns: 1fr; gap: 4px; }
}
#vmodel { max-width: 120px; }

#p-bom .datasheets { margin-top: 14px; }
#p-bom .datasheets ul { margin: 6px 0; padding-left: 18px; line-height: 1.6; }
#p-bom td.ds { white-space: nowrap; }
#p-bom .dsbtn { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2);
  color: var(--fg); text-decoration: none; font-size: 12px; margin-right: 4px; }
#p-bom .dsbtn:hover { border-color: var(--accent); }
#p-bom a.pg { display: inline-block; padding: 1px 5px; margin: 1px 2px; border-radius: 4px; font-size: 11px;
  color: var(--muted); text-decoration: none; background: var(--panel2); }
#p-bom a.pg:hover { color: var(--accent); }

/* piazzamento a mano del PCB (piazza.js) */
.piazza { position: absolute; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.pz-bar { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pz-hint { color: var(--muted); font-size: 12.5px; flex: 1; min-width: 200px; }
.pz-hint kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11px; }
.pz-size { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--fg); }
.pz-bar button { padding: 5px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); }
.pz-bar button.main { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pz-bar button:disabled { opacity: .5; }
.pz-svg { flex: 1; min-height: 0; width: 100%; touch-action: none; user-select: none; }
.pz-msg { padding: 6px 12px; font-size: 13px; color: var(--muted); min-height: 28px; }
.pz-msg.err { color: var(--bad); }
.pz-board { fill: #1f6b3a; stroke: #7ccf95; stroke-width: 0.25; }
.pz-hole { fill: #0f1013; stroke: #c9a227; stroke-width: 0.3; }
.pz-holezone { fill: none; stroke: #c9a22766; stroke-width: 0.15; stroke-dasharray: 0.6 0.6; }
.pz-air { stroke: #ffd60a; stroke-width: 0.12; opacity: .75; }
.pz-air.gnd { stroke: #8a9099; opacity: .35; }
.pz-part { cursor: grab; }
.pz-part.fixed { cursor: not-allowed; opacity: .7; }
.pz-body { fill: #e9e7e122; stroke: #e9e7e1aa; stroke-width: 0.15; }
.pz-body.back { stroke-dasharray: 0.5 0.4; }
.pz-part.sel .pz-body { stroke: var(--accent); stroke-width: 0.3; fill: #e8743b22; }
.pz-part.bad .pz-body { stroke: var(--bad); fill: #e0675b33; }
.pz-pad { fill: #d4af37; }
.pz-ref { fill: #fff; text-anchor: middle; dominant-baseline: central; font-weight: 600; pointer-events: none; }
.pz-handle { fill: var(--accent); cursor: nwse-resize; }
#pcbhand { margin-right: 6px; }

/* simulazione in corso: avviso sopra la scheda Simula */
.simlive { position: absolute; z-index: 4; left: 50%; top: 22px; transform: translateX(-50%); display: flex; gap: 10px;
  align-items: center; background: #1e2126ee; border: 1px solid var(--accent); border-radius: 10px; padding: 10px 16px;
  box-shadow: 0 8px 30px #0008; max-width: 80%; }
.simlive b { display: block; font-size: 13.5px; }
.simlive small { color: var(--muted); font-size: 12px; }
.simlive.bad { border-color: var(--bad); }

/* piu' domande nello stesso turno: quelle ancora senza risposta si evidenziano */
.ask.todo { outline: 2px solid var(--accent); outline-offset: 3px; }

/* consenso a termini e informativa (versione online) */
#consentdlg { width: min(460px, 94vw); }
.consent .cbody { padding: 14px 16px 4px; font-size: 14px; line-height: 1.5; }
.consent .cbody p { margin: 0 0 12px; }
.consent .check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.consent .check input { margin-top: 3px; }
.consent a { color: var(--accent); }
.consent .cerr { color: var(--bad); font-size: 13px; }
.consent footer { display: flex; justify-content: flex-end; padding: 10px 16px 14px; }
.consent footer button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 600; cursor: pointer; }
.consent footer button:disabled { opacity: .5; cursor: default; }
/* modalita' demo per i video: niente scelta del modello, account, crediti, consumi e voci admin; chat piu' leggibile da telefono */
html.demo #model, html.demo #vmodel, html.demo #reason, html.demo #account, html.demo #credbar, html.demo .usage,
html.demo .mdrop a.bd[href^="/admin"] { display: none !important; }
html.demo #msgs { font-size: 16px; }
html.demo #form textarea { font-size: 16px; }
/* involucro da stampare sospeso: niente scheda nelle impostazioni ne' riga nei download */
body.no-encl [data-s="encl"], body.no-encl #fencl { display: none !important; }
/* cantiere: foglio dell'animazione a tutta larghezza, diario del banco sotto come un nastro che scorre da solo:
   le righe vecchie sfumano verso l'alto, l'ultima entra con un colpo di evidenziatore; col mouse sopra si legge tutto */
.c-main { grid-template-columns: minmax(0, 1fr); gap: 18px; }
.c-stage-a { height: min(360px, 40vh); }
.c-log { max-height: none; overflow: visible; transform: rotate(.25deg); padding: 8px 14px 8px 34px;
  background-image: linear-gradient(90deg, transparent 26px, #f0a8a0 26px, #f0a8a0 27px, transparent 27px); }
.c-log h4 { position: absolute; top: 6px; right: 14px; margin: 0; font-size: 14px; opacity: .7; z-index: 1; }
.c-log ol { height: 168px; overflow-y: auto; scroll-behavior: smooth; background: repeating-linear-gradient(transparent 0 23px, #d6e2f0 23px 24px); background-attachment: local; scrollbar-width: none; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 55%); mask-image: linear-gradient(to bottom, transparent 0, #000 55%);
  transition: -webkit-mask-image .3s, mask-image .3s; }
.c-log ol::-webkit-scrollbar { display: none; }
.c-log:hover ol { -webkit-mask-image: none; mask-image: none; scrollbar-width: thin; }
.c-log ol::before { content: ""; display: block; height: 120px; }      /* le prime righe partono dal fondo */
.c-log li { transition: font-size .4s, color .4s; }
.c-log li:last-child { font-size: 14px; font-weight: 600; }
.c-log li.nuova span { animation: c-arriva .5s cubic-bezier(.2, .8, .2, 1) both, c-evidenzia 1.6s ease-out both;
  border-radius: 3px; }
@keyframes c-arriva { from { opacity: 0; transform: translateY(12px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes c-evidenzia { 0%, 25% { background: linear-gradient(transparent 45%, #f6e27a 45%, #f6e27a 88%, transparent 88%); }
  100% { background: linear-gradient(transparent 45%, #f6e27a00 45%, #f6e27a00 88%, transparent 88%); } }
@media (max-width: 900px) { .c-log ol { height: 150px; } }
@media (prefers-reduced-motion: reduce) { .c-log li.nuova span { animation: none; } }
/* distinta: requisito sotto il valore (va bene qualsiasi pezzo che lo rispetta) */
table.bom small.req { display: block; font-size: 11px; color: var(--muted, #8a8f98); white-space: nowrap; }
/* generatore di animazioni del display sopra l'app (da "Add animation" nel simulatore) */
#animbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 24px; }
#animbox.hidden { display: none; }
#animbox .animwin { width: min(1280px, 100%); height: min(760px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
#animbox header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
#animbox .x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
#animbox iframe { flex: 1; border: 0; width: 100%; background: var(--bg); }
/* comandi rapidi accanto ai menu: New, Open, Save, Save as */
.qbar { display: inline-flex; gap: 2px; margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
.qbar button { background: none; border: 0; padding: 5px 7px; border-radius: 6px; color: var(--muted); cursor: pointer; display: inline-flex; }
.qbar button:hover { background: var(--panel2); color: var(--fg); }
.qbar svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 700px) { .qbar { display: none; } }
/* scene del cantiere con l'aspetto di KiCad (scena.js): schema, simulatore, editor PCB, rapporto DRC */
.sc-k { height: 100%; border-radius: 8px; overflow: hidden; border: 1px solid #d8d4c8; }
.sc-k svg { width: 100%; height: 100%; display: block; }
.sc-eesch { background: #f5f4ef; }
.sc-eesch .sym { fill: none; stroke: #840000; stroke-width: 2; stroke-linejoin: round; }
.sc-eesch .sym.ic rect { fill: #ffffc2; }
.sc-eesch .wires { fill: none; stroke: #009600; stroke-width: 1.6; }
.sc-eesch text { font: 12px ui-monospace, Consolas, monospace; } .sc-eesch .ref { fill: #006464; } .sc-eesch .val { fill: #006464; opacity: .8; }
.sc-eesch .sc-pop, .sc-eesch .sc-wire { animation-iteration-count: 1; }
.sc-simk { position: relative; background: #fff; }
.sc-simk .grid path { stroke: #e6e6e6; stroke-width: 1; } .sc-simk .ticks text { font: 9px system-ui; fill: #6b7079; }
.sc-simk .leg { position: absolute; top: 8px; right: 12px; display: flex; gap: 12px; font: 11px ui-monospace, Consolas, monospace;
  background: #ffffffd9; padding: 3px 8px; border: 1px solid #e2ded3; border-radius: 4px; }
.sc-simk .leg i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 4px; }
.sc-pcbk { background: #001023; border-color: #0b2340; }
.sc-pcbk .edge { fill: #0a2a1c33; stroke: #d0d248; stroke-width: 0.25; }
.sc-pcbk .crt { fill: none; stroke: #ff26e2; stroke-width: 0.08; opacity: .7; }
.sc-pcbk .padf rect { fill: #c83434; } .sc-pcbk .padb rect { fill: #4d7fc4; }
.sc-pcbk .silk { fill: #f2eda1; font: 1.3px ui-monospace, Consolas, monospace; }
.sc-pcbk .rats line { stroke: #ffffff; stroke-width: 0.06; opacity: 0; animation: compare .6s ease-out var(--d, 0s) forwards; }
@keyframes compare-rats { to { opacity: .55; } }
.sc-pcbk .rats line { animation-name: compare-rats; } .sc-pcbk .rats.fade line { opacity: .35; animation: none; }
.sc-pcbk .tracks path { fill: none; stroke-width: 0.35; stroke-linecap: round; stroke-linejoin: round; animation-iteration-count: 1; }
.sc-pcbk .trf { stroke: #c83434; } .sc-pcbk .trb { stroke: #4d7fc4; opacity: .9; }
.sc-pcbk .sc-fly { transform-box: view-box; }
.sc-drc { background: #fbfaf7; padding: 12px 16px; }
.sc-drc pre { margin: 0; font: 13px/1.9 ui-monospace, Consolas, monospace; color: #2b2e33; }
.sc-drc pre div { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px dashed #e2ded3; animation: riga .3s ease-out both; }
.sc-drc b.ok { color: #2c8a4f; } .sc-drc b.ko { color: #c0392b; }
.shoplist { margin-top: 18px; }
.shoplist h4 { margin: 0 0 6px; font-size: 14px; }
.shoplist ul { list-style: none; padding: 0; margin: 6px 0 0; }
.shoplist li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.shoplist li label { flex: 1 1 220px; cursor: pointer; }
.shoplist li:has(input:checked) label { opacity: .55; text-decoration: line-through; }
.shoplist button.mini { margin-left: 6px; font-size: 12px; padding: 2px 8px; }

/* scheda del componente (partsheet.js): pannello a destra, sul telefono dal basso */
#partsheet { position: fixed; top: 48px; right: 8px; bottom: 8px; width: 340px; z-index: 40; overflow: auto;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 50px -10px #000a; padding: 0 14px 14px; font-size: 13.5px; }
#partsheet.hidden { display: none; }
#partsheet header { position: sticky; top: 0; background: var(--panel); display: flex; align-items: flex-start; gap: 8px;
  justify-content: space-between; padding: 14px 0 10px; border-bottom: 1px solid var(--line); }
#partsheet .ps-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
#partsheet .ps-head img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: var(--panel2); flex: none; }
#partsheet .ps-ico { width: 56px; height: 56px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center;
  font-weight: 700; color: var(--accent); flex: none; }
#partsheet h3 { margin: 0 0 2px; font-size: 16px; }
#partsheet small { color: var(--muted); }
#partsheet h4 { margin: 14px 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#partsheet p { margin: 0 0 6px; line-height: 1.45; }
#partsheet dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
#partsheet dt { color: var(--muted); } #partsheet dd { margin: 0; overflow-wrap: anywhere; }
#partsheet .ps-pins { width: 100%; border-collapse: collapse; }
#partsheet .ps-pins td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
#partsheet .ps-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
#partsheet .btn { display: inline-block; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--fg); text-decoration: none; cursor: pointer; font: inherit; }
#partsheet .btn:hover { border-color: var(--accent); }
#partsheet .ps-pg a { margin-right: 4px; font-size: 12px; }
#partsheet .ps-x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 4px; }
.zoom .ovl .pickbox { fill: #e8743b22; stroke: #e8743b; stroke-width: .5; }
@media (max-width: 760px) {
  #partsheet { top: auto; left: 8px; right: 8px; width: auto; max-height: 62vh; }
}
