:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #17202b;
  --muted: #5d6b7a;
  --accent: #2456d6;
  --accent-text: #ffffff;
  --accent-soft: #e6edff;
  --ok: #17794a;
  --ok-soft: #e0f4ea;
  --warn: #96600a;
  --warn-soft: #fcefd3;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --live: #7a2bd0;
  --live-soft: #f0e6fd;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #171c23;
    --surface-2: #1f2630;
    --border: #2b3441;
    --text: #e6eaf0;
    --muted: #98a5b5;
    --accent: #7ea2ff;
    --accent-text: #0b1220;
    --accent-soft: #1c2a4d;
    --ok: #5fd39a;
    --ok-soft: #153426;
    --warn: #f0b955;
    --warn-soft: #3a2c10;
    --bad: #ff8a80;
    --bad-soft: #43201d;
    --live: #c59bff;
    --live-soft: #2f2146;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 20px; height: 54px; }
.brand { font-weight: 700; font-size: 15px; color: var(--text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; color: var(--accent-text); font-size: 12px; font-weight: 800; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .grid-2, .split { grid-template-columns: 1fr; } }

/* forms */
label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 74px; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 150px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.sm { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 28px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 550; font-size: 12.5px; }
.chip button { border: 0; background: transparent; color: inherit; padding: 0 4px; font-size: 14px; line-height: 1; border-radius: 999px; }
.quick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.quick button { padding: 2px 8px; font-size: 12px; border-radius: 999px; color: var(--muted); }

/* status */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.completed { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.live { background: var(--live-soft); color: var(--live); }
.badge.running, .badge.starting, .badge.closing, .badge.recording, .badge.processing { background: var(--warn-soft); color: var(--warn); }
.badge.saved { background: var(--ok-soft); color: var(--ok); }
.badge.live::before, .badge.running::before, .badge.starting::before, .badge.recording::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; }
.dot.ok { background: var(--ok); }
.banner { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.thumb-cell { width: 74px; padding-right: 0; }
.thumb { width: 60px; height: 40px; object-fit: cover; object-position: top; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.table-scroll { overflow-x: auto; }

/* galleries */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.shot { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; padding: 0; text-align: left; display: block; width: 100%; font-weight: 400; white-space: normal; }
.shot:hover { border-color: var(--accent); background: var(--surface); }
.shot img { width: 100%; height: 150px; object-fit: cover; object-position: top; display: block; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.shot .cap { padding: 9px 11px; }
.shot .cap div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix { overflow-x: auto; }
.matrix table { min-width: 560px; }
.matrix td { vertical-align: top; width: 240px; }
.matrix .shot img { height: 170px; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 14, 0.82); display: flex; flex-direction: column; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.lightbox-body { flex: 1; overflow: auto; padding: 20px; text-align: center; }
.lightbox-body img { max-width: 100%; height: auto; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5); background: #fff; }

/* session page */
.live-wrap { background: #0b0d11; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin-bottom: 12px; display: grid; place-items: center; }
.live-frame { border: 0; display: block; width: 100%; background: #0b0d11; }
.live-bar { display: flex; gap: 12px; align-items: center; margin: -4px 0 12px; flex-wrap: wrap; }
.snap-box { width: 100%; display: grid; place-items: center; outline: none; }
.snap-box:focus-visible, .snap-box:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.snap { display: block; cursor: crosshair; user-select: none; -webkit-user-drag: none; background: #0b0d11; }
.live-placeholder { color: #9aa4b2; padding: 60px 20px; text-align: center; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 220px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.log { max-height: 340px; overflow-y: auto; font-size: 12.5px; }
.log-line { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.log-line:last-child { border-bottom: 0; }
.log-line time { color: var(--muted); font-family: var(--mono); font-size: 11.5px; padding-top: 1px; }
.log-line.warn span { color: var(--warn); }
.log-line.error span { color: var(--bad); }
video { width: 100%; border-radius: 8px; background: #000; display: block; }
.rec { margin-bottom: 14px; }
.rec:last-child { margin-bottom: 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 26px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; z-index: 60; font-weight: 550; max-width: 90vw; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.toast.bad { background: var(--bad); color: #fff; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.tabs { display: flex; gap: 4px; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* assisted login panel */
.assist-opts { display: grid; gap: 8px; }
.assist-opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; font-weight: 500; }
.assist-opt .ico { font-size: 18px; width: 22px; text-align: center; flex: none; }
.assist-opt .grow { min-width: 0; }
.assist-shot { margin-top: 12px; width: 100%; max-width: 360px; border: 1px solid var(--border); border-radius: 8px; display: block; }
