:root {
  --bg: #f5f7fa;
  --bg-grad-1: #eef2f8;
  --bg-grad-2: #f7f4ef;
  --card: #ffffff;
  --ink: #121826;
  --ink-soft: #525c6b;
  --ink-faint: #646e7e;
  --line: #e6eaf0;
  --brand: #2f6df6;
  --brand-dark: #1f54cc;
  --brand-soft: #eaf0ff;
  --good: #157a52;
  --warn: #c2410c;
  --danger: #b93232;
  --radius: 16px;
  --btn-radius: 11px;
  --btn-shadow: 0 6px 16px rgba(47, 109, 246, .27);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 32px rgba(16, 24, 40, .08);
  --appbar-h: 57px;   /* app-shell header height; sidebar top offset keys off it */
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { height: 100%; }
/* min-height (not height) so body grows to the full document height, and
   position:relative so the absolute .sidebar can stretch to the page bottom. */
body { position: relative; min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--bg-grad-2), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, var(--bg-grad-1), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand); }

.wordmark {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 700; letter-spacing: -.01em; font-size: 1.15rem; color: var(--ink);
}

/* ── Login ──────────────────────────────────────────── */
.center-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow);
  padding: 40px 36px;
}
.auth-card h1 { margin: .5rem 0 .35rem; font-size: 1.7rem; letter-spacing: -.02em; }
.auth-card p.lead { margin: 0 0 1.5rem; color: var(--ink-soft); }

.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--ink-soft); }
input[type=email], select {
  width: 100%; padding: .8rem .9rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input[type=email]:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft);
}

button {
  font: inherit; cursor: pointer; border: none; border-radius: var(--btn-radius);
  transition: background .15s, transform .05s, box-shadow .15s, opacity .15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  width: 100%; margin-top: 1.1rem; padding: .85rem 1rem;
  background: var(--brand); color: #fff; font-weight: 650; font-size: 1rem;
  box-shadow: var(--btn-shadow);
}
.btn-primary:hover { background: var(--brand-dark); }

.note { margin-top: 1.4rem; font-size: .85rem; color: var(--ink-faint); text-align: center; }

.msg, .inline-msg { margin-top: 1rem; padding: .8rem .9rem; border-radius: 11px; font-size: .92rem; display: none; }
.msg { margin-top: 1.1rem; }
.msg.show, .inline-msg.show { display: block; }
.inline-msg a { color: inherit; font-weight: 600; text-decoration: underline; margin-left: .4rem; }
.msg.ok, .inline-msg.ok { background: #e8f7ef; color: var(--good); border: 1px solid #c7ecd8; }
.msg.err, .inline-msg.err { background: #fdecec; color: var(--danger); border: 1px solid #f6d3d3; }

/* ── App shell ──────────────────────────────────────── */
/* Skip link: visually hidden until focused, first tab stop on signed-in pages. */
.skip-link { position: absolute; left: -9999px; top: 10px; z-index: 60; }
.skip-link:focus {
  left: 12px; background: var(--card); color: var(--brand-dark);
  padding: .5rem .9rem; border-radius: 10px; box-shadow: var(--shadow);
}
.main:focus { outline: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .right { display: flex; align-items: center; gap: 1rem; }
.linkbtn {
  background: none; color: var(--ink-soft); padding: .45rem .7rem; border-radius: 9px;
  font-size: .9rem; font-weight: 600;
}
.linkbtn:hover { background: #eef1f6; color: var(--ink); }

.container { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem; margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 .25rem; font-size: 1.1rem; letter-spacing: -.01em; }
.card .sub { margin: 0 0 1.1rem; color: var(--ink-faint); font-size: .9rem; }

/* Dropzone */
.dropzone {
  border: 1.5px dashed #c8d2e0; border-radius: 13px;
  padding: 2rem 1rem; text-align: center; color: var(--ink-soft);
  background: #fbfcfe; transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .big { font-size: 1rem; color: var(--ink); font-weight: 600; }
.dropzone .small { font-size: .85rem; color: var(--ink-faint); margin-top: .3rem; }
.dropzone.has-file { border-style: solid; border-color: var(--brand); background: #fff; }
.dropzone.too-big { border-style: solid; border-color: var(--danger); background: #fdecec; }

.row { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; margin-top: 1.1rem; }
.row .field { flex: 1; min-width: 160px; }
.row .field.grow { flex: 2; }
.row .field-submit { flex: 0 0 auto; }

/* Visually hidden but announced by screen readers (live status text). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Shared brand-filled primary action — Transcribe button + page CTAs.
   (.btn-cta.ghost and .btn-cta.sm variants live in the platform-shell section.) */
.btn-go, .btn-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.15rem; border-radius: var(--btn-radius);
  background: var(--brand); color: #fff; font-weight: 650; font-size: .94rem;
  text-decoration: none; box-shadow: var(--btn-shadow);
}
.btn-go:hover, .btn-cta:hover { background: var(--brand-dark); }

.spinner {
  width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.45);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  vertical-align: -3px; margin-right: .5rem; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-actions { display: flex; gap: .6rem; margin-top: .9rem; align-items: center; flex-wrap: wrap; }
.btn-ghost {
  padding: .55rem .9rem; background: #eef1f6; color: var(--ink); font-weight: 600; font-size: .9rem;
}
.btn-ghost:hover { background: #e3e8f0; }
.btn-ghost .spinner { border-color: rgba(15,23,42,.2); border-top-color: currentColor; }
.result-meta { margin-left: auto; color: var(--ink-faint); font-size: .85rem; }

.inline-msg.warn { background: #fff4e8; color: var(--warn); border: 1px solid #f8e0c5; }

/* Data tables — one shared style for admin usage, billing ledger and the
   privacy legal table (per-table add-ons live next to their pages below). */
table.usage, .ledger, .legal-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.usage th, table.usage td, .ledger th, .ledger td, .legal-table th, .legal-table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); }
table.usage th, .ledger th, .legal-table th { color: var(--ink-faint); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
table.usage td.num, .ledger td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Wide tables scroll inside their card instead of forcing page-wide overflow */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .ledger, .table-scroll > table.usage { min-width: 560px; }
.ledger td, table.usage td { white-space: nowrap; }
.ledger td:nth-child(3) { white-space: normal; min-width: 12ch; }

/* Record */
.record-row { display: flex; align-items: center; gap: .8rem; margin-top: .9rem; flex-wrap: wrap; }
.btn-record {
  display: inline-flex; align-items: center; gap: .55rem; padding: .6rem 1rem;
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  font-weight: 600; font-size: .92rem;
}
.btn-record:hover { background: #f4f6fa; }
.btn-record:disabled { opacity: .55; }
.btn-record .rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--danger); display: inline-block;
}
.btn-record.recording { border-color: var(--danger); color: var(--danger); background: #fdf3f3; }
.btn-record.recording .rec-dot { animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.record-status { font-size: .85rem; color: var(--ink-faint); }

.player { width: 100%; margin: 0 0 1rem; height: 38px; }

.segments { margin-top: 1.1rem; }

/* Speaker toggle */
.check-row {
  display: flex; align-items: center; gap: .55rem; margin-top: .9rem;
  font-size: .92rem; color: var(--ink-soft); cursor: pointer; user-select: none;
}
.check-row input { width: 17px; height: 17px; accent-color: var(--brand); flex: 0 0 auto; }
.check-row small { color: var(--ink-faint); }

/* API card */
.key-row { display: flex; gap: .5rem; align-items: center; }
.key-row input {
  flex: 1; padding: .7rem .8rem; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fcfdff; color: var(--ink);
}
.key-row input.revealed { border-color: var(--warn); background: #fff4e8; }
.small-note { margin: .55rem 0 0; font-size: .8rem; color: var(--ink-faint); line-height: 1.5; }
.small-note code { background: #eef1f6; padding: .1rem .35rem; border-radius: 5px; font-size: .82em; }
.small-note.warn { color: var(--warn); font-weight: 600; }
.curl-label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin: 1.2rem 0 .4rem; }
pre.curl {
  margin: 0 0 .7rem; padding: 1rem; background: #0f1626; color: #d7e0f0; border-radius: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .82rem; line-height: 1.6;
  overflow-x: auto; white-space: pre;
}

.example-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ex-tab {
  padding: .4rem .8rem; background: #eef1f6; color: var(--ink-soft);
  font-weight: 600; font-size: .82rem; border-radius: 8px;
}
.ex-tab:hover { background: #e3e8f0; }
.ex-tab.active { background: var(--brand); color: #fff; }
.example-resp { margin-top: .2rem; }
.resp-label {
  display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 600; margin-bottom: .3rem;
}
pre.curl.resp { background: #f7f9fc; color: #2c3647; border: 1px solid var(--line); }

.footer-note { text-align: center; color: var(--ink-faint); font-size: .82rem; margin-top: 1.5rem; }

/* Legal / privacy page */
.legal { max-width: 760px; }
.legal h1 { font-size: 1.9rem; letter-spacing: -.02em; margin: .5rem 0 .5rem; }
.legal .lead { color: var(--ink-soft); font-size: 1.05rem; line-height: 1.6; margin-bottom: 2rem; }
.legal section { margin-bottom: 1.8rem; }
.legal h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
.legal ul, .legal ol { margin: 0; padding-left: 1.2rem; color: var(--ink-soft); line-height: 1.7; }
.legal li { margin-bottom: .35rem; }
.legal p { color: var(--ink-soft); line-height: 1.7; }
.legal .muted { color: var(--ink-faint); font-size: .9rem; }
/* .legal-table shares the data-table base (see "Data tables" above) */
.legal-table { margin: .4rem 0; }
.legal-table th, .legal-table td { vertical-align: top; }
.legal-table td { color: var(--ink-soft); }

/* Keyboard accessibility */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, a:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   Redesign: app shell + sidebar history + searchable transcript
   ═══════════════════════════════════════════════════════════════════ */

/* The HTML5 hidden attribute must always win, even over class rules that set
   an explicit display (e.g. .clear-confirm, .stored-notice, flex toolbars). */
[hidden] { display: none !important; }

/* App-shell header */
.appbar {
  position: sticky; top: 0; z-index: 30; height: var(--appbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 22px;
  background: rgba(255,255,255,.72); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.appbar-right { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: .8rem; font-size: .9rem; color: var(--ink-soft); }
.appbar-right .email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar (absolute overlay — scrolls with the page) */
.sidebar {
  position: absolute; left: 0; top: var(--appbar-h); bottom: 0; width: 272px;
  z-index: 25; background: var(--card); border-right: 1px solid var(--line);
  box-shadow: 2px 0 16px rgba(16,24,40,.07);
  display: flex; flex-direction: column; padding: 16px;
}
.sidebar[hidden] { display: none; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.clear-all {
  background: none; color: var(--ink-faint); font-size: .76rem; font-weight: 600;
  padding: 4px 6px; border-radius: 6px;
}
.clear-all:hover { color: var(--danger); background: #fdecec; }
.sidebar-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; background: transparent;
  color: var(--ink-faint); flex: 0 0 auto;
}
.sidebar-close:hover { color: var(--danger); background: #fdecec; }
.sidebar-scrim { display: none; }
.clear-confirm {
  margin-top: 8px; display: flex; align-items: center; gap: 8px; padding: 9px 11px;
  border-radius: 9px; background: #fdecec; border: 1px solid #f6d3d3;
}
.clear-confirm span { flex: 1; font-size: .76rem; color: var(--danger); line-height: 1.4; }
.cc-delete { background: var(--danger); color: #fff; font-weight: 600; font-size: .74rem; border-radius: 6px; padding: 5px 10px; }
.cc-cancel { background: none; color: var(--ink-faint); font-size: .74rem; padding: 5px 4px; }
.stored-notice {
  display: flex; align-items: flex-start; gap: 8px; margin: .5rem 0 12px; padding: 9px 11px;
  border-radius: 9px; background: var(--brand-soft); border: 1px solid #d3e0ff; color: var(--brand-dark);
}
.stored-notice svg { flex: 0 0 auto; margin-top: 1px; }
.stored-notice span { font-size: .76rem; line-height: 1.5; }
.stored-notice strong { font-weight: 700; }
.sidebar-search {
  display: flex; align-items: center; gap: 9px; border: 1px solid var(--line);
  border-radius: 11px; padding: 9px 11px; color: var(--ink-faint);
}
.sidebar-search input { flex: 1; min-width: 0; border: none; background: transparent; font: inherit; font-size: 13.5px; color: var(--ink); }
.sidebar-search input:focus { outline: none; box-shadow: none; }
/* The inner input suppresses its own focus ring; the container shows it instead
   (same pattern as the email/select focus rule near the top of the file). */
.sidebar-search:focus-within, .tx-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.sidebar-count { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--ink-faint); margin-top: 8px; }

/* History list + rows */
.history-list { margin-top: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.history-empty { padding: 24px 0; text-align: center; font-size: 13px; color: var(--ink-faint); }
.history-row {
  position: relative; text-align: left; padding: 12px 36px 12px 13px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--card); cursor: pointer;
}
.history-row:hover { border-color: #cdd9f6; }
.history-row.active { background: var(--brand-soft); border-color: #c2d4ff; }
.hr-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hr-name { font-weight: 700; font-size: 13.5px; letter-spacing: -.01em; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hr-viewing { font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: 2px 7px; background: var(--brand); color: #fff; flex: 0 0 auto; }
.hr-meta { margin-top: 4px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 10px; color: var(--ink-faint); line-height: 1.45; }
.hr-snippet { margin-top: 6px; font-size: 12px; color: var(--ink-faint); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hr-del {
  position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; background: transparent; color: var(--ink-faint);
}
.hr-del:hover { color: var(--danger); background: #fdecec; }

/* Scrollbars */
.tx-scroll::-webkit-scrollbar { width: 10px; }
.tx-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 3px solid var(--card); }

/* Model explainer */
.model-explainer { margin-top: 16px; border: 1px solid var(--line); border-radius: 11px; background: #f7f9fc; padding: 16px 18px; }
.me-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.me-name { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: var(--ink); }
.me-tier { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; border-radius: 999px; padding: 3px 9px; }
.me-tier.premium { background: var(--brand-soft); color: var(--brand-dark); }
.me-tier.standard { background: #eef1f6; color: var(--ink-soft); }
.me-meta { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--ink-faint); }
.me-blurb { font-size: 13.5px; color: var(--ink); margin: 9px 0 11px; line-height: 1.5; }
.me-features { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.me-feature { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-faint); }
.me-feature svg { color: var(--brand); flex: 0 0 auto; }

/* Result card head */
/* The whole Result card stays hidden until a transcript is selected/created. */
#result { display: none; }
#result.has-transcript { display: block; }
.result-body { display: none; }
#result.has-transcript .result-body { display: block; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.result-eyebrow { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.result-name { margin: 5px 0 0; font-size: 1.1rem; letter-spacing: -.01em; line-height: 1.2; word-break: break-all; }
.result-head .result-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 9px 0 0; margin-left: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--ink-faint);
}
.lang-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; background: var(--brand-soft); color: var(--brand-dark); }
.saved-pill {
  display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; border-radius: 999px; padding: 5px 11px; background: #e8f7ef; color: var(--good); flex: 0 0 auto;
}
.saved-pill.warn { background: #fff4e8; color: var(--warn); }

/* Speakers bar */
.speakers-bar { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.speakers-bar[hidden] { display: none; }
.speakers-label { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 9px; }
.speakers-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.spk-chip {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 4px 11px 4px 5px;
  border: 1px solid transparent; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.spk-chip .spk-dot { width: 8px; height: 8px; border-radius: 999px; flex: 0 0 auto; }
.spk-chip.editing { border-color: var(--brand); }
.spk-chip input { width: 110px; border: none; background: transparent; font: inherit; font-weight: 600; padding: 0; color: inherit; }
.spk-chip input:focus { outline: none; box-shadow: none; }
.spk-chip.editing:focus-within { box-shadow: 0 0 0 3px var(--brand-soft); }
/* Per-speaker soundbite play button */
.spk-play {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 19px; height: 19px; padding: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .6); color: inherit;
}
.spk-play:hover, .spk-play.playing { background: #fff; }
.spk-play svg { display: block; }
/* Rename trigger (name + pencil) */
.spk-rename { display: inline-flex; align-items: center; gap: 6px; background: none; color: inherit; font: inherit; font-weight: 600; padding: 0; cursor: pointer; }
.spk-rename svg { opacity: .55; flex: 0 0 auto; }

/* Search / replace toolbar */
.tx-search { margin-top: 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); overflow: hidden; }
.txs-row { display: flex; align-items: center; gap: 10px; padding: 10px 13px; }
.txs-icon { color: var(--brand); flex: 0 0 auto; }
.txs-row input, .txs-replace input { flex: 1; border: none; background: transparent; font: inherit; font-size: 14px; color: var(--ink); }
.txs-row input:focus, .txs-replace input:focus { outline: none; box-shadow: none; }
.txs-count { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--ink-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.txs-nomatch { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--danger); }
.txs-nav { display: inline-flex; gap: 2px; }
.txs-nav button, .txs-toggle, .txs-clear { background: none; color: var(--ink-faint); padding: 3px; border-radius: 6px; display: inline-flex; }
.txs-nav button:hover, .txs-toggle:hover, .txs-clear:hover { background: #eef1f6; color: var(--ink); }
.txs-toggle.active { color: var(--brand); }
.txs-divider { width: 1px; height: 18px; background: var(--line); flex: 0 0 auto; }
.txs-replace { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-top: 1px solid var(--line); background: #f7f9fc; }
.txs-replace[hidden] { display: none; }
.txs-icon-pad { width: 16px; flex: 0 0 auto; }
.txs-replace button { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 5px 11px; }
.txs-replace button:hover { background: #eef1f6; }
.txs-count[hidden], .txs-nomatch[hidden], .txs-nav[hidden], .txs-clear[hidden] { display: none; }

/* Audio: deleted notice */
.audio-deleted { margin-top: 14px; display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 11px; background: #eef1f6; border: 1px solid var(--line); color: var(--ink-faint); }
.audio-deleted[hidden] { display: none; }
.audio-deleted svg { flex: 0 0 auto; }
.audio-deleted span { font-size: 12.5px; line-height: 1.45; }
.audio-deleted strong { color: var(--ink); font-weight: 600; }
.player[hidden] { display: none; }
.player { margin: 14px 0 0; }

/* Transcript body (segments) — grid layout */
.segments { margin-top: 14px; max-height: 460px; overflow-y: auto; position: relative; border-top: 1px solid var(--line); }
.seg-row { position: relative; display: grid; grid-template-columns: 70px 1fr; gap: 18px; padding: 15px 12px 15px 14px; border-bottom: 1px solid var(--line); transition: background .15s; }
.seg-row.match { background: #f1f5ff; }
.seg-row.current { background: #e4ecff; }
.seg-row.current::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); border-radius: 0 3px 3px 0; }
.seg-time { align-self: flex-start; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--brand); background: none; border: none; padding: 2px 0; text-align: left; font-variant-numeric: tabular-nums; }
.seg-spk-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 9px; margin-bottom: 7px; white-space: nowrap; }
.seg-spk-pill .spk-dot { width: 6px; height: 6px; border-radius: 999px; }
.seg-body { font-size: 14.5px; line-height: 1.62; color: var(--ink); }
.seg-body mark { border-radius: 3px; padding: 0 1px; }
.seg-body mark.m { background: var(--brand-soft); color: var(--brand-dark); }
.seg-body mark.c { background: var(--brand); color: #fff; padding: 0 2px; }

/* Speaker palette (chips, dots, pills) by order index */
.spk-c0 { background: #eaf0ff; color: #1f54cc; } .spk-c0 .spk-dot { background: #2f6df6; }
.spk-c1 { background: #e8f7ef; color: #157a52; } .spk-c1 .spk-dot { background: #1f9d6b; }
.spk-c2 { background: #fdf0e8; color: #c2410c; } .spk-c2 .spk-dot { background: #c2410c; }
.spk-c3 { background: #f3e8fd; color: #7c3aed; } .spk-c3 .spk-dot { background: #7c3aed; }

.result-words { margin-left: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--ink-faint); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { padding: .75rem 1rem; gap: .5rem; }
  .topbar .right { gap: .5rem; }
  .container { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1.1rem; }
  .row { flex-direction: column; align-items: stretch; }
  .row .field, .row .field.grow { width: 100%; }
  .btn-go { width: 100%; }
  .key-row { flex-wrap: wrap; }
  .key-row input { flex-basis: 100%; }
  pre.curl { font-size: .74rem; }
  .auth-card { padding: 28px 22px; }
  .appbar { padding: 0 14px; }
  .appbar-right .email { max-width: 30vw; font-size: .8rem; }
  .appbar .cp-unit { display: none; }
  .credit-pill { padding: 5px 10px; }
  /* iOS Safari zooms the page when a focused input is under 16px — bump the
     compact inputs to 16px on small screens so focusing them never zooms. */
  .sidebar-search input, .txs-row input, .txs-replace input, .key-row input { font-size: 16px; }
  /* Transcript: drop the fixed 70px time gutter (stack time above the text)
     and let the page scroll instead of a scroll-within-scroll transcript box. */
  .seg-row { grid-template-columns: 1fr; gap: 4px; padding: 12px 10px; }
  .seg-time { padding: 0; }
  .segments { max-height: none; }
}

@media (max-width: 480px) {
  /* The email is already ellipsized to nothing at this width; hide it so the
     pill and logout button keep their shape. */
  .appbar-right .email { display: none; }
}

@media (max-width: 760px) {
  .sidebar { width: min(86vw, 320px); }
  /* Scrim under the history drawer (z-index 35 < the drawer's 40),
     mirroring the left-nav scrim pattern. */
  body.sidebar-open .sidebar-scrim {
    display: block; position: fixed; inset: var(--appbar-h) 0 0 0;
    z-index: 35; background: rgba(16,24,40,.25);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   Platform shell: appbar brand + credit pill, left nav, page chrome
   ═══════════════════════════════════════════════════════════════════ */
.brand-mark { height: 17px; width: auto; display: inline-block; vertical-align: -3px; margin-right: 5px; }
.wordmark { text-decoration: none; }
/* Login card brand lockup (logo + name) */
.brand-lockup { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; color: var(--ink); margin-bottom: .2rem; }
.brand-lockup img { height: 22px; width: auto; }

.nav-burger {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: #eef1f6; color: var(--ink); flex: 0 0 auto;
}
.nav-burger:hover { background: #e3e8f0; }

/* Credit balance pill (appbar) */
.credit-pill {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; flex-shrink: 0;
  padding: 6px 13px; border-radius: 999px; border: 1px solid #d3e0ff;
  background: var(--brand-soft); color: var(--brand-dark); font-size: .9rem;
}
.credit-pill:hover { background: #dfe9ff; }
.credit-pill strong { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.credit-pill .cp-unit { color: var(--brand-dark); font-size: .82rem; }

/* Shell layout: persistent left nav + main column */
.shell { display: flex; align-items: flex-start; }
.nav {
  flex: 0 0 224px; width: 224px; position: sticky; top: var(--appbar-h);
  height: calc(100vh - var(--appbar-h)); overflow-y: auto;
  border-right: 1px solid var(--line); background: rgba(255,255,255,.5);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 3px;
}
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-soft); text-decoration: none; font-size: .94rem; font-weight: 550;
}
.nav-link svg { color: var(--ink-faint); flex: 0 0 auto; }
.nav-link:hover { background: #eef1f6; color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 650; }
.nav-link.active svg { color: var(--brand); }
.nav-scrim { display: none; }

.main { flex: 1 1 auto; min-width: 0; }
.page { max-width: 900px; margin: 0 auto; padding: 30px 26px 80px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }
.page-head .sub { margin: .4rem 0 0; color: var(--ink-soft); font-size: .95rem; max-width: 60ch; }
.section-head { margin: 26px 0 14px; }
.section-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; }
.section-head .sub { margin: .3rem 0 0; color: var(--ink-soft); font-size: .95rem; max-width: 60ch; }
.section-foot { margin-top: 16px; }

.cta-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }
/* .btn-cta base is shared with .btn-go (see the primary-action rule near .row) */
.btn-cta.ghost { background: #eef1f6; color: var(--ink); box-shadow: none; }
.btn-cta.ghost:hover { background: #e3e8f0; }
/* Compact CTA (model cards) */
.btn-cta.sm { padding: .55rem .95rem; font-size: .86rem; font-weight: 600; border-radius: 10px; box-shadow: none; gap: 6px; }

/* Balance hero (overview / billing) */
.balance-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.balance-figure { font-size: 2.6rem; font-weight: 750; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.balance-figure .unit { font-size: 1rem; font-weight: 600; color: var(--ink-faint); margin-left: .4rem; letter-spacing: 0; }
.balance-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 650; margin-bottom: .5rem; }
.balance-worth { font-size: .9rem; color: var(--ink-soft); margin-top: .25rem; font-variant-numeric: tabular-nums; }
.balance-meta { font-size: .85rem; color: var(--ink-soft); margin-top: .5rem; }
.balance-meta.low { color: var(--warn); }
.balance-meta.low a { color: inherit; }

/* Model catalog */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.model-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 18px;
}
.model-card.soon { opacity: .72; }
.mc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-type { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
.mc-badge { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border-radius: 999px; padding: 3px 9px; }
.mc-badge.live { background: #e8f7ef; color: var(--good); }
.mc-badge.soon { background: #eef1f6; color: var(--ink-faint); }
.mc-badge.premium { background: var(--brand-soft); color: var(--brand-dark); }
.mc-name { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.mc-id { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .76rem; color: var(--ink-faint); }
.mc-desc { font-size: .9rem; color: var(--ink-soft); line-height: 1.5; flex: 1; }
.mc-price { font-size: .9rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mc-price .pc { color: var(--brand-dark); }
.mc-money { font-weight: 600; color: var(--ink-faint); font-size: .82rem; }
.mc-feats { display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; list-style: none; }
.mc-feats li { display: flex; align-items: center; gap: 7px; font-size: .83rem; color: var(--ink-soft); }
.mc-feats svg { color: var(--brand); flex: 0 0 auto; }
.mc-action { margin-top: 4px; }
.mc-soon-label { font-size: .82rem; color: var(--ink-faint); font-weight: 600; }

/* Two-column layout helper */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }

/* Ledger / transactions table (base style shared via "Data tables" above) */
.ledger .amt-pos { color: var(--good); font-weight: 600; }
.ledger .amt-neg { color: var(--ink); }
.kind-tag { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.kind-usage { background: #eef1f6; color: var(--ink-soft); }
.kind-refund, .kind-grant, .kind-topup { background: #e8f7ef; color: var(--good); }
.kind-adjustment { background: #fdf0e8; color: var(--warn); }

/* Usage bars (per model spend) */
.spend-row { margin-bottom: 14px; }
.spend-row .sr-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; margin-bottom: 6px; }
.spend-row .sr-name { font-weight: 600; }
.spend-row .sr-amt { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.spend-bar { height: 10px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.spend-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #5a8bff); border-radius: 999px; }

/* Buy-credits card */
.buy-card { text-align: center; }
.buy-card h2 { margin-bottom: .4rem; }
.empty-note { color: var(--ink-faint); font-size: .9rem; padding: 1.2rem 0; text-align: center; }

/* Admin grant form */
.grant-form { display: flex; gap: .7rem; flex-wrap: wrap; align-items: end; }
.grant-form .field { flex: 1; min-width: 150px; }
.grant-form input[type=text], .grant-form input[type=number], .grant-form input[type=email] {
  width: 100%; padding: .7rem .8rem; font-size: .95rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
.grant-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

/* Mobile: nav becomes an off-canvas drawer */
@media (max-width: 880px) {
  .nav-burger { display: inline-flex; }
  .nav {
    position: fixed; top: var(--appbar-h); left: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.4,0,.2,1), visibility .22s;
    visibility: hidden;
    background: var(--card); box-shadow: 2px 0 18px rgba(16,24,40,.12);
  }
  body.nav-open .nav { transform: translateX(0); visibility: visible; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: var(--appbar-h) 0 0 0; z-index: 45; background: rgba(16,24,40,.25); }
  .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 22px 16px 60px; }
}

/* In the platform shell, the playground's history drawer opens from the RIGHT
   (the left is the persistent nav) and overlays as a fixed panel. */
body.app .sidebar {
  position: fixed; left: auto; right: 0; top: var(--appbar-h); bottom: 0; z-index: 40;
  border-right: none; border-left: 1px solid var(--line); box-shadow: -2px 0 16px rgba(16,24,40,.08);
}
.pg-toolbar { display: flex; align-items: center; gap: .6rem; margin-bottom: 4px; }
.pg-history-btn {
  display: inline-flex; align-items: center; gap: .5rem; padding: .55rem .9rem; border-radius: 10px;
  background: #eef1f6; color: var(--ink); border: 1px solid var(--line); font-weight: 600; font-size: .88rem;
}
.pg-history-btn:hover { background: #e3e8f0; }

/* ── Touch targets: grow hit-boxes (not icons) on coarse pointers ────── */
@media (pointer: coarse) {
  .hr-del { width: 34px; height: 34px; top: 5px; right: 5px; }
  .history-row { padding-right: 44px; }
  .txs-nav button, .txs-toggle, .txs-clear { padding: 9px; }
  .spk-play { width: 28px; height: 28px; }
  .seg-time { padding: 8px 8px 8px 0; margin: -6px 0; }
  .nav-burger { width: 42px; height: 42px; }
  .clear-all { padding: 9px 10px; }
}

/* ── Reduced motion ──────────────────────────────────────────────────── */
/* Spinner stays visible as a static ring; recording state is still shown
   via the .recording colors. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto !important; }
}

/* Shared layout utilities (replace one-off inline styles) */
.field.w-200 { flex: 0 0 200px; }
.result-actions.tight { margin-top: .4rem; }
.appbar form { margin: 0; }

/* ── Speech (TTS) studio ─────────────────────────────────────────────────
   The /speech page: a focused composer + voice picker + clone upload, styled
   to match the light-premium shell. Preserves the JS hooks in speech.js. */
.tts-page { max-width: 720px; }
.tts-studio {
  display: flex; flex-direction: column; gap: 20px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.tts-studio .inline-msg { margin: 0; }

/* Composer — the text to speak */
.tts-composer {
  border: 1.5px solid var(--line); border-radius: 13px; background: #fbfcfe;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.tts-composer:focus-within {
  border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: #fff;
}
.tts-composer textarea {
  display: block; width: 100%; border: 0; background: transparent; resize: vertical;
  min-height: 140px; padding: 16px 16px 6px; font: inherit; font-size: 1.02rem;
  line-height: 1.6; color: var(--ink); outline: none;
}
.tts-composer textarea::placeholder { color: var(--ink-faint); }
.tts-composer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 14px 12px;
}
.tts-count { color: var(--ink-faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.tts-price {
  color: var(--ink-soft); font-weight: 600; font-size: .76rem;
  background: #eef2f8; padding: 3px 10px; border-radius: 999px;
}

/* Section blocks */
.tts-block { display: flex; flex-direction: column; gap: 10px; }
.tts-block-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* Voice pills */
.tts-voices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 38px; }
.tts-voices-loading { color: var(--ink-faint); font-size: .9rem; }
.tts-voice {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  background: #fff; border: 1.5px solid var(--line); color: var(--ink-soft);
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.tts-voice svg { color: var(--ink-faint); transition: color .15s; }
.tts-voice:hover { border-color: #c8d2e0; background: #f7f9fc; color: var(--ink); }
.tts-voice.selected {
  background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--btn-shadow);
}
.tts-voice.selected svg { color: #fff; }
.tts-voices.is-disabled { opacity: .4; pointer-events: none; filter: grayscale(.5); }

/* Clone upload (overrides the named voice) */
.tts-clone {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1.5px dashed #c8d2e0; border-radius: 12px; background: #fbfcfe;
  transition: border-color .15s, background .15s;
}
.tts-clone.has-file { border-style: solid; border-color: var(--brand); background: var(--brand-soft); }
.tts-clone-btn {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 8px 13px; background: #fff; border: 1px solid var(--line);
  color: var(--ink); font-weight: 600; font-size: .88rem; border-radius: 9px;
}
.tts-clone-btn:hover { background: #f4f6fa; border-color: #c8d2e0; }
.tts-clone-name {
  flex: 1 1 auto; min-width: 0; color: var(--ink-faint); font-size: .88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tts-clone.has-file .tts-clone-name { color: var(--brand-dark); font-weight: 600; }
.tts-clone-clear {
  flex: 0 0 auto; display: inline-flex; padding: 6px; border-radius: 8px;
  background: transparent; color: var(--ink-faint);
}
.tts-clone-clear:hover { background: #fff; color: var(--danger); }
.tts-hint { margin: 0; font-size: .8rem; color: var(--ink-faint); line-height: 1.5; }

/* Generate */
.tts-generate {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; padding: .9rem 1.2rem; margin-top: 2px;
  background: var(--brand); color: #fff; font-weight: 650; font-size: 1rem;
  border-radius: var(--btn-radius); box-shadow: var(--btn-shadow);
}
.tts-generate:hover { background: var(--brand-dark); }
.tts-generate.busy .tts-go-icon { display: none; }
.tts-generate.busy::before {
  content: ""; width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.45);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}

/* Result */
.tts-result {
  margin-top: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
  animation: tts-rise .3s ease;
}
.tts-result[hidden] { display: none; }
@keyframes tts-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tts-result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tts-result-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: .95rem; color: var(--ink); }
.tts-result-title svg { color: var(--brand); }
.tts-result .result-words { margin-left: auto; }
.tts-result .player { margin: 0; }
.tts-result-actions { margin-top: 14px; }
.tts-result-actions .btn-ghost { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }

@media (max-width: 560px) {
  .tts-studio { padding: 16px; }
  .tts-generate { font-size: .95rem; }
}
