/*
 * Two predefined themes, "dark" (greys + a violetti tint highlight) and
 * "light". Every color pair below was
 * checked against WCAG AA (4.5:1 for text, verified for both the page
 * background and the surface/card background it can sit on). --on-primary
 * is the ink color for text/icons drawn on top of a solid --primary (or
 * similarly saturated --danger) fill — dark theme's --primary is a light
 * violetti tint, so it needs dark ink; light theme's --primary is the
 * brand's violetti (#4e008e), dark enough that it needs light ink. Don't swap --primary's
 * brightness between themes without re-deriving --on-primary, or a CTA's
 * label contrast will silently fail. See docs/brand-colors.md for the full
 * brand palette and the WCAG contrast audit behind these choices.
 *
 * Dark theme's --bg/--surface/--text/--text-muted (2026-09-23 rework) trade
 * some contrast margin for less eye-jumping between near-black and
 * near-white — Discord-style mid greys instead of true black/white, still
 * re-verified at or above 4.5:1 in every place they pair with text. --surface-2
 * is a third, lighter grey used only for hover/active highlighting and has no
 * text-contrast obligation of its own (the text on it is always --text,
 * already re-checked against it).
 */
:root {
  --radius: 16px;
  /* One column width for every screen AND the top bar (whose padding
     aligns its buttons to it), so nothing sticks out past the nav's edges.
     In em - resolved against body's font-size where it's used - so the
     column grows with the text rather than with the viewport: line length
     stays readable, and the nav buttons only spread apart when the text
     they frame got bigger too. 34em = 680px at the 20px desktop size. */
  --content-max: 34em;
  /* 44px is the usual minimum accessible touch target; 46px keeps a small
     margin above that while trimming the composer row's footprint. */
  --composer-btn-size: 46px;
  /* Shared by .composer-row and .composer-actions so the text box, mic and
     send button are always spaced identically, however they're arranged. */
  --composer-gap: 0.4rem;
  /* Corner radius of every full-width action button, shared with the
     composer's mic/send/text box so the bottom bar lines up. */
  --btn-radius: 12px;

  /* dark palette (default; also the no-JS / pre-choice fallback). Greys
     carry a faint violetti undertone. Raw violetti #4e008e is only ~1.35:1
     on --bg, so --primary is a white-lightened violetti tint with deep
     violetti ink. Bubbles differ in hue, not just lightness: the AI's is
     neutral grey, the user's a deep violetti. */
  --bg: #1b1a21;
  --surface: #26242e;
  --surface-2: #312e3a;
  --text: #e4e1ea;
  --text-muted: #aca7b6;
  --primary: #bb9ad8;
  --on-primary: #1a0030;
  --success: #30d158;
  --danger: #ff6b6b;
  /* Situation facts (scenario.js): green = done right, red = a mistake.
     --on-* is the ink for the icon drawn on a solid fill of each. */
  --good: #30d158;
  --on-good: #0b2e14;
  --on-danger: #2a0404;
  --bubble-ai: #2c2b33;
  --bubble-user: #4a2c70;
  --border: rgba(255, 255, 255, 0.08);
  --topnav-bg: var(--surface);
  --topnav-fg: var(--text);
  --topnav-fg-muted: var(--text-muted);
  --topnav-focus: var(--primary);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  /* Only applies before the user (or app init) has set an explicit theme */
  :root:not([data-theme]) {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #ececef;
    --text: #1c1c1e;
    --text-muted: #6c6c70;
    --primary: #4e008e;
    --on-primary: #ffffff;
    --danger: #b3261e;
  --good: #1a7f37;
  --on-good: #ffffff;
  --on-danger: #ffffff;
    --bubble-ai: #e5e5ea;
    --bubble-user: #c3b9d7;
    --border: rgba(0, 0, 0, 0.1);
    /* #topnav goes solid --primary in light theme (dark theme keeps its
       original neutral --surface bar) — these give it its own ink/muted/
       focus colors rather than reusing --primary-on-white ones, which
       would be invisible against a --primary-colored background. */
    --topnav-bg: var(--primary);
    --topnav-fg: var(--on-primary);
    --topnav-fg-muted: color-mix(in srgb, var(--on-primary) 65%, transparent);
    --topnav-focus: var(--on-primary);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #ececef;
  --text: #1c1c1e;
  --text-muted: #6c6c70;
  --primary: #4e008e;
  --on-primary: #ffffff;
  --danger: #b3261e;
  --good: #1a7f37;
  --on-good: #ffffff;
  --on-danger: #ffffff;
  --bubble-ai: #e5e5ea;
  --bubble-user: #c3b9d7;
  --border: rgba(0, 0, 0, 0.1);
  --topnav-bg: var(--primary);
  --topnav-fg: var(--on-primary);
  --topnav-fg-muted: color-mix(in srgb, var(--on-primary) 65%, transparent);
  --topnav-focus: var(--on-primary);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1b1a21;
  --surface: #26242e;
  --surface-2: #312e3a;
  --text: #e4e1ea;
  --text-muted: #aca7b6;
  --primary: #bb9ad8;
  --on-primary: #1a0030;
  --danger: #ff6b6b;
  /* Situation facts (scenario.js): green = done right, red = a mistake.
     --on-* is the ink for the icon drawn on a solid fill of each. */
  --good: #30d158;
  --on-good: #0b2e14;
  --on-danger: #2a0404;
  --bubble-ai: #2c2b33;
  --bubble-user: #4a2c70;
  --border: rgba(255, 255, 255, 0.08);
  --topnav-bg: var(--surface);
  --topnav-fg: var(--text);
  --topnav-fg-muted: var(--text-muted);
  --topnav-focus: var(--primary);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute always hides, whatever display: an element's own
   rules give it. Without this, any `display: flex/grid/...` rule silently
   beats the UA's [hidden] style and the element shows on every screen
   (this app shows/hides whole screens and bars via `hidden`, see
   showScreen() in screens.js). Opt out only deliberately, with an
   !important rule of higher specificity (see #nav-settings[hidden]). */
[hidden] { display: none !important; }

html {
  height: 100%;
  /* Allow native vertical scrolling but not native pinch/double-tap zoom
     or horizontal panning -- pinch-zoom.js replaces zoom with its own
     gesture, applied to #app-shell rather than <body> or <html>. There's
     never legitimate horizontal content to pan to: #app-shell's own
     width is shrunk by JS in exact proportion to its zoom (see the
     comment on #app-shell), so the zoomed result always renders at
     exactly 100% of <body>'s width, whatever the zoom level. */
  touch-action: pan-y;
  overflow: hidden;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 400;
  font-size: clamp(17px, 4vw, 20px);
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  height: 100dvh;
  /* Set by viewport.js from visualViewport.height: some mobile browsers
     (notably iOS Safari) don't shrink 100dvh when the on-screen keyboard
     opens, which left stale blank space that pushed the conversation and
     composer out of view. Falls back to 100dvh where JS hasn't run yet. */
  height: var(--app-height, 100dvh);
  /* Always exactly one viewport in size. #app-shell fills it exactly, so
     the top bar and the composer bar stay put and each screen scrolls
     inside itself (.screen, #conversation); overflow-y here is the
     fallback for when #app-shell's zoom pushes it past its min-height
     floor, below the fold. overflow-x stays hidden not as a clip that's expected to
     ever actually trigger, but because there's genuinely never anything
     to pan or scroll to sideways - pinch-zoom.js measures #app-shell's
     real rendered width and corrects its zoom so that width never
     exceeds this one (see the comment there), rather than letting it
     overflow and relying on this to hide or scroll past the excess. */
  overflow-y: auto;
  overflow-x: hidden;
}

#app-shell {
  display: flex;
  flex-direction: column;
  /* Exactly the visible height (the same --app-height as <body>, see
     viewport.js), not just at least that: a shell that grew with its
     content made <body> the scroller, scrolling the top bar and the
     composer bar away with a long conversation. Fixed, each screen scrolls
     inside itself instead. Divided by pinch-zoom.js's zoom level for the
     same reason as the width compensation there: `zoom` scales this px
     height back up to exactly the viewport.
     min-height is the floor below which squeezing the scroll area any
     further would leave the conversation unreadable (or cut off the
     composer): at a high enough zoom on a short screen, the shell stays
     this tall and <body> scrolls it instead. rem, so it scales with zoom. */
  height: calc(var(--app-height, 100dvh) / var(--shell-zoom, 1));
  min-height: 20rem;
  /* Pinch-zoom.js sets `zoom` (not `transform: scale()`) so pinching
     actually grows elements themselves - text reflows and controls
     resize at their new, bigger layout size, rather than a flat visual
     stretch of an already-flowed page from a single fixed corner.
     `zoom` growing #app-shell's rendered size also means <body> would
     see it as N times wider than the viewport at zoom N, same as it
     would for any other element - so JS shrinks #app-shell's own
     (pre-zoom) width by that same factor every time it changes the
     zoom level. That cancels out in the common case, and JS re-measures
     and corrects it in the rest, so the zoomed result never renders
     wider than <body> - see the comment in pinch-zoom.js. */
}

/* ── Top nav ──────────────────────────────────────────────────────────────── */

/* Always one line: the logo is what gives way first when space runs out
   (see .topnav-brand), then the version badge (see .app-version), never
   the buttons. */
/* The banner landmark around #topnav: just a fixed-height row of
   #app-shell, like #topnav was before it was wrapped. */
.topbar { flex-shrink: 0; }

#topnav {
  display: flex;
  gap: 0.5rem;
  /* Align buttons with content column on wide viewports */
  padding: 0.5rem max(1rem, calc((100% - var(--content-max)) / 2));
  /* One icon button's width: 18px icon + .nav-btn--icon padding + border. */
  --nav-icon-w: calc(18px + 0.8rem + 2px);
  background: var(--topnav-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--topnav-fg-muted);
  color: var(--topnav-fg);
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}

.nav-btn:hover { background: color-mix(in srgb, var(--topnav-fg) 12%, transparent); }
.nav-btn:focus-visible { outline: 2px solid var(--topnav-focus); outline-offset: 2px; }

/* Icon-only nav button (back/menu chevron, settings' gear) - square-ish tap
   target instead of the text buttons' horizontally-biased padding. */
.nav-btn--icon {
  width: var(--nav-icon-w);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
}

/* Settings gear keeps its layout slot even when hidden, so the version
   text next to it (.topnav-right) doesn't shift as screens toggle the
   gear on/off. The one deliberate exception to the global [hidden] rule
   at the top of this file: both are !important, so this one's higher
   specificity wins. */
#nav-settings[hidden] {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}

/* Logo slot between the back button and .topnav-right. A zero flex-basis
   means it only ever gets leftover width, so it empties before anything
   else has to shrink; the container query then drops the logo whole
   rather than clipping it. */
.topnav-brand {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  container: brand / inline-size;
}

/* The logo starts one icon slot + gap in from the column edge whether or
   not the back button is there, mirroring the version text, which always
   has the settings gear's slot after it (see #nav-settings[hidden]). */
#nav-back-menu[hidden] + .topnav-brand { margin-left: calc(var(--nav-icon-w) + 0.5rem); }

/* The logo's width at --logo-h: 1.4rem (1.4 * 1618 / 442 = 5.13rem). */
@container brand (max-width: 5.2rem) {
  .topnav-brand .brand-btn { display: none; }
}

/* The logo's button: just the logo, no button chrome. */
.brand-btn {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.brand-btn:disabled { cursor: default; }
.brand-btn:focus-visible { outline: 2px solid var(--topnav-focus); outline-offset: 2px; }

/* Settings + build info, pinned to the top-right corner regardless of
   whether nav-back-menu (top-left, see index.html) is currently shown,
   and regardless of its mode. */
.topnav-right {
  margin-left: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-version {
  font-size: 0.7em;
  color: var(--topnav-fg-muted);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Very small screens / heavy zoom (media-query em tracks browser zoom):
   drop the build info altogether rather than show a sliver of it. */
@media (max-width: 22em) {
  .app-version { display: none; }
}

/* ── Screens ──────────────────────────────────────────────────────────────── */

main { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem 1rem 2rem;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Wider viewports: use a bit more of the horizontal space, but the same
   cap for every screen (the conversation included) - a wider chat column
   would just mean over-long lines (~120+ chars) and bubbles, header and
   composer overhanging the top bar. 38em/44em = 760px/880px at 20px. */
@media (min-width: 900px) {
  :root { --content-max: 38em; }
}

@media (min-width: 1400px) {
  :root { --content-max: 44em; }
}

/* Interview screen needs a fixed-bottom-controls layout */
#screen-interview {
  padding: 0;
  overflow: hidden;
  /* Anchors .btn-new-message to the bottom of the conversation's view. */
  position: relative;
}

.interview-header {
  padding: 1rem 1rem 0;
  flex-shrink: 0;
}

.persona-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.persona-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

/* The exercise title part of the heading: shown in #conversation-details
   instead. Visually hidden rather than removed - showScreen() focuses this
   heading on every screen change, so it's still announced and kept in the
   document title. */
.persona-exercise {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Conversation details (chat header, see conversation-details.js) ───── */

.details-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 36px;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font: inherit;
  font-size: 0.85em;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.details-toggle:hover { box-shadow: inset 0 0 0 1px var(--primary); }
.details-toggle:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.details-chevron { transition: transform 0.15s; }
.details-toggle[aria-expanded="true"] .details-chevron { transform: rotate(180deg); }

/* Scrolls on its own rather than pushing the conversation off a phone
   screen. */
.conversation-details {
  margin-top: 0.6rem;
  padding: 0.75rem 0.9rem;
  max-height: 45vh;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9em;
}
.conversation-details p { margin: 0; }
#details-situation,
.details-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.details-label {
  color: var(--text-muted);
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.persona-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  font-weight: 700;
  color: #fff;
  border: 1px solid var(--border);
}

.persona-meta { min-width: 0; }
.persona-meta h1 { margin: 0; line-height: 1.15; font-size: clamp(1.1rem, 3.5vw, 1.4rem); }

/* "AI" next to the persona's name (persona-avatar.js). */
.ai-badge {
  display: inline-block;
  vertical-align: middle;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 0.6em;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.persona-status {
  margin: 0;
  font-size: 0.8em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Presence dot, Teams-style — purely decorative (next to the persona's job
   title, or "Online" without one), so it's a plain ::before, not an icon
   needing alt text. */
.persona-status:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ── Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3 { font-weight: 700; }
h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
h2 { font-size: clamp(1.1rem, 3.5vw, 1.4rem); }
h3 { font-size: 1rem; }

/* Each screen's h1, sized like the h2 these used to be. */
#exercise-setup-h1, #feedback-h1 { font-size: clamp(1.1rem, 3.5vw, 1.4rem); }
/* Main menu: the greeting looks like the title, and the h1 below it like
   the lead line it replaced. */
.menu-greeting { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 700; line-height: 1.2; }
.menu-h1 { font-size: 1em; font-weight: 400; }

/* PrepTalk logo (index.html): an inline <svg><use> of images/preptalk-logo.svg,
   whose fill is currentColor - so it takes the theme's primary colour here,
   and CanvasText in forced-colors mode. Width follows the 1618x442 artwork. */
.brand-logo {
  --logo-h: clamp(3rem, 12vw, 4.5rem);
  display: block;
  height: var(--logo-h);
  width: calc(var(--logo-h) * 1618 / 442);
  max-width: 100%;
  color: var(--primary);
}
/* In the top bar, which is solid --primary in the light theme. */
.brand-logo--nav { --logo-h: 1.4rem; color: var(--topnav-fg); }

/* On phones, the app name and the interview header should take up as
   little vertical space as possible: that's room the conversation and the
   on-screen keyboard are fighting over. */
@media (max-width: 480px) {
  #welcome-h1 .brand-logo { --logo-h: 2.5rem; }

  /* Smaller than the desktop default (still saving room for the
     conversation/keyboard below), but not so trim that #status ends up
     flush against the nav bar - 0.2rem read as glued to it in practice. */
  .interview-header { padding: 0.6rem 0.75rem 0; }

  .persona-avatar { width: 30px; height: 30px; }

  #status { font-size: 0.8em; }
  #status:not(:empty):not(:has(> .visually-hidden)) { min-height: 1.1em; padding-bottom: 0.15rem; }

  /* Matches the header's own trim above - without the title, the header
     + this padding was leaving a visible dead band before the first
     bubble. */
  #conversation { padding-top: 0.6rem; }
}

.lead { font-weight: 400; }
.role-summary { color: var(--text-muted); font-size: 0.9em; }
/* Collapsed out of flow while empty (e.g. settings reached before a work
   role has been saved yet) so it doesn't leave a dead gap via its flex
   container's `gap`. */
.role-summary:empty { display: none; }

/* Setup screen: the job line with its "Change job" button beside it,
   wrapping under it when the line is long or the screen narrow. */
.setup-job-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.setup-job-row .role-summary { flex: 1 1 14rem; margin: 0; }

/* ── Form elements ────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label { font-weight: 400; font-size: 0.9em; }
.required-mark { color: var(--text-muted); }

input[type="text"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  padding: 0.75rem 1rem;
  width: 100%;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input[type="text"]:disabled,
textarea:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

textarea { resize: none; }

/* ── Work role feedback ───────────────────────────────────────────────────── */

.field-hint {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border-left: 3px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  font-size: 0.9em;
  line-height: 1.5;
}

.field-error {
  color: var(--danger);
  font-size: 0.875em;
  padding: 0.15rem 0;
}

.field-example {
  color: var(--text-muted);
  font-size: 0.85em;
}

/* ── Situation panel (setup screen, see scenario.js) ──────────────────────── */

/* Heading and instructions sit on the page like the rest of the setup
   screen; only the situation itself (.scenario-card) is boxed. */
/* "About these practice conversations" on the mode screen (supervisor
   mode): the AI note's tinted box, with a heading and a short list. */
.ai-limits-notice {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border-left: 3px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  font-size: 0.9em;
  line-height: 1.5;
}
.ai-limits-notice h2 { font-size: 1rem; margin-bottom: 0.35rem; }
.ai-limits-list { margin: 0.35rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.35rem; }

.scenario-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.scenario-panel h2 { font-size: 1.05rem; }

.scenario-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem;
  border-radius: 12px;
  background: var(--surface);
}
.scenario-panel p:empty:not([role="status"]) { display: none; }
/* Collapsed while empty, but never display:none - a live region hidden that
   way isn't tracked, so text put into it later goes unannounced (NVDA). */
#scenario-status:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.scenario-summary {
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
}

.scenario-colleague {
  margin: 0;
  line-height: 1.35;
}

.scenario-edit {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* One box per kind of fact (scenario.js): the same icon as the shown
   fact, and a coloured edge, with tighter padding than other text boxes so
   three of them still fit on a phone. */
.fact-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.fact-field label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9em;
  font-weight: 700;
}
.fact-field textarea {
  padding: 0.5rem 0.75rem;
  line-height: 1.4;
  overflow-y: hidden;
}
.fact-field--good textarea { border-left: 3px solid var(--good); }
.fact-field--bad textarea { border-left: 3px solid var(--danger); }

/* Situation facts (renderFactList() in scenario.js), on the setup screen
   and in the chat header's details panel. Each kind has its own colour
   AND its own icon (plus a hidden label), so colour is never the only
   cue: ✓ green = done right, ✕ red = your mistake, plain = background. */
.fact-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  line-height: 1.4;
}

.fact {
  /* Keeps the visually hidden kind label inside the item (and inside the
     details panel's scroll box). */
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  /* Shorter lines are easier to read than the full card width. */
  max-width: 32em;
}

.fact-icon {
  flex-shrink: 0;
  width: 1.3rem;
  height: 1.3rem;
  margin-top: 0.05rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.fact--good { background: color-mix(in srgb, var(--good) 13%, transparent); }
.fact--good .fact-icon,
.fact-field--good .fact-icon { background: var(--good); color: var(--on-good); }
.fact--good .fact-icon::before,
.fact-field--good .fact-icon::before { content: "✓"; }

.fact--bad { background: color-mix(in srgb, var(--danger) 13%, transparent); }
.fact--bad .fact-icon,
.fact-field--bad .fact-icon { background: var(--danger); color: var(--on-danger); }
.fact--bad .fact-icon::before,
.fact-field--bad .fact-icon::before { content: "✕"; }

.fact--info .fact-icon::before,
.fact-field--info .fact-icon::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--text-muted);
}

.fact-list--compact { gap: 0.3rem; }
.fact-list--compact .fact { padding: 0.3rem 0.5rem; }

.scenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Small tinted pill with an icon: nothing like the outlined, surface-filled
   card, so the card doesn't read as a button too. */
.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-chip:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--primary); }
.btn-chip:active:not(:disabled) { opacity: 0.75; }
.btn-chip:disabled { opacity: 0.45; cursor: default; }
.btn-chip:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ── Settings rows ────────────────────────────────────────────────────────── */

/* Tighter row/section spacing than the shared .screen gap - this screen is
   a long vertical list of settings and benefits from being denser than a
   form or the conversation view. */
#screen-settings { gap: 0.55rem; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -0.5rem;
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.15s;
}

.setting-row:hover { background: var(--surface-2); }

.setting-label {
  flex: 1;
  padding-right: 0.75rem;
  cursor: pointer;
}

.setting-hint {
  font-size: 0.82em;
  color: var(--text-muted);
  line-height: 1.4;
}

/* A label with its explanation stacked under it, inside the row, so the
   note reads as part of that setting rather than floating below the row's
   divider. */
.setting-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-right: 0.75rem;
}
.setting-text .setting-label { padding-right: 0; }

.setting-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

/* ── Toggle switch ────────────────────────────────────────────────────────── */

.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  min-width: 52px;
  min-height: 30px;
  background: var(--text-muted);
  border: none;
  border-radius: 15px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  touch-action: manipulation;
  padding: 0;
}

.toggle[aria-checked="true"] { background: var(--primary); }

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  pointer-events: none;
}

.toggle[aria-checked="true"] .toggle-thumb { transform: translateX(22px); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

/* One system for every full-width action button, told apart by fill only:
     .btn-primary / .btn-start  solid --primary (the one main action)
     .btn-tonal                 --primary-tinted fill (a highlighted but
                                secondary action, e.g. "End & get feedback")
     .btn-secondary             neutral --surface fill
     .btn-danger                --danger-tinted fill (starts something
                                destructive, e.g. "Clear my data")
     .btn-danger-solid          solid --danger (confirms it)
   Same size, corners, hover, press, disabled and focus everywhere. Small
   inline actions are pills instead (.btn-chip and friends). Tinted fills
   with colored text (.btn-danger, the chips) show a ring on hover rather
   than a deeper tint, which would drop that text below 4.5:1. */
.btn-primary, .btn-start, .btn-tonal, .btn-secondary,
.btn-danger, .btn-danger-solid {
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

/* Hover mixes toward --text: lighter in dark theme, darker in light, so the
   ink's contrast only improves. */
.btn-primary, .btn-start { background: var(--primary); color: var(--on-primary); }
.btn-start { font-size: 1.05rem; }
.btn-primary:hover:not(:disabled),
.btn-start:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, var(--text)); }

.btn-tonal {
  background: color-mix(in srgb, var(--primary) 18%, var(--surface));
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
}
.btn-tonal:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 28%, var(--surface)); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

/* A secondary action next to a line of text rather than a full-width
   step of its own (e.g. setup's "Change job"). */
.btn-small {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-danger {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}
.btn-danger:hover:not(:disabled) { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }

.btn-danger-solid { background: var(--danger); color: var(--on-danger); }
.btn-danger-solid:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, var(--text)); }

:is(.btn-primary, .btn-start, .btn-tonal, .btn-secondary, .btn-danger, .btn-danger-solid):active:not(:disabled) { opacity: 0.8; }
:is(.btn-primary, .btn-start, .btn-tonal, .btn-secondary, .btn-danger, .btn-danger-solid):disabled { opacity: 0.45; cursor: default; }
:is(.btn-primary, .btn-start, .btn-tonal, .btn-secondary):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
:is(.btn-danger, .btn-danger-solid):focus-visible { outline: 3px solid var(--danger); outline-offset: 2px; }

/* One of the longer button labels in the app (longer still in Finnish:
   "Lopeta ja saa palaute") - the shared 1.5rem side padding left too
   little room for the text on narrow screens. */
#btn-end-interview {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Draws the eye to "End & get feedback" once the conversation has reached
   its natural end and the composer above it has gone grey/disabled, so the
   next step is obvious without the app switching screens on its own: from
   its usual tinted fill to solid + glow + pulse. */
#btn-end-interview.is-highlighted {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
}

.clear-data-row { margin-top: auto; padding-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.clear-data-warning { font-size: 0.875em; color: var(--danger); }

/* Links to the standalone data handling/accessibility pages (welcome note,
   Settings' About section). */
.text-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.text-link:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 2px; }

/* Settings' footer: a divider, then everything centred, under a small
   muted heading that reads as a section label, not a second title. */
.settings-about {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.settings-about h2 { font-size: 0.85em; color: var(--text-muted); margin-bottom: 0.25rem; }
/* Tap-sized rows. */
.about-links { list-style: none; }
.about-links .text-link { display: inline-flex; align-items: center; min-height: 44px; }
.clear-data-actions { display: flex; flex-direction: column; gap: 0.5rem; }

/* The palette's own --danger, as a tint behind --text, rather than fixed
   alert pink: still unmistakably a warning, but in the app's colors in
   every theme. */
.leave-interview-confirm {
  margin: 0.75rem 1rem 0;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
  border-left-width: 4px;
  border-radius: var(--btn-radius);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  flex-shrink: 0;
}
.leave-interview-warning { font-size: 0.875em; color: var(--text); margin: 0 0 0.5rem; }
.leave-interview-actions { display: flex; gap: 0.5rem; }

/* ── Exercise list ────────────────────────────────────────────────────────── */

.exercise-list { display: flex; flex-direction: column; gap: 0.75rem; list-style: none; }
/* Each <li> a column too, so its button (or group box) stretches to the
   full width - buttons don't fill their container on their own. */
.exercise-list > li { display: flex; flex-direction: column; }

/* A titled subsection (e.g. "Disclosing a mistake"): a primary-tinted box
   holding its heading and buttons. 12% --primary over --surface separates it
   from the page in every theme (1.3-1.5:1 against the dark --bg) while its
   --surface buttons still stand apart; the heading is --text, not
   --text-muted, which drops to ~4:1 on the light tint. */
.exercise-group {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
}
.exercise-group-heading {
  font-size: 1rem;
  color: var(--text);
  margin: 0 0 0.75rem;
}

.btn-exercise {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: border-color 0.15s, background 0.15s;
}

.btn-exercise:hover:not(:disabled, [aria-disabled="true"])  { border-color: var(--primary); background: var(--surface-2); }
.btn-exercise:active:not(:disabled, [aria-disabled="true"]) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.btn-exercise:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* "Coming soon" exercises (exercises.js) are aria-disabled, not disabled,
   so they stay focusable; dimmed, but less than a plain disabled button so
   their names stay readable. */
.btn-exercise:disabled { opacity: 0.4; cursor: default; }
.btn-exercise[aria-disabled="true"] {
  cursor: default;
  border-style: dashed;
  color: var(--text-muted);
}
.btn-exercise[aria-disabled="true"] .exercise-icon { opacity: 0.5; }

/* "Coming soon", pushed to the button's end. */
.exercise-badge {
  margin-left: auto;
  flex-shrink: 0;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.exercise-icon { font-size: 1.4rem; flex-shrink: 0; }

/* ── Choice cards (focus areas on #screen-goals, company names) ───────────── */

/* Chunky, tappable cards (thicker bottom border, a press-down on tap) with a
   tinted badge, in the spirit of Duolingo's onboarding pickers - each is the
   <label> of a visually hidden radio (.choice-input). Each card's
   --choice-hue (goals.js, company-names.js) only tints backgrounds - borders,
   text, chips and the check mark use theme colors, which are
   contrast-checked; a yellow hue on the light theme wouldn't be. Selection shows as a filled check
   circle (a shape change, not just color) plus a --primary border. */
.choice-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Two columns once both fit at 15rem (the 34em+ column on a laptop), one
   on a phone or at heavy zoom - never three, however wide the column gets,
   so four cards are always 2x2 or 1x4 rather than 3 + 1: a column's minimum
   is at least half the row (minus the gap). "No particular focus" gets its
   own full-width row at the top. */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, max(15rem, (100% - 0.75rem) / 2)), 1fr)
  );
  gap: 0.75rem;
}
.choice-card--none { grid-column: 1 / -1; }

.choice-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 2.75rem 0.8rem 0.8rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-bottom-width: 5px;
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.choice-card--none { align-items: center; }
.choice-card:hover { background: var(--surface-2); }
.choice-card:active { transform: translateY(2px); }
.choice-card:has(.choice-input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.choice-card:has(.choice-input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--choice-hue) 14%, var(--surface));
}

/* Still focusable and operable (the whole card is its <label>, and the
   arrow keys move between the radios), just not drawn - the card is. */
.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.choice-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  background: color-mix(in srgb, var(--choice-hue) 24%, var(--surface));
}

.choice-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.choice-label { font-weight: 700; line-height: 1.25; }
.choice-hint { font-size: 0.8em; line-height: 1.35; color: var(--text-muted); }
/* --text-muted is only checked against the plain --surface. */
.choice-card:has(.choice-input:checked) .choice-hint { color: var(--text); }

/* What the area covers, as small pills - on the plain --surface (not the
   card's tint), so their --text is always on a checked background. */
.goal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.goal-chip {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.75em;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.choice-check {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
}
.choice-card--none .choice-check { top: 50%; margin-top: -0.75rem; }
.choice-check svg { visibility: hidden; }
.choice-card:has(.choice-input:checked) .choice-check {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  animation: choice-pop 0.25s ease-out;
}
.choice-card:has(.choice-input:checked) .choice-check svg { visibility: visible; }

@keyframes choice-pop {
  0%   { transform: scale(0.6); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@media (forced-colors: active) {
  .choice-card:has(.choice-input:checked) { border-color: Highlight; }
  .choice-card:has(.choice-input:checked) .choice-check { background: Highlight; color: HighlightText; }
  .goal-chip { border-color: CanvasText; }
}

/* Very small screens / heavy zoom: a smaller badge leaves the text room. */
@media (max-width: 22em) {
  .choice-card { gap: 0.6rem; padding: 0.7rem 2.4rem 0.7rem 0.7rem; }
  .choice-icon { width: 2.25rem; height: 2.25rem; font-size: 1.2rem; }
  .choice-check { right: 0.65rem; }
}

/* ── Company picker (#screen-work-role, see company-names.js) ─────────────── */

/* Tighter than the goals screen's fieldset - it's one field among others -
   and the legend reads like the other fields' labels. A container, so the
   @container rule below reacts to the column's own width in em - which
   shrinks with zoom and with bigger text. */
.company-fieldset { gap: 0.5rem; container: company / inline-size; }
.company-fieldset legend { font-size: 0.9em; padding: 0; margin-bottom: 0.4rem; }

/* Three side by side, logo above the name, check circle in the corner -
   long names ("Millbrook Employment Office", "työvoimatoimisto") hyphenate
   (by <html lang>) rather than overflow. */
.company-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.company-grid .choice-card {
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 0.5rem 0.75rem;
  text-align: center;
}
.company-grid .choice-label { font-size: 0.9em; hyphens: auto; overflow-wrap: break-word; }
.company-grid .choice-check { top: 0.45rem; right: 0.45rem; width: 1.25rem; height: 1.25rem; }

/* Heavy zoom or very large text (e.g. 400% on a laptop): one per row, logo
   beside the name, like the focus cards. */
@container company (max-width: 18em) {
  .company-grid { grid-template-columns: 1fr; gap: 0.6rem; }
  .company-grid .choice-card {
    flex-direction: row;
    gap: 0.75rem;
    padding: 0.8rem 2.75rem 0.8rem 0.8rem;
    text-align: start;
  }
  .company-grid .choice-label { font-size: 1em; }
  .company-grid .choice-check { top: 50%; right: 0.8rem; width: 1.5rem; height: 1.5rem; margin-top: -0.75rem; }
}

/* The initials as a pretend logo: bold, a ring in the card's hue, and one of
   three shapes so the cards look like different brands. The ring is
   decoration - the initials are --text on a light tint, like the goal icons. */
.company-logo {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 0 2px var(--choice-hue);
}
.company-logo-square { border-radius: 10px; }
.company-logo-leaf { border-radius: 50% 8px; }

/* The hint on the left, "Show other names" at the far right of the same
   line; when both don't fit, the button wraps to its own line at the left
   (space-between starts a lone item at the start edge). */
.company-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
}
.company-head .field-example { margin: 0; }

/* An action, not a fourth option: a compact dashed pill in --primary
   (text-contrast-checked on --bg in every theme) with a shuffle icon, where
   the cards are solid, chunky and --text coloured. */
.btn-company-new {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.3rem 0.8rem;
  border: 2px dashed var(--primary);
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.btn-company-new svg { flex: none; }
.btn-company-new:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.btn-company-new:active { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.btn-company-new:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

@media (forced-colors: active) {
  .company-logo { box-shadow: none; border: 2px solid CanvasText; }
}

/* ── Interview screen layout ──────────────────────────────────────────────── */

#status {
  font-size: 0.85em;
  color: var(--primary);
}

/* min-height/padding only reserved while there's actually a visible
   message (a connect error, "Conversation restored", …) - #status sits
   empty the vast majority of the time, and reserving its line
   unconditionally was the real source of the dead space above the first
   chat bubble (on every screen size, not just phones). "Starting…" /
   "Processing…" are screen-reader-only (a .visually-hidden span, see
   announceLoading()) since the typing dots show that visually, so they
   don't reserve the line either. */
#status:not(:empty):not(:has(> .visually-hidden)) {
  min-height: 1.4em;
  margin-top: 0.3rem;
  padding-bottom: 0.25rem;
}

#conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Scrolling past either end doesn't carry on to <body> (see #app-shell's
     min-height fallback) or trigger pull-to-refresh on mobile. */
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 0.5rem 1rem;
}

/* Focusable only so keyboard users can scroll it (see index.html); inset,
   as #screen-interview's overflow:hidden would clip an outside outline. */
#conversation:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* "New message" pill over the bottom of the conversation, shown while
   scrolled up when a reply arrives (see chat-scroll.js). */
.btn-new-message {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.9rem 0.45rem 1.1rem;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.35);
}

.btn-new-message:hover { background: color-mix(in srgb, var(--primary) 88%, var(--text)); }
.btn-new-message:active { opacity: 0.8; }
.btn-new-message:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.message {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius);
  max-width: 85%;
  /* word-break: break-word only changes line-breaking, not the box's
     min-content width - a single long unbroken run (a URL, a typo'd
     run of characters) could still force the bubble itself wider than
     max-width. overflow-wrap: anywhere also shrinks that min-content
     size, so the 85% cap actually holds. */
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 0;
}

.message--assistant {
  background: var(--bubble-ai);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.message--user {
  background: var(--bubble-user);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-body {
  margin: 0;
  white-space: pre-wrap;
}

/* Bouncing-dots bubble shown in place of the assistant's reply while it's
   being generated. Reuses .message--assistant's bubble shape so it reads as
   "a reply is forming here" rather than a separate loading widget; the
   accessible equivalent is #status's aria-live text, so this stays
   aria-hidden and never touches the #messages aria-live log. */
.typing-indicator {
  padding: 0.75rem 1.125rem;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

.message-actions {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}

.btn-plain-language {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82em;
  font-weight: 700;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-plain-language:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--primary); }

.btn-plain-language:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-plain-language:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* "Edit" / "Cancel & edit" on the latest user message. Drawn in the
   bubble's own --text colour rather than --primary: --primary isn't
   contrast-checked against the --bubble-user fill. */
.message--user .message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0;
  border-top: 0;
}

.btn-edit-message {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82em;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--text) 60%, transparent);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-edit-message:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-color: var(--text);
}

.btn-edit-message:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-edit-message:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

.plain-language-panel {
  margin-top: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-radius: 0 8px 8px 0;
}

.plain-language-label {
  margin: 0 0 0.25rem;
  font-size: 0.75em;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plain-language-text {
  margin: 0;
  font-size: 0.95em;
  white-space: pre-wrap;
}

/* A step lighter than the conversation area's --bg, same tier as the top
   nav bar - reads as its own "input" section rather than a floating strip
   over the conversation. A sibling of #screen-interview (not nested inside
   it - see index.html/showScreen()) so it's never clipped by that screen's
   own overflow:hidden, and its background can bleed to the full app width
   the same way #topnav's does, via the same max(min-inset, centering-calc)
   padding trick topnav uses to keep the composer/buttons themselves at
   their original --content-max size and position rather than stretching
   full-width. */
#controls {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem max(0.85rem, calc((100% - var(--content-max)) / 2)) 0.85rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ── Composer (mic + text + send) ─────────────────────────────────────────── */

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  /* Lets the @container rule below react to the composer's own rendered
     width - which shrinks under pinch-zoom the same way it would on a
     narrower device (see pinch-zoom.js) - rather than the viewport's. */
  container-type: inline-size;
  container-name: composer;
}

.mic-hint-panel {
  font-size: 0.78em;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 0.5rem 0.65rem;
  /* One tier lighter than #controls (its container, also --surface now)
     so it still reads as its own nested panel rather than blending in. */
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.mic-hint-panel p { margin: 0; }

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: var(--composer-gap);
}

.composer-actions {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: var(--composer-gap);
}

.composer-voice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  /* Was flex-shrink: 0 (never shrinks), which - combined with .btn-send's
     own flex-shrink: 0 - left #text-input as the only row member that
     could give up width, squeezing it hard whenever the row got tight
     (e.g. zoomed in). Shrinks like any other row member now, but no
     further than its own natural (mic button) width. */
  flex-shrink: 1;
  min-width: var(--composer-btn-size, 52px);
}

.composer-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.composer-icon-btn svg {
  width: 22px;
  height: 22px;
}

.composer-icon-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface-2);
}

.composer-icon-btn[aria-expanded="true"] {
  color: var(--primary);
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.composer-icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--composer-btn-size, 52px);
  height: var(--composer-btn-size, 52px);
  padding: 0;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#mic-btn:active:not(:disabled) { transform: scale(0.97); }

#mic-btn[data-state="listening"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 35%, transparent);
  animation: pulse 1.2s ease-in-out infinite;
}

#mic-btn[data-state="processing"],
#mic-btn[data-state="speaking"] {
  opacity: 0.55;
  cursor: wait;
}

#mic-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#mic-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
}

.mic-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.04); }
}

.composer-row #text-input {
  flex: 1;
  /* Was 0 (free to shrink to nothing before the mic/send buttons give up
     any of their own floor - see .composer-voice above). At the browser's
     normal width that's fine since the row itself never gets narrower than
     the viewport. But pinch-zoom.js's zoom-overflow correction only kicks
     in once the composer row is wide enough to force #app-shell past the
     viewport - with no floor here, #text-input just kept absorbing zoom's
     squeeze forever instead, collapsing to a column of single characters
     well before that ever happened. A real floor gives the row something
     to overflow on, so the zoom correction actually engages before the
     text box turns illegible. */
  min-width: 3.5rem;
  /* Fixed, not content-driven - there's no autosize.js anymore. Matches
     mic/send's own height here; the @container rule below swaps this to
     their combined stacked height once they stack, so the text box is
     never taller than the actions sitting beside it either way. Text past
     what fits scrolls (overflow-y: auto) instead of growing the box. */
  height: var(--composer-btn-size, 52px);
  padding: 0.5rem 0.65rem;
  line-height: 1.35;
  border-radius: 12px;
  resize: none;
  overflow-y: auto;
  /* Overrides the shared input rule's --surface: #controls (this box's
     container) is --surface too now, so the text box needs its own,
     lighter tier to still read as a raised field rather than blending
     into the bar around it. */
  background: var(--surface-2);
}

.btn-send {
  /* See .composer-voice above: shrinks like #text-input now instead of
     forcing all the squeeze onto the text box, down to a floor that
     still fits the "Send" label. */
  flex-shrink: 1;
  min-width: 3.8rem;
  height: var(--composer-btn-size, 52px);
  min-height: var(--composer-btn-size, 52px);
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--btn-radius);
  padding: 0 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-send:hover:not(:disabled, [aria-disabled="true"]),
#mic-btn[data-state="idle"]:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, var(--text)); }
.btn-send:active:not(:disabled, [aria-disabled="true"]) { opacity: 0.8; }
.btn-send:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn-send:disabled,
.btn-send[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* Below this width, mic + send no longer fit beside a readable text box
   (#text-input's own floor above is 3.5rem, but that's a last resort, not
   a comfortable reading width). Stack mic above send instead of continuing
   to squeeze #text-input - this is what pinch-zoom.js's width compensation
   can trigger well before #text-input's floor would otherwise force zoom
   itself to back off. The breakpoint is a comfortable #text-input width
   (6rem) plus mic-btn's width (--composer-btn-size, 2.875rem) and
   .btn-send's floor (3.8rem), with their --composer-gap gaps (0.4rem
   each) - recompute if any of those change.
   Stacked, #text-input's height matches mic + send's own combined height
   (each --composer-btn-size tall, stacked with the same --composer-gap
   between them) instead of one button's height, but is fixed either way -
   never taller than whichever arrangement of actions sits beside it. */
@container composer (max-width: 13.5rem) {
  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* Stretch mic-btn to the column's full width (matching .btn-send, which
     already stretches since it has no width of its own) instead of
     staying at its own icon-only width - .composer-voice's own
     align-items: center (for centering the icon inside mic-btn) would
     otherwise keep mic-btn pinned to its natural size here. */
  .composer-voice {
    align-items: stretch;
  }

  #mic-btn {
    width: auto;
  }

  .composer-row #text-input {
    height: calc(var(--composer-btn-size, 52px) * 2 + var(--composer-gap, 0.4rem));
  }
}

/* ── Feedback ─────────────────────────────────────────────────────────────── */

/* Collapsed out of the flex flow while empty (the steady state once
   feedback has loaded) so #screen-feedback's own row `gap` doesn't leave a
   dead band above/below an invisible element - same class of bug as
   #status above, but here the flex `gap` (unlike #status's plain block
   flow) still reserves space around an empty item unless it's removed
   from flow entirely. */
#status-feedback:empty {
  display: none;
}

#status-feedback {
  font-size: 0.85em;
  color: var(--primary);
}

/* Overall | Your conversation (feedback-view.js). Underline + bold on the
   selected tab, not colour alone. */
.feedback-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.feedback-tabs [role="tab"] {
  flex: 1;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: var(--btn-radius) var(--btn-radius) 0 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.feedback-tabs [role="tab"][aria-selected="true"] {
  border-bottom-color: var(--primary);
  color: var(--text);
  font-weight: 700;
}

.feedback-tabs [role="tab"]:hover { background: var(--surface-2); }

.feedback-panel { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.feedback-panel h2 { font-size: 0.95em; color: var(--primary); margin-top: 0.75rem; }
.feedback-panel p  { line-height: 1.6; }

/* Under a section's heading when the coach wrote it about one of the
   trainee's practice goals (goals.js's goalBadge()). */
.feedback-panel .feedback-goal-badge {
  align-self: flex-start;
  margin: 0;
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--goal-hue) 20%, var(--surface));
  color: var(--text);
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1.6;
}

.feedback-section-body { margin: 0; }

.feedback-points {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.6;
}

.feedback-points li + li { margin-top: 0.35rem; }

/* The note the Overall tab ends on. */
.feedback-closing {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--good) 45%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--good) 12%, var(--surface));
}

.feedback-panel .feedback-closing h2 { margin-top: 0; color: var(--text); }
.feedback-closing-text { margin: 0.25rem 0 0; }

/* Your conversation: the chat's own bubbles, with each message's comments
   right under it, on the same side as the message. */
.feedback-transcript {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.feedback-transcript .message-body { margin: 0; }

.feedback-notes {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 85%;
  margin-bottom: 0.5rem;
}

.feedback-notes--user      { align-self: flex-end; }
.feedback-notes--assistant { align-self: flex-start; }

/* The kind is spelled out in .feedback-note-label; the right border only
   repeats it: green went well, --primary could try, muted grey for a
   neutral note on the trainer's message. */
.feedback-note {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-right: 4px solid var(--text-muted);
  border-radius: var(--btn-radius) 0 0 var(--btn-radius);
  background: var(--surface);
}

.feedback-note--strength   { border-right-color: var(--good); }
.feedback-note--suggestion { border-right-color: var(--primary); }

.feedback-panel .feedback-note p { margin: 0; }
.feedback-panel .feedback-note-label { font-size: 0.8em; font-weight: 700; }
.feedback-panel .feedback-note .feedback-example { margin: 0.5rem 0 0; }

.feedback-example-label {
  margin: 0 0 0.25rem;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Bold + underline + tint, not colour alone, so the emphasis still reads
   for users who can't tell the tint from the bubble behind it. */
.feedback-highlight {
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
  border-radius: 4px;
  padding: 0 0.15em;
}

/* Distinct from .plain-language-panel (which shares this same left-border
   callout shape but uses --primary) so the two aren't visually confused. */
.feedback-example {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.85rem;
  border-left: 3px solid var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  border-radius: 0 8px 8px 0;
}

.feedback-example-text {
  margin: 0;
  white-space: pre-wrap;
}

/* ── Motion ───────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .toggle-thumb    { transition: none; }
  .toggle          { transition: none; }
  #conversation    { scroll-behavior: auto; }
  #mic-btn[data-state="listening"] { animation: none; }
  #btn-end-interview.is-highlighted { animation: none; }
  .typing-dot { animation: none; opacity: 0.8; }
  .choice-card { transition: none; }
  .choice-card:active { transform: none; }
  .choice-card:has(.choice-input:checked) .choice-check { animation: none; }
}
