/* Discord Recorder — design tokens in DESIGN.md */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 60px;
  --player-h: 88px;
  --accent: #7c83ff;
  --accent-strong: #5b63f0;
  --live: #ff5c6c;
  --mark-yellow: 245, 200, 76;
  --mark-green: 76, 195, 138;
  --mark-blue: 90, 169, 255;
  --mark-pink: 244, 114, 182;
}
:root[data-theme='dark'] {
  --bg: #0d0e12;
  --bg-grad: radial-gradient(1200px 600px at 70% -10%, rgba(124, 131, 255, .10), transparent 60%);
  --surface: #15171d;
  --surface-2: #1c1f27;
  --surface-3: #252935;
  --border: #272b35;
  --text: #f1f2f6;
  --text-2: #c4c8d2;
  --muted: #858c9b;
  --dim: rgba(241, 242, 246, .34);
  --past: rgba(241, 242, 246, .58);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --zebra: rgba(255, 255, 255, .015);
}
:root[data-theme='light'] {
  --bg: #f5f5f8;
  --bg-grad: radial-gradient(1200px 600px at 70% -10%, rgba(91, 99, 240, .08), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --surface-3: #e6e8ee;
  --border: #e1e3ea;
  --text: #14161b;
  --text-2: #3d424d;
  --muted: #6b7280;
  --dim: rgba(20, 22, 27, .33);
  --past: rgba(20, 22, 27, .58);
  --shadow: 0 10px 40px rgba(20, 22, 40, .12);
  --zebra: rgba(0, 0, 0, .015);
  --accent: #5b63f0;
  --accent-strong: #4950dc;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-feature-settings: 'cv11', 'ss01';
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.search {
  flex: 1; min-width: 0; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 14px; height: 40px;
}
.search:focus-within { border-color: var(--accent); }
.search svg { color: var(--muted); width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer; color: var(--text-2); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:root[data-theme='dark'] .sun, :root[data-theme='light'] .moon { display: none; }

/* ---------- buttons, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.chip.ok { color: #2fb67a; }
.chip.wait { color: #d7a019; }
.chip.err { color: var(--live); }
.chip.live { color: #fff; background: var(--live); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pulse { animation: pulse 1.4s ease-in-out infinite; background: #fff; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 36px 32px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { margin: 14px 0 4px; font-size: 24px; letter-spacing: -.02em; }
.login-card form { margin-top: 24px; display: grid; gap: 14px; text-align: left; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.login-card input {
  height: 44px; padding: 0 14px; border-radius: 10px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.form-error { min-height: 20px; margin: 0; color: var(--live); font-size: 13.5px; text-align: center; }

/* ---------- home ---------- */
.page { max-width: 980px; margin: 0 auto; padding: 28px 20px calc(var(--player-h) + 40px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.live-banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  padding: 14px 18px; border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 92, 108, .16), rgba(255, 92, 108, .04));
  border: 1px solid rgba(255, 92, 108, .35);
}
.day { margin: 26px 0 8px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rec-list { display: grid; gap: 8px; }
.rec {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 16px; align-items: start;
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  text-decoration: none; transition: border-color .15s, transform .15s, background .15s;
}
.rec:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: color-mix(in srgb, var(--surface) 92%, var(--accent)); }
.rec-time { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.rec-dur { font-size: 12.5px; color: var(--muted); }
.rec-title { font-weight: 650; font-size: 16px; letter-spacing: -.01em; margin-bottom: 3px; }
.rec-sum { color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rec-meta { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.avatars { display: flex; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; border: 2px solid var(--surface); margin-left: -6px;
}
.avatars .avatar:first-child { margin-left: 0; }
.rec-side { display: grid; gap: 6px; justify-items: end; }
.mini { display: inline-flex; gap: 4px; align-items: center; font-size: 12.5px; color: var(--muted); }
.mini svg { width: 15px; height: 15px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state svg { width: 44px; height: 44px; margin-bottom: 10px; }

/* search results */
.hit-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.hit-head { padding: 12px 16px; font-weight: 650; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.hit { display: grid; grid-template-columns: 60px 1fr; gap: 12px; padding: 10px 16px; text-decoration: none; border-top: 1px solid var(--border); }
.hit:first-of-type { border-top: 0; }
.hit:nth-child(even) { background: var(--zebra); }
.hit:hover { background: var(--surface-2); }
.hit-t { color: var(--accent); font-weight: 650; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.hit mark { background: rgba(var(--mark-yellow), .35); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- recording page ---------- */
.rec-page {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0;
  max-width: 1400px; margin: 0 auto; min-height: calc(100vh - var(--topbar-h));
}
.side {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h) - var(--player-h));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; gap: 2px; padding: 14px 14px 0; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; padding: 9px 4px 11px; background: none; border: 0; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { font-size: 11px; color: var(--muted); margin-left: 3px; }
.side-body { overflow-y: auto; padding: 16px 18px 24px; flex: 1; min-height: 0; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.side h3:first-child { margin-top: 2px; }
.summary-text { color: var(--text-2); font-size: 14.5px; line-height: 1.6; margin: 0; }
.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.bullets li { position: relative; padding-left: 16px; font-size: 14px; color: var(--text-2); }
.bullets li::before { content: ''; position: absolute; left: 2px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.action { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.action b { color: var(--text); }
.action .due { color: var(--muted); font-size: 12.5px; }
.toc { display: grid; gap: 2px; }
.toc-item {
  display: grid; grid-template-columns: 56px 1fr; gap: 8px; align-items: baseline;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; background: none; border: 0; text-align: left;
}
.toc-item:hover { background: var(--surface-2); }
.toc-item.on { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.toc-item .t { color: var(--accent); font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.toc-item .n { font-size: 14px; font-weight: 550; }
.mark-item { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 8px; border-left: 3px solid; cursor: pointer; }
.mark-item:hover { background: var(--surface-3); }
.mark-item .q { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mark-item .c { font-size: 14px; margin-top: 6px; white-space: pre-wrap; }
.mark-item .mh { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mark-item .mh button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
.mark-item .mh button:hover { color: var(--live); }
.note-area {
  width: 100%; min-height: 320px; resize: vertical;
  padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.6; outline: none;
}
.note-area:focus { border-color: var(--accent); }
.note-state { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.hint { font-size: 13px; color: var(--muted); }

.main { min-width: 0; padding: 30px 48px calc(var(--player-h) + 120px); }
.rec-head { max-width: 860px; margin-bottom: 26px; }
.rec-head .crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rec-head .crumbs a { text-decoration: none; }
.rec-head .crumbs a:hover { color: var(--text); }
.title-input {
  margin: 8px 0 10px; padding: 2px 0; border-bottom: 1px dashed transparent; cursor: text;
  color: var(--text); font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; outline: none; overflow-wrap: anywhere;
}
.title-input:hover { border-bottom-color: var(--border); }
.title-input:focus { border-bottom-color: var(--accent); }
.speakers { display: flex; gap: 6px; flex-wrap: wrap; }
.speaker-chip { cursor: pointer; }
.speaker-chip.off { opacity: .4; }
.processing {
  display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 22px; max-width: 860px;
}
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* lyrics */
.lyrics { max-width: 860px; }
.chapter-title {
  margin: 44px 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); display: flex; gap: 10px; align-items: center; cursor: pointer;
}
.chapter-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.chapter-title:first-child { margin-top: 0; }
.block { margin: 0 0 26px; }
.block.hidden-speaker { display: none; }
.who { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; font-weight: 700; }
.who .ts { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; cursor: pointer; }
.who .ts:hover { color: var(--accent); }
.who .lang { font-size: 10.5px; padding: 0 5px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.para { font-size: 25px; line-height: 1.42; font-weight: 700; letter-spacing: -.018em; margin: 0; }
.ln { cursor: pointer; border-radius: 6px; transition: color .25s ease, background-color .2s; box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: 1px 2px; }
.ln:hover { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 5px; text-decoration-thickness: 2px; }
.karaoke .ln { color: var(--dim); }
.karaoke .ln.past { color: var(--past); }
.karaoke .ln.now { color: var(--text); text-shadow: 0 0 22px color-mix(in srgb, var(--accent) 35%, transparent); }
.ln.m-yellow { background: rgba(var(--mark-yellow), .26); }
.ln.m-green { background: rgba(var(--mark-green), .26); }
.ln.m-blue { background: rgba(var(--mark-blue), .26); }
.ln.m-pink { background: rgba(var(--mark-pink), .26); }
.ln.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 35%, transparent); } }
.cmt-badge {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2); vertical-align: middle; margin: 0 4px; cursor: pointer; border: 0;
}
.cmt-badge svg { width: 13px; height: 13px; }

.follow-btn {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 18px); z-index: 25;
  box-shadow: var(--shadow);
}

/* selection toolbar & popover */
.sel-bar {
  position: absolute; z-index: 40; display: flex; gap: 2px; padding: 4px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.sel-bar button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.sel-bar button:hover { background: var(--surface-2); }
.sel-bar svg { width: 16px; height: 16px; }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.popover {
  position: absolute; z-index: 41; width: 320px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.popover textarea { width: 100%; min-height: 90px; resize: vertical; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; outline: none; }
.popover textarea:focus { border-color: var(--accent); }
.popover .row { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 10px; }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button.on { border-color: var(--text); }

/* ---------- player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: var(--player-h);
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.player-inner { height: 100%; max-width: 1400px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 18px; }
.player-controls { display: flex; align-items: center; gap: 6px; }
.player-controls svg text { font-family: var(--font); }
.play-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--text); color: var(--bg); transition: transform .12s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.play-btn .i-pause, .playing .play-btn .i-play { display: none; }
.playing .play-btn .i-pause { display: block; }
.player-track { flex: 1; min-width: 0; }
.player-now { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; min-height: 19px; }
.player-now b { color: var(--text); }
.scrub { display: flex; align-items: center; gap: 12px; }
.time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; }
.time:last-child { text-align: right; }
.scrub-bar { position: relative; flex: 1; height: 22px; cursor: pointer; touch-action: none; }
.scrub-bar::before { content: ''; position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--surface-3); }
.scrub-fill { position: absolute; left: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--accent); width: 0; }
.scrub-knob { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--text); left: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); opacity: 0; transition: opacity .15s; }
.scrub-bar:hover .scrub-knob, .scrub-bar.drag .scrub-knob { opacity: 1; }
.scrub-ticks { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; top: 7px; width: 2px; height: 8px; margin-left: -1px; background: var(--muted); opacity: .6; border-radius: 1px; }
.tick.mark { top: 1px; height: 5px; width: 6px; margin-left: -3px; border-radius: 2px; opacity: 1; }
.speed-btn { min-width: 52px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 700; font-size: 13px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 70px); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
}

/* ---------- docs ---------- */
.doc { max-width: 760px; margin: 0 auto; padding: 32px 20px 80px; }
.doc h1 { font-size: 30px; letter-spacing: -.025em; }
.doc h2 { margin-top: 34px; font-size: 20px; }
.doc p, .doc li { color: var(--text-2); }
.doc code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 13.5px; }
.doc .flow { display: grid; gap: 8px; margin: 16px 0; }
.doc .flow div { padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc td, .doc th { border-top: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .rec-page { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .side-body { max-height: 46vh; }
  .main { padding: 22px 20px calc(var(--player-h) + 120px); }
}
@media (max-width: 640px) {
  :root { --player-h: 112px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand span { display: none; }
  .search { height: 38px; }
  .top-actions { gap: 0; }
  .top-actions .icon-btn { width: 34px; }
  .top-actions a.icon-btn { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page { padding: 18px 16px calc(var(--player-h) + 40px); }
  .page-head h1 { font-size: 22px; }
  .rec { grid-template-columns: 1fr; gap: 6px; padding: 14px; }
  .rec-side { justify-items: start; grid-auto-flow: column; justify-content: start; }
  .title-input { font-size: 24px; }
  .para { font-size: 20px; }
  .main { padding: 18px 16px calc(var(--player-h) + 120px); }
  .player-inner { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; align-content: center; }
  .player-track { order: -1; flex-basis: 100%; }
  .player-controls { flex: 1; justify-content: center; }
  .popover { width: calc(100vw - 32px); }
}
