:root {
  --bg: #12100e;
  --bg-soft: #1a1714;
  --panel: #201c18;
  --line: #2e2822;
  --ink: #e9e3d8;
  --ink-dim: #a0968a;
  --ink-faint: #6d645a;
  --accent: #d9a05b;
  --accent-soft: rgba(217, 160, 91, .13);
  --mark: rgba(217, 160, 91, .32);
  --danger: #d9736b;
  --ok: #7bbf8a;
  --reader-size: 19.5px;
  --player-h: 84px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- login gate */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(217, 160, 91, .10), transparent 70%),
    var(--bg);
  padding: 24px;
  z-index: 60;
}

.gate-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #1d1915, #171411);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 30px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

.gate-mark {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: var(--accent-soft);
  border: 1px solid rgba(217, 160, 91, .35);
  position: relative;
  margin-bottom: 18px;
}
.gate-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.gate h1 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
}

.gate-sub {
  margin: 0 0 26px;
  color: var(--ink-faint);
  font-size: 13px;
}

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 11.5px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #141110;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: rgba(217, 160, 91, .55); background: #181513; }
.field input::placeholder { color: #5f574e; }

.gate-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13px;
}

.primary {
  width: 100%;
  height: 46px;
  margin-top: 6px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #1b1409;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; cursor: default; }

.gate-hint {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: #5f574e;
}

/* ---------------------------------------------------------------- topbar */

.app { height: 100%; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: none; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex: none;
}

.brand-text { min-width: 0; }

.topbar h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}

.meta {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40ch;
}

.legend { display: flex; gap: 6px; flex-wrap: wrap; overflow: hidden; flex: 1 1 auto; min-width: 0; }

.spk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px 0 7px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-dim);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 18ch;
}
.spk-chip:hover { color: var(--ink); border-color: #4a4038; }
.spk-chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.spk-chip span { overflow: hidden; text-overflow: ellipsis; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  height: 36px;
  width: min(30vw, 280px);
  flex: none;
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: #4a4038; background: #1f1b17; }
.search svg {
  width: 14px; height: 14px; flex: none;
  fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round;
}
.search input {
  flex: 1; min-width: 0;
  border: 0; background: none; color: var(--ink);
  font-size: 13px; outline: none;
}
.search input::placeholder { color: var(--ink-faint); }
.count { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; flex: none; }

.tools { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }

.peers { display: flex; align-items: center; }
.peer {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: #16120d;
  border: 2px solid var(--bg);
  margin-left: -7px;
  padding: 0;
  position: relative;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s;
}
.peer:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 0 2px rgba(255,255,255,.22), 0 4px 10px rgba(0,0,0,.45); z-index: 2; }
.peer:disabled { cursor: default; opacity: .55; }
.peer:first-child { margin-left: 0; }
.peer.me { outline: 1px solid rgba(255, 255, 255, .18); }

.fontsize { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.fontsize button {
  width: 32px; height: 32px;
  border: 0; background: var(--bg-soft);
  color: var(--ink-dim);
  font-size: 12px;
  cursor: pointer;
}
.fontsize button + button { border-left: 1px solid var(--line); }
.fontsize button:hover { color: var(--ink); background: #241f1a; }

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.ghost svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ghost:hover { color: var(--ink); border-color: #4a4038; background: #241f1a; }
.ghost.on { color: var(--accent); border-color: rgba(217, 160, 91, .4); background: rgba(217, 160, 91, .09); }

#btnHistory { width: 34px; justify-content: center; padding: 0; }

.pill {
  display: inline-block;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #1b1409;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
}

.user {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px 0 8px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-dim);
  font-size: 12.5px;
  cursor: pointer;
  max-width: 16ch;
}
.user:hover { color: var(--ink); border-color: #4a4038; }
.user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  background: #1d1915;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 6px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, .55);
  z-index: 40;
}
.menu button {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-dim);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: rgba(255, 255, 255, .05); color: var(--ink); }
.menu em { color: var(--ink-faint); font-style: normal; font-family: var(--mono); font-size: 11px; }

/* ------------------------------------------------------------ transcript */

#scroller {
  position: absolute;
  inset: 64px 0 var(--player-h) 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  transition: padding-right .2s;
}
#scroller::-webkit-scrollbar { width: 12px; }
#scroller::-webkit-scrollbar-thumb { background: #3a332c; border: 4px solid var(--bg); border-radius: 8px; }
#scroller::-webkit-scrollbar-thumb:hover { background: #4d443a; }

#transcript {
  max-width: 940px;
  margin: 0 auto;
  padding: 30px 26px 20px;
}

.block {
  position: relative;
  margin: 0 0 18px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--sp, transparent);
}

#transcript:not(.multi) .block { border-left-color: transparent; padding-left: 6px; }

.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 6px;
  font-size: 11px;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--sp, var(--ink-faint));
}
.block-head i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.block-head button {
  border: 0; background: none; color: inherit; cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  padding: 1px 4px; border-radius: 5px;
}
.block-head button:hover { background: rgba(255, 255, 255, .06); }

.line {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  column-gap: 12px;
  padding: 6px 40px 6px 6px;
  margin-left: -6px;
  border-radius: 7px;
  transition: background-color .16s ease;
}
.line:hover { background: rgba(255, 255, 255, .028); }
.line.active { background: var(--accent-soft); }
.line.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 4px; bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.gutter {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 5px;
  padding-top: .42em;
  user-select: none;
}

.ts {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  cursor: pointer;
  opacity: .7;
  transition: color .15s, opacity .15s;
  white-space: nowrap;
}
.line:hover .ts { opacity: 1; color: var(--ink-dim); }
.line.active .ts { opacity: 1; color: var(--accent); }

.status { display: flex; gap: 3px; align-items: center; padding-top: .1em; }
.status .badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 9.5px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--accent);
  border: 1px solid rgba(217, 160, 91, .5);
  background: rgba(217, 160, 91, .1);
  font-weight: 700;
  cursor: pointer;
}
.status .badge.cm { border-color: rgba(127, 159, 216, .55); background: rgba(127, 159, 216, .12); color: #a8bee6; }
.status .badge.ed { border-color: #453d34; background: none; color: var(--ink-faint); font-weight: 600; cursor: default; }

.tx {
  font-family: var(--serif);
  font-size: var(--reader-size);
  line-height: 1.62;
  color: #d8d1c5;
  cursor: text;
  outline: none;
  border-radius: 5px;
  padding: 0 2px;
  margin: 0 -2px;
  transition: color .15s;
  overflow-wrap: break-word;
}
.line:hover .tx { color: var(--ink); }
.line.active .tx { color: #fdf7ec; }

.tx[contenteditable="true"] {
  background: #1d1915;
  box-shadow: 0 0 0 1px rgba(217, 160, 91, .5), 0 0 0 4px rgba(217, 160, 91, .08);
  cursor: text;
  padding: 2px 5px;
  margin: 0 -5px;
}

.line.flagged { background: rgba(217, 160, 91, .07); }
.line.flagged::before {
  content: "";
  position: absolute;
  left: -16px; top: 4px; bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: .55;
}
.line.flagged .tx { color: #efe6d6; }
.line.done { opacity: .62; }

.tx mark { background: var(--mark); color: #fff3e0; border-radius: 3px; }
.tx ins { background: rgba(123, 191, 138, .22); color: #cfeed7; text-decoration: none; border-radius: 3px; }
.tx del { background: rgba(217, 115, 107, .2); color: #e6b0ab; text-decoration: line-through; border-radius: 3px; }

.tx.lowconf { text-decoration: underline dotted rgba(217, 160, 91, .4); text-underline-offset: 5px; }

.acts {
  position: absolute;
  right: 4px;
  top: 5px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s;
}
.line:hover .acts, .line:focus-within .acts { opacity: 1; }

.acts button {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}
.acts button:hover { color: var(--ink); background: rgba(255, 255, 255, .07); border-color: var(--line); }
.acts button.on { color: var(--accent); }
.acts svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.peer-marks { position: absolute; right: 38px; top: 6px; display: flex; gap: 3px; }
.peer-marks span {
  width: 15px; height: 15px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 8.5px;
  font-weight: 700;
  color: #16120d;
  box-shadow: 0 0 0 2px var(--bg);
}

/* comment threads */

.thread {
  grid-column: 2;
  margin: 6px 0 4px;
  border-left: 2px solid rgba(127, 159, 216, .5);
  padding: 4px 0 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.comment {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  position: relative;
}
.comment b { color: var(--ink); font-weight: 600; }
.comment time { color: var(--ink-faint); font-size: 11px; margin-left: 6px; }
.comment button.del {
  border: 0; background: none; color: var(--ink-faint);
  cursor: pointer; font-size: 11px; padding: 0 2px; margin-left: 4px;
}
.comment button.del:hover { color: var(--danger); }

.comment-form { display: flex; gap: 6px; align-items: flex-start; }
.comment-form textarea {
  flex: 1;
  min-height: 34px;
  max-height: 140px;
  resize: vertical;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #141110;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  outline: none;
}
.comment-form textarea:focus { border-color: rgba(127, 159, 216, .5); }
.comment-form button {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid rgba(127, 159, 216, .35);
  background: rgba(127, 159, 216, .12);
  color: #b9cdf0;
  font-size: 12px;
  cursor: pointer;
}
.comment-form button:hover { background: rgba(127, 159, 216, .2); }

/* ---------------------------------------------------------------- drawer */

.drawer {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: var(--player-h);
  width: min(390px, 92vw);
  background: #17130f;
  border-left: 1px solid var(--line);
  z-index: 25;
  display: flex;
  flex-direction: column;
  box-shadow: -30px 0 60px rgba(0, 0, 0, .45);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 6px;
}
.drawer-head h2 { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.drawer-sub { margin: 0 16px 10px; font-size: 11.5px; color: var(--ink-faint); }
.drawer-body { overflow-y: auto; padding: 0 12px 20px; }

.flag-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  margin-bottom: 8px;
  background: #1b1612;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.flag-card:hover { border-color: #4a4038; background: #201a15; }
.flag-card .fc-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink-faint); }
.flag-card .fc-text {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-dim);
}
.flag-card .fc-notes { margin-top: 8px; font-size: 11.5px; color: #9db2d6; }
.flag-card .fc-actions { display: flex; gap: 6px; margin-top: 9px; }
.flag-card .fc-actions button {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-dim);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}
.flag-card .fc-actions button:hover { color: var(--ink); border-color: #4a4038; }

.empty-note { color: var(--ink-faint); font-size: 12.5px; padding: 10px; line-height: 1.6; }

/* ----------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 6, .62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
}
.modal-card {
  width: min(820px, 100%);
  max-height: min(78vh, 760px);
  display: flex;
  flex-direction: column;
  background: #1a1612;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .6);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 600; }
.modal-body { overflow-y: auto; padding: 8px 18px 18px; }

.x {
  border: 0;
  background: none;
  color: var(--ink-faint);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.x:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }

.vrow {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid rgba(46, 40, 34, .6);
  font-size: 13px;
}
.vrow:last-child { border-bottom: 0; }
.vrow .when { color: var(--ink-faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.vrow .who { color: var(--ink-dim); }
.vrow .diff { font-family: var(--serif); font-size: 14px; line-height: 1.6; color: var(--ink-dim); margin-top: 3px; }
.vrow .upd { color: var(--ink-faint); font-size: 11px; margin-top: 4px; }
.vrow .jump {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-dim);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.vrow .jump:hover { color: var(--ink); border-color: #4a4038; }

.type {
  display: inline-block;
  font-size: 9.5px;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 4px;
  background: #2a241e;
  color: var(--ink-faint);
  margin-right: 6px;
}
.type.edit { background: rgba(217, 160, 91, .18); color: #e2b276; }
.type.flag { background: rgba(217, 115, 107, .16); color: #d99b95; }
.type.comment { background: rgba(127, 159, 216, .16); color: #a8bee6; }

/* ---------------------------------------------------------------- player */

.player {
  position: fixed;
  inset: auto 0 0 0;
  height: var(--player-h);
  background: linear-gradient(to top, #16130f, #1a1613);
  border-top: 1px solid var(--line);
  z-index: 30;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
.player .row { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 1180px; margin: 0 auto; }

.play {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #1a1309;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s, filter .15s;
  box-shadow: 0 2px 14px rgba(217, 160, 91, .22);
}
.play:hover { filter: brightness(1.08); }
.play:active { transform: scale(.95); }
.play svg { width: 20px; height: 20px; fill: currentColor; }
.play .i-pause { display: none; }
.play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }

.skip {
  height: 30px;
  padding: 0 9px;
  flex: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-faint);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.skip:hover { color: var(--ink); border-color: #4a4038; }

.timeline { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.time { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink-dim); min-width: 42px; text-align: center; }
.time.dim { color: var(--ink-faint); }

.track {
  position: relative;
  flex: 1;
  height: 26px;
  display: flex;
  align-items: center;
  cursor: pointer;
  outline: none;
  touch-action: none;
}
.track .rail { position: relative; height: 5px; width: 100%; border-radius: 4px; background: #332c26; overflow: hidden; transition: height .12s; }
.track:hover .rail, .track.dragging .rail { height: 7px; }
.track .fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, #b5813f, var(--accent)); border-radius: 4px; }
.track .knob {
  position: absolute; left: 0;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff4e4;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .55);
  transform: translateX(-50%) scale(0);
  transition: transform .12s;
  pointer-events: none;
}
.track:hover .knob, .track.dragging .knob { transform: translateX(-50%) scale(1); }
.bubble {
  position: absolute; bottom: 26px; left: 0;
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 6px;
  background: #0d0b09;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  white-space: nowrap;
}
.track:hover .bubble, .track.dragging .bubble { opacity: 1; }

.speed select {
  appearance: none;
  height: 32px;
  padding: 0 24px 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0968a' stroke-width='2.4' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>")
    no-repeat right 6px center / 12px,
    var(--bg-soft);
  color: var(--ink-dim);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-faint);
  font-size: 12px;
  cursor: pointer;
}
.toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toggle.on { color: var(--accent); border-color: rgba(217, 160, 91, .35); background: rgba(217, 160, 91, .08); }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-h) + 18px);
  transform: translateX(-50%) translateY(8px);
  background: #241f1a;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  opacity: 0;
  transition: opacity .18s, transform .18s;
  pointer-events: none;
  z-index: 70;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------ responsive */

/* make room for the drawer on wide screens */
@media (min-width: 1180px) {
  body.review-open #scroller { padding-right: 390px; }
  body.review-open #transcript { max-width: 880px; }
}

/* touch devices have no hover: keep the line actions visible */
@media (hover: none) {
  .acts { opacity: 1; }
  .line { padding-right: 92px; }
}

@media (max-width: 1100px) {
  .legend { display: none; }
  .search { width: min(26vw, 210px); }
  .ghost span { display: none; }
  #btnReview, #btnExport, #btnHistory { width: 34px; justify-content: center; padding: 0; }
  .pill { position: absolute; transform: translate(11px, -11px); }
}

@media (max-width: 820px) {
  .topbar { height: auto; padding: 10px 12px; flex-wrap: wrap; }
  #scroller { inset: 104px 0 var(--player-h) 0; }
  #transcript { padding: 20px 14px 16px; }
  .line { grid-template-columns: 46px minmax(0, 1fr); column-gap: 8px; padding-right: 30px; }
  .user span:last-child { display: none; }
  .user { width: 34px; justify-content: center; padding: 0; }
  .speed { display: none; }
  .drawer { top: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
