/* Layout: banco 3D a tutto schermo; strumenti in sovrimpressione, pannello a destra (in basso sul telefono).
   Palette: grafite fredda della camera bianca + ambra delle sue luci gialle. Tema unico scuro, scelto di proposito. */
:root {
  color-scheme: dark;
  --bg: #0a0d11;
  --panel: rgba(13, 17, 23, 0.84);
  --panel-2: rgba(255, 255, 255, 0.035);
  --fg: #e6e9ee;
  --muted: #8d97a5;
  --line: rgba(196, 212, 232, 0.11);
  --accent: #f2b544;
  --accent-ink: #1b1306;
  --hot: #ff6a3d;
  --ok: #4cd08a;
  --cool: #5ab4ff;
  --f-display: "Saira Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 12px;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px; overflow: hidden; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }

.hud {
  position: fixed; inset: 0; pointer-events: none;
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 384px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.hud > * { pointer-events: auto; }

/* Testata e componenti */
.brand { grid-column: 1; grid-row: 1; align-self: start; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.brand-row { display: flex; align-items: center; gap: 12px; }
.mark { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 700 17px/1 var(--f-display); letter-spacing: .02em; flex: none; }
h1 { margin: 0; font: 700 26px/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 6px 11px; border-radius: 999px; font: 500 13px var(--f-body); cursor: pointer; backdrop-filter: blur(10px); }
.chip[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip:disabled { cursor: not-allowed; color: var(--muted); }
.chip small { font: 500 10px var(--f-mono); letter-spacing: .06em; text-transform: uppercase; opacity: .75; }

/* Didascalia dell'assemblaggio sullo sfondo */
.assembly { grid-column: 1; grid-row: 2; align-self: start; justify-self: start; max-width: 300px; pointer-events: none; padding: 10px 12px; border-left: 2px solid var(--accent); background: linear-gradient(90deg, rgba(10,13,17,.7), rgba(10,13,17,0)); }
.as-k { font: 500 11px var(--f-mono); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.as-t { font: 600 19px/1.15 var(--f-display); letter-spacing: .03em; margin-top: 4px; text-wrap: balance; }
.as-d { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 3px; }
.as-bar { height: 2px; background: var(--line); margin-top: 8px; border-radius: 2px; overflow: hidden; }
.as-bar i { display: block; height: 100%; width: 0; background: var(--accent); }

/* Comandi della vista */
.controls { grid-column: 1; grid-row: 3; align-self: end; justify-self: start; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(12px); max-width: 100%; }
.ctl { display: flex; align-items: center; gap: 8px; padding: 0 6px; font: 500 12px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ctl input { width: 130px; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button, .tbtn { border: 0; background: transparent; color: var(--fg); font: 500 13px var(--f-body); padding: 7px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover, .tbtn:hover { background: var(--panel-2); }
.tbtn { border: 1px solid var(--line); border-radius: 8px; display: inline-flex; align-items: center; gap: 7px; }
.tbtn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--muted); }
.tbtn[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pannello */
.panel { grid-column: 2; grid-row: 1 / 4; min-height: 0; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(16px); display: flex; flex-direction: column; }
.tabs { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; background: rgba(13,17,23,.96); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 13px 10px; font: 600 15px var(--f-display); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.pv { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.c-k, .h-k { font: 500 11px var(--f-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin: 0; }
.card { display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font: 700 28px/1.02 var(--f-display); letter-spacing: .01em; text-wrap: balance; }
.c-alt { color: var(--muted); font: 400 12.5px var(--f-mono); margin-top: -4px; }
.c-role { margin: 0; line-height: 1.55; font-size: 14.5px; }
.c-detail { margin: 0; line-height: 1.55; color: #b9c1cc; font-size: 13.5px; }
.specs { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.specs dt { color: var(--muted); font: 500 11.5px var(--f-mono); text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.specs dd { margin: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; min-width: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); font: 600 13.5px var(--f-body); padding: 8px 13px; border-radius: 8px; cursor: pointer; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--fg); font: 500 13px var(--f-body); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.ghost:hover { background: var(--panel-2); }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: layer; }
.plist button { width: 100%; text-align: left; display: grid; grid-template-columns: 26px 1fr; gap: 2px 8px; align-items: baseline; border: 1px solid transparent; background: transparent; color: var(--fg); padding: 8px 8px; border-radius: 8px; cursor: pointer; counter-increment: layer; }
.plist button::before { content: counter(layer, decimal-leading-zero); grid-row: 1 / 3; font: 500 11px var(--f-mono); color: var(--muted); }
.plist button:hover { background: var(--panel-2); }
.plist button[aria-current="true"] { border-color: rgba(242,181,68,.45); background: rgba(242,181,68,.08); }
.pl-n { font: 500 14px var(--f-body); }
.pl-m { grid-column: 2; font-size: 12px; color: var(--muted); }

/* Simulazione */
.sim-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill { font: 600 11px var(--f-mono); text-transform: uppercase; letter-spacing: .07em; padding: 5px 9px; border-radius: 999px; border: 1px solid currentColor; color: var(--ok); white-space: nowrap; }
.pill[data-s="power"] { color: var(--accent); }
.pill[data-s="thermal"] { color: var(--hot); }
.pill[data-s="idle"] { color: var(--cool); }
.wl { display: flex; flex-wrap: wrap; gap: 6px; }
.wl button { border: 1px solid var(--line); background: transparent; color: var(--fg); padding: 6px 10px; border-radius: 999px; font: 500 13px var(--f-body); cursor: pointer; }
.wl button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.wl-desc { margin: 0; color: #b9c1cc; font-size: 13px; line-height: 1.5; min-height: 3em; }
.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g { padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.g-k { font: 500 10.5px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.g-v { font: 600 28px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.g-v small { font: 500 13px var(--f-body); color: var(--muted); margin-left: 3px; }
.g-n { font-size: 11.5px; color: var(--muted); }
.bar { height: 4px; border-radius: 3px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .15s linear; }
.cores { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.core { position: relative; height: 54px; border-radius: 6px; border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 4px 4px 3px; background: rgba(255,255,255,.02); }
.core i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--u, 0) * 100%); background: var(--c, var(--cool)); opacity: .32; }
.core b, .core span { position: relative; font: 500 10px var(--f-mono); }
.core b { color: var(--muted); }
.core span { font-variant-numeric: tabular-nums; }
.core.watch { border-color: var(--accent); }
.cores-k { display: flex; justify-content: space-between; font: 500 10.5px var(--f-mono); color: var(--muted); margin-top: -10px; }

.pipe { display: flex; flex-direction: column; gap: 4px; }
.st { display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.015); transition: background .2s, border-color .2s; }
.st-n { font: 600 13px var(--f-display); letter-spacing: .05em; text-transform: uppercase; }
.st-n small { display: block; font: 400 10.5px var(--f-body); color: var(--muted); letter-spacing: 0; text-transform: none; }
.st-i { font: 500 12.5px var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.st.busy .st-i { color: var(--fg); }
.st.busy { border-color: rgba(90,180,255,.28); }
.st.stall { border-color: rgba(242,181,68,.5); background: rgba(242,181,68,.06); }
.st.wait { border-color: var(--accent); background: rgba(242,181,68,.14); }
.st.flush .st-i { color: var(--hot); }
.pipe-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-variant-numeric: tabular-nums; }
.pipe-stats div { display: flex; flex-direction: column; gap: 2px; }
.pipe-stats b { font: 600 20px var(--f-display); }
.pipe-stats span { font: 500 10.5px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.code { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,.28); border: 1px solid var(--line); font: 500 12px/1.65 var(--f-mono); overflow-x: auto; color: #c9d1db; }
.code .cm { color: var(--muted); }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font: 400 12px/1.45 var(--f-mono); }
.log li { color: #b9c1cc; padding-left: 10px; border-left: 2px solid var(--line); }
.log li[data-l="L2"] { border-color: var(--cool); }
.log li[data-l="L3"] { border-color: var(--accent); }
.log li[data-l="RAM"] { border-color: var(--hot); }
.log li[data-l="BR"] { border-color: #c77dff; }
.note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.speed { display: flex; align-items: center; gap: 8px; font: 500 11px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.speed input { width: 110px; accent-color: var(--accent); }

.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.cool { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.chain { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.node { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 7px 6px; border-radius: 8px; border: 1px solid var(--c, var(--line)); background: rgba(0,0,0,.18); min-width: 0; }
.node + .node::before { content: "›"; position: absolute; left: -9px; top: 50%; transform: translateY(-50%); color: var(--muted); font: 600 13px var(--f-mono); }
.node span { font: 500 10px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node b { font: 600 17px var(--f-display); font-variant-numeric: tabular-nums; }
.cstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; font-variant-numeric: tabular-nums; }
.cstats div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cstats b { font: 600 19px var(--f-display); }
.rails { display: grid; gap: 7px; font-variant-numeric: tabular-nums; }
.rail { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; align-items: center; font-size: 12.5px; }
.rail span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail b { font: 500 12px var(--f-mono); }
.rail .bar { grid-column: 1 / -1; }
.wl button:disabled { opacity: .45; cursor: not-allowed; }
.sum { display: grid; gap: 4px; }
.sum button { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; text-align: left; border: 1px solid var(--line); background: transparent; color: var(--fg); padding: 7px 10px; border-radius: 8px; cursor: pointer; font: 500 13px var(--f-body); }
.sum button:hover { background: var(--panel-2); border-color: rgba(242,181,68,.4); }
.sum b { font: 500 12px var(--f-mono); color: var(--muted); text-align: right; }
.cstats span { font: 500 10px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fanrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.speed input:disabled { opacity: .55; }
.tip { position: fixed; z-index: 20; pointer-events: none; padding: 5px 9px; border-radius: 6px; background: rgba(10,13,17,.92); border: 1px solid var(--line); font: 500 12.5px var(--f-body); transform: translate(14px, 14px); white-space: nowrap; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; font: 600 18px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--bg); z-index: 30; transition: opacity .6s; }
.loading.gone { opacity: 0; pointer-events: none; }

@media (max-width: 760px) {
  .hud { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto 40%; gap: 8px; }
  .panel { grid-column: 1; grid-row: 4; }
  .assembly { max-width: 240px; padding: 6px 10px; }
  .as-d { display: none; }
  .as-t { font-size: 16px; }
  h1 { font-size: 21px; }
  .sub { display: none; }
  .mark { width: 32px; height: 32px; font-size: 15px; }
  .controls { gap: 6px; padding: 6px; }
  .ctl input { width: 96px; }
  .seg button, .tbtn { padding: 6px 8px; font-size: 12.5px; }
  .card h2 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }
