:root {
  --bg: #0f1210;
  --panel: #181d1a;
  --panel-2: #1f2521;
  --line: #2a322c;
  --text: #e9e7df;
  --muted: #98a09a;
  --accent: #e8b04b;
  --accent-dim: #a8813a;
  --sage: #85ab8d;
  --danger: #d47c6a;
  --radius: 14px;
  --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px));
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---------- chrome ---------- */
#topbar { display: flex; align-items: center; gap: 20px; padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; cursor: pointer; }
#desktopnav { display: none; gap: 4px; margin-left: 8px; }
#desktopnav a { padding: 7px 14px; border-radius: 99px; color: var(--muted); font-weight: 550; }
#desktopnav a.active { color: var(--text); background: var(--panel-2); }
#netstate { margin-left: auto; font-size: 12.5px; color: var(--bg); background: var(--accent);
  padding: 3px 10px; border-radius: 99px; font-weight: 650; }

#tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); }
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
#tabbar a svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
#tabbar a[data-nav="downloads"] svg { fill: none; stroke: currentColor; }
#tabbar a.active { color: var(--accent); }

main { padding: 18px 16px calc(var(--tabbar-h) + 28px); max-width: 1200px; margin: 0 auto; }

@media (min-width: 900px) {
  #desktopnav { display: flex; }
  #tabbar { display: none; }
  main { padding-bottom: 48px; }
}

/* ---------- generic ---------- */
h1 { font-size: 22px; margin: 6px 0 16px; }
h2 { font-size: 16px; color: var(--muted); font-weight: 650; text-transform: uppercase;
  letter-spacing: .8px; margin: 26px 0 12px; }
.pill { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 9px;
  border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.pill.accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
  border-radius: 10px; background: var(--panel-2); font-weight: 600; font-size: 14.5px;
  border: 1px solid var(--line); transition: background .15s; }
.btn:hover { background: var(--line); }
.btn.primary { background: var(--accent); color: #171207; border-color: transparent; }
.btn.primary:hover { background: var(--accent-dim); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; pointer-events: none; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

#toast { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px); z-index: 60; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); padding: 10px 18px;
  border-radius: 12px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  max-width: min(92vw, 480px); text-align: center; }

/* ---------- login ---------- */
.login-wrap { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login-wrap svg { margin: 0 auto 12px; }
.login-wrap input { width: 100%; padding: 12px 14px; margin: 18px 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; }
.login-wrap input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- library ---------- */
.serieshead { display: flex; align-items: baseline; gap: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform .12s, border-color .12s; position: relative; }
.card:hover { transform: translateY(-2px); border-color: #3a453d; }
.card .thumb { aspect-ratio: 16/9; background: #0a0c0a center/cover no-repeat; position: relative; }
.card .thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75);
  padding: 2px 7px; border-radius: 6px; font-size: 12px; font-weight: 650; }
.card .thumb .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.card .thumb .offbadge { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.7);
  color: var(--sage); border-radius: 6px; padding: 2px 7px; font-size: 11.5px; font-weight: 700; }
.card .meta { padding: 11px 13px 13px; }
.card .meta .t { font-weight: 620; font-size: 15px; line-height: 1.35; }
.card .meta .s { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- player ---------- */
.player-layout { display: flex; flex-direction: column; gap: 16px; }
.video-col { position: sticky; top: calc(54px + env(safe-area-inset-top, 0px)); z-index: 10;
  background: var(--bg); padding-bottom: 4px; }
video { width: 100%; border-radius: 12px; background: #000; display: block;
  max-height: 56vh; }
.ptitle { font-size: 17px; font-weight: 650; margin: 10px 2px 2px; line-height: 1.35; }
.psub { color: var(--muted); font-size: 13.5px; margin: 2px 2px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.controls-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.rate-btn.active { border-color: var(--accent); color: var(--accent); }

.hl-strip { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.hl-chip { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
.hl-chip:hover { border-color: var(--accent-dim); }
.hl-chip .tm { color: var(--accent); font-weight: 700; font-size: 13px; white-space: nowrap; margin-top: 1px; }
.hl-chip .tx { font-size: 14px; }
.hl-chip .tx .n { color: var(--muted); font-size: 13px; margin-top: 2px; }

.transcript { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 0; }
.tr-tools { display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2; border-radius: var(--radius) var(--radius) 0 0; align-items: center; }
.tr-tools input { flex: 1; min-width: 100px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 14px; }
.tr-tools input:focus { outline: 1.5px solid var(--accent); }
.seg { display: flex; gap: 12px; padding: 7px 14px; cursor: pointer; border-left: 3px solid transparent; }
.seg:hover { background: var(--panel-2); }
.seg.current { background: color-mix(in srgb, var(--accent) 9%, transparent); border-left-color: var(--accent); }
.seg.inclip { border-left-color: var(--accent-dim); }
.seg .st { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums;
  white-space: nowrap; margin-top: 3px; min-width: 52px; }
.seg .sp { font-weight: 700; font-size: 13px; margin-bottom: 1px; }
.seg .sp.speaker-0 { color: var(--sage); }
.seg .sp.speaker-1 { color: var(--accent); }
.seg .sp.speaker-2 { color: #9fb8d8; }
.seg .tx { font-size: 14.5px; }
.seg.hidden { display: none; }

@media (min-width: 900px) {
  .player-layout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr); gap: 20px; align-items: start; }
  .video-col { position: sticky; top: 76px; }
  .transcript { max-height: calc(100vh - 110px); overflow-y: auto; }
  .tr-tools { border-radius: var(--radius) var(--radius) 0 0; }
  video { max-height: none; }
}

/* clip overlay */
.clip-banner { display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  border: 1px solid var(--accent-dim); border-radius: 10px; padding: 9px 13px; margin-top: 10px; font-size: 14px; }

/* ---------- highlights page ---------- */
.hero { background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 14%, var(--panel)), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.hero p { margin: 6px 0 0; color: var(--text); font-size: 14.5px; }
.hlcard { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.hlcard .row { display: flex; gap: 14px; padding: 14px; }
.hlcard .thumb { width: 150px; min-width: 150px; aspect-ratio: 16/9; border-radius: 9px;
  background: #0a0c0a center/cover no-repeat; position: relative; cursor: pointer; }
.hlcard .thumb::after { content: ""; position: absolute; inset: 0; margin: auto; width: 34px; height: 34px;
  background: rgba(0,0,0,.65) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23e8b04b"><path d="M8 5.5v13l11-6.5z"/></svg>') center/16px no-repeat;
  border-radius: 99px; }
.hlcard .t { font-weight: 650; font-size: 15.5px; line-height: 1.35; }
.hlcard .from { color: var(--muted); font-size: 13px; margin-top: 3px; }
.hlcard .blurb { font-size: 14px; margin-top: 8px; color: #cfd4cd; }
.hlcard .quote { border-left: 3px solid var(--accent-dim); padding: 2px 0 2px 10px; margin: 10px 0 0;
  color: var(--muted); font-style: italic; font-size: 13.5px; }
.hlcard .actions { display: flex; gap: 8px; padding: 0 14px 14px; }
@media (max-width: 640px) {
  .hlcard .row { flex-direction: column; }
  .hlcard .thumb { width: 100%; }
}

/* ---------- downloads ---------- */
.dl-row { display: flex; align-items: center; gap: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.dl-row .thumb { width: 84px; min-width: 84px; aspect-ratio: 16/9; border-radius: 8px; background: #0a0c0a center/cover no-repeat; }
.dl-row .t { font-weight: 620; font-size: 14.5px; line-height: 1.3; }
.dl-row .s { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.dl-row .bar { height: 4px; border-radius: 4px; background: var(--panel-2); margin-top: 8px; overflow: hidden; }
.dl-row .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.dl-actions { display: flex; gap: 6px; margin-left: auto; }
.storage-note { color: var(--muted); font-size: 13px; margin: 0 0 10px; line-height: 1.5; }
.dl-err { color: var(--danger); font-weight: 600; }
.quota-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 16px; }
.quota-card .btn { width: 100%; justify-content: center; }

/* mobile: keep titles from squeezing the buttons out of the row */
.dl-row .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.dl-row .s { overflow-wrap: anywhere; }
.dl-actions { flex-shrink: 0; }
@media (max-width: 520px) {
  .dl-row { gap: 10px; padding: 11px 12px; }
  .dl-row .thumb { width: 64px; min-width: 64px; }
  .dl-row .t { font-size: 14px; }
  .dl-row .s { font-size: 12px; }
  .dl-actions .btn { padding: 7px 9px; }
}

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty svg { margin: 0 auto 14px; opacity: .5; }
