@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/assets/fonts/inter-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/assets/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  --bg: #0a0b0e;
  --bg-2: #0f1115;
  --panel: #14161b;
  --panel-2: #1a1d23;
  --panel-3: #22252d;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --text: #eceef2;
  --muted: #8d929e;
  --faint: #5c616c;
  --accent: #ff5b3a;
  --accent-2: #ff8b5e;
  --accent-soft: rgba(255, 91, 58, .14);
  --ok: #3ddc84;
  --warn: #ffb020;
  --r: 14px;
  --r-sm: 10px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 50px -20px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------------- stage ---------------- */
.stage { position: relative; overflow: hidden; background: #000; contain: strict; }
.stage-fit, .stage-view { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage-view { transition: transform .08s linear; will-change: transform; }
.stage-frames, .stage-frames iframe, .stage-ink, .stage-laser { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-frames iframe {
  border: 0; background: #fff; opacity: 0; transition: opacity .35s ease; pointer-events: none;
  color-scheme: light;
}
.stage-frames iframe.on { opacity: 1; }
.stage-frames iframe.top { z-index: 1; }
.stage-ink, .stage-laser { pointer-events: none; overflow: visible; z-index: 2; }
.stage-laser { z-index: 3; opacity: 0; transition: opacity .15s; }
.stage-laser.on { opacity: 1; }
.laser-dot { fill: rgba(255, 40, 40, .28); filter: drop-shadow(0 0 10px rgba(255, 30, 30, .9)); }
.laser-core { fill: #ff3b30; stroke: #fff; stroke-width: 2; }
.laser-trail { fill: none; stroke: rgba(255, 50, 40, .45); stroke-linecap: round; stroke-linejoin: round; }
.stage-cover {
  position: absolute; inset: 0; z-index: 5; background: #000; opacity: 0; pointer-events: none;
  transition: opacity .45s ease; display: grid; place-items: center;
}
.stage.is-hidden .stage-cover { opacity: 1; }

/* ---------------- shared controls ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text);
  font-weight: 550; letter-spacing: -.005em; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #ff6d4f; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { color: #ff7a6b; }
.btn.danger.armed { background: #c9301e; color: #fff; border-color: transparent; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted);
  transition: background .15s, color .15s, transform .08s; text-decoration: none; position: relative;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--text); color: #0b0c0f; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.armed { background: #c9301e; color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 500;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- login ---------------- */
.login-page {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 91, 58, .16), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(110, 90, 255, .12), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; padding: 32px 28px 28px; border-radius: 20px;
  background: rgba(20, 22, 27, .82); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.login-card h1 { margin: 20px 0 6px; font-size: 22px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.field {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line-2); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card .btn { width: 100%; height: 46px; margin-top: 12px; font-size: 15px; }
.login-err { min-height: 20px; margin-top: 12px; color: #ff7a6b; font-size: 13px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.02em; font-size: 15px; }
.logo-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none; position: relative;
  background: linear-gradient(135deg, var(--accent), #ff2d6f);
  box-shadow: 0 6px 18px -6px rgba(255, 70, 60, .7);
}
.logo-mark::after {
  content: ""; position: absolute; left: 7px; top: 8px; width: 12px; height: 8px; border-radius: 2px;
  border: 2px solid #fff; border-bottom-width: 3px;
}

/* ---------------- presenter ---------------- */
.presenter { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.topbar > * { flex-shrink: 0; }
.topbar > .set-picker { flex-shrink: 1; }
.topbar {
  display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}
.topbar .spacer { flex: 1; }
.divider { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; flex: none; }
.set-picker {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 420px; height: 38px; padding: 0 10px 0 12px;
  border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line); text-align: left;
  transition: background .15s, border-color .15s;
}
.set-picker:hover { background: var(--panel-2); border-color: var(--line-2); }
.set-picker .lbl { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.set-picker .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-picker svg { color: var(--muted); }
.timer {
  font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 550; padding: 6px 10px; border-radius: 8px;
  background: none; border: 0;
}
.timer:hover { background: var(--panel); color: var(--text); }
.live-pill {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 550; font-size: 13px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-pill.live { color: #ffd9cf; background: var(--accent-soft); border-color: rgba(255, 91, 58, .3); }
.live-pill.live .dot { background: var(--accent); animation: pulse 1.8s infinite; }
.live-pill.paused .dot { background: var(--warn); }
.live-pill.offline { color: var(--warn); }
.live-pill.offline .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 91, 58, .6); } 70% { box-shadow: 0 0 0 8px rgba(255, 91, 58, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 91, 58, 0); } }
#hideBtn.on { background: var(--warn); color: #1a1200; border-color: transparent; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.main-col { display: flex; flex-direction: column; gap: 12px; padding: 16px; min-width: 0; min-height: 0; }
.stage-wrap {
  position: relative; flex: 1; min-height: 0; border-radius: var(--r); overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #16181d, #0b0c0f 70%);
  border: 1px solid var(--line);
}
.stage-wrap .stage { position: absolute; inset: 0; background: transparent; }
.stage-wrap .stage .stage-fit { box-shadow: 0 30px 80px -30px #000; }
.stage-wrap .stage-view { transition: none; }
.stage-wrap .stage-cover {
  background: rgba(8, 9, 12, .72); backdrop-filter: blur(2px);
  color: var(--warn); font-weight: 600; letter-spacing: .01em;
}
.stage-wrap .stage-cover span { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: rgba(0,0,0,.6); border: 1px solid rgba(255,176,32,.35); }
.surface { position: absolute; inset: 0; z-index: 10; touch-action: none; }
.surface[data-tool="move"] { cursor: grab; }
.surface[data-tool="move"].dragging { cursor: grabbing; }
.surface[data-tool="pen"], .surface[data-tool="hl"] { cursor: crosshair; }
.surface[data-tool="laser"] { cursor: none; }
.surface[data-tool="erase"] { cursor: cell; }
.zoom-badge {
  position: absolute; right: 12px; top: 12px; z-index: 11; padding: 5px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .65); border: 1px solid var(--line-2); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.zoom-badge.show { opacity: 1; }
.empty-stage {
  position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; text-align: center; padding: 24px;
  color: var(--muted);
}
.empty-stage h2 { color: var(--text); margin: 16px 0 6px; font-size: 20px; letter-spacing: -.02em; }
.empty-stage p { margin: 0 0 18px; }
.empty-stage .big-icon { width: 56px; height: 56px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--accent); }
.empty-stage .big-icon svg { width: 26px; height: 26px; }

.toolbar {
  display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); flex-wrap: nowrap;
}
.toolbar .group { display: flex; align-items: center; gap: 2px; flex: none; }
.toolbar .tools-scroll { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.toolbar .zoom-group { margin-left: auto; }
body:not(.has-set) .stage-wrap .stage .stage-fit { box-shadow: none; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 6px; flex: none; }
.toolbar .grow { flex: 1; }
.nav { gap: 4px !important; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--line-2); font-weight: 600;
  transition: background .15s, transform .08s;
}
.nav-btn:hover { background: var(--panel-3); }
.nav-btn:active { transform: scale(.96); }
.nav-btn:disabled { opacity: .35; pointer-events: none; }
.nav-btn.next { background: var(--text); color: #0b0c0f; border-color: transparent; }
.nav-btn.next:hover { background: #fff; }
.counter { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.counter b { color: var(--text); }
.swatch {
  width: 24px; height: 24px; border-radius: 50%; border: 0; padding: 0; margin: 0 3px; flex: none;
  background: var(--c); box-shadow: 0 0 0 1px rgba(255,255,255,.18) inset; position: relative;
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--c), 0 0 0 1px rgba(255,255,255,.2) inset; }
.swatch[style*="#111"].on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px #777; }
.size-btn { width: 32px; }
.size-btn i { display: block; border-radius: 50%; background: currentColor; }
.zoom-val { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); font-size: 13px; background: none; border: 0; height: 32px; border-radius: 8px; }
.zoom-val:hover { background: var(--panel-2); color: var(--text); }

.side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg-2); }
.side-sec { padding: 16px 16px 0; }
.side-label { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .09em; margin-bottom: 10px; }
.side-label span:last-child { text-transform: none; letter-spacing: 0; font-weight: 550; }
.next-card { position: relative; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line-2); aspect-ratio: var(--ar, 16/9); background: #000; cursor: pointer; }
.next-card .stage { position: absolute; inset: 0; }
.next-card .end { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-weight: 600; background: var(--panel); }
.strip { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: max-content; gap: 10px; align-content: start; scrollbar-width: thin; }
.thumb {
  position: relative; display: block; width: 100%; border-radius: 8px; overflow: hidden; background: #fff;
  border: 0; padding: 0; outline: 1px solid var(--line-2); outline-offset: 0; transition: outline-color .15s, transform .12s;
}
.thumb::before { content: ""; display: block; padding-top: var(--arp, 56.25%); }
.thumb:hover { outline-color: rgba(255,255,255,.35); }
.thumb.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.thumb-inner iframe { border: 0; width: 100%; height: 100%; display: block; background: #fff; color-scheme: light; }
.thumb .num {
  position: absolute; left: 6px; bottom: 6px; z-index: 1; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: 11px; font-weight: 650; display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.thumb.on .num { background: var(--accent); }

/* ---------------- library sheet ---------------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 7, .66); backdrop-filter: blur(6px); animation: fade .2s; }
.sheet {
  position: relative; width: 100%; max-width: 920px; max-height: min(820px, calc(100dvh - 48px)); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; box-shadow: var(--shadow);
  animation: rise .25s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px 22px; }
.sheet-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; flex: 1; }
.sheet-body { overflow: auto; padding: 0 22px 22px; }
.drop {
  display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--r);
  border: 1.5px dashed var(--line-2); background: var(--bg-2); transition: border-color .15s, background .15s; position: relative; overflow: hidden;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .drop-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); flex: none; }
.drop .drop-text { flex: 1; min-width: 0; }
.drop .drop-text b { display: block; font-size: 15px; letter-spacing: -.01em; }
.drop .drop-text span { color: var(--muted); font-size: 13px; }
.drop .drop-actions { display: flex; gap: 8px; }
.drop .progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; transition: width .2s; }
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-auto-rows: max-content; gap: 14px; margin-top: 18px; }
.set-card {
  border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.set-card:hover { border-color: var(--line-2); }
.set-card.live { border-color: rgba(255, 91, 58, .5); box-shadow: 0 0 0 1px rgba(255, 91, 58, .25); }
.set-card .thumb { border-radius: 0; outline: 0; cursor: pointer; }
.set-card .badge {
  position: absolute; left: 10px; top: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.set-card .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.set-card .info { padding: 12px 12px 4px; }
.set-card .title-input {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 4px 6px; margin: -4px -6px 2px;
  font-weight: 650; font-size: 15px; letter-spacing: -.01em; outline: none; text-overflow: ellipsis;
}
.set-card .title-input:hover { border-color: var(--line-2); }
.set-card .title-input:focus { border-color: var(--accent); background: var(--panel); }
.set-card .meta { color: var(--muted); font-size: 12.5px; }
.set-card .actions { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px; }
.set-card .actions .btn { height: 34px; }
.set-card .actions .btn.primary { flex: 1; }
.set-card select {
  height: 34px; border-radius: var(--r-sm); background: var(--panel-2); border: 1px solid var(--line-2); padding: 0 8px; font-size: 13px; color: var(--muted);
}
.sets-empty { grid-column: 1/-1; text-align: center; padding: 36px 0 18px; color: var(--muted); }

/* ---------------- viewer ---------------- */
.viewer { background: #000; overflow: hidden; height: 100dvh; cursor: default; }
.viewer.idle-cursor { cursor: none; }
.viewer #stage { position: fixed; inset: 0; }
.viewer .stage-frames iframe { background: #000; }
.viewer .stage-frames iframe.on { background: #fff; }
.idle-screen {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; text-align: center; padding: 24px;
  background:
    radial-gradient(1000px 600px at 50% 120%, rgba(255, 91, 58, .13), transparent 60%),
    #050608;
  opacity: 0; pointer-events: none; transition: opacity .6s ease;
}
.viewer.no-set .idle-screen { opacity: 1; }
.idle-screen .brand { justify-content: center; font-size: clamp(18px, 2.4vw, 30px); }
.idle-screen .logo-mark { width: 1.6em; height: 1.6em; border-radius: .5em; }
.idle-screen .logo-mark::after { left: 27%; top: 30%; width: 46%; height: 32%; }
.idle-screen p { margin: 1.2em 0 0; color: var(--muted); font-size: clamp(13px, 1.3vw, 18px); display: inline-flex; align-items: center; gap: .7em; }
.idle-screen p i { width: .55em; height: .55em; border-radius: 50%; background: var(--accent); animation: pulse 1.8s infinite; }
.conn {
  position: fixed; left: 50%; top: 18px; z-index: 30; transform: translate(-50%, -10px); opacity: 0; transition: all .25s;
  padding: 8px 14px; border-radius: 999px; background: rgba(20, 22, 27, .85); border: 1px solid var(--line-2); color: var(--warn); font-weight: 550; font-size: 13px;
  pointer-events: none; display: flex; align-items: center; gap: 8px;
}
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); animation: pulse 1s infinite; }
.viewer.offline .conn { opacity: 1; transform: translate(-50%, 0); }
.fs-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 30; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; background: rgba(20, 22, 27, .7); border: 1px solid var(--line-2); color: var(--text);
  backdrop-filter: blur(10px); opacity: 0; transition: opacity .3s;
}
.viewer.ui .fs-btn { opacity: 1; }

/* ---------------- responsive ---------------- */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 240px; }
  .timer { display: none; }
}
@media (max-width: 900px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar .nav { order: 1; width: 100%; }
  .toolbar .nav .nav-btn { flex: 1; justify-content: center; height: 44px; }
  .toolbar .nav-sep { display: none; }
  .toolbar .tools-scroll { order: 2; }
}
@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  .topbar { height: 54px; gap: 6px; padding: 0 10px; }
  .topbar .brand span, .set-picker .lbl, .open-label, .hide-label, .divider { display: none; }
  .set-picker { flex: 1; max-width: none; }
  .live-pill { padding: 0 10px; }
  .live-pill .word { display: none; }
  .workspace { display: flex; flex-direction: column; overflow: hidden; }
  .main-col { padding: 10px 10px 8px; gap: 8px; flex: none; }
  .stage-wrap { flex: none; aspect-ratio: var(--ar, 16/9); max-height: 52dvh; border-radius: 12px; }
  .toolbar { padding: 6px; gap: 4px; }
  .toolbar .tools-scroll { width: 100%; overflow-x: auto; scrollbar-width: none; display: flex; align-items: center; gap: 2px; padding-bottom: 2px; }
  .toolbar .tools-scroll::-webkit-scrollbar { display: none; }
  .icon-btn { width: 40px; height: 40px; }
  .side { flex: 1; border-left: 0; border-top: 1px solid var(--line); }
  .side .next-sec { display: none; }
  .strip { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 10px 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .side-sec { padding: 12px 10px 0; }
  .sheet-wrap { padding: 0; align-items: end; }
  .sheet { max-width: none; max-height: 92dvh; border-radius: 20px 20px 0 0; border-bottom: 0; }
  .sheet-body { padding: 0 14px calc(18px + env(safe-area-inset-bottom)); }
  .sheet-head { padding: 16px 12px 12px 18px; }
  .drop { flex-wrap: wrap; }
  .drop .drop-actions { width: 100%; }
  .drop .drop-actions .btn { flex: 1; }
  .sets { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  #copyLink, .set-picker > svg:first-child { display: none; }
  .topbar .icon-btn { width: 36px; }
}
@media (max-width: 400px) {
  .strip { grid-template-columns: repeat(2, 1fr); }
}
/* phone in landscape: give the stage everything */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { height: 46px; }
  .workspace { display: grid; grid-template-columns: minmax(0, 1fr) 150px; }
  .main-col { padding: 8px; gap: 6px; }
  .stage-wrap { flex: 1; aspect-ratio: auto; max-height: none; }
  .toolbar { flex-wrap: nowrap; }
  .toolbar .nav { order: 0; width: auto; }
  .toolbar .nav .nav-btn { flex: none; height: 38px; }
  .toolbar .nav .nav-btn span { display: none; }
  .toolbar .tools-scroll { width: auto; flex: 1; overflow-x: auto; display: flex; scrollbar-width: none; }
  .side { border-top: 0; border-left: 1px solid var(--line); }
  .side .next-sec { display: none; }
  .strip { grid-template-columns: 1fr; padding: 0 8px 8px; }
  .side-sec { padding: 8px 8px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- agent access ---------------- */
.agent-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  font-variant-numeric: tabular-nums; transition: background .15s, color .15s, border-color .15s;
}
.agent-btn:hover { background: var(--panel-2); color: var(--text); }
.agent-btn.on { color: #b6f5cf; background: rgba(61, 220, 132, .12); border-color: rgba(61, 220, 132, .32); }
.agent-btn.on svg { color: var(--ok); }
.agent-btn span:empty { display: none; }
.agent-status {
  font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2);
}
.agent-status.on { background: rgba(61, 220, 132, .12); color: var(--ok); border-color: rgba(61, 220, 132, .35); }
.agent-sheet { max-width: 860px; }
.agent-closed { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); }
.agent-hero-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); color: var(--ok); flex: none; }
.agent-hero-icon svg { width: 22px; height: 22px; }
.agent-hero-text { flex: 1; min-width: 0; }
.agent-hero-text b { display: block; font-size: 15px; letter-spacing: -.01em; margin-bottom: 2px; }
.agent-hero-text span { color: var(--muted); font-size: 13px; }
.lease {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px 16px; padding: 16px 18px; border-radius: var(--r);
  background: linear-gradient(180deg, rgba(61, 220, 132, .08), rgba(61, 220, 132, .02)); border: 1px solid rgba(61, 220, 132, .25);
}
.lease-text b { display: block; font-size: 18px; letter-spacing: -.02em; color: #c9f7dc; font-variant-numeric: tabular-nums; }
.lease-text span { color: var(--muted); font-size: 13px; }
.lease-actions { display: flex; gap: 8px; }
.lease-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.lease-bar i { display: block; height: 100%; width: 100%; background: var(--ok); border-radius: 4px; transition: width .6s; }
.key-block { position: relative; margin-top: 14px; border-radius: var(--r); background: #07080a; border: 1px solid var(--line-2); }
.key-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.key-head span { color: var(--muted); font-size: 13px; font-weight: 550; }
.key-block pre {
  margin: 0; padding: 14px 18px 16px; max-height: 260px; overflow: auto; font: 12.5px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: #cfd3dc; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all;
}
.agent-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 18px; }
.agent-cols h3 { margin: 0 0 8px; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .09em; }
.agent-log { max-height: 230px; overflow: auto; border-radius: var(--r-sm); background: var(--bg-2); border: 1px solid var(--line); padding: 4px; scrollbar-width: thin; }
.log-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: baseline; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; }
.log-row:nth-child(odd) { background: rgba(255, 255, 255, .02); }
.log-row time { color: var(--faint); font-variant-numeric: tabular-nums; }
.log-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.log-row span b { color: var(--muted); font-weight: 600; margin-right: 2px; }
.log-row em { font-style: normal; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ok); }
.log-row.bad em { color: #ff7a6b; }
.log-row.lease-ev span { font-family: var(--font); color: #c9f7dc; font-weight: 550; }
.fb-row { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.fb-row:last-child { border-bottom: 0; }
.fb-row b { font-size: 13px; }
.fb-row time { display: block; color: var(--faint); font-size: 11.5px; margin: 1px 0 4px; }
.fb-row p { margin: 0; color: var(--muted); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-empty { padding: 14px 10px; color: var(--faint); font-size: 13px; }
@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  .agent-btn { padding: 0 8px; }
  .agent-closed { flex-wrap: wrap; }
  .agent-closed .btn { width: 100%; }
  .lease { grid-template-columns: 1fr; }
  .lease-actions .btn { flex: 1; }
  .agent-cols { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .agent-btn span { display: none; } }

@media (max-width: 480px) { .key-block pre { font-size: 11px; padding: 12px 14px; } .key-head { padding-left: 14px; } .key-head span { display: none; } .key-head .btn { width: 100%; } }
