/* All Voices web app. Mobile-first, responsive, light/dark. */

:root {
  --bg: #fafafa;
  --warnbg: #fff6e0;
  --warn: #8a5a00;
  --errorbg: #fdecea;
  --surface: #ffffff;
  --surface2: #f0f2f5;
  --text: #1a1c1e;
  --muted: #5f6368;
  /* The brand's own colours, the same two the logo and the landing page use
     (ground #7A2BF0, mark #FFC53D). The app used to run on an unrelated
     indigo, so a customer crossing from the marketing page into the product
     met different buttons on the other side. */
  --primary: #7A2BF0;
  --primary-hover: #8a41f4;
  --primary-contrast: #ffffff;
  --brand-amber: #FFC53D;
  --brand-amber-hover: #ffd05c;
  --brand-amber-ink: #2b1a00;
  /* The identity pair, fixed in both themes: the hero faces and the mark
     itself are these two colours whatever the page ground is. */
  --brand-purple-fixed: #7A2BF0;
  /* Functional, NOT brand: the translation under a line, and links. Kept
     teal so a translation stays visually distinct from brand furniture. */
  --accent: #0b7568; /* AA on --bg/--surface (5.3:1); #0e8f83 measured 3.8:1 */
  --accent-contrast: #ffffff;
  --error: #b3261e;
  --border: #dfe3e8;
  --radius: 10px;
  /* Height of the sticky top bar; anything else that sticks below it offsets
     by this rather than guessing. */
  --topbar-h: 55px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --surface: #181c21;
    --surface2: #222830;
    --text: #e4e6e8;
    --muted: #9aa0a6;
    /* A tint of the brand purple that stays legible on a dark ground; the
       amber needs no lightening. */
    --primary: #b794ff;
    --primary-hover: #c9b0ff;
    --primary-contrast: #1c0b3a;
    --brand-amber: #FFC53D;
    --brand-amber-hover: #ffd05c;
    --brand-amber-ink: #2b1a00;
    --accent: #6fd6c9;
    --accent-contrast: #06302c;
    --error: #f2b8b5;
    /* These had no dark values, so the low-hours bar painted cream-on-brown
       over a dark page. */
    --warnbg: #33280a;
    --warn: #ffd98a;
    --errorbg: #3a1a18;
    --border: #303840;
  }
}

* { box-sizing: border-box; }
/* The hidden attribute must win over display:flex/grid on layout classes. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 900px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
#brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
/* The brand must yield before the nav does: on a narrow phone the wordmark
 * was wrapping to two lines to make room for the session action. */
.brand-link { flex: 0 0 auto; }
/* On a phone the logo alone is the brand: the wordmark was clipping
   mid-word to make room for the nav, which looks broken. Tapping the logo
   still goes home. */

#nav { display: flex; gap: 4px; margin-left: auto; }
#nav[hidden] { display: none; }
#nav a {
  padding: 6px 12px; border-radius: 999px; color: var(--text); font-size: 15px;
}
#nav a.active { background: var(--surface2); font-weight: 600; }
/* The session entry is an ACTION, not a place: a filled pill, visibly a
 * different kind of thing from the Meetings/Settings tabs. While a session
 * runs it turns into a live timer, which is also the way back to it. */
#nav a.nav-action {
  background: var(--primary); color: var(--primary-contrast); font-weight: 600;
  white-space: nowrap;
}
#nav a.nav-action.active { background: var(--primary); }
#nav a.nav-action.running { background: var(--error); font-variant-numeric: tabular-nums; }
#nav a.nav-action.running.paused { background: var(--muted); }

/* Ready state: what will happen, and the gesture that starts it. */
.ready-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px 18px; margin: 8px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.ready-card .ready-body { margin: 0; color: var(--muted); max-width: 46ch; line-height: 1.5; }
.ready-card .ready-start { font-size: 17px; padding: 12px 26px; border-radius: 999px; }
.ready-card .ready-hours { font-size: 14px; }

.container { max-width: 900px; margin: 0 auto; padding: 16px; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
/* The live view's fixed bottom bar is two rows tall; without this the last
 * transcript lines hide behind it (and behind Safari's bottom address bar). */
.container.has-livebar { padding-bottom: calc(200px + env(safe-area-inset-bottom)); }

h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 20px 0 8px; color: var(--primary); }
.muted { color: var(--muted); font-size: 14px; }
.error-text { color: var(--error); font-size: 14px; }
.ok-text { color: var(--accent); font-size: 15px; font-weight: 600; margin: 0; }
/* The card the reader was sent to, so the promise they clicked is the thing
   they see first. */
.card.highlight { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { background: var(--surface2); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row .spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  padding: 9px 18px;
}
button.primary { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); font-weight: 600; }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
/* The one amber button, matching the landing page: the recommended pack.
   Everything else is purple, so the amber means "this is the one". */
button.primary.alt { background: var(--brand-amber); border-color: var(--brand-amber); color: var(--brand-amber-ink); }
button.primary.alt:hover { background: var(--brand-amber-hover); border-color: var(--brand-amber-hover); }
button.danger { color: var(--error); }
button:disabled { opacity: 0.45; cursor: default; }
button.small { padding: 5px 12px; font-size: 14px; }

input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 110px; resize: vertical; }
label { font-size: 13px; color: var(--muted); display: block; margin: 10px 0 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 14px; cursor: pointer; user-select: none;
  background: var(--surface);
}
.chip.on { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.chip.static { cursor: default; }

.tag {
  display: inline-block; font-size: 12px; padding: 2px 8px;
  border-radius: 6px; background: var(--surface2); color: var(--muted);
}

.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tabs button {
  border: none; background: none; border-radius: 0; padding: 10px 14px;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }

/* live text-size setting (older/low-vision users). Applied to the live
 * transcript container. "m" is the base size and needs no rules; only the
 * TOP step is offered on wide viewports only. Mirrors liveFontScale in
 * LiveScreen.kt (x1.0 / x1.3 / x1.7 / x2.1 on the base). */
.live-font-l .seg .src { font-size: 21px; line-height: 1.4; }
.live-font-l .seg .tr { font-size: 19px; line-height: 1.4; }
.live-font-xl .seg .src { font-size: 27px; line-height: 1.35; }
.live-font-xl .seg .tr { font-size: 24px; line-height: 1.35; }
.live-font-xxl .seg .src { font-size: 34px; line-height: 1.3; }
.live-font-xxl .seg .tr { font-size: 30px; line-height: 1.3; }
.font-chip { align-items: baseline; gap: 2px; }
.font-chip .a-small { font-size: 11px; }
.font-chip .a-big { font-size: 18px; font-weight: 700; }
.font-sample-l { font-size: 21px; }
.font-sample-xl { font-size: 26px; }
.font-sample-xxl { font-size: 32px; }

/* transcript segments */
.seg { display: flex; gap: 10px; padding: 7px 0; }
/* Whole-turn wash (P4). The padding moves INSIDE the wash so the tint reads
 * as a block, and the small radius keeps consecutive turns from fusing. */
.seg.washed { padding: 8px 10px; margin: 2px -10px; border-radius: 8px; }
/* P3: dim filler, mark key lines. Never hidden - a skim view can be added
 * later; for now the emphasis is always on. */
.seg.dim .src, .seg.dim .tr { opacity: 0.45; }
.seg.key { border-left: 2px solid var(--primary); padding-left: 8px; margin-left: -10px; }
.seg .bar { width: 3px; border-radius: 2px; flex: none; }
.seg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg .speaker { font-weight: 600; padding: 1px 8px; border-radius: 6px; font-size: 12px; }
.seg .src { margin: 2px 0 0; }
.seg .tr { margin: 2px 0 0; color: var(--accent); font-size: 15px; }
.seg.provisional { opacity: 0.6; }

/* The live status line sticks under the top bar: elapsed time and hours left
 * are glanceable only if they stay on screen while the transcript grows. */
.rec-row {
  /* Below the top bar, which is itself sticky at 0 and 55px tall; the lower
     z-index lets this slide under it rather than over it. */
  position: sticky; top: var(--topbar-h); z-index: 19;
  background: var(--bg); padding: 8px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}

/* live bottom bar */
#livebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
#livebar .inner { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #d33;
  animation: pulse 1.2s infinite alternate; display: inline-block;
}
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }
.level { display: inline-flex; gap: 2px; align-items: flex-end; height: 18px; }
.level i { width: 4px; background: var(--surface2); border-radius: 1px; display: block; }
.level i.on { background: var(--primary); }

.banner {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px;
  font-size: 14px;
}

/* chat */
.chat-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--primary); color: var(--primary-contrast); }
.msg.assistant { align-self: flex-start; background: var(--surface2); }

/* Assistant-is-answering indicator: three pulsing dots in an assistant bubble. */
.msg.typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px 15px; }
.msg.typing .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: typing-dot 1.2s ease-in-out infinite;
}
.msg.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg.typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Composer stays visible while the log scrolls; input and Send share one line. */
.chat-composer {
  position: sticky; bottom: 0; z-index: 10;
  background: var(--bg);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  flex-wrap: nowrap;
}
.chat-composer input { flex: 1; width: auto; min-width: 0; }
/* Keep the newest message clear of the sticky composer when scrolled into view. */
.chat-log > * { scroll-margin-bottom: 84px; }

/* markdown-lite */
.md h3 { font-size: 16px; margin: 14px 0 4px; }
.md h4 { font-size: 15px; margin: 10px 0 3px; }
.md ul { margin: 4px 0; padding-inline-start: 22px; }
.md p { margin: 6px 0; }

.center { text-align: center; }

/* login */
.login-wrap {
  min-height: calc(100dvh - 120px);
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 500px at 15% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
    radial-gradient(900px 480px at 110% 15%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 55%);
  border-radius: var(--radius);
}
.login-box {
  max-width: 400px; width: 100%; margin: 0 auto; padding: 28px 26px 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 10px 40px rgba(20, 24, 80, 0.10);
}
.login-logo { width: 84px; height: 84px; margin: 0 auto 4px; display: block; border-radius: 20px; }
.brand-title { letter-spacing: 0.5px; margin-top: 2px; }
button.ghost { background: none; border-color: var(--border); color: var(--muted); }
#brand-logo { width: 26px; height: 26px; border-radius: 7px; vertical-align: middle; margin-inline-end: 8px; }
.topbar-inner #brand { display: inline-flex; align-items: center; }
/* On a phone the logo alone is the brand: the wordmark was clipping mid-word
 * to make room for the session action, which reads as broken. Tapping the
 * logo still goes home. Specificity must match the rule above. */
@media (max-width: 560px) { .topbar-inner #brand { display: none; } }
.brand-link { display: inline-flex; align-items: center; color: inherit; }
.brand-link:hover { opacity: 0.85; }

audio { width: 100%; margin: 6px 0; }

@media (max-width: 480px) {
  .container { padding: 12px; padding-bottom: 110px; }
  #nav a { padding: 6px 9px; font-size: 14px; }
  /* Keep the action readable when three items must share a phone width. */
  #nav { gap: 2px; }
  #nav a.nav-action { padding: 6px 10px; }

  h1 { font-size: 19px; }
  /* Smaller nav padding here, so what sticks below the bar offsets less. */
  :root { --topbar-h: 49px; }
}

/* bottom sheet (language pickers) */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); color: var(--text);
  width: 100%; max-width: 640px; max-height: 75dvh;
  border-radius: 16px 16px 0 0; padding: 14px 0 calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.sheet h3 { margin: 2px 18px 10px; font-size: 17px; }
/* The scroll area clears the bottom by more than any mobile browser's
 * overlaying toolbar. Firefox Focus (and similar privacy browsers) draw an
 * opaque bottom bar over fixed content WITHOUT shrinking the viewport, so the
 * last row of a bottom sheet - e.g. "Extra large" in the text-size picker -
 * landed under it: black on black and untappable (reported 2026-08-18). The
 * safe-area inset is 0 on those browsers, so a hard floor does the work. */
.sheet .rows {
  overflow-y: auto; flex: 1;
  padding-bottom: max(env(safe-area-inset-bottom), 56px);
  scroll-padding-bottom: 56px;
}
.sheet .row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; cursor: pointer; font-size: 16px;
  color: var(--text);
}
.sheet .row-item:active { background: var(--surface2); }
.sheet .row-item .native { margin-left: auto; color: var(--muted); font-size: 14px; }
.sheet .row-item .tick { width: 22px; color: var(--primary); font-weight: 700; }
.sheet .actions { display: flex; gap: 10px; padding: 10px 18px 4px; }
.sheet .actions button { flex: 1; }

/* floating "recording continues" pill (non-live views) */
#recpill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  background: var(--error); color: var(--surface);
  border: none; font-weight: 600; font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
#recpill.paused { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 8px 18px; border-radius: 999px; font-size: 14px;
  z-index: 60; opacity: 0; transition: opacity 0.2s; pointer-events: none;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 0.92; }

/* copy buttons */
.copy-btn {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 2px 6px; font-size: 15px; border-radius: 6px; line-height: 1;
}
.copy-btn:hover { background: var(--surface2); color: var(--text); }
/* N5: per-line translation playback. Same quiet chrome as the copy button;
 * the active (speaking) state is the one moment it may stand out. */
.tts-btn { margin-left: 6px; font-size: 12px; vertical-align: middle; }
.tts-btn.tts-active { color: var(--accent, #7A2BF0); }
.msg-row { display: flex; align-items: flex-end; gap: 2px; }
.msg-row.user { flex-direction: row-reverse; align-self: flex-end; }
.msg-row.assistant { align-self: flex-start; }

/* Purchase page (#/get): trial and pack cards inside the login box. */
.get-box { max-width: 460px; }
.get-card { text-align: left; }
.get-card h2 { border: 0; padding: 0; }
.pack .pack-price { font-size: 20px; }
.check-row { gap: 8px; align-items: center; cursor: pointer; }
.check-row input { width: auto; margin: 0; }
.hours-value { font-size: 18px; }
.hours-note { font-variant-numeric: tabular-nums; }

/* Signed-in chrome before the bundle runs (see the inline script in app.html):
 * [hidden] would otherwise keep the navigation invisible for the first ~700 ms
 * of a page load, which looks exactly like the signed-out site. */
/* !important, because the [hidden] reset above is !important too: without
 * it this rule always lost and the whole mechanism was inert. */
html.signed-in #nav[hidden] { display: flex !important; }

/* Share lives in the top bar: it is the app's growth path, and at the bottom
 * of Settings nobody found it. Icon-only, so it costs no horizontal room. */
#nav-share {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 32px; padding: 0; margin-left: 2px;
  border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--muted);
}
#nav-share:hover { background: var(--surface2); color: var(--text); }

/* The access link on the purchase page: it is the one thing the buyer has to
 * act on, so it is a link, not selectable text. */
/* Third-party sign-in buttons: the provider's mark sits beside the label. */
/* Pack ladder: the badged tier is the one the page recommends. */
.get-card.badged { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.pack-badge {
  display: inline-block; margin: -4px 0 6px; padding: 2px 9px;
  background: var(--primary); color: var(--primary-contrast);
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pack-rate { font-size: 13px; }

.signin-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }

.link-card { color: var(--primary); }
.link-card:hover { text-decoration: underline !important; }

/* P6: account detail under the balance. */
.acct-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0; font-size: 14px; }
.acct-kv .acct-k { color: var(--muted); }
.acct-chart-title { font-size: 13px; color: var(--muted); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.acct-chart { display: flex; align-items: flex-end; gap: 3px; height: 44px; }
/* A few days should not stretch to full width; cap each column. */
.acct-bar-wrap { flex: 0 1 28px; display: flex; align-items: flex-end; }
.acct-bar { width: 100%; background: var(--primary); border-radius: 2px 2px 0 0; min-height: 3px; }
.acct-history { font-size: 14px; }
.acct-hrow { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--border); }

/* P7: low-hours notice above the app. */
#lowhours { background: var(--warnbg); color: var(--warn);
  border-bottom: 1px solid var(--border); padding: 8px 16px; font-size: 14px;
  display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
#lowhours.out { background: var(--errorbg); color: var(--error); }
#lowhours .link { background: none; border: 0; color: inherit; font: inherit;
  text-decoration: underline; cursor: pointer; padding: 0; }

/* --- audience (N9) -------------------------------------------------------- */
.aud-sheet { max-width: 420px; }
.aud-qr { display: flex; justify-content: center; margin: 8px 0; }
.aud-qr svg { width: min(60vw, 260px); height: auto; background: #fff; border-radius: 12px; padding: 6px; }
.aud-code { text-align: center; font-size: 40px; font-weight: 700; letter-spacing: .12em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.aud-print { display: none; }
@media print {
  body > *:not(.aud-print) { display: none !important; }
  .aud-print { display: block; text-align: center; padding-top: 8vh; }
  .aud-print-title { font-size: 34pt; font-weight: 700; margin-bottom: 24pt; }
  .aud-print-qr svg { width: 110mm; height: 110mm; }
  .aud-print-code { font-size: 44pt; font-weight: 700; letter-spacing: .14em; margin-top: 18pt; }
  .aud-print-url { font-size: 16pt; margin-top: 6pt; color: #444; }
  .aud-print-choose { font-size: 12pt; margin-top: 28pt; color: #444; }
}

/* Jump back to the live tail (double chevron) while scrolled up. */
.live-jump {
  position: fixed; right: 16px; bottom: 132px; z-index: 30;
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent, #7A2BF0); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.28);
}
.live-jump:active { transform: scale(.94); }
