/* Sandbox call screen - standalone dark theme (this page does NOT load /assets/theme.css:
   the customer-facing sandbox is a dark "call in progress" experience, unlike the internal
   light reviewer/portal pages). The dark ramp is tinted toward PG brand ink (#1f3131) rather
   than neutral charcoal. Accent is a bright PG teal-green (brand ramp: PG teal #006155 /
   accent #22a595, brightened for contrast); the primary CTA uses the PG signature lime
   (#98c441) on brand ink so the sandbox action color matches the rest of the product. */

:root {
  --bg: #0f1615; /* PG brand ink #1f3131 darkened; subtly teal, not neutral black */
  --panel: #182221;
  --panel-2: #212d2b;
  --line: #2c3a38;
  --text: #eef2f1;
  --muted: #93a5a1; /* AA on --bg */
  --accent: #2ec4a6; /* bright teal for accents/structure on dark */
  --accent-dim: rgba(46, 196, 166, 0.13);
  --accent-line: rgba(46, 196, 166, 0.42);
  --teal: #006155; /* brand teal - borders/fills */
  --teal-text: #35b39a; /* readable teal for labels/links on dark */
  --lime: #98c441; /* THE action color */
  --lime-hover: #88b338;
  --lime-ink: #1f3131; /* text on lime (AA); never white on lime */
  --danger: #e08573; /* coral, readable on dark */
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win: class rules here set `display` (e.g. .actions{display:flex},
 * .row), which silently override the UA `[hidden]{display:none}` default - so show(el,false)
 * (sets el.hidden=true) left .actions rows like #call-ended-row visible ("Start another call"
 * during a live call). Same guard as assets/theme.css. (UI audit wave 2.) */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  /* One atmospheric layer: a faint teal glow from the top so the page isn't a flat void. */
  background-image: radial-gradient(90% 55% at 50% -8%, rgba(0, 97, 85, 0.12), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  /* System stack only - a strict CSP (script-src 'self') blocks webfont CDNs, so a leading
     "Inter" never loaded and silently fell back anyway. */
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* Visible keyboard focus everywhere (dark-theme AA). */
:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  /* Brand accent bar (teal ramp), visible in every state incl. the sign-in gate and the fail
     card, so PG brand shows before auth. Teal-only on purpose: lime stays reserved for the one
     action per screen, so it never competes with the CTA below. Solid teal is the fallback. */
  border-bottom: 2px solid var(--accent);
  border-image: linear-gradient(90deg, var(--teal), var(--accent)) 1;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Connexus app mark, left of the wordmark. */
.topbar .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex: none;
  display: block;
}

.topbar .brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

header.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

header.topbar h1 .wordmark {
  color: var(--accent);
}

header.topbar h1 .sub {
  color: var(--muted);
  font-weight: 400;
}

.topbar .by-pg {
  color: #aebbb7;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* Signed-in affordance (top-right): the WorkOS user email + a Sign out button. Hidden until
   authenticated (the [hidden] guard above beats this display:flex). */
.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  color: var(--muted);
  font-size: 13px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 40px 24px 64px;
  min-height: calc(100vh - 58px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* Pre-call flow states (auth/setup/verify/dial-in): one narrow centered column so the page
   reads as a focused call console, not a form stretched across a dark void. The in-call
   stage below overrides back to full width. */
#auth-panel,
#sandbox-panel,
#verify-panel,
#dialin-panel {
  width: 100%;
  max-width: 560px;
  /* Optically center the (single, short) visible flow card in the viewport instead of pinning
     it to the top over a tall void. margin:auto in a flex column collapses to 0 if the card ever
     exceeds the height, so the top is never clipped (unlike justify-content:center). */
  margin-block: auto;
}

#call-stage {
  width: 100%;
}

/* Setup summary chip: the collapsed recap of the setup form, shown once the user advances so
   only the current step + its single action are on screen. */
.setup-summary {
  width: 100%;
  max-width: 560px;
  margin: 5vh auto 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}

.setup-summary-icon {
  flex: none;
  display: flex;
  color: var(--teal-text);
}

.setup-summary-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentcolor;
  fill: none;
}

.setup-summary-text {
  flex: 1;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.4;
}

.setup-summary-edit {
  flex: none;
  height: 32px;
  padding: 0 14px;
}

/* With the chip present, the following flow panel sits directly beneath it (the two read as one
   top-anchored group) instead of each auto-centering independently and drifting apart. */
.setup-summary:not([hidden]) ~ #verify-panel,
.setup-summary:not([hidden]) ~ #dialin-panel {
  margin-top: 0;
  margin-bottom: auto;
}

/* Field helper line (e.g. the selected persona's scenario under the picker). */
.field-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

/* Progress eyebrow at the top of each pre-call card (Set up -> Connect -> Talk), so a prospect
   sees the flow is short and where they are. */
.step-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.step-dots {
  display: inline-flex;
  gap: 5px;
}

.step-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}

.step-dots i.on {
  background: var(--accent);
}

.step-dots i.done {
  background: var(--teal-text);
}

/* ---- generic panels / forms (setup + verify + dial-in phases) ---- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 2px 0 24px;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  flex: 1;
  min-width: 180px;
}

select,
input {
  width: 100%;
  height: 44px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 15px;
  font-family: inherit;
}

/* Custom chevron (CSP img-src allows data:), so the mode/language selects look intentional
   rather than default OS chrome. appearance:none + right padding for the glyph. */
select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M1 1.5 7 7l6-5.5' stroke='%2393a5a1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

select:hover {
  border-color: var(--accent-line);
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder {
  color: #67736f;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background 0.12s,
    transform 0.08s;
}

.btn:hover:not(:disabled) {
  border-color: var(--teal-text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--lime-ink);
  height: 48px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--lime-hover);
  border-color: var(--lime-hover);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

/* One primary action per pre-call screen -> full width. */
#signin-btn,
#start-btn,
#call-btn {
  width: 100%;
}

/* Verify's inline buttons share a width so the phone + code inputs share a right edge. */
#send-code,
#verify-btn {
  min-width: 104px;
}

.btn-danger {
  background: #e5484d;
  border-color: #e5484d;
  color: #fff;
  font-weight: 600;
}

.btn-danger:hover {
  filter: brightness(1.08);
  border-color: #e5484d;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0 0;
}

/* Gate / failure state: a centered card (reuses .panel) instead of a naked red sentence.
   Neutral heading + one short red reason line + muted detail + retry + a PG contact footer.
   Built by fail() in app.js; shown for config/auth/org boot failures. */
.fail-card {
  max-width: 480px;
  margin: 15vh auto;
  text-align: center;
}

.fail-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.fail-reason {
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

.fail-actions {
  justify-content: center;
  margin: 0 0 16px;
}

.fail-footer {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

/* Topbar "Sign out": compact ghost so it never dominates or wraps. */
.user-box .btn {
  height: 34px;
  padding: 0 14px;
}

/* ---- signed-out hero (the product's front door) ---- */
.hero {
  text-align: center;
}

/* The front door earns a touch more presence: a soft teal halo behind the card lifts it off
   the flat void without adding any external asset (pure shadow, CSP-safe). */
#auth-panel.hero {
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.35),
    0 0 90px rgba(0, 97, 85, 0.2);
}

/* Brand mark centered above the sign-in headline, rounded like the app icon. */
.hero-mark {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: block;
  margin: 0 auto 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.hero h2 {
  font-size: 33px;
  letter-spacing: -0.02em;
  line-height: 1.14;
  margin: 0 0 14px;
  text-wrap: balance;
}

.hero-sub {
  font-size: 16px;
  color: var(--muted);
  margin: 0 auto 28px;
  max-width: 42ch;
  line-height: 1.55;
}

.hero .actions {
  justify-content: center;
}

.hero-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.hero-trust svg {
  flex: none;
  width: 14px;
  height: 14px;
  stroke: var(--teal-text);
  fill: none;
}

/* Hero "how it works": three quick steps, so a prospect knows what they're signing in to. */
.how-it-works {
  display: flex;
  gap: 10px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.how-it-works li {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: 14px 10px;
}

.how-icon {
  display: flex;
  color: var(--teal-text);
}

.how-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentcolor;
  fill: none;
}

.how-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---- language pair: "You speak  <->  They speak" ----
   Two EQUAL columns (grid 1fr/1fr, same gap as .row) so the seam between the two selects lands
   at the exact center - matching the Talk-to / Call-direction row below it (they were misaligned
   when this was a flex row that reserved width for the glyph). The swap button is absolutely
   positioned OVER the center gutter, so it's out of grid flow and doesn't steal column width. */
.lang-pair {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.lang-pair label {
  margin: 0;
}

/* Functional swap control (JS swaps source<->target) styled as a circular ghost badge so it
   reads as pressable, not decorative. Centered on the gutter, vertically on the select midline. */
.swap-glyph {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 50%);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--teal-text);
  cursor: pointer;
  transition:
    border-color 0.12s,
    color 0.12s;
}

.swap-glyph:hover {
  border-color: var(--teal-text);
  color: var(--text);
}

.swap-glyph svg {
  width: 16px;
  height: 16px;
  stroke: currentcolor;
  fill: none;
}

/* ---- storage disclosure: an inset note, not throwaway fine print ---- */
.disclosure {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--teal);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 4px 0 20px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.disclosure svg {
  flex: none;
  width: 16px;
  height: 16px;
  stroke: var(--teal-text);
  fill: none;
  margin-top: 1px;
}

.disclosure strong {
  color: var(--text);
  font-weight: 600;
}

/* ---- dial-in "ticket": the number + join code ARE the job of this screen ----
   Two matching inset steps (solid hairline, NOT dashed - dashed reads as coupon/dropzone), with
   numbered eyebrows so the sequence (call first, THEN enter the code) is explicit. */
.ticket {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ticket-step {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 16px 18px;
  text-align: center;
}

.ticket-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--teal);
  color: #eafaf6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.ticket-value-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.ticket-number {
  font-size: 27px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
}

.ticket-code {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
}

.copy-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.12s,
    color 0.12s;
}

.copy-btn:hover {
  border-color: var(--teal-text);
  color: var(--teal-text);
}

.copy-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentcolor;
  fill: none;
}

.copy-btn.copied {
  color: var(--teal-text);
  border-color: var(--teal-text);
}

/* Living cue so the dial-in screen (the one step with no button) doesn't feel dead-ended. */
.dialin-waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-line);
  animation: pulse-ring 1.8s ease-out infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(46, 196, 166, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(46, 196, 166, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(46, 196, 166, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot {
    animation: none;
  }
}

/* ---- flow-state mobile ---- */
@media (max-width: 640px) {
  main {
    padding: 24px 16px 48px;
  }

  .panel {
    padding: 24px 20px;
  }

  .panel h2 {
    font-size: 21px;
  }

  .hero h2 {
    font-size: 26px;
  }

  /* Stack the language pair; the swap button stays absolute, re-centered in the vertical gap
     between the two selects and rotated to point down. */
  .lang-pair {
    grid-template-columns: 1fr;
    gap: 38px;
  }

  .swap-glyph {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  /* Keep the DID on one line beside its copy button in the narrow card. */
  .ticket-number {
    font-size: 22px;
  }

  header.topbar {
    padding: 12px 16px;
  }

  header.topbar h1 {
    font-size: 15px;
  }
}

/* Very narrow: drop the email entirely (keep just Sign out) so the header never wraps. */
@media (max-width: 460px) {
  .user-email {
    display: none;
  }
}

/* ---- the in-call stage ---- */

#call-stage {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.call-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* The single source of call state on the stage: pulsing dot + label + timer. nowrap so
   "Call in progress" never breaks mid-phrase when the row wraps on a narrow screen. */
.call-state {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.call-state .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.call-state.ended .dot {
  background: var(--muted);
  animation: none;
}

.call-state .timer {
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* Redundant with the call-state label; raw status text ("active"/"completed") is engineer-speak
   on a customer console. Kept in the DOM (JS writes it) but not shown. */
#status-pill {
  display: none;
}

.pair-badge-row {
  display: flex;
  justify-content: center;
}

.pair-badge {
  padding: 6px 20px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: var(--accent-dim);
  color: var(--teal-text);
  font-size: 13px;
  font-weight: 600;
}

/* These pills are populated via textContent once the call config resolves; before that they
 * rendered as hollow outlined shells during the connecting state. Hide until they have text
 * (UI audit 2026-07-03). */
.pair-badge:empty,
.name-tag:empty,
.dir-pill:empty {
  display: none;
}

/* Three participants: Caller | AI Interpreter (hero) | AI assistant or second party. */
.stage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.stage-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 26px 20px;
  min-height: 200px;
}

/* Caller + partner avatars: a brand-tinted disc, not a flat gray video-tile placeholder. */
.stage-panel .avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  background: radial-gradient(circle at 50% 36%, rgba(46, 196, 166, 0.22), var(--panel-2) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-panel .avatar svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: #cdeee6;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Name centered BELOW the avatar (a clean participant card), not a floating bottom-left caption. */
.name-tag {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* The interpreter is the product - a teal-lit hero card between the two participants. */
.stage-panel.interpreter {
  background: linear-gradient(180deg, #18211f, #131a19);
  border-color: var(--accent-line);
  box-shadow: 0 0 50px rgba(0, 97, 85, 0.18);
  gap: 12px;
}

.interp-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 15px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
}

.interp-mark svg {
  width: 30px;
  height: 30px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2.3;
}

.stage-panel.interpreter h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.dir-pill {
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  color: var(--teal-text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.wave {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 46px;
}

.wave i {
  width: 5px;
  border-radius: 3px;
  background: var(--line);
  height: 20%;
}

/* Live: taller teal bars with a soft glow so the interpreter's center is unmistakably alive -
   this is the product's heartbeat, so it should out-weigh the label pills around it. */
.wave.active i {
  background: linear-gradient(180deg, var(--accent), var(--teal));
  filter: drop-shadow(0 0 6px rgba(46, 196, 166, 0.55));
  animation: wave 1.1s ease-in-out infinite;
}

.wave i:nth-child(1) {
  animation-delay: 0s;
}
.wave i:nth-child(2) {
  animation-delay: 0.15s;
}
.wave i:nth-child(3) {
  animation-delay: 0.3s;
}
.wave i:nth-child(4) {
  animation-delay: 0.45s;
}
.wave i:nth-child(5) {
  animation-delay: 0.6s;
}
.wave i:nth-child(6) {
  animation-delay: 0.75s;
}
.wave i:nth-child(7) {
  animation-delay: 0.9s;
}

@keyframes wave {
  0%,
  100% {
    height: 22%;
  }
  50% {
    height: 100%;
  }
}

/* A quiet reassurance caption, not a boxed callout competing with the pills. */
.latency-note {
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.stage-note {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.stage-note strong {
  color: var(--text);
  letter-spacing: 0.04em;
}

/* Respect reduced-motion for all the stage's live animation. */
@media (prefers-reduced-motion: reduce) {
  .call-state .dot,
  .live-dot,
  .wave.active i {
    animation: none;
  }
  .wave.active i {
    height: 60%;
  }
}

/* ---- transcript ---- */

/* Live = only the latest turn (with a subtle pulse). History = the full finalized log.
   The pulse marks the live pane as the in-flight view vs the static history. */
.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

/* One transcript pane: the full log in a fixed-height frame; lines scroll inside it. */
.transcript-panel {
  height: 340px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}

.transcript-panel > h3 {
  flex: none;
}

.transcript-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin-top: 12px;
  /* Fade the top edge so older lines scroll away gracefully; the newest (bottom) stays crisp. */
  mask-image: linear-gradient(to bottom, transparent 0, #000 16px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.transcript-lines::-webkit-scrollbar {
  width: 8px;
}

.transcript-lines::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.transcript-lines::-webkit-scrollbar-track {
  background: transparent;
}

/* In-call conversation-starter tip: a first line for a solo caller (dismissible). */
.call-tip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
}

.call-tip-text {
  flex: 1;
}

.call-tip-x {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.call-tip-x:hover {
  color: var(--text);
}

.call-tip-x svg {
  width: 15px;
  height: 15px;
  stroke: currentcolor;
  fill: none;
}

.t-entry {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
}

.t-entry.right {
  align-self: flex-end;
  align-items: flex-end;
  text-align: right;
}

/* Per-speaker chip (sentence case, not tracked all-caps): caller neutral, AI / partner teal. */
.t-speaker {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
}

.t-entry.right .t-speaker {
  align-self: flex-end;
}

.t-entry.assistant .t-speaker,
.t-entry.partner .t-speaker {
  color: var(--teal-text);
  border-color: var(--accent-line);
  background: var(--accent-dim);
}

.t-text {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  display: inline-block;
}

.t-entry.right .t-text {
  background: var(--accent-dim);
  border-color: var(--accent-line);
}

/* The translation output: an inline language tag + italic teal text, attached to its turn. */
.t-translation {
  font-size: 13.5px;
  color: var(--teal-text);
  padding: 0 12px;
  font-style: italic;
}

.t-xlation-tag {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 5px;
}

/* The current (in-flight) turn while the call is live: a soft accent ring on its bubble. */
#call-stage:not(.ended) .t-entry.current .t-text {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 1px var(--accent-line);
}

.t-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 12px;
  text-align: center;
  line-height: 1.5;
}

/* Active-speaker glow: the panel of whoever last spoke lights up (caller / interpreter / partner). */
.stage-panel.speaking {
  border-color: var(--accent-line);
  box-shadow: 0 0 34px rgba(0, 97, 85, 0.28);
}

.stage-panel.speaking .avatar {
  border-color: var(--accent);
}

/* Post-call summary: duration / turns / language pair, shown when the call ends. */
.call-summary {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.summary-stat {
  flex: 1;
  min-width: 120px;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Ended: the console powers down - gray the live dot, dim the participants + badge, settle the
   wave to a flat line - so a finished call never looks live (a truth cue on a trust surface). */
#call-stage.ended .live-dot {
  background: var(--muted);
  animation: none;
}

#call-stage.ended .avatar,
#call-stage.ended .pair-badge,
#call-stage.ended .interp-mark,
#call-stage.ended .dir-pill {
  opacity: 0.5;
}

#call-stage.ended .wave i {
  height: 4px;
}

@media (max-width: 900px) {
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    min-height: 150px;
  }

  /* Size the transcript to its content (up to a cap) rather than a rigid 340px frame. */
  .transcript-panel {
    height: auto;
    max-height: 320px;
  }

  .summary-stat {
    max-width: none;
  }
}

@media (max-width: 640px) {
  /* Keep the timer + End call reachable during a live call without scrolling back up. */
  .call-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    padding: 10px 0;
  }

  /* Compress the two human panels to short rows (avatar left, name right) so the transcript
     rises instead of sitting screens down. The interpreter hero keeps its full column. */
  .stage-panel:not(.interpreter) {
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    min-height: 0;
    padding: 14px 18px;
  }

  .stage-panel:not(.interpreter) .avatar {
    width: 54px;
    height: 54px;
  }

  .stage-panel:not(.interpreter) .avatar svg {
    width: 26px;
    height: 26px;
  }
}
