* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-brand);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* CRT overlay — same treatment as magivision.io */
.crt { position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(to bottom, var(--scan) 0 1px, transparent 1px 3px); mix-blend-mode: screen; }
.crt::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(0,0,0,.8); }

.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
  border-radius: var(--r-sm); padding: 7px 14px; font-size: 12px; font-weight: 500; letter-spacing: .02em;
  transition: border-color .15s, background .15s, color .15s; }
.btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--text); border-color: var(--text); color: var(--on-blue); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { border-color: transparent; color: var(--blue); }
.btn-sm { padding: 3px 8px; font-size: 10.5px; }
.btn-block { width: 100%; }

/* ============ ONBOARDING ============ */
.screen { min-height: 100%; }
#onboarding { position: relative; display: flex; flex-direction: column; overflow: hidden; }
#onboarding > .ma-head { position: relative; z-index: 3; }        /* the same header as the editor, over the pentacle loop */
.ob-main { position: relative; z-index: 2; flex: 1; display: grid; place-items: center;
  padding-block: 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.ob-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .85; }
#onboarding::before { content: ""; position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(ellipse 60% 55% at 50% 50%, rgba(3,3,4,.55), rgba(3,3,4,.15) 70%, rgba(3,3,4,.6)); }
.ob-panel { position: relative; z-index: 2; width: min(800px, 100%);
  background: linear-gradient(180deg, rgba(14,18,20,.86), rgba(8,9,10,.92));
  border: 1px solid var(--border-strong); border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 28px 40px 40px; box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(0,229,255,.05) inset; }
.ob-eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; color: var(--blue); text-align: center; text-transform: uppercase; }
.ob-panel h1 { margin: 6px 0 26px; text-align: center; font-weight: 800; font-size: clamp(28px, 4.2vw, 44px); letter-spacing: -.01em; line-height: 1.1; text-wrap: balance; }
.roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; padding-inline: 0; }
.role { position: relative; display: flex; flex-direction: column; text-align: center; gap: 6px;
  padding: 26px 16px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); transition: border-color .2s, transform .2s, box-shadow .2s; }
.role:hover, .role:focus-visible { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 0 0 1px var(--blue), 0 12px 40px rgba(0,229,255,.12); outline: none; }
.role[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.role h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.role p { margin: 0 auto; font-size: 12px; color: var(--text-dim); line-height: 1.45; max-width: 30ch; min-height: 2.9em; }
.role-art { margin-top: 12px; aspect-ratio: 271 / 130; max-width: 100%; border-radius: 6px; overflow: hidden; position: relative; background: var(--bg); border: 1px solid var(--border); }
.role-art img { width: 100%; height: 100%; object-fit: cover; display: block; }   /* coach art: option C, off-balance phase (coach_still_variants.py) */
.role-art::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(to bottom, rgba(0,229,255,.06) 0 1px, transparent 1px 3px); }
.role-art svg { width: 100%; height: 100%; display: block; }
.role-tag { position: absolute; left: 8px; bottom: 7px; z-index: 1; padding: 1px 4px; background: rgba(3,3,4,.6); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .08em; color: var(--blue); }
.role-go { margin-top: 12px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; color: var(--text-dim); text-transform: uppercase; }
.role:hover .role-go, .role:focus-visible .role-go { color: var(--blue); }
.ob-foot { margin-top: 22px; text-align: center; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }

/* ============ MATCH ANALYSIS ============ */
#analysis { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100%; min-height: 680px; background: var(--bg); }
.ma-head { display: flex; align-items: center; gap: 20px; padding-block: 14px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, var(--bg-alt), var(--bg)); border-bottom: 1px solid var(--border); }
.lockup { height: var(--lockup-h, 40px); width: auto; color: var(--text); display: block; flex: none; }
/* Header text sits on the logo's pentacle axis, not its box: in the v3 lockup the pentacle's centre is 36.93% down
   (140.44 / 380.33); the g descender pulls the box centre to 50%. Shift = (0.5 − 0.3693) × logo height. */
.ma-tagline, .forged, .ma-head-actions { position: relative; top: calc(var(--lockup-h, 40px) * -0.1307); }   /* every header item shares the pentacle axis */
.ma-tagline { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ma-tagline b { color: var(--blue); font-weight: 500; }
.ma-head-actions { display: flex; align-items: center; gap: 10px; }
/* FORGED BY SZ LABS: same mark as the Qt app header and the HUD topbar (tracked, dim, right of the tagline) */
.forged { flex: none; font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em; color: var(--text-dim); white-space: nowrap; }
.role-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 99px; background: transparent; color: var(--text-dim); }
.role-chip:hover { color: var(--blue); border-color: var(--blue-dim); }
.role-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 8px var(--blue); }

.ma-body { display: grid; grid-template-columns: 338px minmax(0, 1fr); min-height: 0; }

/* rail */
.rail { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 16px 18px 18px 22px; border-right: 1px solid var(--border); background: var(--bg-alt); }
.rail-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }
.rail-label span { font-family: var(--font-mono); font-weight: 400; font-size: 10px; letter-spacing: .04em; color: var(--text-dim); text-transform: none; }
.rounds { display: flex; gap: 6px; flex-wrap: wrap; }
.round-chip { font-family: var(--font-mono); font-size: 10.5px; padding: 3px 8px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--panel); color: var(--text-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-chip[aria-current="true"] { color: var(--blue); border-color: var(--blue-dim); background: var(--blue-wash); }
.rounds-empty { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }

.panel { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); }
.panel.grow { flex: 1 1 0; }
.panel.grow.cand { flex-grow: 2; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px 7px; border-bottom: 1px solid var(--border); }
.panel-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; color: var(--text); white-space: nowrap; }
.panel-title .slashes { color: var(--blue); }
.panel-title .count { color: var(--text-dim); margin-left: 6px; }
.panel-title small { color: var(--text-dim); font-size: 10px; letter-spacing: .02em; }
.sort { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--panel-2); font-family: var(--font-mono); font-size: 9.5px; color: var(--text-dim); }
.sort select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font-family: var(--font-mono); font-size: 9.5px; color: var(--text); padding: 0 2px; }
.sort select option { background: var(--panel-2); }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 6px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.empty-note { padding: 14px 8px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); line-height: 1.5; }

.item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 6px; border-radius: var(--r-sm); border: 1px solid transparent; }
.item + .item { margin-top: 2px; }
.item:hover { background: var(--panel-2); }
.item[aria-selected="true"] { border-color: var(--blue-dim); background: var(--blue-wash); }
.item .t { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; background: none; border: 0; padding: 0; text-align: left; }
.item .what { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11.5px; background: none; border: 0; padding: 0; text-align: left; color: var(--text); }
.item .what span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .acts { display: flex; gap: 4px; }
.dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.k-throw { --k: var(--red); }
.k-offbalance { --k: var(--blue); }
.k-entry { --k: var(--blue-dim); }
.k-manual { --k: var(--text-dim); }
.dot { background: var(--k); box-shadow: 0 0 6px var(--k); }
.score { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.score.hi { color: var(--red); }
.iconbtn { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim); padding: 0; }
.iconbtn:hover { color: var(--blue); border-color: var(--blue-dim); }
.iconbtn.on { color: var(--blue); border-color: var(--blue-dim); background: var(--blue-wash); }
.iconbtn .icon { width: 12px; height: 12px; }
.reel .item { cursor: grab; grid-template-columns: auto auto minmax(0, 1fr) auto; }
.reel .item.dragging { opacity: .4; }
.reel .item.drop-before { box-shadow: 0 -2px 0 var(--blue); }
.reel .num { font-family: var(--font-mono); font-size: 10px; color: var(--blue); width: 16px; text-align: right; }

.panel.brand .panel-head { border-bottom: 0; padding-bottom: 4px; }
.brand-row { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px 9px; min-width: 0; }
.brand-row img { width: 26px; height: 26px; border-radius: 50%; object-fit: contain; background: #fff; flex: none; }
.brand-row .bname { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 10.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-row .bhint { flex: 1; min-width: 0; font-size: 10.5px; line-height: 1.35; color: var(--text-dim); }
.dots { display: flex; gap: 4px; flex: none; }
.dots i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border-strong); }
.count-chip { margin-left: 8px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--blue-dim); color: var(--blue); font-size: 9.5px; letter-spacing: .04em; }

/* stage */
.stage { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-height: 0; min-width: 0; padding: 16px 24px 18px 20px; gap: 12px; }
.viewer { position: relative; min-height: 280px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-strong);
  background: radial-gradient(ellipse at 50% 40%, #0d1518, var(--panel) 70%); }
.viewer.drag { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), inset 0 0 80px rgba(0,229,255,.08); }
.viewer::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, rgba(0,229,255,.03) 0 1px, transparent 1px 3px); }
.analyze { position: absolute; z-index: 4; top: 16px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px; padding: 9px 18px 9px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: .01em; color: var(--text);
  background: rgba(14,18,20,.82); border: 1px solid var(--border-strong); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.analyze .icon { width: 22px; height: 22px; color: var(--blue); }
.analyze:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.analyze:disabled { opacity: .55; cursor: not-allowed; }
.analyze.running .icon { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.drop { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; padding: 70px 16px 40px; }
.drop-plus { width: 76px; height: 76px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--blue); transition: transform .2s, border-color .2s, box-shadow .2s; }
.drop-plus .icon { width: 36px; height: 36px; stroke-width: 1.6; }
.drop-plus:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 0 30px rgba(0,229,255,.18); }
.drop strong { font-size: 15px; font-weight: 600; }
.drop p { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.drop .fmt { margin-top: 10px; font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); letter-spacing: .04em; }
.drop .link { margin-top: 14px; }

.feed { position: absolute; inset: 0; background: var(--bg); }
.feed video, .feed img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--bg); }
.feed img.still { object-fit: cover; background: transparent; filter: invert(1) sepia(.5) hue-rotate(140deg) saturate(2) brightness(.9); }
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; font-family: var(--font-mono); font-size: 10.5px; color: var(--text); }
.hud::before, .hud::after { content: ""; position: absolute; left: 0; right: 0; height: 96px; }
.hud::before { top: 0; background: linear-gradient(180deg, var(--shade), transparent); }
.hud::after { bottom: 0; background: linear-gradient(0deg, var(--shade), transparent); }
.hud > * { z-index: 1; }
.hud .tl { position: absolute; top: 16px; left: 16px; display: flex; flex-direction: column; gap: 2px; }
.hud .tl b { color: var(--blue); font-weight: 500; letter-spacing: .06em; }
.hud .tr { position: absolute; top: 16px; right: 16px; text-align: right; color: var(--text-dim); }
.hud .flag { position: absolute; left: 16px; bottom: 16px; padding: 3px 8px; border-radius: 2px; background: var(--k); color: var(--on-blue); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 10px; }
.hud .box { position: absolute; border: 1px solid var(--blue); box-shadow: 0 0 12px rgba(0,229,255,.25); }
.hud .box::before { content: attr(data-label); position: absolute; top: -17px; left: -1px; padding: 1px 5px; background: var(--blue); color: var(--on-blue); font-size: 9.5px; }
.fs { position: absolute; z-index: 4; right: 14px; bottom: 12px; color: var(--text); background: var(--shade); border-color: var(--border); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sample-tag { position: absolute; z-index: 3; top: 56px; right: 16px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; color: var(--red); border: 1px solid var(--red-dim); padding: 2px 6px; border-radius: 2px; background: var(--shade); }

.progress { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; padding: 10px 16px 12px; background: linear-gradient(0deg, rgba(3,3,4,.92), rgba(3,3,4,0)); font-family: var(--font-mono); font-size: 10.5px; color: var(--text); }
.bar { margin-top: 6px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--blue); box-shadow: 0 0 10px var(--blue); transition: width .25s; }

/* transport */
.transport { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.transport-mid { display: flex; align-items: center; gap: 12px; }
.crop-group { justify-self: end; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ctl-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; color: var(--text-dim); text-transform: uppercase; white-space: nowrap; }
.panel-foot { padding: 6px 10px 7px; border-top: 1px solid var(--border); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; justify-self: start; }
.seg button { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 0; background: var(--panel-2); color: var(--text-dim); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .03em; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button:hover:not(:disabled) { color: var(--blue); }
.seg button[aria-pressed="true"] { background: var(--blue); color: var(--on-blue); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.ar { display: inline-block; width: 14px; height: 8px; border: 1.5px solid currentColor; border-radius: 1.5px; }
.ar.v { width: 7px; height: 12px; }

/* mobile crop (9:16) */
.cropper { position: absolute; z-index: 3; overflow: hidden; pointer-events: none; }
.crop-win { position: absolute; top: 0; height: 100%; border: 1.5px solid var(--blue); box-shadow: 0 0 0 200vmax rgba(3,3,4,.66); pointer-events: auto; cursor: grab; touch-action: none; transition: left .14s linear;
  background-image: linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(0,229,255,.22) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(0,229,255,.22) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px)); }
.crop-win.dragging { cursor: grabbing; transition: none; }
.cropper.guide .crop-win { box-shadow: none; border: 1.5px dashed rgba(0,229,255,.75); background-image: none; }
.cropper.guide .ghost-lockup { display: none; }
.cropper.guide .clbl { background: rgba(3,3,4,.7); color: var(--blue); }
.crop-win .clbl { position: absolute; bottom: 0; left: 0; padding: 2px 6px; background: var(--blue); color: var(--on-blue); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em; white-space: nowrap; }
.crop-win .clbl.fixed { background: var(--text); }
/* mobile lockup: centred; both logos +20% then +40% (badge 128 px, MAGI 78 px at 1080 wide).
   MAGI is the v3 lockup (same #magi-lockup symbol as the header), aligned on its pentacle / letter-body axis
   (36.9% down its box), not its box: the g descender would pull it high. */
.ghost-lockup { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--ch) * .08); display: flex; align-items: center; gap: calc(var(--cw) * .0407); opacity: .95; pointer-events: none; }
.ghost-lockup img { height: calc(var(--cw) * .1185); width: auto; display: block; }
.ghost-lockup .dia { height: calc(var(--cw) * .0731); width: auto; display: block; }   /* divider F: line · cyan diamond · line */
.ghost-lockup svg { height: calc(var(--cw) * .0722); width: auto; color: #fff; display: block; transform: translateY(13.1%); }
.transport-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-self: start; min-width: 0; }
.play { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); padding: 0; }
.play:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.play:disabled { opacity: .4; cursor: not-allowed; }
.play .icon { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.tc { font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text); }
.tc .sep { color: var(--border-strong); margin: 0 6px; }
.tc .dur { color: var(--text-dim); }
.kbd-hint { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }
.kbd-hint kbd { font-family: inherit; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: 2px; color: var(--text); }

/* event track */
.track-wrap { border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.track { position: relative; height: 112px; min-width: 100%; }
.ruler { position: absolute; left: 0; right: 0; top: 0; height: 18px; border-bottom: 1px solid var(--border); }
.tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--border); padding-left: 4px; font-family: var(--font-mono); font-size: 9px; line-height: 17px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.lane { position: absolute; left: 0; right: 0; top: 18px; bottom: 0; cursor: pointer; }
.ev { position: absolute; height: 34px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 0 9px;
  border-radius: 4px; border: 1px solid color-mix(in srgb, var(--k) 55%, transparent); background: color-mix(in srgb, var(--k) 12%, var(--panel-2));
  color: var(--text); text-align: left; overflow: hidden; }
.ev::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--k); }
.ev b { font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.ev span { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-dim); white-space: nowrap; }
.ev:hover { border-color: var(--k); }
.ev[aria-selected="true"] { border-color: var(--k); box-shadow: 0 0 0 1px var(--k), 0 0 18px color-mix(in srgb, var(--k) 35%, transparent); }
.ev.kept::after { content: "★"; position: absolute; top: 4px; right: 6px; font-size: 9px; color: var(--k); }
.playhead { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--red); z-index: 3; pointer-events: none; }
.playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 5px solid transparent; border-top-color: var(--red); }
.track-empty { position: absolute; inset: 18px 0 0; display: grid; place-items: center; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }
.track-empty-blocks { position: absolute; inset: 30px 12px 12px; display: grid; grid-template-columns: 1fr 1.6fr .3fr 1.1fr .5fr .6fr; gap: 14px; opacity: .55; }
.track-empty-blocks i { border: 1px dashed var(--border-strong); border-radius: 4px; }
.track-empty-blocks i:nth-child(3), .track-empty-blocks i:nth-child(5) { border: 0; }
.track-empty span { position: relative; z-index: 1; padding: 3px 8px; background: var(--panel); }

/* dialogs */
dialog { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(440px, calc(100% - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.7); }
dialog::backdrop { background: rgba(3,3,4,.7); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.dlg-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.dlg-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lbl { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; color: var(--text-dim); text-transform: uppercase; }
.field input[type=text], .field select { background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; }
.field input[type=text]:focus, .field select:focus { border-color: var(--blue); outline: none; }
.colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.colors input[type=color] { width: 100%; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--panel-2); padding: 2px; }
.logo-drop { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--r-md); }
.logo-drop .prev { width: 52px; height: 52px; border-radius: var(--r-sm); background: var(--panel-2); display: grid; place-items: center; overflow: hidden; font-family: var(--font-mono); font-size: 9px; color: var(--text-dim); }
.logo-drop .prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; }
.check input { accent-color: var(--blue); margin-top: 3px; }
.check small { display: block; color: var(--text-dim); font-size: 11px; }
.export-summary { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); padding: 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel-2); }
.export-summary b { color: var(--text); font-weight: 500; }

/* export result */
.result-tabs { margin-bottom: 10px; }
.result-player.portrait video { aspect-ratio: 9 / 16; width: auto; height: min(52dvh, 540px); max-width: 100%; margin: 0 auto; }
#result-files { max-height: 330px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
dialog.wide { width: min(1080px, calc(100% - 32px)); }
/* Export complete: title and the Show in Finder row stay on screen; only the middle scrolls when space runs out */
dialog.wide[open] { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); overflow: hidden; }
dialog.wide > .dlg-head, dialog.wide > .result-foot { flex: none; }
dialog.wide > .result { flex: 1 1 auto; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.result { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; padding: 16px 18px; }
.result-player video { display: block; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px; }
.result-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.file { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 4px 10px; align-items: center; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel-2); text-align: left; }
.file + .file { margin-top: 6px; }
.file-wrap { display: flex; gap: 6px; align-items: stretch; }
.file-wrap + .file-wrap { margin-top: 6px; }
.file-wrap .file { flex: 1; min-width: 0; margin-top: 0; }
.dl { align-self: center; text-decoration: none; }
.file:hover { border-color: var(--blue-dim); }
.file[aria-current="true"] { border-color: var(--blue); background: var(--blue-wash); }
.file b { display: block; font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; }
.file small { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.file .tag { font-family: var(--font-mono); font-size: 9px; color: var(--blue); letter-spacing: .08em; }
.checks { display: flex; flex-direction: column; gap: 8px; font-size: 11.5px; line-height: 1.4; }
.checks div { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 6px; }
.checks i { font-style: normal; color: var(--blue); }
.checks small { color: var(--text-dim); font-family: var(--font-mono); font-size: 10px; }
.result-folder { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); margin-top: 2px; overflow-wrap: anywhere; }
.result-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.result-foot .score { flex: 1 1 280px; line-height: 1.45; }
@media (max-width: 760px) { .result { grid-template-columns: minmax(0, 1fr); } }

/* ---------- guided tour ---------- */
.tour { position: fixed; inset: 0; z-index: 70; }
.tour-spot { position: fixed; border: 2px solid var(--blue); border-radius: 10px; box-shadow: 0 0 0 200vmax rgba(3,3,4,.76); pointer-events: none;
  transition: left .28s ease, top .28s ease, width .28s ease, height .28s ease; }
.tour-spot::after { content: ""; position: absolute; inset: -8px; border: 2px solid var(--blue); border-radius: 14px; opacity: 0; animation: tour-pulse 1.6s ease-out infinite; }
@keyframes tour-pulse { 0% { opacity: .7; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.06); } }
.tour-tip { position: fixed; width: min(320px, calc(100vw - 24px)); padding: 16px 16px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border-strong);
  box-shadow: 0 20px 60px rgba(0,0,0,.6); outline: none; }
.tour-count { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; color: var(--blue); text-transform: uppercase; }
.tour-tip h4 { margin: 4px 0 6px; font-size: 17px; font-weight: 700; text-wrap: balance; }
.tour-tip p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text); }
/* the real button, drawn inline where the copy names it */
.tour-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; margin: 0 2px; vertical-align: -6px; border-radius: 3px;
  border: 1px solid var(--blue-dim); background: var(--blue-wash); color: var(--blue); }
.tour-ico .icon { width: 13px; height: 13px; }
.tour-ico.solid { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.tour-tip .tour-op { margin-top: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.tour-dots { display: flex; gap: 5px; margin-top: 12px; }
.tour-dots i { width: 6px; height: 6px; transform: rotate(45deg); background: var(--border-strong); }
.tour-dots i.on { background: var(--blue); }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tour-foot .grow { flex: 1; }
.tw { text-align: left; }
.tw h3 { margin: 4px 0 6px; font-size: 20px; font-weight: 700; }
.tw p { margin: 0; font-size: 13px; color: var(--text-dim); }
.tw-steps { list-style: none; counter-reset: s; display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; padding: 0; }
.tw-steps li { counter-increment: s; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border: 1px solid var(--border-strong); border-radius: 99px; font-size: 11.5px; }
.tw-steps li::before { content: counter(s); width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; background: var(--blue); color: var(--on-blue); font: 600 10px var(--font-mono); }
@media (max-width: 600px) {
  .tour-tip { left: 12px !important; right: 12px; top: auto !important; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: auto; }
  #tour-btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tour-spot::after { animation: none; } }

/* toast */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  max-width: calc(100% - 32px); padding: 8px 14px; border-radius: var(--r-sm); background: var(--panel-2); border: 1px solid var(--border-strong); font-family: var(--font-mono); font-size: 11px; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* demo-only state switcher */
.demo-bar { position: fixed; z-index: 55; left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 4px; padding: 4px; border-radius: 8px; background: rgba(10,11,12,.9); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 10px; }
.demo-bar span { padding: 4px 6px; color: var(--text-dim); letter-spacing: .08em; }
.demo-bar a { padding: 4px 8px; border-radius: 5px; color: var(--text-dim); text-decoration: none; }
.demo-bar a:hover { color: var(--blue); }
.demo-bar a[aria-current="true"] { color: var(--on-blue); background: var(--blue); }

body.demo .rail { padding-bottom: 60px; }

/* role-dependent detail */
body[data-role="coach"] .op-only { display: none !important; }

@media (max-width: 900px) {
  #analysis { height: auto; min-height: 100%; }
  .ma-body { grid-template-columns: minmax(0, 1fr); }
  .rail { order: 2; border-right: 0; border-top: 1px solid var(--border); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .panel.grow { flex: none; height: 200px; }
  .panel.grow.cand { height: 300px; }
  .transport { grid-template-columns: minmax(0, 1fr) auto; }
  .stage { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .viewer { aspect-ratio: 16 / 10; min-height: 0; max-width: 100%; }
  .ma-tagline { display: none; }
  .ma-head { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); justify-content: space-between; }
  .roles { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .ob-panel { padding: 24px 18px 24px; }
  .ob-main { place-items: start center; align-content: center; padding-block: 28px; }
}
@media (max-width: 600px) { .forged { display: none; } }
@media (max-width: 520px) {
  .ma-head { --lockup-h: 30px; }
  .analyze { font-size: 12px; padding: 7px 12px 7px 10px; }
  .kbd-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ob-bg { display: none; }
  #onboarding { background: center / cover url("assets/magi_pentacle_bg_poster.jpg"), var(--bg); }
}

/* ---------- portal-host additions: highlight extras, tag popover ---------- */
.item .below { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 2px 0 2px 0; }
.chip { font-family: var(--font-mono); font-size: 9.5px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--blue-dim); color: var(--blue); background: var(--blue-wash); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trim-row { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }
.trim-row .lbl { text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
.trim-row .tnum { color: var(--text); min-width: 5.2ch; text-align: center; }
.trim-row .iconbtn { font-size: 13px; line-height: 1; }
.tag-pop { position: fixed; z-index: 65; width: 260px; max-height: 340px; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--border-strong); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.tag-pop .pop-head { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; color: var(--text-dim); text-transform: uppercase; }
.tag-pop .pop-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; max-height: 190px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.tag-pop .pop-add { display: flex; gap: 6px; }
.tag-pop .pop-add input { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 5px 8px; font-size: 12px; }
.tag-pop .pop-add input:focus { border-color: var(--blue); outline: none; }
#add-moment { white-space: nowrap; }
