:root {
  --ink: #eef2f8;
  --ink-2: rgba(232, 238, 248, 0.68);
  --ink-3: rgba(232, 238, 248, 0.42);
  --glass: rgba(12, 18, 30, 0.58);
  --glass-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
  --amber: #ffb547;
  --amber-2: #ff9a3c;
  --green: #5fe39a;
  --red: #ff6b5b;
  --r: 16px;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --serif: 'Fraunces', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1220; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(5, 10, 20, 0.38) 100%); }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }
.label { font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }

.card {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* --- marchio --- */
.brand { position: fixed; top: 22px; left: 26px; pointer-events: none; text-shadow: 0 2px 18px rgba(0, 20, 50, 0.45); }
.logo { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 44px; line-height: 0.9; letter-spacing: -0.02em; }
.logo::after { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); margin-left: 4px; box-shadow: 0 0 14px var(--amber); }
.tag { margin-top: 8px; font-size: 12.5px; line-height: 1.35; color: rgba(255, 255, 255, 0.85); font-weight: 500; }

/* --- barra comandi --- */
.dock {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  z-index: 5;
}
.dock .sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.dock button { border: 0; background: transparent; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); transition: background 0.15s, color 0.15s; white-space: nowrap; }
.dock button:hover { background: var(--glass-2); color: var(--ink); }
.dock button.icon { width: 34px; padding: 0; display: grid; place-items: center; }
.dock button.icon svg { width: 18px; height: 18px; }
.dock button.icon.on { color: var(--amber); }
.dock .primary { display: flex; align-items: center; gap: 6px; background: var(--amber); color: #2a1600; font-weight: 700; padding: 0 16px 0 10px; }
.dock .primary:hover { background: #ffc46b; color: #2a1600; }
.dock .primary .ico { width: 18px; height: 18px; display: grid; place-items: center; }
.dock .primary .ico svg { width: 18px; height: 18px; }
.dock .primary.on { background: rgba(255, 181, 71, 0.14); color: var(--amber); box-shadow: inset 0 0 0 1px rgba(255, 181, 71, 0.45); }
.dock .primary.on .lbl::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 7px; vertical-align: 1px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.seg { display: flex; background: rgba(0, 0, 0, 0.18); border-radius: 999px; padding: 2px; }
.seg button { height: 30px; padding: 0 10px; }
.seg button.on { background: rgba(255, 255, 255, 0.14); color: var(--ink); }

.opts-wrap { position: relative; }
.opts-wrap .panel {
  position: absolute; top: 46px; right: -60px; width: 300px; padding: 16px; display: none;
  background: rgba(12, 18, 30, 0.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.opts-wrap.open .panel { display: block; animation: drop 0.18s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.panel h4 { margin: 4px 0 10px; font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); }
.panel h4:not(:first-child) { margin-top: 18px; }
.sw { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); margin: 9px 0; cursor: pointer; line-height: 1.3; }
.sw input { display: none; }
.sw span { flex: none; width: 30px; height: 18px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background 0.15s; }
.sw span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.sw input:checked + span { background: var(--amber); }
.sw input:checked + span::after { transform: translateX(12px); }
.range { margin: 12px 0 6px; }
.rl { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.rl span:last-child { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--amber); border: 3px solid #1a2333; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--amber); border: 3px solid #1a2333; cursor: pointer; }
input[type=range]:disabled { opacity: 0.35; }
.btns { display: grid; gap: 8px; margin-top: 16px; }
.btns button { border: 1px solid var(--line); background: var(--glass-2); border-radius: 10px; padding: 9px 12px; font-size: 13px; text-align: left; color: var(--ink); }
.btns button:hover { background: rgba(255, 255, 255, 0.1); }
.btns .danger { color: var(--red); }

/* --- scheda statistiche --- */
.stats { position: fixed; right: 20px; width: 300px; padding: 16px 16px 12px; overflow: auto; scrollbar-width: none; }
.gen-row { display: flex; justify-content: space-between; align-items: flex-start; }
.gen { font-family: var(--serif); font-size: 52px; line-height: 1; font-weight: 500; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.viewtag { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.viewtag.album { color: var(--amber); }
.gen-row .right { text-align: right; }
.gen-row .right .mono { font-size: 15px; margin-top: 6px; }
.dimtxt { color: var(--ink-3); font-size: 12px !important; margin-top: 2px !important; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 12px; transition: opacity 0.2s; }
.kpis.dim { opacity: 0.3; }
.kpis div { background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 8px 6px 7px; text-align: center; }
.kpis b { display: block; font-family: var(--mono); font-size: 17px; font-weight: 700; }
.kpis span { display: block; font-size: 10px; color: var(--ink-3); margin-top: 2px; }
.kpis .ok b { color: var(--green); }
.kpis .bad b { color: var(--red); }
.chart-wrap canvas { width: 100%; height: 92px; display: block; }
.legend { display: flex; gap: 12px; font-size: 10.5px; color: var(--ink-3); margin-top: 6px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 2px; margin-right: 5px; vertical-align: 3px; }
.l-p::before { background: var(--amber); height: 3px !important; }
.l-m::before { background: rgb(160, 180, 210); }
.l-b::before { background: rgba(255, 255, 255, 0.45); }
.l-l::before { background: rgba(95, 227, 154, 0.5); height: 7px !important; vertical-align: 0 !important; }
.album { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.album .rl { margin-bottom: 8px; }
#live { border: 0; background: var(--amber); color: #2a1600; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 3px 9px; }
.milestones { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.milestones li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink-3); padding: 3px 0; }
.milestones .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.25); flex: none; }
.milestones .ml { flex: 1; }
.milestones .mg { font-family: var(--mono); font-size: 11px; }
.milestones li.done { color: var(--ink); }
.milestones li.done .dot { background: var(--green); border-color: var(--green); box-shadow: 0 0 8px rgba(95, 227, 154, 0.6); }
.milestones li.expert .dot { background: var(--amber); border-color: var(--amber); }

/* --- notifiche --- */
#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 4; }
.toast { background: rgba(12, 18, 30, 0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid rgba(255, 181, 71, 0.35); color: var(--ink); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; opacity: 0; transform: translateY(-8px) scale(0.98); transition: all 0.45s cubic-bezier(.2, .9, .3, 1.2); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); }
.toast b { color: var(--amber); font-weight: 600; }
.toast.in { opacity: 1; transform: none; }

/* --- strumenti --- */
.hud { position: fixed; left: 20px; right: 20px; bottom: 20px; display: flex; gap: 14px; align-items: stretch; pointer-events: none; }
.hud .card { pointer-events: auto; }
.instruments { display: flex; align-items: center; gap: 16px; padding: 14px 18px; }
#adi { width: 118px; height: 118px; flex: none; }
.readouts { display: grid; grid-template-columns: repeat(2, 104px); gap: 10px 14px; }
.readouts div { display: flex; flex-direction: column; }
.readouts b { font-family: var(--mono); font-weight: 700; font-size: 24px; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.readouts i { font-style: normal; font-size: 10.5px; color: var(--ink-3); }
.readouts .warn b { color: var(--red); animation: pulse 0.5s infinite; }
.levers { display: flex; gap: 12px; height: 112px; padding-left: 16px; border-left: 1px solid var(--line); }
.lever { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 34px; }
.lever .track { position: relative; flex: 1; width: 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.lever .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, var(--amber-2), var(--amber)); border-radius: 6px; }
.lever.center .fill { background: linear-gradient(to top, #7fb2ff, #b9d4ff); border-radius: 2px; }
.lever .mid { position: absolute; left: -2px; right: -2px; top: 50%; height: 1px; background: rgba(255, 255, 255, 0.5); }
.lever span { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }

.mission { flex: 1; min-width: 0; padding: 12px 16px 10px; display: flex; flex-direction: column; }
.mission-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.who { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who b { color: var(--amber); font-weight: 600; }
.clock { font-size: 12px; color: var(--ink-3); }
.status { font-family: var(--serif); font-size: 21px; margin: 2px 0 6px; min-height: 27px; }
.status .ok { color: var(--green); }
.status .bad { color: var(--red); }
.status .meh { color: var(--ink-2); }
#profile { width: 100%; height: 84px; display: block; }
.bar { height: 2px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; margin-top: 6px; overflow: hidden; }
#progress { height: 100%; width: 0; background: var(--amber); }

/* --- finestre --- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(6, 10, 18, 0.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.35s; z-index: 10; }
.modal.open { opacity: 1; pointer-events: auto; }
.sheet { position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 38px 40px 30px; border-radius: 24px; background: rgba(10, 16, 28, 0.82); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3); border: 1px solid var(--line); box-shadow: 0 30px 120px rgba(0, 0, 0, 0.5); transform: translateY(10px); transition: transform 0.45s cubic-bezier(.2, .9, .3, 1); }
.modal.open .sheet { transform: none; }
.sheet.wide { width: min(1040px, 100%); }
.kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); font-weight: 600; }
.sheet h1 { font-family: var(--serif); font-weight: 500; font-size: 50px; line-height: 1.02; letter-spacing: -0.025em; margin: 14px 0 18px; }
.sheet h1 em { color: var(--amber); font-weight: 400; }
.sheet h2 { font-family: var(--serif); font-weight: 500; font-size: 32px; letter-spacing: -0.02em; margin: 10px 0 20px; }
.sheet h3 { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 8px; color: var(--ink); }
.sheet section h3:not(:first-child) { margin-top: 20px; }
.sheet p { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); margin: 0 0 12px; }
.sheet section p { font-size: 13.5px; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.cta { display: grid; gap: 10px; margin-top: 24px; }
.cta button { border: 1px solid var(--line); background: var(--glass-2); border-radius: 14px; padding: 14px 18px; font-size: 14.5px; font-weight: 500; text-align: left; transition: background 0.15s, transform 0.15s; }
.cta button:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-1px); }
.cta .primary { background: var(--amber); color: #2a1600; border-color: transparent; font-weight: 700; }
.cta .primary:hover { background: #ffc46b; }
.cta .primary span::after { content: ' →'; }
.hint { margin-top: 18px; font-size: 11.5px; color: var(--ink-3); }
.close { position: absolute; top: 16px; right: 18px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--glass-2); font-size: 22px; line-height: 1; color: var(--ink-2); }
.close:hover { background: rgba(255, 255, 255, 0.12); color: var(--ink); }

/* --- schermi medi --- */
.stats { top: var(--top, 76px); max-height: calc(100vh - var(--top, 76px) - var(--hud, 180px) - 16px); }
#toasts { top: var(--top, 76px); }
@media (max-width: 1240px) {
  .brand .tag { display: none; }
  .logo { font-size: 34px; }
  .dock { left: auto; right: 20px; transform: none; }
  #cams button { padding: 0 8px; }
  #toasts { left: 20px; transform: none; justify-items: start; }
}
@media (max-width: 1000px) {
  .brand { display: none; }
  .dock { left: 12px; right: 12px; top: 12px; flex-wrap: wrap; justify-content: center; border-radius: 22px; }
  .stats { right: 12px; width: 270px; }
  .album, .milestones { display: none; }
  .hud { left: 12px; right: 12px; bottom: 12px; flex-direction: column; gap: 10px; }
  .instruments { justify-content: space-between; }
  .opts-wrap .panel { right: -10px; }
  #toasts { left: 12px; }
}

/* --- telefono --- */
@media (max-width: 640px) {
  .dock { gap: 2px; padding: 4px; }
  .dock .sep { display: none; }
  .dock .primary { padding: 0 12px 0 8px; height: 32px; }
  .dock button { height: 32px; }
  .dock button.icon { width: 32px; }
  #cams button { font-size: 11px; padding: 0 6px; height: 28px; }
  #speed button { padding: 0 6px; font-size: 11px; height: 28px; }
  .stats { width: 150px; padding: 10px 12px; border-radius: 14px; }
  .gen-row .label { font-size: 9px; }
  .gen { font-size: 30px; }
  .viewtag, .chart-wrap, .gen-row .right { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); margin: 8px 0 0; gap: 4px; }
  .kpis div { padding: 5px 4px; }
  .kpis b { font-size: 14px; }
  .hud { gap: 8px; }
  .instruments { padding: 10px 12px; gap: 10px; }
  #adi { width: 72px; height: 72px; }
  .readouts { grid-template-columns: repeat(2, 1fr); gap: 4px 10px; flex: 1; }
  .readouts b { font-size: 16px; }
  .levers { display: none; }
  .mission { padding: 10px 12px 8px; }
  .status { font-size: 16px; min-height: 22px; }
  #profile { height: 56px; }
  .opts-wrap .panel { position: fixed; left: 12px; right: 12px; width: auto; top: var(--top, 90px); max-height: 60vh; overflow: auto; }
  .sheet { padding: 28px 22px 22px; }
  .sheet h1 { font-size: 36px; }
  .cols { grid-template-columns: 1fr; gap: 6px; }
  .toast { font-size: 12.5px; border-radius: 14px; }
}
