/* Beyond The Blue — design system. Tokens first, then components, then modes.
   Target: Chromium 95+ (OBS 28 embedded browser), so no :has(), colour mixing or container queries. */

:root {
    --font-ui: 'Inter', 'Noto Sans Telugu', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-telugu: 'Noto Sans Telugu', 'Mandali', 'Inter', sans-serif;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08);
    --shadow: 0 10px 30px rgba(15, 23, 42, .14);
}

:root,
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef2f8;
    --surface-3: #e2e8f2;
    --border: #d9e0ea;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #7c8aa0;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #dbe7ff;
    --accent-text: #ffffff;
    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --live: #e11d48;
    --live-soft: #ffe4ea;
    --focus: 0 0 0 3px rgba(37, 99, 235, .35);
    --backdrop: rgba(15, 23, 42, .45);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b24;
    --surface-2: #1d2430;
    --surface-3: #283141;
    --border: #2b3445;
    --text: #e8edf5;
    --text-2: #a7b2c4;
    --text-3: #75839a;
    --accent: #4f8bff;
    --accent-hover: #6d9eff;
    --accent-soft: #1b2b4d;
    --accent-text: #ffffff;
    --ok: #34d399;
    --ok-soft: #10302a;
    --warn: #fbbf24;
    --warn-soft: #3a2e10;
    --danger: #f87171;
    --danger-soft: #3b1a1d;
    --live: #fb7185;
    --live-soft: #3d1420;
    --focus: 0 0 0 3px rgba(79, 139, 255, .45);
    --backdrop: rgba(0, 0, 0, .6);
    --shadow: 0 12px 34px rgba(0, 0, 0, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.telugu { font-family: var(--font-telugu); }
.icon { flex: none; display: block; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---- utilities ------------------------------------------------------------------- */
.row { display: flex; align-items: center; }
.row.gap { gap: var(--space-2); }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.full { width: 100%; }
.row.full .input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-6); }
.center-items { align-items: center; text-align: center; }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-3); }
.grid-3 { display: grid; grid-template-columns: 110px 1fr 1fr; gap: var(--space-3); }
@media (max-width: 600px) { .grid-3 { grid-template-columns: 1fr; } .hide-sm { display: none; } }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }

/* ---- buttons --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
    border: 1px solid transparent; font-weight: 600; font-size: 13px; cursor: pointer;
    transition: background .15s var(--ease), border-color .15s, color .15s, transform .05s;
    text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn.is-active { background: var(--live-soft); border-color: var(--live); color: var(--live); }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none;
    border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn-soft { background: var(--surface-2); color: var(--text); }
.icon-btn.is-off { color: var(--danger); }
.mini-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer; }
.mini-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---- form fields ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.field-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 11px; color: var(--text-3); }
.input {
    width: 100%; min-height: 38px; padding: 8px 11px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.color { width: 100%; height: 38px; padding: 3px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.range { width: 100%; accent-color: var(--accent); }
.range-value { color: var(--text); font-variant-numeric: tabular-nums; }
.search-wrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.search-wrap > .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search-input { padding-left: 34px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text); }
.switch-input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 36px; height: 21px; border-radius: 999px; background: var(--surface-3); transition: background .15s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.switch-input:checked + .switch-track { background: var(--accent); }
.switch-input:checked + .switch-track::after { transform: translateX(15px); }
.switch-input:focus-visible + .switch-track { box-shadow: var(--focus); }

/* ---- segmented / tabs ------------------------------------------------------------ */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segment { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 0 11px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; flex: 1; }
.segment:hover { color: var(--text); }
.segment.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .segment.active { background: var(--surface-3); }

/* ---- pills / tags ---------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-pending { background: var(--accent-soft); color: var(--accent); }
.pill-pending .pill-dot { animation: pulse 1.2s infinite; }
.pill-btn { border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 999px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.tag-amber { background: var(--warn-soft); color: var(--warn); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-live { background: var(--live-soft); color: var(--live); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip-removable { padding: 0; overflow: hidden; }
.chip-main { border: 0; background: transparent; padding: 0 4px 0 10px; min-height: 28px; cursor: pointer; font-size: 12px; }
.chip-x { border: 0; background: transparent; color: var(--text-3); padding: 0 8px 0 2px; min-height: 28px; cursor: pointer; }
.chip-add { border-style: dashed; color: var(--text-2); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- notices --------------------------------------------------------------------- */
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: 13px; }
.notice-amber { background: var(--warn-soft); color: var(--warn); }
.banner { padding: 8px 14px; font-size: 12px; font-weight: 600; }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.status-box { display: flex; flex-direction: column; gap: 3px; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.status-box span { color: var(--text-2); font-size: 12px; }
.status-connected { background: var(--ok-soft); border-color: transparent; }
.status-connected strong { color: var(--ok); }
.status-error { background: var(--danger-soft); border-color: transparent; }
.status-error strong { color: var(--danger); }
.status-connecting strong { color: var(--accent); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 20px; text-align: center; color: var(--text-2); }
.full-center { min-height: 100vh; min-height: 100dvh; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- sheets / toasts ------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--backdrop); opacity: 0; transition: opacity .16s var(--ease); }
.sheet-backdrop.open { opacity: 1; }
.sheet-backdrop.closing { opacity: 0; }
.sheet { display: flex; flex-direction: column; width: 100%; max-height: min(88vh, 860px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); transform: translateY(10px) scale(.98); transition: transform .18s var(--ease); }
.sheet-backdrop.open .sheet { transform: none; }
.sheet-sm { max-width: 440px; }
.sheet-md { max-width: 620px; }
.sheet-lg { max-width: 820px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--border); }
.sheet-title { flex: 1; font-size: 17px; }
.sheet-body { padding: 16px 20px 20px; overflow-y: auto; }
.sheet-foot { padding: 12px 20px; border-top: 1px solid var(--border); }
.dialog-text { font-size: 14px; color: var(--text); }
@media (max-width: 560px) {
    .sheet-backdrop { align-items: flex-end; padding: 0; }
    .sheet { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; transform: translateY(30px); }
}
.toast-host { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: 999px; background: #0f172a; color: #f8fafc; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s var(--ease); }
.toast.show { opacity: 1; transform: none; }
.toast-ok { background: #15803d; }
.toast-error { background: #b91c1c; }

/* ---- app chrome ------------------------------------------------------------------ */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); text-decoration: none; }
.brand-logo { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; }
.brand-name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-row { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.dock-header .brand-name { display: none; }
@media (min-width: 520px) { .dock-header .brand-name { display: inline; } }
.controller-header .pill-btn { margin-left: auto; }

.live-strip { display: flex; gap: 10px; padding: 10px; background: var(--surface); border-bottom: 1px solid var(--border); }
.preview-frame { flex: none; width: 42%; max-width: 240px; min-width: 120px; align-self: flex-start; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); line-height: 0; }
.preview-canvas { width: 100%; height: auto; display: block; }
.checker { background-color: #1f2430; background-image: linear-gradient(45deg, #2a3040 25%, transparent 25%), linear-gradient(-45deg, #2a3040 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #2a3040 75%), linear-gradient(-45deg, transparent 75%, #2a3040 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.live-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.live-kicker { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--live); }
.live-kicker.idle { color: var(--text-3); }
.live-kicker.idle .live-dot { background: var(--text-3); animation: none; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px rgba(225, 29, 72, .25); animation: pulse 1.6s infinite; flex: none; }
.live-label { font-weight: 650; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.live-actions { display: flex; align-items: center; gap: 4px; margin-top: auto; flex-wrap: wrap; }

.tabbar { display: flex; width: auto; margin: 10px 10px 0; }
.view-host { flex: 1; min-height: 0; }
.view { display: flex; flex-direction: column; min-height: 0; }
.view-toolbar { position: sticky; top: 50px; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 10px; background: var(--bg); }
.view-body { padding: 0 10px 24px; }
.view-body.cards { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.category-host { flex: 0 1 42%; min-width: 0; }
.category-select { font-size: 13px; }
@media (max-width: 420px) { .view-toolbar { flex-wrap: wrap; } .category-host { flex-basis: 100%; } }

/* ---- lists ----------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list.compact { border-radius: var(--radius-sm); }
.list-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; color: var(--text); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover:not(.static) { background: var(--surface-2); }
.list-row.static { cursor: default; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chevron { color: var(--text-3); }
.num-badge { flex: none; min-width: 38px; height: 26px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; }
.list-more { display: flex; justify-content: center; padding: 10px; }

.detail-head { display: flex; align-items: flex-start; gap: 6px; padding: 4px 0 12px; }
.detail-title { flex: 1; min-width: 0; }
.detail-kicker { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.detail-title h2 { font-size: 19px; }
.detail-sub { font-size: 12px; color: var(--text-2); }
.stanza-list { display: flex; flex-direction: column; gap: 8px; }
.stanza { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); text-align: left; cursor: pointer; transition: border-color .12s, background .12s; }
.stanza:hover { border-color: var(--accent); }
.stanza.is-chorus { border-left: 4px solid #f59e0b; }
.stanza.is-live { border-color: var(--live); background: var(--live-soft); box-shadow: 0 0 0 1px var(--live); }
.stanza.is-static, .verse.is-static { cursor: default; }
.stanza-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.stanza-text { white-space: pre-line; font-size: 15px; line-height: 1.6; }
.stanza .live-dot { position: absolute; top: 14px; right: 14px; }

/* ---- Bible ----------------------------------------------------------------------- */
.ref-wrap { position: relative; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); overflow: hidden; }
.suggest-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.suggest-item:hover { background: var(--surface-2); }
.crumbs { display: flex; align-items: center; gap: 4px; padding: 0 10px 6px; color: var(--text-3); flex-wrap: wrap; }
.crumb { border: 0; background: transparent; padding: 4px 6px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.crumb.active { color: var(--text); }
.recent-row { padding: 0 10px 8px; align-items: center; max-height: 104px; overflow-y: auto; }
.history-label { margin-right: 2px; }
.chip-live { border-color: var(--live); background: var(--live-soft); font-weight: 600; }
.chip-clear { border-style: dashed; color: var(--text-2); }
.group-title { margin: 12px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.grid { display: grid; gap: 6px; }
.book-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.num-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.scene-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.grid-btn { min-height: 40px; padding: 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.grid-btn:hover { border-color: var(--accent); }
.grid-btn.current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.scene-btn.current { background: var(--live); border-color: var(--live); }
.verse-list { display: flex; flex-direction: column; gap: 4px; }
.verse { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--surface); text-align: left; cursor: pointer; }
.verse:hover { border-color: var(--accent); }
.verse.is-live { border-color: var(--live); background: var(--live-soft); }
.verse-num { flex: none; min-width: 26px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.verse-text { font-size: 15px; line-height: 1.55; }
.chapter-nav { justify-content: space-between; padding-top: 10px; }

/* ---- cards ----------------------------------------------------------------------- */
.card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.card.is-live { border-color: var(--live); box-shadow: 0 0 0 1px var(--live); }
.card-head { display: flex; align-items: center; gap: 8px; color: var(--text); }
.card-head h3 { flex: 1; }
.card-head > .icon { color: var(--accent); }
.countdown-readout { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.countdown-readout.warn { color: var(--danger); }
.status-line { font-size: 12px; }
.program-preview { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ---- menus / sheets content -------------------------------------------------------- */
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-row { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; cursor: pointer; color: var(--text); }
.menu-row:hover { background: var(--surface-2); }
.menu-row > .icon:first-child { color: var(--accent); }
.menu-row.danger, .menu-row.danger > .icon:first-child { color: var(--danger); }
.menu-theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; font-weight: 600; }
.qr-frame { padding: 10px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); line-height: 0; }
.qr { width: 220px; height: 220px; image-rendering: pixelated; }
.url-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.url { flex: 1; min-width: 0; word-break: break-all; }
.setup-step, .help-step { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.setup-step.done { border-color: var(--ok); }
.step-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.setup-step.done .step-num { background: var(--ok); color: #fff; }
.step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.editor-section { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.editor-section .select { width: auto; min-width: 140px; }
.import-panel { padding: 12px; border: 1px dashed var(--border-strong, var(--border)); border-radius: var(--radius-sm); }
.import-label { min-width: 72px; }
.import-chorus { border-left: 3px solid #f59e0b; }
.import-bridge { border-left: 3px solid #a855f7; }
.import-stanza { border-left: 3px solid var(--accent); }
.import-ignore { opacity: .6; }

/* ---- bottom nav (phone) -------------------------------------------------------------- */
.mode-controller .view-host { padding-bottom: 78px; }
.bottom-nav { position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 60; display: flex; padding: 4px; border-radius: 16px; box-shadow: var(--shadow); background: var(--surface); border: 1px solid var(--border); }
.bottom-nav .segment { flex-direction: column; gap: 2px; min-height: 52px; font-size: 11px; border-radius: 12px; }
.bottom-nav .segment.active { color: var(--accent); }
.mode-controller .view-toolbar { top: 53px; }

/* ---- phone pairing gate ---------------------------------------------------------- */
.gate { max-width: 420px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; padding: 24px; text-align: center; }
.gate-logo { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); }
.scan-frame { position: relative; width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: #000; }
.scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-target { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 14px; }

/* ---- home ------------------------------------------------------------------------ */
.home { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px 48px; display: flex; flex-direction: column; gap: 36px; }
.home-nav { display: flex; gap: 14px; margin-left: 10px; }
.home-nav a { color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 13px; }
.home-nav a:hover { color: var(--text); }
@media (max-width: 560px) { .home-nav { display: none; } }
.theme-switch .segment { padding: 0 8px; }
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center; padding: 40px 0 8px; }
.hero h1 { font-size: clamp(28px, 5vw, 42px); letter-spacing: -.03em; }
.lead { margin: 12px 0 20px; font-size: 16px; color: var(--text-2); max-width: 54ch; }
.feature-list { list-style: none; margin: 0; padding: 18px; display: flex; flex-direction: column; gap: 12px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.feature-list li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.feature-list .icon { color: var(--accent); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; padding-top: 24px; } }
.home-section { scroll-margin-top: 70px; display: flex; flex-direction: column; gap: 14px; }
.section-head { align-items: center; }
.library-host { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); max-height: 70vh; overflow: auto; }
.library-host .view-toolbar { top: 0; }
.home-footer { padding-top: 12px; border-top: 1px solid var(--border); word-break: break-all; }

/* ---- Display Designer ------------------------------------------------------------ */
.designer { position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; background: var(--bg); }
.designer-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.designer-title { display: flex; align-items: center; gap: 8px; }
.designer-title .icon { color: var(--accent); }
.designer-tools { margin-left: auto; }
.size-label { margin-left: 4px; }
.designer-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 1fr 300px; }
.designer-panel { min-height: 0; overflow-y: auto; padding: 10px; background: var(--surface); }
.layers-panel { border-right: 1px solid var(--border); }
.inspector-panel { border-left: 1px solid var(--border); }
.designer-stage { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; background: var(--surface-2); }
.designer-frame { position: relative; box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.designer-render, .designer-ui { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.designer-ui { touch-action: none; }
.designer-mobile-tabs { display: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px 8px; }
.panel-head h3 { flex: 1; font-size: 13px; }
.layer-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.layer { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 6px 6px 8px; border-radius: 7px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text); font-size: 13px; text-align: left; }
.layer:hover { background: var(--surface-2); }
.layer.selected { background: var(--accent-soft); border-color: var(--accent); }
.layer.is-hidden .layer-name { opacity: .45; text-decoration: line-through; }
.layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-layer { margin-top: 10px; border: 1px dashed var(--border); }
.add-menu { display: flex; flex-direction: column; gap: 1px; }
.add-group { padding: 8px 6px 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.add-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 13px; color: var(--text); text-align: left; }
.add-item:hover { background: var(--surface-2); }
.add-item .icon { color: var(--accent); }
.inspect-section { border-bottom: 1px solid var(--border); padding: 6px 2px 10px; }
.inspect-section > summary { cursor: pointer; padding: 6px 2px; font-weight: 700; font-size: 13px; list-style-position: inside; }
.inspect-body { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.inspect-body .segmented { width: 100%; }
.inspect-actions { padding-top: 12px; }
@media (max-width: 900px) {
    .designer-main { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 45vh) 1fr; }
    .designer-stage { grid-row: 1; }
    .layers-panel, .inspector-panel { grid-row: 2; border: 0; border-top: 1px solid var(--border); }
    .designer[data-panel="props"] .layers-panel { display: none; }
    .designer[data-panel="layers"] .inspector-panel { display: none; }
    .designer-mobile-tabs { display: flex; margin: 6px 10px 10px; }
}

/* ---- Display (OBS Browser Source) ------------------------------------------------ */
html.display-mode, html.display-mode body { background: transparent !important; overflow: hidden; width: 100%; height: 100%; }
html.display-mode .app { min-height: 0; height: 100vh; }
.display-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; object-fit: contain; display: block; }
.display-debug { position: fixed; left: 12px; bottom: 12px; padding: 6px 10px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; font: 12px var(--font-ui); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
