:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --surface-2: #f0ebe3;
  --ink: #1d1b18;
  --ink-2: #5c564d;
  --ink-3: #8a8378;
  --line: #e2dbd0;
  --accent: #b5651d;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6d4;
  --ok: #2f7d4f;
  --ok-soft: #dff0e5;
  --warn: #9a6b00;
  --warn-soft: #fbefcf;
  --bad: #b2362b;
  --bad-soft: #f8dedb;
  --info-soft: #e3ebf5;
  --info: #2f5a8a;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #1f1c19;
    --surface-2: #2a2622;
    --ink: #efe9e0;
    --ink-2: #b8afa3;
    --ink-3: #8a8277;
    --line: #36312b;
    --accent: #e09145;
    --accent-ink: #1a1208;
    --accent-soft: #3a2a1a;
    --ok: #6fc391;
    --ok-soft: #1f3327;
    --warn: #e2b54a;
    --warn-soft: #3a3019;
    --bad: #ef8579;
    --bad-soft: #3d2220;
    --info-soft: #1e2a3a;
    --info: #8db4e2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; margin-top: 1.6rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: .85em; }
small, .muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* ---------------------------------------------------------------- shell */

.topbar {
  display: flex; align-items: center; gap: 20px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; color: var(--ink); letter-spacing: .01em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 6px 16px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.topbar nav a.on { color: var(--ink); }
.who { color: var(--ink-2); font-size: .9rem; white-space: nowrap; }
.role-pill { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); font-size: .78rem; margin-left: 4px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }
footer {
  max-width: 1180px; margin: 32px auto 24px; padding: 16px 24px 0; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: .82rem; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

.crumbs { color: var(--ink-3); font-size: .88rem; margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 20px; flex-wrap: wrap; }
.subnav a { padding: 8px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.subnav a.on { color: var(--ink); border-color: var(--accent); }
.subnav a:hover { text-decoration: none; color: var(--ink); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .75rem; text-align: center; margin-left: 4px; font-weight: 600; }

/* ---------------------------------------------------------------- blocks */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: .9rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

.stat { font-family: var(--serif); font-size: 1.8rem; font-weight: 600; }
.stat-label { color: var(--ink-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

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

label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field + .field { margin-top: 10px; }
.inline-check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); font-size: .9rem; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--ink-3); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); }
button.small, .btn.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
form.inline { display: inline; }

audio { width: 100%; height: 36px; }
audio.compact { max-width: 280px; }

/* ---------------------------------------------------------------- script / segments */

.script { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: 44px 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.line.dialogue { border-left: 3px solid var(--accent); }
.line .idx { color: var(--ink-3); font-family: var(--mono); font-size: .8rem; padding-top: 2px; }
.line .who-said { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.line .text { font-family: var(--serif); font-size: 1.05rem; }
.line .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.line details { margin-top: 8px; }
.line details summary { cursor: pointer; color: var(--ink-2); font-size: .85rem; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.edit-grid .wide { grid-column: 1 / -1; }
.suggestion { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); margin-top: 8px; font-size: .9rem; flex-wrap: wrap; }

.prompt { font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }

.diff del { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; padding: 0 2px; border-radius: 3px; }
.diff ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; padding: 0 2px; border-radius: 3px; }

.take { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.take.active { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.takes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.proposal { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.quote { font-family: var(--serif); font-size: 1.05rem; border-left: 3px solid var(--line); padding-left: 12px; color: var(--ink); }
.note-body { font-style: italic; }

/* ---------------------------------------------------------------- review portal */

.player { position: sticky; top: 58px; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.transcript { font-family: var(--serif); font-size: 1.12rem; line-height: 1.75; }
.transcript .seg { cursor: pointer; border-radius: 4px; padding: 1px 2px; transition: background .15s; }
.transcript .seg:hover { background: var(--surface-2); }
.transcript .seg.now { background: var(--accent-soft); }
.transcript .seg.unrendered { color: var(--ink-3); }
.transcript .spk { font-family: var(--sans); font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); margin-right: 4px; }

.login-list { display: grid; gap: 10px; max-width: 520px; }
.login-list button { width: 100%; justify-content: space-between; padding: 14px 16px; }

@media (max-width: 760px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .proposal { grid-template-columns: 1fr; }
  .edit-grid { grid-template-columns: 1fr; }
  .line { grid-template-columns: 1fr; }
  .line .idx { display: none; }
}
