:root {
  --primary: #4a5cff;
  --primary-soft: #e9ecff;
  --tertiary: #ff7a59;
  --tertiary-soft: #ffe7df;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --border: #e3e5ec;
  --error: #A23A2E;
  --success: #1f9d55;
  --recording: #e23a3a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 6px 30px rgba(20,30,80,0.06);
  margin-bottom: 16px;
}

h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.error { color: var(--error); margin-top: 8px; min-height: 1.2em; font-size: 14px; }
/* When the same <p class="error"> is being used for a non-error gating hint
   (e.g. "Pick the other person's language to enable Start"), this class
   demotes it from alarm-red to a calm muted-blue so it reads as instruction
   rather than failure. Toggled by app.js updateStartGate(). */
.error.hint { color: var(--primary); font-weight: 500; }

.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.hidden { display: none !important; }

input, select, button {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: white;
  margin: 8px 0;
}
input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

button {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease;
  -webkit-user-select: none;
  user-select: none;
}
button:hover { background: #3a4cdf; }
button:active { transform: scale(0.99); }
button:disabled { background: #c5cad8; cursor: not-allowed; }

button.link {
  background: transparent;
  color: var(--primary);
  width: auto;
  padding: 6px 8px;
}
button.link:hover { background: var(--primary-soft); }

button.swap {
  background: transparent;
  color: var(--muted);
  width: 44px; height: 44px;
  margin: 4px auto;
  padding: 0;
  border-radius: 22px;
  border: 1px solid var(--border);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
button.swap:hover { background: var(--bg); color: var(--text); }

.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tab {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  margin: 0;
}
.tab.active { background: var(--primary); color: white; }

label { display: block; color: var(--muted); font-size: 13px; margin-top: 12px; }
label select { margin-top: 4px; color: var(--text); }
label input, label textarea { margin-top: 4px; color: var(--text); }

textarea {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: white;
  resize: vertical;
  min-height: 60px;
}

.setup-section { margin-top: 16px; }
.setup-section .setup-label {
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em;
}
details.advanced > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 0;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "▸ "; transition: transform 0.1s; }
details.advanced[open] > summary::before { content: "▾ "; }

.domain-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 4px;
}
.domain-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 4px;
  margin: 0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
}
.domain-btn .dom-icon { font-size: 22px; }
.domain-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.domain-btn:hover { background: var(--primary-soft); color: var(--primary); }
.domain-btn.active:hover { background: var(--primary); color: white; }

.toggle-row { margin-top: 10px; }
.toggle {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 14px; color: var(--text); cursor: pointer;
}
.toggle input[type="checkbox"] {
  width: auto; margin: 4px 0 0 0;
  accent-color: var(--primary);
}
.toggle span small { display: block; color: var(--muted); font-size: 12px; }

.domain-badge {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 4px 12px;
  width: fit-content;
  margin: 0 auto 12px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 12px 0;
}
.qa-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 4px;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
}
.qa-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* Big prominent End Session control at the bottom of the convo card, plus
   a Pause/Resume control beside it. Replaces the tiny header "End" link
   that testers couldn't find — Lina's feedback (2026-04-27) was specifically
   "I dont see end session". The buttons are unmistakable now: full-width,
   danger-red end + neutral pause, with a pulsing recording-style red dot
   on End and a short help line underneath. */
.end-session-bar {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.session-controls-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .session-controls-row { grid-template-columns: 1fr; }
}
.pause-session-btn,
.resume-session-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 16px 14px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 14px;
  cursor: pointer;
  margin: 0;
  transition: background 0.12s, border-color 0.12s;
}
.pause-session-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.resume-session-btn {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.resume-session-btn:hover { background: #0e8a6f; border-color: #0e8a6f; }
.end-session-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--error);
  color: #fff;
  border: none;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 14px;
  cursor: pointer;
  margin: 0;
  box-shadow: 0 4px 14px rgba(211,61,61,0.25);
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}
.end-session-btn:hover {
  background: #b91c1c;
  box-shadow: 0 6px 20px rgba(211,61,61,0.35);
}
.end-session-btn:active { transform: translateY(1px); }
.end-session-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.end-session-btn .end-dot {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  animation: end-dot-pulse 1.6s ease-in-out infinite;
}
@keyframes end-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.end-session-help {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.45;
}

.export-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.export-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  padding: 10px 6px;
  margin: 0;
  border-radius: 10px;
}
.export-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* Picker beta-recording transparency notice — surfaces above the explainer
   so users see it BEFORE they decide to start a session. Soft red background
   to match the "we're recording" semantic without being alarming. */
.picker-recording-notice {
  background: rgba(211,61,61,0.06);
  border: 1px solid rgba(211,61,61,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 6px 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-700);
}
.picker-recording-notice strong { color: var(--error); }

/* Picker mental-model explainer (top of /picker). Reframes the page from
   "settings" to "two real people in a real conversation" — testers were
   consistently mistaking the picker for a chatbot output-language preference
   until this banner went in. */
.picker-explainer {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 10px 0 18px;
}
.picker-explainer-icon {
  font-size: 24px;
  line-height: 1.1;
  flex-shrink: 0;
  white-space: nowrap;
}
.picker-explainer-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 4px;
}
.picker-explainer-body {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.picker-explainer-body em { color: var(--primary); font-style: normal; font-weight: 600; }
.picker-explainer-body strong { color: var(--primary); }
/* Deep-link from picker into /help#how-a-session-works — sized small so it
   reads as a footnote to the explainer, not a CTA competing with Start session. */
.picker-explainer-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dotted var(--primary);
  padding-bottom: 1px;
}
.picker-explainer-link:hover { color: var(--primary); border-bottom-style: solid; }

/* Participant cards in setup. Each card represents a real person with a name
   and a language they speak. The first card is the host ("YOU SPEAK"); the
   rest are the other party ("OTHER PERSON SPEAKS" when there are exactly 2,
   "PERSON N SPEAKS" for 3+ way conversations). The card framing — versus
   the old single-line rows — is what makes "two distinct people" register. */
#participant-list { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.participant-card {
  background: var(--bg);
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.participant-card[data-role="host"] {
  border-color: var(--primary);
  background: linear-gradient(0deg, var(--bg) 0%, rgba(74,92,255,0.04) 100%);
}
.pc-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.participant-card[data-role="host"] .pc-badge { color: var(--primary); }
.pc-badge .swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.pc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pc-fields label { font-size: 12px; font-weight: 500; color: var(--muted); display: block; margin-bottom: 4px; }
.pc-fields input, .pc-fields select { margin: 0; padding: 9px 10px; font-size: 14px; width: 100%; box-sizing: border-box; }
/* Visual cue on the language <select> when it's still the empty placeholder —
   draws the eye to the unfinished decision the user must make to start. */
.pc-fields select.needs-pick {
  border-color: var(--gold);
  background: rgba(201,150,58,0.06);
  box-shadow: 0 0 0 2px rgba(201,150,58,0.15);
}
@media (max-width: 480px) { .pc-fields { grid-template-columns: 1fr; } }

/* v0.2.26 — gender selector. Two-pill toggle group sitting between the
 * fields grid and the action buttons. Pills inherit Tuareg-indigo theme;
 * active state uses saffron fill. Touch-friendly 44px+ tap targets. */
.pc-gender-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 4px;
}
.pc-gender-row > label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
  flex: 0 0 auto;
}
.gender-pills {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.gender-pill {
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 38px;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.gender-pill + .gender-pill {
  border-left: 1px solid var(--border);
}
.gender-pill:hover { background: var(--primary-soft); }
.gender-pill.active {
  background: var(--gold, #D4A030);
  color: var(--navy, #283655);
  font-weight: 700;
}
.gender-pill:focus-visible {
  outline: 2px solid var(--gold, #D4A030);
  outline-offset: 2px;
}
.pc-actions { display: flex; gap: 8px; align-items: center; }
.pc-actions .voice-btn {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 8px 12px;
  font-size: 12px;
  margin: 0;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 500;
}
.pc-actions .voice-btn.registered { background: var(--success); color: white; border-color: var(--success); }
.pc-actions .voice-btn.recording {
  background: var(--recording); color: white; border-color: var(--recording);
  animation: pulse 1s ease-out infinite;
}
.pc-actions .remove-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 13px;
  padding: 8px 12px;
  margin: 0 0 0 auto;
  border-radius: 10px;
  font-weight: 500;
}
.pc-actions .remove-btn:hover { background: rgba(211,61,61,0.1); color: var(--error); border-color: var(--error); }

/* Visual middle marker between cards: "↔ Iris translates between you" — only
   appears when there are exactly 2 cards, where the symmetry is the point. */
.pc-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: -4px 0;
}
.pc-divider::before, .pc-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* Legacy .participant-row class — kept around in case any old cached SPA code
   tries to render against it; not used by current app.js. */
.participant-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr auto auto;
  gap: 6px;
  align-items: center;
  background: var(--bg);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.participant-row .swatch {
  width: 28px; height: 28px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.08);
  margin: 0;
}
.participant-row input, .participant-row select {
  margin: 0;
  padding: 8px 10px;
  font-size: 14px;
}
.participant-row .voice-btn {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 8px 10px;
  font-size: 12px;
  margin: 0;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 500;
}
.participant-row .voice-btn.registered {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.participant-row .voice-btn.recording {
  background: var(--recording);
  color: white;
  border-color: var(--recording);
  animation: pulse 1s ease-out infinite;
}
.participant-row .remove-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 18px;
  width: 28px; height: 28px;
  padding: 0; margin: 0;
  border-radius: 50%;
}
.participant-row .remove-btn:hover { background: rgba(211,61,61,0.1); color: var(--error); }

.ghost-btn {
  background: transparent;
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 10px;
  border-radius: 12px;
  margin-top: 8px;
  font-weight: 500;
  font-size: 13px;
}
.ghost-btn:hover { background: var(--primary-soft); }

/* Conversation: participant chips at top */
.party-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.party-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--bg);
  color: var(--text);
}
.party-chip .dot { width: 8px; height: 8px; border-radius: 4px; }

/* Admin page */
.users-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin-table th, table.admin-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.admin-table th { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
table.admin-table td.actions { white-space: nowrap; }
table.admin-table .row-act {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 10px;
  font-size: 12px;
  margin: 0 2px 0 0;
  border-radius: 8px;
  width: auto;
}
table.admin-table .row-act:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
table.admin-table .row-act:disabled { opacity: 0.4; cursor: not-allowed; }
table.admin-table .delete-btn:hover { background: rgba(211,61,61,0.1); color: var(--error); border-color: var(--error); }
table.admin-table select.role-pick {
  width: auto;
  padding: 4px 6px;
  margin: 0;
  font-size: 12px;
  border-radius: 8px;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.me-tag { font-size: 10px; background: var(--success); color: white; padding: 1px 6px; border-radius: 999px; margin-left: 4px; }

.create-user-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.create-user-grid input { margin: 0; }
.create-user-grid select { margin: 0; }
.create-user-grid button { grid-column: 1 / -1; margin: 4px 0 0; }

.audit-wrap { max-height: 320px; overflow-y: auto; padding: 4px 0; }
.audit-row {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
  display: grid;
  grid-template-columns: 150px 160px 1fr;
  gap: 8px;
}
.audit-row:last-child { border-bottom: none; }
.audit-row .audit-action { color: var(--primary); font-weight: 600; }
.audit-row .audit-detail { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.link-btn {
  display: inline-block;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  text-decoration: none;
  margin-right: 8px;
  padding: 4px 8px;
  border-radius: 6px;
}
.link-btn:hover { background: var(--primary-soft); }

/* Multi-translation block inside a bubble */
.bubble .translation-block { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(0,0,0,0.08); }
.bubble .translation-block + .translation-block { border-top-style: dashed; }

.bubble.editable { cursor: pointer; position: relative; }
.bubble.editable::after {
  content: "✎";
  position: absolute; top: 6px; right: 8px;
  font-size: 11px; color: var(--muted); opacity: 0;
  transition: opacity 0.1s;
}
.bubble.editable:hover::after { opacity: 0.7; }
.bubble.redacted::before {
  content: "⚠ contains redacted PHI";
  display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px;
}

/* ====== Mic / hands-free area ====== */
#mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 12px;
  position: relative;
}

.mic-btn {
  width: 110px;
  height: 110px;
  border-radius: 55px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 2;
  transition: background 0.2s ease, transform 0.1s ease;
}
.mic-btn:hover { background: #3a4cdf; }

.mic-btn.listening {
  background: var(--success);
}
.mic-btn.recording {
  background: var(--recording);
}
.mic-btn.translating {
  background: var(--tertiary);
}
.mic-btn.playing {
  background: #1f76d8;
}

#mic-pulse {
  position: absolute;
  width: 110px;
  height: 110px;
  top: 24px;
  border-radius: 55px;
  background: rgba(74,92,255,0.25);
  z-index: 1;
  opacity: 0;
  transform: scale(1);
  pointer-events: none;
}
.mic-btn.recording ~ #mic-pulse {
  background: rgba(226,58,58,0.3);
  animation: pulse 1.2s ease-out infinite;
  opacity: 1;
}
.mic-btn.listening ~ #mic-pulse {
  background: rgba(31,157,85,0.3);
  animation: pulse 2s ease-out infinite;
  opacity: 1;
}
@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.7); opacity: 0; }
}

.status {
  text-align: center;
  margin: 18px 8px 4px;
  font-size: 14px;
  color: var(--muted);
  min-height: 2.5em;
  line-height: 1.4;
}

.turns {
  min-height: 80px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  max-width: 88%;
  font-size: 15px;
}
.bubble.source { background: var(--primary-soft); align-self: flex-start; }
.bubble.target { background: var(--tertiary-soft); align-self: flex-end; }
.bubble.interpreter {
  align-self: center;
  background: #ececec;
  color: #4a4a4a;
  text-align: center;
  font-size: 14px;
  max-width: 92%;
  border: 1px dashed #c2c5cd;
}
.bubble.interpreter .lang { color: #6b7280; }
.bubble.interpreter .translated { font-style: normal; border-top: none; padding-top: 0; margin-top: 4px; }
.bubble .lang { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.bubble .original { color: var(--text); }
.bubble .translated { font-style: italic; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(0,0,0,0.08); }

.title-row { font-weight: 600; }

.summary {
  white-space: pre-wrap;
  font-family: inherit;
  background: var(--bg);
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
  color: var(--text);
}

#history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.history-item {
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}
.history-item:hover { background: var(--primary-soft); }
.history-item .title { font-weight: 600; }
.history-item .meta { color: var(--muted); font-size: 12px; }

/* ----- PWA Phase 3: safe-area insets + display-mode + landscape -----
 * iPhone notch / home indicator can otherwise crop pinned UI when the page is
 * loaded with viewport-fit=cover. We pad body left/right by max(existing, safe-
 * area-inset). Bottom inset is critical so the End/Pause buttons don't sit
 * underneath the home indicator. Top inset matters when the PWA runs in
 * standalone mode (no browser chrome above).
 */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
/* Standalone-only adjustments: when the PWA is launched from the home screen,
 * we own the whole viewport — so the body's top/bottom pad against the device
 * insets (notch + home indicator) instead of the browser handling it. */
@media all and (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}
/* Landscape on phones / small tablets: the convo card was portrait-first.
 * In landscape, prefer a 2-column layout (status/controls on left, transcript
 * scroll on right) so we use the horizontal real estate. Keep small screens
 * (sub-tablet) collapsed to a single column. */
@media (orientation: landscape) and (max-height: 540px) and (min-width: 640px) {
  #convo > .card {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 2fr;
    column-gap: 16px;
    align-items: start;
  }
  #convo > .card > .convo-header,
  #convo > .card > .session-controls-row,
  #convo > .card > .domain-badge,
  #convo > .card > #convo-status,
  #convo > .card > #party-chips,
  #convo > .card > .quick-actions-row {
    grid-column: 1;
  }
  #convo > .card > #turns {
    grid-column: 2;
    grid-row: 1 / span 999;
    max-height: 88vh;
    overflow-y: auto;
  }
}
