:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1c1b19;
  --muted: #6d6a64;
  --line: #e3e0d9;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --them: #2f5bd3;
  --me: #1f8a5b;
  --tr: #8a4b12;
  --warn-bg: #fff4d6;
  --err-bg: #fde4e1;
  --err: #b3261e;
  --live: #1f8a5b;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315;
    --panel: #1b1c1f;
    --ink: #ecebe8;
    --muted: #9a978f;
    --line: #2c2d31;
    --accent: #6d8fff;
    --accent-ink: #0d0e10;
    --them: #8aa5ff;
    --me: #5fd19d;
    --tr: #f0b97a;
    --warn-bg: #3a3017;
    --err-bg: #3d1d1b;
    --err: #ff8a80;
    --live: #5fd19d;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); display: flex; flex-direction: column; font-size: 15px; }

button, select, input, textarea, .ghost { font: inherit; color: inherit; }
button, .ghost, select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary.stop { background: var(--err); border-color: var(--err); color: #fff; }
.small { padding: 4px 9px; font-size: 13px; }
.ghost:hover, select:hover { border-color: var(--muted); }

.bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot[data-state="live"] { background: var(--live); box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 25%, transparent); }
.dot[data-state="busy"] { background: #d79b1e; }
.dot[data-state="error"] { background: var(--err); }
.field, .check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.check input { accent-color: var(--accent); }
.status { font-size: 13px; color: var(--muted); }
.spacer { flex: 1; }

.meter { display: block; width: 80px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--them); transition: width 90ms linear; }
kbd { font: 600 11px ui-monospace, monospace; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 6px; opacity: .6; }
#pauseBtn.active { background: #d79b1e; border-color: #d79b1e; color: #1c1b19; }

.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.chip[data-state="ready"] { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.chip[data-state="thinking"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.chip[data-state="starting"] { background: var(--warn-bg); color: var(--ink); }
.chip[data-state="error"] { background: var(--err-bg); color: var(--err); }

.card { margin: 12px 14px 0; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius); display: grid; gap: 10px; transition: border-color .15s; }
.card.streaming { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card.locked { border-color: var(--me); background: color-mix(in srgb, var(--me) 7%, var(--panel)); }
.card.locked .ans-text { font-size: 18px; }
.card-top { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.lock-badge { font-size: 12px; font-weight: 700; color: var(--me); }
.held { color: var(--tr); }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px 0; }

.banner { margin: 10px 16px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--err-bg); color: var(--err); font-size: 14px; }
.banner[data-kind="warn"] { background: var(--warn-bg); color: var(--ink); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 14px; padding: 14px 16px 16px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.col-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.col-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 auto 0 0; }

.subs-list { flex: 1; overflow-y: auto; padding: 14px 18px 40vh; scroll-behavior: smooth; }
.empty { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 62ch; }
.empty ul { margin: 4px 0 6px; padding-left: 18px; }

.utt { padding: 8px 0 10px; border-bottom: 1px dashed var(--line); }
.utt .orig { margin: 3px 0 0; font-size: 21px; line-height: 1.4; }
.utt .int { color: var(--muted); font-style: italic; }
.utt .tr { margin: 4px 0 0; font-size: 19px; line-height: 1.4; color: var(--tr); }
.utt .tr:empty { display: none; }
.utt .tr.err { font-size: 13px; color: var(--err); }
body.hide-orig .utt.done:not(.native-it) .orig { display: none; }
body.hide-tr .utt .tr { display: none; }

.side { overflow-y: auto; }
.side select { padding: 4px 8px; font-size: 13px; }
.focus { margin: 10px 14px 12px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 13px; }
.lang-block { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; }
.lang-tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); padding-top: 4px; }
.ans-text { font-size: 16px; line-height: 1.55; min-height: 1.5em; }
.ans-text.muted { color: var(--muted); font-size: 14px; }
.ans-text .li { display: block; padding-left: 14px; position: relative; }
.ans-text .li::before { content: "•"; position: absolute; left: 2px; color: var(--muted); }
.ans-text mark { background: var(--warn-bg); color: inherit; padding: 0 3px; border-radius: 3px; }
.ans-text .err { color: var(--err); font-size: 14px; }
.typing { color: var(--muted); }
.meta { font-size: 12px; color: var(--muted); font-weight: 400; }

details { border-top: 1px solid var(--line); padding: 10px 14px; }
summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.hist-item { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; line-height: 1.5; }
.hist-item .en { color: var(--muted); margin-top: 4px; }
.docs textarea {
  width: 100%; min-height: 220px; margin-top: 8px; resize: vertical; padding: 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 13px; line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.docs-actions { display: flex; gap: 8px; margin-top: 6px; }
.file { cursor: pointer; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(50vh, 1fr) auto; }
  .utt .orig { font-size: 18px; }
}

/* login */
.login { margin: auto; width: min(360px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.login input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 12px; }
.login button { width: 100%; padding: 10px; }
.login .err { color: var(--err); font-size: 14px; }
