/* MI Digital Learning – futuristic, clean, accessible.
   All colours come from semantic variables set by js/theme.js (contrast-checked to ≥ 4.5:1). */
:root {
  --bg: #070b16; --bg2: #0c1324; --surface: rgba(17, 25, 45, .78); --surface-solid: #111a2e; --surface2: #17223b;
  --text: #e8eefc; --muted: #a9b6d3; --border: rgba(148, 170, 220, .22);
  --accent: #39d0ff; --accent-text: #39d0ff; --accent2: #a78bfa; --on-accent: #00131a;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --info: #60a5fa;
  --glow: 0 0 0 1px rgba(57, 208, 255, .25), 0 0 24px rgba(57, 208, 255, .18);
  --radius: 16px; --radius-sm: 10px; --gap: 16px; --pad: 20px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --scale: 1;
  font-size: calc(16px * var(--scale));
}
[data-density="compact"] { --gap: 10px; --pad: 12px; --radius: 12px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body::before { content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background: radial-gradient(40% 40% at 15% 10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
              radial-gradient(35% 35% at 85% 20%, color-mix(in srgb, var(--accent2) 20%, transparent), transparent 70%),
              radial-gradient(45% 45% at 60% 95%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--bg);
  animation: drift 40s ease-in-out infinite alternate; }
[data-glow="off"] body::before, body.no-glow::before { animation: none; background: var(--bg); }
@keyframes drift { to { transform: translate3d(3%, -2%, 0) scale(1.05); } }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } * { transition: none !important; animation-duration: .001s !important; } }

a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); } h2 { font-size: clamp(1.3rem, 2.2vw, 1.8rem); } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .tiny { font-size: .78rem; }
.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; } .grow { flex: 1; } .right { margin-left: auto; }
.stack > * + * { margin-top: var(--gap); }
.hidden { display: none !important; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.card.glow { box-shadow: var(--glow); }
[data-glow="off"] .card.glow { box-shadow: none; }
.glass-line { height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .5; margin: var(--gap) 0; }
.kicker { text-transform: uppercase; letter-spacing: .14em; font-size: .74rem; font-weight: 700; color: var(--accent-text); margin-bottom: .4rem; }
.pill { display: inline-flex; align-items: center; gap: .35em; padding: .15em .7em; border-radius: 999px; border: 1px solid var(--border); font-size: .8rem; background: var(--surface2); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; padding: .62em 1.1em; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); min-height: 44px; transition: transform .12s, box-shadow .2s, background .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--glow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent2))); color: var(--on-accent); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: .3em .7em; min-height: 34px; font-size: .86rem; border-radius: 9px; }
.icon-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2); cursor: pointer; font-size: 1.05rem; position: relative; }
.icon-btn:hover { box-shadow: var(--glow); }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; font-weight: 700; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=search], select, textarea { width: 100%; padding: .7em .85em; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-solid); color: var(--text); min-height: 44px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--glow); outline: none; }
label.field { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.check { display: flex; gap: .6em; align-items: flex-start; padding: .5em .2em; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: .15em; accent-color: var(--accent); flex: none; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px; padding: 10px clamp(10px, 2vw, 22px); background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; text-decoration: none; color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); font-weight: 900; box-shadow: var(--glow); }
.brand small { display: block; font-weight: 600; color: var(--muted); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; }
.top-progress { flex: 1; min-width: 120px; max-width: 420px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); box-shadow: 0 0 12px var(--accent); transition: width .5s; border-radius: inherit; }
.timer { font-family: var(--mono); font-size: .9rem; padding: .3em .6em; border-radius: 8px; border: 1px solid var(--border); }
.music { display: flex; align-items: center; gap: 4px; }
.music .name { font-size: .74rem; color: var(--muted); max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }

main { padding: clamp(10px, 2.5vw, 28px); max-width: 1400px; margin: 0 auto; }

/* ---------- login ---------- */
.login-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; padding: 20px; }
.login { width: min(520px, 100%); }
.login h1 { font-size: 1.9rem; }
.candidate { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); box-shadow: var(--glow); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); flex: none; }
.otp-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .5em; text-align: center; }

/* ---------- dashboard ---------- */
.hero-dash { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--gap); }
.level { margin-top: calc(var(--gap) * 1.5); }
.level-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--gap); }
.mod { position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 190px; }
.mod .code { font-family: var(--mono); font-weight: 700; color: var(--accent-text); }
.mod.locked { opacity: .62; }
.mod .badge-mini { position: absolute; right: 14px; top: 12px; width: 52px; height: 52px; }
.mod .cta { margin-top: auto; }
.badge-shelf { display: flex; gap: 16px; flex-wrap: wrap; }
.badge-shelf figure { margin: 0; text-align: center; width: 96px; }
.badge-shelf figcaption { font-size: .78rem; color: var(--muted); }
.badge-shelf .ghost { opacity: .22; filter: grayscale(1); }

/* ---------- player ---------- */
.player { display: grid; grid-template-columns: 290px 1fr; gap: var(--gap); align-items: start; }
.rail { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding: 12px; }
.rail h4 { margin: 12px 6px 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.rail button { display: flex; width: 100%; text-align: left; gap: 8px; align-items: center; background: none; border: 0; padding: 7px 8px; border-radius: 9px; cursor: pointer; color: var(--text); font-size: .88rem; }
.rail button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.rail button:disabled { color: var(--muted); cursor: not-allowed; opacity: .6; }
.rail .tick { width: 18px; flex: none; text-align: center; }
.stage { min-height: 60vh; display: flex; flex-direction: column; }
.slide { flex: 1; animation: slidein .35s ease; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }
.slide-nav { display: flex; gap: 10px; align-items: center; margin-top: var(--gap); position: sticky; bottom: 0; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.noselect { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.noselect input, .noselect textarea, .noselect [contenteditable] { -webkit-user-select: text; user-select: text; }
.rail-toggle, .rail .rail-toggle { display: none; }

.hero-slide { min-height: 52vh; display: flex; flex-direction: column; justify-content: center; padding: clamp(20px, 5vw, 60px); background: radial-gradient(80% 120% at 100% 0%, color-mix(in srgb, var(--accent2) 22%, transparent), transparent 60%), var(--surface); }
.hero-slide h1 { font-size: clamp(2rem, 4.4vw, 3.4rem); background: linear-gradient(90deg, var(--text), var(--accent-text)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.grid-blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin: var(--gap) 0; }
.grid-blocks .gb { padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface2); }
.grid-blocks .gb .ic { font-size: 1.4rem; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); font-weight: 800; margin-bottom: 8px; }
.callout { border-radius: 14px; padding: 14px 16px; border: 1px solid var(--border); border-left: 4px solid var(--info); background: color-mix(in srgb, var(--info) 8%, var(--surface)); margin: var(--gap) 0; }
.callout.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.callout.example { border-left-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 8%, var(--surface)); }
.callout b { display: block; margin-bottom: 4px; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.t th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
code.ui, .ui { font-family: var(--font); font-weight: 700; padding: .05em .4em; border-radius: 6px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); white-space: nowrap; }

/* walkthrough */
.wt { display: grid; grid-template-columns: 1.7fr 1fr; gap: var(--gap); align-items: start; }
.wt > [data-visual] { position: sticky; top: 84px; }
.wt .steps { max-height: min(62vh, 560px); overflow: auto; padding-right: 4px; scroll-behavior: smooth; }
.wt-screen { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #fff; cursor: zoom-in; }
.wt-screen svg, .wt-screen img { display: block; width: 100%; height: auto; }
.shot-hs { position: absolute; border: 3px solid #00e5ff; border-radius: 10px; box-shadow: 0 0 0 4000px rgba(0,0,0,.18), 0 0 18px #00e5ff; animation: pulse 1.6s infinite; pointer-events: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4000px rgba(0,0,0,.18), 0 0 4px #00e5ff; } }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .85rem; background: var(--surface2); border: 1px solid var(--border); }
.steps li[aria-current="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.steps li[aria-current="true"]::before { background: var(--accent); color: var(--on-accent); }
.steps li.done::before { content: "✓"; color: var(--ok); }
.steps .st { font-weight: 700; } .steps .sx { font-size: .9rem; color: var(--muted); }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.82); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox > div { position: relative; width: min(1400px, 96vw); background: #fff; border-radius: 12px; overflow: hidden; }

/* video */
.video { position: relative; aspect-ratio: 16/9; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* quiz */
.q { padding: 18px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface2); }
.q + .q { margin-top: var(--gap); }
.q .qp { font-weight: 650; margin-bottom: 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); margin: 6px 0; cursor: pointer; background: var(--surface-solid); }
.opt:hover { border-color: var(--accent); }
.opt input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin-top: 2px; }
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface-solid)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface-solid)); }
.fb { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: .94rem; }
.fb.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.fb.hint { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.fb.final { background: color-mix(in srgb, var(--info) 12%, transparent); border: 1px solid color-mix(in srgb, var(--info) 40%, transparent); }
.order-list { list-style: none; padding: 0; margin: 0; }
.order-list li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin: 6px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-solid); cursor: grab; }
.order-list li.dragging { opacity: .5; }
.order-list .mv { margin-left: auto; display: flex; gap: 4px; }

/* widgets */
.bins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bin { min-height: 130px; padding: 10px; border-radius: 14px; border: 2px dashed var(--border); background: var(--surface2); }
.bin.over { border-color: var(--accent); box-shadow: var(--glow); }
.bin h5 { margin: 0 0 6px; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chip { display: inline-block; padding: 8px 10px; margin: 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-solid); cursor: grab; font-size: .9rem; max-width: 100%; }
.chip.sel { border-color: var(--accent); box-shadow: var(--glow); }
.chip.ok { border-color: var(--ok); } .chip.bad { border-color: var(--bad); }
.pool { min-height: 60px; padding: 8px; border-radius: 14px; border: 1px solid var(--border); margin-bottom: 10px; }
.via-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.via-grid button { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2); cursor: pointer; }
.via-grid button[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--glow); }
.virtue { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-text); }
.preview-post { border-radius: 14px; border: 1px solid var(--border); padding: 14px; background: var(--surface-solid); white-space: pre-wrap; }
.meter { display: flex; gap: 4px; } .meter i { flex: 1; height: 6px; border-radius: 3px; background: var(--surface2); } .meter i.on { background: var(--accent); }
.frame-box { position: relative; aspect-ratio: 1; max-width: 420px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface2); display: grid; place-items: center; }
.frame-box img { width: 100%; height: 100%; object-fit: cover; }
.frame-box svg.guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scale { display: flex; gap: 6px; } .scale button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); cursor: pointer; font-weight: 700; } .scale button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.path-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.path-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* summary */
.summary { display: grid; grid-template-columns: 260px 1fr; gap: calc(var(--gap) * 1.5); align-items: center; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface2); }
.stat b { display: block; font-size: 1.5rem; font-family: var(--mono); }
.badge-big { width: 240px; filter: drop-shadow(0 0 24px color-mix(in srgb, var(--accent) 45%, transparent)); animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6) rotate(-8deg); opacity: 0; } }

/* drawer / modal */
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 100vw); z-index: 80; background: var(--surface-solid); border-left: 1px solid var(--border); box-shadow: -10px 0 40px rgba(0,0,0,.35); display: flex; flex-direction: column; transform: translateX(105%); transition: transform .25s; }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.drawer .body { padding: 16px; overflow: auto; flex: 1; }
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.4); }
.modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.55); }
.modal > .card { width: min(720px, 100%); max-height: 90vh; overflow: auto; background: var(--surface-solid); }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatches button { aspect-ratio: 1.4; border-radius: 12px; border: 2px solid var(--border); cursor: pointer; position: relative; }
.swatches button[aria-pressed="true"] { border-color: var(--text); box-shadow: var(--glow); }
.swatches span { position: absolute; bottom: 3px; left: 0; right: 0; font-size: .62rem; font-weight: 700; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg button { padding: .5em .9em; border: 0; background: var(--surface2); cursor: pointer; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--surface2); border: 1px solid var(--border); font-size: .92rem; }
.msg.me { align-self: flex-end; background: color-mix(in srgb, var(--accent) 16%, var(--surface2)); }
.msg time { display: block; font-size: .7rem; color: var(--muted); }

/* teacher */
.tbl-compact { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tbl-compact th, .tbl-compact td { padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.tbl-compact th { position: sticky; top: 0; background: var(--surface-solid); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); cursor: pointer; z-index: 1; }
.tbl-compact tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.st-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.st-online { background: var(--ok); box-shadow: 0 0 8px var(--ok); } .st-departed { background: var(--warn); } .st-offline { background: #6b7280; }
.mini-bar { width: 80px; height: 6px; border-radius: 3px; background: var(--surface2); display: inline-block; vertical-align: middle; overflow: hidden; } .mini-bar i { display: block; height: 100%; background: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.kpi { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2); } .kpi b { font-size: 1.3rem; font-family: var(--mono); display: block; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* editor */
.editor { display: grid; grid-template-columns: 250px 1fr 380px; gap: var(--gap); align-items: start; }
.editor .list button { display: flex; width: 100%; gap: 6px; text-align: left; padding: 6px 8px; border: 0; background: none; border-radius: 8px; cursor: pointer; font-size: .84rem; color: var(--text); }
.editor .list button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.editor .props { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.editor textarea.json { font-family: var(--mono); font-size: .78rem; min-height: 260px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 100; padding: 12px 16px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--accent); box-shadow: var(--glow); max-width: 92vw; }
.toast.bad { border-color: var(--bad); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-banner { background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 25%, transparent), transparent); border-bottom: 1px solid var(--border); padding: 6px 16px; font-size: .82rem; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .editor { grid-template-columns: 210px 1fr; } .editor .props { grid-column: 1 / -1; position: static; max-height: none; } }
@media (max-width: 980px) {
  .player { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 60; max-height: none; transform: translateX(-105%); transition: transform .25s; border-radius: 0; background: var(--surface-solid); }
  .rail.open { transform: none; }
  .rail-toggle, .rail .rail-toggle { display: inline-grid; }
  .wt { grid-template-columns: 1fr; }
  .wt > [data-visual] { position: static; }
  .wt .steps { max-height: 38vh; }
  .hero-dash, .summary { grid-template-columns: 1fr; }
  .bins { grid-template-columns: repeat(2, 1fr); }
  .top-progress { display: none; }
}
@media (max-width: 420px) { .hide-xs { display: none !important; } .timer { font-size: .78rem; padding: .2em .4em; } }
@media (max-width: 640px) {
  .music .name, .brand small, .hide-sm { display: none; }
  .topbar { gap: 6px; } .icon-btn { width: 38px; height: 38px; }
  .editor { grid-template-columns: 1fr; }
  .bins { grid-template-columns: 1fr; }
  .swatches { grid-template-columns: repeat(5, 1fr); }
}
@media print {
  .topbar, .rail, .slide-nav, .drawer, .toast { display: none !important; }
  body::before { display: none; }
}
