:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #0b0b0f;
  --ink-2: #4b5563;
  --ink-3: #8a8f98;
  --line: #e6e7ea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #e8f0fe;
  --red: #dc2626;
  --green: #16a34a;
  --amber: #f59e0b;
  --radius: 22px;
  --fs: 16px;            /* transcript text size, changed by the +/- stepper */
  --dock-h: 96px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding: 20px 40px 40px;
  display: flex; flex-direction: column;
}
body.route-playground { padding-bottom: calc(var(--dock-h) + 36px); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- portal top bar ---------- */
h1 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.app-top { display: flex; align-items: center; gap: 28px; margin-bottom: 26px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: #f0f1f3; border-radius: 999px; }
.tabs a { padding: 8px 18px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.hours-chip { font-size: 14px; font-weight: 600; color: var(--blue-dark); background: var(--blue-soft); padding: 7px 14px; border-radius: 999px; text-decoration: none; }
.hours-chip:empty { display: none; }
.hours-chip.low { color: #92400e; background: #fef3c7; }
.pill.small { height: 38px; padding: 0 16px; font-size: 14px; }

/* ---------- sign in / sign up ---------- */
.auth { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px 0; }
.brand.big { font-size: 20px; }
.brand.big img { width: 40px; height: 40px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px 32px 28px; box-shadow: 0 12px 40px rgba(15,23,42,.06); }
.auth-card h1 { font-size: 28px; margin-bottom: 8px; }
.auth-card .lead { margin: 0 0 20px; color: var(--ink-2); line-height: 1.5; font-size: 15px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-3); margin-bottom: 14px; }
.auth-card form { margin: 0; }
.auth-switch { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; font-size: 14px; color: var(--ink-2); }
.auth-switch a { color: var(--blue-dark); font-weight: 600; }

/* ---------- Account / Billing pages ---------- */
.page { width: 100%; max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page > h1 { margin-bottom: 4px; }
.page > .lead { margin: 0; color: var(--ink-2); font-size: 16px; }
.panels { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.panel-label { margin: 0 0 6px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.panel .big { margin: 0 0 14px; font-size: 44px; font-weight: 800; letter-spacing: -.02em; }
.panel .email { margin: 0 0 12px; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 22px; }
.breakdown div { background: #f7f8fa; border-radius: 14px; padding: 12px 14px; }
.breakdown dt { font-size: 13px; color: var(--ink-3); }
.breakdown dd { margin: 4px 0 0; font-size: 16px; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .primary { width: auto; }
.list { width: 100%; border-collapse: collapse; font-size: 15px; }
.list th { text-align: left; font-weight: 500; font-size: 13px; color: var(--ink-3); padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.list td { padding: 12px 0; border-bottom: 1px solid #f1f2f4; color: var(--ink-2); }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; }
.banner { padding: 12px 16px; border-radius: 14px; font-size: 15px; background: var(--blue-soft); color: #1e3a8a; border: 1px solid #bfd3fb; }
.banner.ok { background: #ecfdf3; color: #166534; border-color: #bbf7d0; }
.banner.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.pack { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 30px 26px; display: flex; flex-direction: column; }
.pack-price { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.pack-hours { margin: 6px 0 2px; font-size: 18px; font-weight: 600; color: var(--ink-2); }
.pack-rate { margin: 0 0 22px; font-size: 15px; color: var(--ink-3); }
.pack .primary { margin-top: auto; }
.packs-note { margin: 0; text-align: center; font-size: 15px; color: var(--ink-3); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: 15px; color: var(--ink-2); white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.pill:hover { background: #f3f4f6; }
.pill.tool { height: 40px; padding: 0 16px; }
.pill.tool.icon { width: 40px; padding: 0; justify-content: center; }
.pill.tool[aria-pressed="true"] { border-color: var(--blue); color: var(--blue-dark); background: var(--blue-soft); }

/* ---------- transcript card ---------- */
#view-playground { flex: 1; display: flex; flex-direction: column; min-height: 0; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.card {
  position: relative;
  flex: 1; min-height: 300px;
  height: calc(100dvh - 300px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  padding: 0 30px; height: 60px; align-items: center;
  border-bottom: 1px solid #f0f0f2;
}
.col-title { font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.status {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2);
}
.meter { width: 54px; height: 6px; border-radius: 3px; background: #eceef1; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--green); transition: width .08s linear; }

.toast {
  margin: 12px 22px 0; padding: 10px 14px; border-radius: 12px;
  background: #fef2f2; color: #991b1b; font-size: 14px; border: 1px solid #fecaca;
}
.toast.info { background: var(--blue-soft); color: #1e3a8a; border-color: #bfd3fb; }

.transcript { flex: 1; overflow-y: auto; padding: 8px 30px 28px; font-size: var(--fs); line-height: 1.55; scroll-behavior: smooth; }

/* paired rows ("Stacked"): each original sits beside its translation */
.rows { display: flex; flex-direction: column; }
.rows.newest-first { flex-direction: column-reverse; }
.rows .block { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; padding: 14px 0; border-bottom: 1px solid #f3f3f5; }
.rows .block:last-child { border-bottom: 0; }

/* independent columns */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; align-items: start; }
.cols .col { display: flex; flex-direction: column; }
.cols .col.newest-first { flex-direction: column-reverse; }
.cols .cell { padding: 7px 0; }

.cell { min-width: 0; overflow-wrap: anywhere; }
.cell.orig { color: var(--ink-2); }
.cell.trans { color: var(--ink); font-weight: 500; }
.cell .live { opacity: .6; }
.cell .live::after { content: "▍"; margin-left: 2px; animation: blink 1s steps(2, start) infinite; opacity: .6; }
.cell .err { color: var(--ink-3); font-style: italic; font-weight: 400; }
.spk { display: none; font-size: .72em; letter-spacing: .05em; text-transform: uppercase; color: var(--blue-dark); margin-bottom: 2px; font-weight: 600; }
.multi-speaker .spk { display: block; }
@keyframes blink { to { visibility: hidden; } }

.empty { max-width: 460px; margin: 6vh auto 0; text-align: center; color: var(--ink-3); font-size: 15px; }
.empty-title { font-size: 18px; color: var(--ink-2); margin: 0 0 10px; font-weight: 600; }
.empty ol { text-align: left; display: inline-block; margin: 0; padding-left: 20px; line-height: 1.9; }
.empty-note { color: var(--red); margin-top: 14px; }

/* ---------- view tools (under the card, right aligned) ---------- */
.view-tools { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.stepper {
  display: inline-flex; align-items: center; height: 40px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2);
}
.stepper button { width: 32px; height: 32px; border: 0; background: none; border-radius: 50%; font-size: 20px; line-height: 1; color: var(--ink-3); }
.stepper button:hover:not(:disabled) { background: #f3f4f6; color: var(--ink); }
.stepper span { min-width: 30px; text-align: center; font-size: 14px; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, .12);
  z-index: 20; max-width: calc(100vw - 24px);
}
.dock .pill { background: #fcfcfd; height: 46px; padding: 0 20px; }
.dock .pill:hover { background: #f3f4f6; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-dark); font-size: 15px; font-weight: 500; }
.pill.lang { gap: 10px; padding: 0 16px; }
.pill.lang .swap { width: 16px; }
.pill.lang .trans { color: var(--ink-2); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink-3); margin-left: 2px; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,.18); }

.start-group { display: flex; border-radius: 999px; overflow: hidden; box-shadow: 0 4px 14px rgba(37,99,235,.35); }
.start, .start-more { height: 66px; border: 0; background: var(--blue); color: #fff; }
.start { display: inline-flex; align-items: center; gap: 12px; padding: 0 34px 0 34px; font-size: 20px; font-weight: 500; min-width: 210px; justify-content: center; }
.start svg { width: 22px; height: 22px; }
.start-more { width: 60px; display: grid; place-items: center; border-left: 1px solid rgba(255,255,255,.28); }
.start-more svg { width: 22px; height: 22px; stroke-width: 2; }
.start:hover, .start-more:hover { background: var(--blue-dark); }
.start-group.live .start, .start-group.live .start-more { background: var(--red); }
.start-group.live { box-shadow: 0 4px 14px rgba(220,38,38,.35); }
.start-group.live .start:hover, .start-group.live .start-more:hover { background: #b91c1c; }
.start-group.busy .start { opacity: .8; pointer-events: none; }

/* ---------- popovers ---------- */
.pop-anchor { position: relative; }
.popover {
  position: absolute; bottom: calc(100% + 16px); left: 50%; transform: translateX(-50%);
  width: 300px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 34px rgba(15,23,42,.16);
  font-size: 14px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px;
}
.popover[hidden] { display: none; }
.popover.wide { width: 360px; }
.popover.help { width: 320px; }
.popover label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-3); }
.popover ul { margin: 0; padding-left: 18px; line-height: 1.5; }
.pop-title { margin: 0; font-weight: 600; color: var(--ink); }
.swap-btn { align-self: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); display: grid; place-items: center; }
.swap-btn:hover { background: #f3f4f6; }
.radio { flex-direction: row !important; align-items: flex-start; gap: 10px !important; color: var(--ink-2) !important; font-size: 14px !important; cursor: pointer; }
.radio input { margin-top: 4px; accent-color: var(--blue); }
.radio small { display: block; color: var(--ink-3); font-size: 13px; line-height: 1.4; margin-top: 2px; }
.radio b { color: var(--ink); font-weight: 600; }
.hint { margin: 0; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.link, .linkbtn { color: var(--blue-dark); background: none; border: 0; padding: 0; font-size: 14px; text-decoration: underline; text-align: left; }

select, input[type="email"], input[type="text"], textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
textarea { resize: vertical; line-height: 1.5; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }

/* ---------- dialogs ---------- */
dialog {
  width: min(460px, calc(100vw - 32px)); padding: 26px 28px 24px; border: 0; border-radius: 22px;
  box-shadow: 0 24px 70px rgba(15,23,42,.3); color: var(--ink); background: var(--surface);
}
dialog::backdrop { background: rgba(15, 23, 42, .4); }
dialog h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.01em; }
dialog .lead { margin: 0 0 16px; color: var(--ink-2); line-height: 1.5; font-size: 15px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-3); margin-bottom: 14px; }
dialog form { margin: 0; }
dialog code { background: #f3f4f6; padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.dlg-close-row { position: absolute; top: 12px; right: 14px; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--ink-3); width: 34px; height: 34px; border-radius: 50%; }
.x:hover { background: #f3f4f6; color: var(--ink); }
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: 999px; font-size: 15px; font-weight: 500; text-decoration: none;
}
.primary { border: 0; background: var(--blue); color: #fff; width: 100%; }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.secondary:hover { background: #f3f4f6; }
.as-link { width: 100%; margin-bottom: 10px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.row .primary { width: auto; }
#dlg-context .primary, #dlg-ended .secondary { margin-top: 6px; }
#dlg-ended .secondary { width: 100%; }
.linkbtn { margin-top: 12px; }
.form-error { margin: 12px 0 0; color: #b91c1c; font-size: 14px; }
#auth-contact { display: inline-block; margin-top: 8px; }
.fair-note { margin-top: 12px; text-align: center; }
#turnstile-box { margin: 0 0 14px; min-height: 65px; }
.usage-bar { height: 10px; border-radius: 6px; background: #eceef1; overflow: hidden; }
.usage-bar i { display: block; height: 100%; width: 100%; background: var(--blue); transition: width .3s; }
.usage p { margin: 10px 0 16px; color: var(--ink-2); font-size: 15px; }
.usage b { color: var(--ink); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  body { padding: 16px 16px 32px; }
  body.route-playground { padding-bottom: calc(var(--dock-h) + 120px); }
  h1 { font-size: 28px; }
  .app-top { gap: 12px 16px; margin-bottom: 18px; }
  .tabs { order: 3; width: 100%; justify-content: center; }
  .tabs a { flex: 1; text-align: center; padding: 8px 10px; }
  .panels, .packs { grid-template-columns: 1fr; }
  .panel { padding: 22px 20px; }
  .panel .big, .pack-price { font-size: 36px; }
  .card { height: calc(100dvh - 380px); }
  .card-head { padding: 0 18px; }
  .transcript { padding: 6px 18px 24px; }
  .rows .block, .cols { gap: 0 16px; }
  .dock { flex-wrap: wrap; justify-content: center; bottom: 12px; padding: 12px; gap: 8px; width: calc(100vw - 24px); }
  .dock .pill { height: 42px; padding: 0 14px; font-size: 14px; }
  .start, .start-more { height: 54px; }
  .start { min-width: 150px; padding: 0 22px; font-size: 18px; }
  .start-wrap { order: -1; width: 100%; display: flex; justify-content: center; }
  .popover { position: fixed; left: 12px; right: 12px; bottom: 150px; width: auto !important; transform: none; }
  .status { display: none; }
}
@media (max-width: 480px) {
  h1 { font-size: 24px; }
  .brand span { display: none; }
  .breakdown { grid-template-columns: 1fr; }
  .auth-card { padding: 26px 20px 22px; }
}
@media (prefers-reduced-motion: reduce) { .transcript { scroll-behavior: auto; } .cell .live::after { animation: none; } }
