:root {
  color-scheme: dark;
  --bg: #0d1014;
  --surface: #161a20;
  --surface-2: #1e242c;
  --line: #2a323c;
  --text: #e8ecf1;
  --muted: #98a2b0;
  --accent: #4f9cf9;
  --accent-ink: #061020;
  --danger: #e56060;
  --good: #58c98a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
img { max-width: 100%; display: block; }

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .04em; color: var(--text); text-transform: uppercase; }
.topnav { display: flex; gap: 1rem; }
.topnav a { color: var(--muted); }
.topnav a.on, .topnav a:hover { color: var(--text); }
.searchbox { margin-left: auto; }
.searchbox input { width: 200px; }
.account { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.account a { color: var(--muted); }

.page { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.footer { padding: 1.5rem; text-align: center; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
.row { margin-bottom: 2.5rem; }
.narrow { max-width: 460px; }
.muted, .meta { color: var(--muted); }
.meta { font-size: .85rem; }
.description { color: #c4ccd6; margin: .4rem 0; white-space: pre-wrap; }
.empty { color: var(--muted); padding: 1rem 0; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: .35rem; }
.crumbs span { padding: 0 .35rem; }
.byline { margin: .15rem 0 .4rem; color: #c4ccd6; }

/* ---------- forms ---------- */

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=file], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .5rem .65rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin-bottom: .85rem; font-size: .9rem; color: var(--muted); }
label input, label textarea, label select { margin-top: .3rem; color: var(--text); }
label small { display: block; margin-top: .25rem; font-size: .8rem; }
label.checkbox, .autoplay { display: flex; align-items: center; gap: .5rem; }
label.checkbox input, .autoplay input { width: auto; margin: 0; }
.stack { display: block; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.inline-form input { flex: 1 1 12rem; width: auto; }

.button {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .5rem .95rem;
  cursor: pointer;
  color: var(--text);
}
.button:hover { background: #262e38; text-decoration: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.button.primary:hover { filter: brightness(1.1); }
.button.danger { border-color: #5d3030; color: var(--danger); }
.button.small { padding: .25rem .6rem; font-size: .82rem; }
.link { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; }
.link:hover { color: var(--text); text-decoration: underline; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.alert { background: #3a1f1f; border: 1px solid #5d3030; color: #ffc9c9; padding: .7rem .9rem; border-radius: 8px; }
.notice { background: #1d3a2a; border: 1px solid #2f5d43; color: #bdf0d2; padding: .7rem .9rem; border-radius: 8px; }
.log { background: #0a0d11; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; overflow-x: auto; font-size: .78rem; color: #d8b0b0; white-space: pre-wrap; }

/* ---------- cards ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.25rem; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }

.card, .resume-card { color: var(--text); display: block; }
.card:hover, .resume-card:hover { text-decoration: none; }
.card h3, .resume-card h4 { margin: .55rem 0 .15rem; font-size: .95rem; }
.card:hover h3, .resume-card:hover h4 { color: var(--accent); }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty {
  display: grid; place-items: center; height: 100%;
  font-size: 2rem; font-weight: 700; color: var(--line);
}
.thumb-empty.large { aspect-ratio: 16/9; border: 1px solid var(--line); border-radius: var(--radius); }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.6); }
.bar span { display: block; height: 100%; background: var(--accent); }
.badge { position: absolute; top: .5rem; left: .5rem; background: rgba(0,0,0,.75); padding: .1rem .45rem; border-radius: 4px; font-size: .72rem; }

/* ---------- detail ---------- */

.detail { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 1.75rem; margin-bottom: 2.5rem; }
.detail-poster img { border-radius: var(--radius); border: 1px solid var(--line); }

.volume { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-bottom: 1.75rem; }
.vnum { color: var(--muted); font-weight: 400; font-size: .85rem; display: block; }

.segments { list-style: none; margin: .75rem 0 0; padding: 0; }
.segment { display: flex; gap: .9rem; align-items: flex-start; padding: .7rem .5rem; border-radius: 8px; }
.segment:hover { background: var(--surface); }
.segment.done .stitle { color: var(--muted); }
.snum { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.6rem; text-align: right; font-size: .9rem; }
.sbody { flex: 1; min-width: 0; }
.stitle { font-weight: 500; }
.sstate { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.duration { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.pill { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.done { color: var(--good); border-color: #2f5d43; }
.pill.bad { color: var(--danger); border-color: #5d3030; }
.pill.working { color: var(--accent); border-color: #2c4a72; }

/* ---------- watch ---------- */

.watch { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 330px); gap: 1.75rem; }
.player-shell { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.player-shell video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }
.watch-head { margin-top: 1rem; }
.prevnext { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0 .75rem; }

.outline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; max-height: 80vh; overflow-y: auto; }
.outline h2 { font-size: 1rem; }
.outline h3 { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 1rem 0 .4rem; }
.outline-segments { list-style: none; margin: 0; padding: 0; }
.outline-segments li a, .outline-segments li .unavailable {
  display: flex; gap: .5rem; align-items: baseline;
  padding: .4rem .5rem; border-radius: 6px; color: var(--text);
}
.outline-segments li a:hover { background: var(--surface-2); text-decoration: none; }
.outline-segments li.current a { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.outline-segments li.done .otitle { color: var(--muted); }
.outline-segments li .unavailable { color: var(--muted); }
.otitle { flex: 1; min-width: 0; }
.outline-segments .duration { font-size: .78rem; }

/* ---------- tags, people, results, tables ---------- */

.taglist { display: flex; flex-wrap: wrap; gap: .5rem; }
.taglist.inline { margin: .35rem 0; }
.tag { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .65rem; font-size: .82rem; color: #c4ccd6; }
.tag:hover { border-color: var(--accent); text-decoration: none; }
.tag span { color: var(--muted); margin-left: .3rem; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.person { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.person:hover { border-color: var(--accent); text-decoration: none; }
.avatar { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); font-size: 1.3rem; font-weight: 700; color: var(--muted); }
.pname { font-weight: 500; }

.results { list-style: none; margin: .5rem 0; padding: 0; }
.results li { border-bottom: 1px solid var(--line); }
.results li a { display: flex; flex-direction: column; padding: .7rem .5rem; color: var(--text); }
.results li a:hover { background: var(--surface); text-decoration: none; }
.rtitle { font-weight: 500; }

.table { width: 100%; border-collapse: collapse; margin-top: .75rem; display: block; overflow-x: auto; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .82rem; }
.table tr.dim { opacity: .55; }
.rowactions { display: flex; gap: .35rem; flex-wrap: wrap; }
.rowactions form { display: inline; }
.copyable { font-family: ui-monospace, monospace; font-size: .78rem; min-width: 22rem; }

/* ---------- admin ---------- */

.admin-volume { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; }
.admin-volume-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.admin-volume-head h3 { margin: 0; }
.admin-volume-head .rowactions { margin-left: auto; }
.admin-segments { list-style: none; margin: .75rem 0; padding: 0; }
.admin-segments li { border-top: 1px solid var(--line); padding: .7rem 0; }
.seg-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.status { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status.ready { color: var(--good); border-color: #2f5d43; }
.status.failed { color: var(--danger); border-color: #5d3030; }
.status.processing, .status.queued { color: var(--accent); border-color: #2c4a72; }
.upload-form { border: 1px dashed var(--line); border-radius: var(--radius); padding: .9rem; margin-top: .75rem; }
.upload-form h4 { margin-bottom: .6rem; }
.upload-form input { margin-bottom: .6rem; }
.upload-progress { width: 100%; height: 6px; margin-top: .6rem; }

@media (max-width: 900px) {
  .detail, .watch { grid-template-columns: minmax(0, 1fr); }
  .outline { max-height: none; }
  .searchbox { margin-left: 0; order: 3; width: 100%; }
  .searchbox input { width: 100%; }
}
