/* Previzion's tokens, as the client uses them. Interaction steps: hover 8%, pressed 12%, selected 16%.
   The accent is kept for the main action and status badges; selection is the white fill. */
:root {
  --base: #1c1e21;
  --panel: #1f2226;
  --card: #222428;
  --raised: #24272c;
  --input: #292d32;
  --chip: #141719;
  --text: #f0f2f1;
  --text-2: rgba(240, 242, 241, 0.66);
  --text-3: rgba(240, 242, 241, 0.44);
  --line: rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.07);
  --hover: rgba(255, 255, 255, 0.08);
  --pressed: rgba(255, 255, 255, 0.12);
  --selected: rgba(240, 242, 241, 0.16);
  --accent: #50ffb0;
  --on-accent: #03190f;
  --danger: #e05252;
  --series: #5a8de0;
  --radius: 10px;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--base);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.danger { color: var(--danger); }
:focus-visible { outline: 2px solid rgba(240, 242, 241, 0.7); outline-offset: 2px; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.brand .tag { font-size: 12px; font-weight: 500; color: var(--text-2); padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; }
.topbar .spacer { flex: 1; }

/* --- controls --- */
.segment { display: inline-flex; padding: 3px; gap: 2px; background: var(--input); border: 1px solid var(--line); border-radius: 9px; }
.segment a { padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.segment a:hover { background: var(--hover); color: var(--text); }
.segment a[aria-current="true"] { background: var(--selected); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  background: var(--input); border: 1px solid var(--line);
  font-size: 14px; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: color-mix(in srgb, var(--input), white 8%); }
.btn:active { background: color-mix(in srgb, var(--input), white 12%); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent), white 18%); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.destructive { color: var(--danger); }
.btn.small { height: 28px; padding: 0 9px; font-size: 13px; border-radius: 7px; }
.btn[aria-pressed="true"] { background: var(--selected); border-color: transparent; }
.btn[aria-pressed="true"] svg.icon { fill: currentColor; }

.field { height: 32px; padding: 0 10px; background: var(--input); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; min-width: 0; }
.field::placeholder { color: var(--text-3); }
select.field { padding-right: 6px; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--chip); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.chip.live { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip.warn { color: #e7c063; }
.chip.off { color: var(--danger); }

/* --- the board --- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 28px 24px 64px; }
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.head .count { color: var(--text-2); font-size: 13px; padding-bottom: 3px; }
.head .spacer { flex: 1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 288px), 1fr)); gap: 24px 20px; }
.post { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--chip); border-radius: var(--radius); border: 1px solid var(--line-soft);
}
.thumb video, .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { border-color: var(--line); }
.thumb .version { position: absolute; left: 8px; top: 8px; }
.post .title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post .row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.post .who { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); font-size: 13px; }
.post .who a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post .who a:hover { color: var(--text); }
.post .who time { flex: none; white-space: nowrap; }
.post .stats { margin-left: auto; display: flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13px; }
.stat { display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; height: 28px; }
button.stat { background: none; border: 0; border-radius: 7px; cursor: pointer; color: var(--text-2); }
button.stat:hover { background: var(--hover); color: var(--text); }
button.stat:active { background: var(--pressed); }
button.stat[aria-pressed="true"] { color: var(--text); }
button.stat[aria-pressed="true"] svg.icon { fill: currentColor; }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--input); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text);
}
.avatar.large { width: 36px; height: 36px; font-size: 15px; }

/* The admin's cards: the same post, larger, with its files and its place on the board. */
.grid.large { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 28px 20px; }
.thumb-box { position: relative; }
.thumb-box .status { position: absolute; right: 8px; top: 8px; pointer-events: none; }
.post .tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.post .tools form { display: contents; }

.empty { padding: 96px 16px; text-align: center; color: var(--text-2); }
.empty h2 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 36px; color: var(--text-2); font-size: 13px; }

/* --- one post --- */
.watch { max-width: 1120px; }
.player { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); display: block; }
.watch-head { display: flex; align-items: flex-start; gap: 16px; margin: 18px 0 28px; flex-wrap: wrap; }
.watch-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.watch-meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--text-2); font-size: 13px; }
.watch-meta .name { color: var(--text); font-size: 14px; font-weight: 500; }
.watch-meta .name:hover { text-decoration: underline; }
.watch-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.section-title { font-size: 16px; font-weight: 600; margin: 0 0 14px; }

/* --- admin shell --- */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.side a { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: 14px; }
.side a:hover { background: var(--hover); color: var(--text); }
.side a[aria-current="page"] { background: var(--selected); color: var(--text); }
.main { padding: 26px 28px 64px; min-width: 0; }
.main > .head { margin-bottom: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; }
.tile .note { color: var(--text-3); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel > h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.panel > .sub { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; font-weight: 600; }
.panel-head .spacer { flex: 1; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.cols.wide-left { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; }

.lead { display: flex; align-items: flex-end; gap: 20px; margin-top: 14px; }
.lead .count { flex: none; }
.lead .what { min-width: 0; padding-bottom: 3px; }
.lead .figure { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.lead .title { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead .title:hover { text-decoration: underline; }
.runners { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line-soft); display: grid; gap: 2px; }
.runners li a { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 6px; margin: 0 -6px; border-radius: 6px; font-size: 13px; }
.runners li a:hover { background: var(--hover); }
.runners .rank { width: 14px; color: var(--text-3); }
.runners .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th { text-align: left; font-weight: 500; color: var(--text-2); padding: 0 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
table.list .r { text-align: right; }
table.list th:first-child, table.list td:first-child { padding-left: 0; }
table.list th:last-child, table.list td:last-child { padding-right: 0; }
table.list a.link:hover { text-decoration: underline; }
table.list .wide { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.actions form { display: contents; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter i { display: block; height: 6px; border-radius: 3px; background: var(--series); min-width: 2px; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .spacer { flex: 1; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form label { color: var(--text-2); font-size: 13px; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--chip); border: 1px solid var(--line); font-size: 13px; margin-bottom: 14px; }
.notice.error { border-color: color-mix(in srgb, var(--danger), transparent 50%); color: var(--danger); }

.key-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--chip); border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); font-size: 16px; overflow-x: auto; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; font-size: 13px; margin: 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
pre.log { margin: 0; padding: 14px; background: var(--chip); border: 1px solid var(--line-soft); border-radius: 8px; font: 12px/1.5 var(--mono); max-height: 520px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- charts --- */
.chart { padding-left: 48px; }
.chart .plot { position: relative; height: 180px; }
.chart .rule { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-soft); }
.chart .rule.base { border-color: var(--line); }
.chart .rule span { position: absolute; right: 100%; top: 0; margin-right: 8px; transform: translateY(-50%); color: var(--text-3); font-size: 12px; white-space: nowrap; }
.chart .bars { position: absolute; inset: 0; display: flex; }
.chart .slot { flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center; }
.chart .slot:hover { background: var(--hover); }
.chart .slot i { display: block; width: clamp(2px, 62%, 24px); min-height: 2px; background: var(--series); border-radius: 4px 4px 0 0; }
.chart .days { display: flex; height: 18px; margin-top: 6px; }
.chart .days span { flex: 1; min-width: 0; position: relative; }
.chart .days b { position: absolute; left: 50%; transform: translateX(-50%); color: var(--text-3); font-size: 12px; font-weight: 400; white-space: nowrap; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; display: none;
  padding: 6px 9px; border-radius: 7px; background: #0e1012; border: 1px solid var(--line);
  font-size: 12px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.tip b { font-weight: 600; font-size: 13px; display: block; }
details.as-table { margin: 10px 0 0 -48px; font-size: 13px; }
details.as-table summary { color: var(--text-2); cursor: pointer; width: max-content; }
details.as-table .table-scroll { margin-top: 10px; max-height: 260px; overflow: auto; }

/* --- sign in --- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin form { width: 320px; display: grid; gap: 14px; padding: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.signin .brand { margin-bottom: 4px; }
.signin .field, .signin .btn { height: 38px; width: 100%; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .side a { flex: none; }
  .cols, .cols.wide-left { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 20px 16px 48px; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 16px; }
  .wrap { padding: 20px 16px 48px; }
}

