:root {
    --bg: #0e0f13; --panel: #161821; --panel-2: #1d2030; --border: #272b3a;
    --text: #e8eaf0; --muted: #9098aa; --accent: #fe2c55; --accent-2: #25f4ee;
    --ok: #3ddc84; --warn: #f5b942; --radius: 10px;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
section { margin-bottom: 28px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 16px 60px; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 10px 20px; background: rgba(14,15,19,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a, .linkbtn { color: var(--muted); padding: 6px 10px; border-radius: 8px; font: inherit; background: none; border: 0; cursor: pointer; }
.topbar nav a:hover, .linkbtn:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--panel-2); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 16px; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 20px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(254,44,85,.25); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.narrow { max-width: 460px; }
.panel p { margin: 0 0 8px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.actions { display: flex; gap: 10px; align-items: center; }
.flash { background: rgba(37,244,238,.08); border: 1px solid rgba(37,244,238,.3); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 20px; }
.error { color: #ff8095; font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 28px !important; }

input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
select { width: auto; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(37,244,238,.4); border-color: transparent; }
textarea { resize: vertical; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
label.check { display: inline-flex; align-items: center; gap: 6px; }
label.check input { width: auto; }
.stack { display: grid; gap: 12px; }
.inline { display: inline; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; color: var(--text);
    background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a3f55; text-decoration: none; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: #3a1520; border-color: #6d2436; color: #ff9aac; }
.btn.danger-outline { background: none; border-color: #6d2436; color: #ff9aac; }
.btn.disabled { opacity: .4; pointer-events: none; }

.pill, .badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: rgba(61,220,132,.35); }
.pill.bad { color: #ff8095; border-color: rgba(255,128,149,.4); }
.badge.recording, .badge.live { color: #fff; background: var(--accent); border-color: var(--accent); }
.badge.recording::before, .badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.badge.processing, .badge.warn { color: var(--warn); border-color: rgba(245,185,66,.4); }
.badge.completed { color: var(--ok); border-color: rgba(61,220,132,.35); }
.badge.failed { color: #ff8095; border-color: rgba(255,128,149,.4); }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .badge::before { animation: none !important; } }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2); }
.table tr:last-child td { border-bottom: 0; }
.table .clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlink { cursor: pointer; } .rowlink:hover td { background: rgba(255,255,255,.02); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.sub { color: var(--muted); font-size: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { display: block; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.card .title { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 10px; }
.card .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.num b { display: block; font-size: 17px; } .num span { color: var(--muted); font-size: 11px; }
.cards .empty-card { color: var(--muted); padding: 20px; border: 1px dashed var(--border); border-radius: var(--radius); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.stat b { display: block; font-size: 20px; } .stat span { color: var(--muted); font-size: 12px; }

.live-layout { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 16px; align-items: start; }
.video-col { display: grid; gap: 10px; position: sticky; top: 64px; }
.video-box { aspect-ratio: 9 / 16; max-height: calc(100vh - 220px); display: grid; place-items: center; background: #000; }
.video-box video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-box .placeholder { color: var(--muted); padding: 24px; text-align: center; }
.parts { display: flex; gap: 6px; flex-wrap: wrap; }
.parts:empty { display: none; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.downloads b { width: 100%; }

.data-col { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 480px; }
.tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; background: var(--panel-2); }
.tabs button { font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 16px; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bg); font-size: 11px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 160px; width: auto; }
.pane { flex: 1; overflow-y: auto; padding: 6px 0; }
.pane .empty { padding: 40px 20px; }
.more { display: block; margin: 12px auto; }

.line { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 5px 16px; }
.line:hover { background: rgba(255,255,255,.03); }
.ts { color: var(--accent-2); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 2px; cursor: pointer; background: none; border: 0; font-family: inherit; text-align: left; }
.ts:hover { text-decoration: underline; }
.who { font-weight: 600; } .who .nick { color: var(--muted); font-weight: 400; margin-left: 4px; }
.chat-line .text { overflow-wrap: anywhere; }

.group { border-bottom: 1px solid var(--border); }
.group summary { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; list-style: none; }
.group summary::-webkit-details-marker { display: none; }
.group summary:hover { background: rgba(255,255,255,.03); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.group .meta { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group .line { padding-left: 54px; }
.hl { background: rgba(245,185,66,.3); color: inherit; border-radius: 2px; }

.login-card { max-width: 380px; margin: 10vh auto 0; padding: 28px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    /* live page: player + timeline stay pinned while the transcript scrolls underneath */
    .live-layout { display: flex; flex-direction: column; gap: 10px; }
    .video-col { display: contents; }
    .player-sticky { order: 1; position: sticky; top: var(--topbar-h, 56px); z-index: 6; display: grid; gap: 6px; background: var(--bg); padding: 4px 0 6px; }
    .parts { order: 2; }
    .data-col { order: 3; height: 72vh; min-height: 380px; }
    .downloads { order: 4; }
    .video-box { aspect-ratio: auto; height: 34vh; max-height: none; width: 100%; }
    .video-box.audio-only { height: 84px; }
    .timeline-panel { padding: 8px 10px; }
}


/* watch-along: timeline, active line, search navigation */
.timeline-panel { padding: 10px 12px; }
.timeline { position: relative; height: 18px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); cursor: pointer; overflow: hidden; }
.tl-done { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(37,244,238,.14); pointer-events: none; }
.tl-head { position: absolute; top: 0; bottom: 0; width: 2px; left: 0; background: var(--accent-2); pointer-events: none; }
.tl-marks i { position: absolute; top: 2px; bottom: 2px; width: 3px; margin-left: -1px; border-radius: 2px; background: var(--warn); }
.tl-marks i.cur { background: var(--accent); top: 0; bottom: 0; width: 4px; }
.tl-info { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.tl-note { color: var(--warn); font-size: 12px; flex: 1; }
#go-live { margin-left: auto; }
.search-nav { display: inline-flex; align-items: center; gap: 4px; }
.line.now { background: rgba(37,244,238,.10); box-shadow: inset 3px 0 0 var(--accent-2); }
.line.now .ts { font-weight: 700; }
.line.hit { background: rgba(245,185,66,.08); }
.line.hit.cur { background: rgba(245,185,66,.22); }
.line.future { opacity: .55; }

/* audio-only recordings: a compact player instead of a tall video frame */
.mode-pick { display: flex; gap: 16px; flex-wrap: wrap; }
.video-box.audio-only { aspect-ratio: auto; height: 96px; position: relative; }
.video-box.audio-only::before { content: "Audio only"; position: absolute; top: 10px; left: 12px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.video-box.audio-only video { height: 54px; align-self: end; }

/* the hidden attribute must win over component display rules (.btn, .search-nav, ...) */
[hidden] { display: none !important; }


/* ---------------------------------------------------------------- phones */
@media (max-width: 640px) {
    :root { --topbar-h: 49px; }
    .topbar { flex-wrap: nowrap; padding: 8px 10px; gap: 8px; min-height: 49px; }
    .topbar nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 0; }
    .topbar nav::-webkit-scrollbar { display: none; }
    .topbar nav a, .linkbtn { padding: 6px 8px; white-space: nowrap; font-size: 13px; }
    .brand { font-size: 14px; white-space: nowrap; }
    .wrap { padding: 14px 12px 40px; }
    h1 { font-size: 18px; }
    section { margin-bottom: 20px; }
    .page-head { margin-bottom: 12px; gap: 10px; }
    .panel { padding: 12px; }
    input, textarea, select { font-size: 16px; }     /* stops iOS zooming into fields */
    .btn.small { min-height: 34px; }
    .flash { margin-bottom: 12px; }

    .stats { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
    .stat { padding: 7px 9px; }
    .stat b { font-size: 15px; line-height: 1.3; }
    .stat span { font-size: 11px; }
    .cards .nums { grid-template-columns: repeat(2, 1fr); }

    .tabs button { padding: 10px 11px; font-size: 13px; }
    .toolbar { padding: 8px; gap: 6px; }
    .line { grid-template-columns: 54px 1fr; gap: 8px; padding: 6px 12px; }
    .group .line { padding-left: 20px; }
    .group summary { padding: 10px 12px; }

    /* tables become cards */
    .table.cards-mobile thead { display: none; }
    .table.cards-mobile, .table.cards-mobile tbody { display: block; }
    .table.cards-mobile tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .table.cards-mobile tr:last-child { border-bottom: 0; }
    .table.cards-mobile td { display: block; padding: 0; border: 0; order: 2; }
    .table.cards-mobile td.cell-main { order: 0; flex: 1 1 55%; min-width: 0; }
    .table.cards-mobile td.cell-badge { order: 0; }
    .table.cards-mobile td.cell-sub { order: 1; flex: 1 1 100%; max-width: none; white-space: normal; color: var(--muted); }
    .table.cards-mobile td.cell-actions { order: 3; flex: 1 1 100%; }
    .table.cards-mobile td.cell-num { display: none; }
    .table.cards-mobile td.empty { flex: 1 1 100%; }
    .table.cards-mobile td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
    .table.cards-mobile .row-actions { justify-content: flex-start; flex-wrap: wrap; }

    .dialog { width: calc(100vw - 24px); }
    .dialog-actions { flex-direction: column; }
    .dialog-actions .btn { width: 100%; }
}

/* stop-monitoring dialog */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 20px; max-width: 460px; }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h3 { margin: 0 0 8px; font-size: 17px; }
.dialog p { margin: 0 0 16px; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions { flex-wrap: wrap; }

@media (max-width: 640px) {
    .brand { flex: none; }
    .topbar nav { flex: 1 1 auto; min-width: 0; justify-content: flex-start; }
    .topbar nav form { flex: none; }
}

@media (max-width: 900px) {
    .live-layout { align-items: stretch; min-width: 0; }
    .live-layout > *, .player-sticky > *, .data-col, .data-col > * { min-width: 0; max-width: 100%; }
    .data-col { width: 100%; }
}
