:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1d1f24; --muted: #646a73; --line: #e2e0d9; --soft: #f0eee8;
  --accent: #2f5bd3; --accent-ink: #ffffff; --accent-soft: #e6ecfb; --ok: #1f7a4d; --warn: #a15c00; --err: #b3261e;
  --ok-soft: #e5f3eb; --warn-soft: #fbf0df; --err-soft: #fbe6e4; --chip: #eef0f5; --time: #2f5bd3;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #15171b; --card: #1d2026; --ink: #e9eaee; --muted: #9aa0aa; --line: #2e323a; --soft: #23262d;
  --accent: #7d9cff; --accent-ink: #0e1220; --accent-soft: #232c45; --ok: #5cc98f; --warn: #e8a64a; --err: #f08a80;
  --ok-soft: #1b2e24; --warn-soft: #33281a; --err-soft: #3a1f1d; --chip: #262a32; --time: #93aeff;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .875rem; }
.muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.back { text-decoration: none; font-size: .875rem; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.brand strong { white-space: nowrap; }
.logo { width: 26px; height: 26px; flex: none; }
.lg-paper { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.lg-wave { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; fill: none; }
.lg-rule { stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.session { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .875rem; cursor: pointer; text-decoration: none; min-height: 34px; }
.pill:hover:not(:disabled) { border-color: var(--accent); }
.pill.solid { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.ghost { cursor: default; background: var(--soft); }
.pill.tiny { padding: 3px 10px; min-height: 28px; font-size: .8125rem; }
.pill:disabled { opacity: .5; cursor: not-allowed; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 12px 22px; font: inherit; font-weight: 600; cursor: pointer; min-height: 46px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

.wrap { max-width: 920px; margin: 0 auto; padding: 16px 16px 48px; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.15; margin: 18px 0 10px; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 14px; max-width: 70ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.chips-label { font-size: .875rem; color: var(--muted); }
.chip { border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .875rem; cursor: pointer; min-height: 34px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 0 0 16px; }
.cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card h2 { font-size: 1.15rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .8125rem; font-weight: 700; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; cursor: pointer; background: var(--soft); }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop-big { font-weight: 600; }
.recrow, .sttrow, .runrow, .btnrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btnrow { margin-top: 10px; }
.btnrow.tight { margin: 0 0 10px; }
.rectime { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4ch; }
.meterbar { width: 120px; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.meterbar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
.recording .rectime { color: var(--err); }
textarea, input[type="text"], select { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
textarea { resize: vertical; font-size: .9375rem; }
select { width: auto; max-width: 100%; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.player { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.player audio { width: 100%; }
.stt { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.prog { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.prog span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.lines { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.lines li { display: flex; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--soft); font-size: .9375rem; }
.lines li:last-child { border-bottom: 0; }
.lines li.hit { background: var(--accent-soft); }
.lines li.silent { color: var(--muted); font-style: italic; }
.lines li.empty { color: var(--muted); }
.tbtn { flex: none; font: inherit; font-size: .8125rem; font-variant-numeric: tabular-nums; color: var(--time); background: none; border: 1px solid transparent; border-radius: 6px; padding: 0 5px; cursor: pointer; min-width: 3.6em; text-align: left; height: 1.6em; }
.tbtn:hover { border-color: var(--time); }
.tbtn.nolink { color: var(--muted); cursor: default; border-color: transparent; }
.scan { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.scan li { font-size: .875rem; padding: 6px 10px; border-radius: 8px; background: var(--soft); }
.scan li.ok { background: var(--ok-soft); }
.scan li.warn { background: var(--warn-soft); }
.scan li.err { background: var(--err-soft); }

.settings { display: grid; gap: 12px; }
.settings label { display: grid; gap: 4px; font-size: .9375rem; }
.fmt { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.fmt legend { margin-bottom: 4px; }
.radio { display: flex !important; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.engines { border: 0; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.engines legend { margin-bottom: 4px; }
.eng { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.eng:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.eng input { margin-top: 4px; }
.eline { display: block; margin-top: 2px; }
.etag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); margin-left: 4px; }
.etag.free { background: var(--ok-soft); color: var(--ok); }
.quote { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--soft); }
.grid2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.note { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--soft); font-size: .875rem; }
.note.warn { background: var(--warn-soft); }
.gate { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: .9375rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.progress { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.progress h3 { margin: 0 0 8px; font-size: 1rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.step { color: var(--muted); font-size: .9375rem; }
.step.active { color: var(--ink); font-weight: 600; }
.step.done { color: var(--ok); }
.step-ic { display: inline-block; width: 1.2em; font-family: ui-monospace, monospace; }
.raw { white-space: pre-wrap; word-break: break-word; background: var(--soft); padding: 12px; border-radius: 8px; font-size: .8125rem; max-height: 360px; overflow: auto; }

.notes { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.nhead h3 { font-size: 1.35rem; margin: 6px 0 8px; }
.badge { display: inline-block; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.summary { margin: 0 0 8px; font-size: 1.0625rem; }
.nsec { margin-top: 18px; }
.nsec h4 { margin: 0 0 8px; font-size: .8125rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.osec { margin: 0 0 12px; }
.osec h5 { margin: 0 0 4px; font-size: 1rem; display: flex; gap: 6px; align-items: baseline; }
.osec ul, .items { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 5px; }
.osec li { padding-left: 1.1em; position: relative; }
.osec li::before { content: ""; position: absolute; left: .25em; top: .65em; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.items li { display: flex; gap: 6px; align-items: baseline; }
.items li .tag { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; background: var(--chip); color: var(--muted); flex: none; }
.items li .tag.review { background: var(--ok-soft); color: var(--ok); }
.defs { margin: 0; display: grid; gap: 8px; }
.defs div { display: grid; gap: 2px; }
.defs dt { font-weight: 700; display: flex; gap: 6px; align-items: baseline; }
.defs dd { margin: 0; color: var(--ink); }
.none { color: var(--muted); font-style: italic; }
.tablewrap { overflow-x: auto; }
.acts { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.acts th, .acts td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.acts th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.exports { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.inline { display: inline-flex; gap: 6px; align-items: center; }

.hist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.hrow { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.hinfo { flex: 1; min-width: 0; display: grid; }
.hinfo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist li.none { padding: 8px 0; }

.foot { max-width: 920px; margin: 0 auto; padding: 0 16px 40px; color: var(--muted); font-size: .8125rem; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 20; width: min(92vw, 520px); }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: .9375rem; box-shadow: 0 4px 18px rgba(0,0,0,.2); transition: opacity .5s; }
.toast.err { background: var(--err); color: #fff; }
.toast a { color: inherit; font-weight: 700; }
.toast.gone { opacity: 0; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .brand strong { font-size: .9375rem; }
  .back { display: none; }
  .acts th:nth-child(4), .acts td:nth-child(4) { white-space: nowrap; }
}
@media print {
  body { background: #fff; color: #000; }
  .topbar, .hero, .card:not(#notesCard), .settings, .exports, .foot, .toasts, .progress, #how, .recon { display: none !important; }
  #notesCard { border: 0; box-shadow: none; padding: 0; }
  #notesCard > .cardhead { display: none; }
  .notes { border: 0; margin: 0; padding: 0; }
  .tbtn { color: #444; border: 0; }
  .wrap { max-width: none; padding: 0; }
  .print-only.on { display: block !important; }
  .lines { max-height: none; overflow: visible; border: 0; }
}
.print-only { display: none; }
