/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Three clean levels — ground, lifted, highest */
  --bg:           #d6c9b2;   /* ground — warm stone, sidebar recedes here too */
  --surface:      #f0e6d4;   /* cards — lifted off the ground */
  --surface-high: #f8f2e8;   /* topbar + bottombar — highest */
  --surface2:     #d6c9b2;   /* alias for sidebar = same as bg, naturally recedes */
  --border:       #bfb09a;
  --border-light: #d0c2aa;

  --gold:         #b87418;
  --gold-bright:  #d4920a;
  --gold-glow:    rgba(184, 116, 24, 0.15);

  --sticky:       #ffe566;
  --sticky-dark:  #c8a800;

  --text:         #221408;
  --text-muted:   #6a5030;
  --text-dim:     #a89070;

  /* Shadows — warm-tinted, not grey */
  --shadow-sm:    0 1px 3px rgba(80, 50, 10, 0.10), 0 1px 2px rgba(80, 50, 10, 0.08);
  --shadow-md:    0 4px 12px rgba(80, 50, 10, 0.12), 0 2px 4px rgba(80, 50, 10, 0.08);
  --shadow-top:   0 2px 16px rgba(80, 50, 10, 0.14), 0 1px 4px rgba(80, 50, 10, 0.10);
  --shadow-card:  0 2px 8px rgba(80, 50, 10, 0.10), 0 1px 2px rgba(80, 50, 10, 0.07);
  --shadow-press: 0 1px 2px rgba(80, 50, 10, 0.08);

  --red:          #c94a2e;
  --red-glow:     rgba(201, 74, 46, 0.12);
  --green:        #3a8a50;

  --radius-sm:    10px;
  --radius:       16px;
  --radius-lg:    22px;

  --topbar-h:     96px;
  --sidebar-w:    100px;
  --bottombar-h:  72px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  user-select: none;
}

/* ── Sentence Bar — top, full width ──────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface-high);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  z-index: 100;
  box-shadow: var(--shadow-top);
}

#sentence-display {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-height: 62px;
  display: flex;
  align-items: center;
  box-shadow: inset 0 2px 4px rgba(80, 50, 10, 0.08);
}

#sentence-text {
  font-size: 1.2rem;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  width: 100%;
}

#sentence-text.placeholder {
  color: var(--text-dim);
  font-style: italic;
  font-size: 1rem;
}

/* Subtle pulse when hidden trigger fires — child sees it, caretaker won't notice */
#sentence-text.trigger-pulse {
  animation: trigger-pulse 0.9s ease-out forwards;
}

@keyframes trigger-pulse {
  0%   { color: var(--text);        }
  30%  { color: var(--gold-bright); }
  100% { color: var(--text);        }
}

/* Speak button in topbar — prominent */
#btn-speak-top {
  flex-shrink: 0;
  width: 62px;
  height: 62px;
  border-radius: var(--radius);
  border: 1.5px solid var(--gold);
  background: var(--gold-glow);
  color: var(--gold-bright);
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#btn-speak-top:active {
  background: var(--gold);
  color: var(--bg);
  transform: scale(0.94);
}

/* ── Left sidebar — categories ───────────────────────────────── */
#category-nav {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: var(--bottombar-h);
  width: var(--sidebar-w);
  background: var(--surface2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  z-index: 90;
  box-shadow: inset -2px 0 8px rgba(80, 50, 10, 0.04);
}

#category-nav::-webkit-scrollbar { display: none; }

.cat-btn {
  width: 100%;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cat-btn .cat-emoji { font-size: 1.4rem; }

.cat-btn:active {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold-bright);
  transform: scale(0.96);
}

.cat-btn.active {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* ── Symbol Grid — center hero ───────────────────────────────── */
#symbol-grid {
  position: fixed;
  top: var(--topbar-h);
  left: var(--sidebar-w);
  right: 0;
  bottom: var(--bottombar-h);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 4), 1fr);
  gap: 12px;
  align-content: start;
}

.symbol-card {
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.1s, box-shadow 0.12s;
  padding: 14px 10px 12px;
  min-height: 150px;
  box-shadow: var(--shadow-card);
}

.symbol-card:active {
  background: var(--gold-glow);
  border-color: var(--gold);
  transform: scale(0.93);
  box-shadow: var(--shadow-press);
}

.symbol-card.flash {
  background: var(--gold-glow);
  border-color: var(--gold-bright);
}

.symbol-pic {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.symbol-emoji {
  font-size: 3rem;
  line-height: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.symbol-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  flex-shrink: 0;
}

/* ── Bottom bar — grounded, balanced ─────────────────────────── */
#bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottombar-h);
  background: var(--surface-high);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 16px;
  gap: 10px;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(80, 50, 10, 0.10);
}

.bar-btn {
  flex: 1;
  max-width: 120px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  transition: all 0.12s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bar-btn:active {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold-bright);
  transform: scale(0.95);
}

.bar-btn .bar-icon { font-size: 1.2rem; }

/* Help bar button — warm red, stands out but doesn't scream */
#bar-help {
  border-color: var(--red);
  color: var(--red);
  background: rgba(201, 74, 46, 0.08);
}

#bar-help:active {
  background: var(--red-glow);
  color: #fff;
  border-color: var(--red);
}

/* Hold-to-clear progress ring */
#bar-clear {
  position: relative;
  overflow: visible;
}

#clear-progress {
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0s;
}

#clear-progress.filling {
  width: 100%;
  transition: width 0.9s linear;
}

/* ── Keyboard Overlay ────────────────────────────────────────── */
#keyboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: flex-end;
  z-index: 200;
}

#keyboard-inner {
  background: var(--surface);
  width: 100%;
  padding: 20px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#keyboard-inner h3 {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#keyboard-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.1rem;
  padding: 14px;
  resize: none;
  font-family: inherit;
}

#keyboard-input:focus {
  outline: none;
  border-color: var(--gold);
}

#keyboard-actions { display: flex; gap: 10px; }

#keyboard-actions button {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: inherit;
}

#kb-speak { background: var(--gold);    color: var(--bg); }
#kb-add   { background: var(--green);   color: #fff;      }
#kb-close { background: var(--surface2); color: var(--text-muted);
            border: 1px solid var(--border-light); }

/* ── Help Modal — Choose Path ────────────────────────────────────── */
#help-modal, #help-sent-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
}

#help-modal-inner, #help-sent-inner {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 24px 28px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  border: 1.5px solid var(--border-light);
}

#help-modal-icon { font-size: 3rem; margin-bottom: 16px; }

#help-modal-inner h2, #help-sent-inner h2 {
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 10px;
  font-weight: 700;
}

#help-modal-inner p, #help-sent-inner p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 22px;
}

#help-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-choice-btn {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.12s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--surface2);
  color: var(--text);
}

.help-choice-btn:active { transform: scale(0.97); }

.help-choice-icon { font-size: 1.4rem; flex-shrink: 0; }
.help-choice-text { flex: 1; }

.help-choice-btn.general {
  background: var(--surface2);
  border-color: var(--border-light);
}

.help-choice-btn.general:active {
  background: var(--gold-glow);
  border-color: var(--gold);
}

/* Private path — stands out but isn't alarming */
.help-choice-btn.private {
  background: rgba(58, 138, 80, 0.08);
  border-color: var(--green);
  color: var(--text);
}

.help-choice-btn.private:active {
  background: rgba(58, 138, 80, 0.18);
}

.help-choice-btn.cancel {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  justify-content: center;
  padding: 10px;
}

#help-sent-ok {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 40px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ── Private Safety Channel ──────────────────────────────────────── */
#private-channel-modal {
  position: fixed;
  inset: 0;
  /* Deliberately different from the rest of the app — child knows this is a safe space */
  background: #1a1108;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 310;
  padding: 24px;
}

#pc-inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

#pc-shield {
  font-size: 3.5rem;
  animation: shield-breathe 3s ease-in-out infinite;
}

@keyframes shield-breathe {
  0%, 100% { transform: scale(1);    opacity: 1;    }
  50%       { transform: scale(1.08); opacity: 0.85; }
}

#pc-heading {
  font-size: 1.6rem;
  font-weight: 800;
  color: #f5e6c8;
  line-height: 1.2;
}

#pc-subtext {
  font-size: 0.9rem;
  color: #a08060;
  line-height: 1.7;
  max-width: 320px;
}

#pc-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.pc-option {
  width: 100%;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1.5px solid #3a2a14;
  background: #241a0c;
  color: #f0ddb8;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 0.15s;
  line-height: 1.35;
}

.pc-option:active {
  background: #3a2a14;
  border-color: #c8860a;
  color: #ffe9b0;
  transform: scale(0.98);
}

#pc-back {
  background: transparent;
  border: none;
  color: #6a4f30;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 16px;
  margin-top: 4px;
}

#pc-back:active { color: #a08060; }

/* ── Private Sent — "You are brave" ─────────────────────────────── */
#private-sent-modal {
  position: fixed;
  inset: 0;
  background: #1a1108;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 320;
  padding: 24px;
}

#ps-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  position: relative;
}

/* Warm radial glow behind the heart */
#ps-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,146,10,0.18) 0%, transparent 70%);
  pointer-events: none;
  animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -60%) scale(1);    }
  50%       { opacity: 1;   transform: translate(-50%, -60%) scale(1.15); }
}

#ps-heart {
  font-size: 4.5rem;
  animation: heart-beat 2.2s ease-in-out infinite;
  position: relative;
}

@keyframes heart-beat {
  0%, 100% { transform: scale(1);    }
  14%       { transform: scale(1.12); }
  28%       { transform: scale(1);    }
  42%       { transform: scale(1.06); }
}

#ps-inner h2 {
  font-size: 2rem;
  font-weight: 800;
  color: #f5e6c8;
  line-height: 1.1;
  position: relative;
}

#ps-inner p {
  color: #c8a060;
  font-size: 1rem;
  line-height: 1.6;
  position: relative;
}

.ps-sub {
  color: #a08060 !important;
  font-size: 0.88rem !important;
}

#ps-ok {
  margin-top: 16px;
  padding: 16px 48px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #3a2a14;
  background: #241a0c;
  color: #f0ddb8;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  position: relative;
}

#ps-ok:active {
  background: #3a2a14;
  border-color: #c8860a;
}

/* ── More button ─────────────────────────────────────────────── */
.more-card {
  border-style: dashed;
  border-color: var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
}

.more-card .symbol-emoji {
  color: var(--gold);
  font-size: 2rem !important;
}

/* ── Kiosk badge ─────────────────────────────────────────────────── */
#kiosk-badge {
  flex-shrink: 0;
  font-size: 1rem;
  opacity: 0.35;
  padding: 0 4px;
  user-select: none;
  pointer-events: none;
}

/* ── Setup toggle ────────────────────────────────────────────────── */
.setup-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.setup-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}

.setup-toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

/* ── AI Sentence Button ──────────────────────────────────────────── */
#btn-ai {
  flex-shrink: 0;
  width: 62px;
  height: 62px;
  border-radius: var(--radius);
  border: 1.5px solid var(--gold-bright);
  background: linear-gradient(135deg, rgba(184,116,24,0.18), rgba(212,146,10,0.22));
  color: var(--gold-bright);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  animation: ai-pulse 2.4s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(184, 116, 24, 0.25), var(--shadow-sm);
}

@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(184, 116, 24, 0.22), var(--shadow-sm); }
  50%       { box-shadow: 0 0 24px rgba(212, 146, 10, 0.50), var(--shadow-sm); }
}

#btn-ai:active {
  background: var(--gold);
  color: var(--bg);
  transform: scale(0.93);
}

#btn-ai.loading {
  animation: none;
  opacity: 0.6;
  cursor: not-allowed;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

/* ── PIN Modal ───────────────────────────────────────────────────── */
#pin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 24px;
}

#pin-inner {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  border: 1.5px solid var(--border-light);
  box-shadow: var(--shadow-md);
}

#pin-inner h2 {
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 700;
}

#pin-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

#pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all 0.15s;
}

.pin-dot.filled {
  background: var(--gold);
  border-color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(184, 116, 24, 0.4);
}

#pin-error {
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 4px;
  min-height: 1.2em;
}

#pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.pin-key {
  height: 58px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}

.pin-key:active {
  background: var(--gold-glow);
  border-color: var(--gold);
  transform: scale(0.93);
}

.pin-key.pin-special {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ── Provider Setup Modal ────────────────────────────────────────── */
#setup-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 350;
  display: flex;
  flex-direction: column;
}

#setup-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

#setup-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

#setup-home-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.12s;
}

#setup-home-link:hover { color: var(--text-muted); }

#setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-high);
  flex-shrink: 0;
}

#setup-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

#setup-close {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: inherit;
}

#setup-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}

.setup-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.setup-section h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold-bright);
  font-weight: 700;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.setup-hint {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.setup-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.setup-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.setup-input:focus { border-color: var(--gold); }

.key-status {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.key-status.ok      { background: rgba(58,138,80,0.12); color: var(--green); }
.key-status.missing { background: rgba(201,74,46,0.06);  color: var(--text-muted); }

#setup-save {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--gold);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: inherit;
  transition: all 0.15s;
  margin-top: 4px;
}

#setup-save:active { transform: scale(0.97); }

#setup-saved {
  text-align: center;
  color: var(--green);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px;
}

/* ── AI button locked state ──────────────────────────────────────── */
#btn-ai.locked {
  opacity: 0.7;
  border-style: dashed;
}

/* ── Upgrade Prompt ──────────────────────────────────────────────── */
#upgrade-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
}

#upgrade-inner {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 28px 32px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  border: 1.5px solid var(--border-light);
}

#upgrade-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: ai-pulse 2s ease-in-out infinite;
}

#upgrade-inner h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

#upgrade-inner p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 10px;
}

.upgrade-plan-note {
  font-size: 0.82rem !important;
  color: var(--gold-bright) !important;
  font-weight: 600;
  margin-bottom: 24px !important;
}

#upgrade-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#upgrade-go {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gold);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#upgrade-cancel {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ── Plans Modal ─────────────────────────────────────────────────── */
#plans-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 350;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#plans-inner {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#plans-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#plans-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

#plans-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

#plans-close {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#plans-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.plan-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.plan-card.plan-featured {
  border-color: var(--gold-bright);
  background: linear-gradient(160deg, var(--surface-high), var(--surface));
  box-shadow: 0 4px 20px rgba(184, 116, 24, 0.18), var(--shadow-card);
}

.plan-badge {
  position: absolute;
  top: -11px;
  left: 20px;
  background: var(--gold);
  color: var(--bg);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 20px;
}

.plan-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.plan-featured .plan-name {
  color: var(--gold-bright);
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
}

.plan-amount {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.plan-period {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-features .feat {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.plan-features .feat::before {
  content: "✓";
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  color: var(--green);
}

.plan-features .feat.no {
  opacity: 0.45;
}

.plan-features .feat.no::before {
  content: "–";
  color: var(--text-dim);
  font-weight: 400;
}

.plan-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}

.plan-btn:active { transform: scale(0.97); }
.plan-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.plan-btn-primary {
  background: var(--gold);
  border-color: var(--gold-bright);
  color: var(--bg);
  font-size: 0.95rem;
  box-shadow: 0 2px 12px rgba(184, 116, 24, 0.3);
}

.plan-btn-dark {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface-high);
}

#setup-open-plans {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gold);
  background: var(--gold-glow);
  color: var(--gold-bright);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}

#setup-open-plans:active { transform: scale(0.97); }

#plans-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0 10px;
}

/* ── Provider Dashboard ──────────────────────────────────────────── */
#dashboard-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 360;
  display: flex;
  flex-direction: column;
}

#db-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

#db-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-high);
  flex-shrink: 0;
  gap: 12px;
}

#db-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

#db-user-name {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

#db-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#db-seed, #db-close {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: inherit;
}

#db-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

/* ── Stat cards ── */
#db-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.db-stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, background 0.2s;
}

.db-stat-card.db-stat-alert {
  border-color: var(--red);
  background: rgba(201, 74, 46, 0.06);
}

.db-stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.db-stat-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
}

/* ── Sections ── */
.db-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border-light);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.db-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.db-empty {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
  padding: 6px 0;
}

/* ── Alert rows ── */
.db-alert-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.db-alert-row:last-child { border-bottom: none; }

.db-alert-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }

.db-alert-reason {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.db-alert-meta { font-size: 0.74rem; color: var(--text-muted); }

/* ── Communication rows ── */
.db-comm-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.db-comm-row:last-child { border-bottom: none; }

.db-comm-left  { flex-shrink: 0; width: 22px; text-align: center; margin-top: 1px; }
.db-ai-tag     { font-size: 0.95rem; }
.db-sym-tag    { font-size: 0.68rem; color: var(--text-dim); }

.db-comm-text  { font-size: 0.88rem; color: var(--text); font-weight: 500; margin-bottom: 3px; line-height: 1.4; }
.db-comm-meta  { font-size: 0.74rem; color: var(--text-muted); }

/* ── Bar charts ── */
.db-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.db-bar-row:last-child { margin-bottom: 0; }

.db-bar-label {
  width: 88px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.db-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 4px;
}

.db-bar-cat {
  background: linear-gradient(90deg, var(--gold-bright), var(--gold));
}

.db-bar-count {
  width: 34px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

/* ── Dashboard button in setup ── */
#setup-open-dashboard {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--gold);
  background: var(--gold-glow);
  color: var(--gold-bright);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}

#setup-open-dashboard:active { transform: scale(0.97); }

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Grid columns via CSS variable ──────────────────────────── */
:root { --grid-cols: 4; }

/* ── Profile body modifiers ──────────────────────────────────── */
body.large-targets .symbol-card  { min-height: 175px; }
body.large-targets .symbol-emoji { font-size: 3.5rem; }
body.large-targets .symbol-label { font-size: 0.8rem; }

/* Large targets — sidebar + bottom bar scale up too */
body.large-targets {
  --bottombar-h: 88px;
}
body.large-targets .cat-btn             { padding: 13px 4px; }
body.large-targets .cat-btn .cat-emoji  { font-size: 1.8rem; }
body.large-targets .cat-btn             { font-size: 0.8rem; }
body.large-targets .bar-btn             { height: 66px; font-size: 0.9rem; }
body.large-targets .bar-btn .bar-icon   { font-size: 1.5rem; }

body.high-contrast {
  --bg:           #0c0c0c;
  --surface:      #1a1a1a;
  --surface-high: #222;
  --surface2:     #111;
  --border:       #444;
  --border-light: #333;
  --text:         #f0f0f0;
  --text-muted:   #b0b0b0;
  --text-dim:     #777;
}

body.reduced-animations .symbol-card         { transition: none; }
body.reduced-animations .symbol-card.flash   { animation: none; background: var(--gold-glow); }
body.reduced-animations #btn-ai              { animation: none; }
body.reduced-animations #ps-glow            { animation: none; }
body.reduced-animations #pc-shield          { animation: none; }

/* ── Password Gate ───────────────────────────────────────────── */
#password-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

#pw-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 300px;
  text-align: center;
}

#pw-logo { font-size: 3.5rem; }

#pw-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#pw-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: -6px;
}

#pw-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  padding: 16px 18px;
  font-family: inherit;
  outline: none;
  text-align: center;
  letter-spacing: 0.2em;
  margin-top: 10px;
  transition: border-color 0.15s;
}

#pw-input:focus { border-color: var(--gold); }

#pw-submit {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--gold);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 12px rgba(184, 116, 24, 0.3);
  transition: transform 0.12s;
}

#pw-submit:active { transform: scale(0.97); }

#pw-error {
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── Onboarding Overlay ──────────────────────────────────────── */
#onboarding-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ob-card {
  width: 100%;
  max-width: 520px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header: app name + progress bar + skip */
#ob-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-high);
  flex-shrink: 0;
}

#ob-app-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--gold-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

#ob-progress-track {
  flex: 1;
  height: 4px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

#ob-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
}

#ob-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

#ob-home-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 0.12s;
}

#ob-home-link:hover,
#ob-home-link:active { color: var(--text-muted); }

#ob-skip-setup {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
}

#ob-skip-setup:active { color: var(--text-muted); }

/* Step content — scrollable */
#ob-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px 24px 16px;
}

/* Footer: back + next */
#ob-footer {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-high);
}

#ob-back-btn {
  padding: 16px 22px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
  flex-shrink: 0;
}

#ob-back-btn:active { border-color: var(--gold); color: var(--gold-bright); }

#ob-next-btn {
  flex: 1;
  padding: 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--gold);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.12s;
  box-shadow: 0 2px 12px rgba(184, 116, 24, 0.3);
}

#ob-next-btn:active   { transform: scale(0.97); }
#ob-next-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Welcome screen ──────────────────────────────────────────── */
.ob-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 8px 0;
  gap: 20px;
}

.ob-welcome-icon {
  font-size: 4rem;
  animation: heart-beat 3s ease-in-out infinite;
}

.ob-welcome-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
}

.ob-welcome-body {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 340px;
}

.ob-welcome-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  text-align: left;
  margin-top: 4px;
}

.ob-welcome-feat {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.ob-wf-icon { font-size: 1.2rem; flex-shrink: 0; }

.ob-wf-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.4;
}

.ob-welcome-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  max-width: 300px;
  text-align: center;
  line-height: 1.5;
}

/* ── Question wrapper ────────────────────────────────────────── */
.ob-qwrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ob-question {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.ob-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.ob-optional {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
}

/* ── Text input ──────────────────────────────────────────────── */
.ob-text-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.15rem;
  padding: 16px 18px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.ob-text-input:focus { border-color: var(--gold); }

/* ── Single-select choices ───────────────────────────────────── */
.ob-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ob-choice {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-light);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  transition: border-color 0.12s, background 0.12s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.ob-choice:active { transform: scale(0.98); }

.ob-choice.ob-selected {
  border-color: var(--gold-bright);
  background: var(--gold-glow);
  color: var(--text);
}

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

.ob-choice-label { flex: 1; font-weight: 700; }

.ob-choice-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-top: 2px;
  line-height: 1.3;
}

/* Multi-select: selected has a checkmark feel */
.ob-choice-multi.ob-selected {
  border-color: var(--gold-bright);
  background: var(--gold-glow);
}

/* ── Diagnosis list ──────────────────────────────────────────── */
.ob-diag-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ob-diag-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--gold-bright);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.ob-diag-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ob-diag-item {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-bottom: none;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  line-height: 1.3;
}

.ob-diag-item:first-of-type { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ob-diag-item:last-of-type  {
  border-bottom: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.ob-diag-item:only-of-type  { border-radius: var(--radius-sm); border-bottom: 1px solid var(--border-light); }

.ob-diag-item:active { background: var(--gold-glow); }

.ob-diag-item.ob-selected {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--text);
}

/* ── Contact fields ──────────────────────────────────────────── */
.ob-contact-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ob-field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ── Done screen ─────────────────────────────────────────────── */
.ob-done-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  padding: 16px 0;
}

.ob-done-icon {
  font-size: 4rem;
  animation: heart-beat 2.2s ease-in-out infinite;
}

.ob-done-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}

.ob-done-config {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.ob-done-bullet {
  font-size: 0.86rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}

.ob-done-bullet::first-letter { color: var(--green); font-weight: 800; }

.ob-launch-btn {
  width: 100%;
  padding: 18px;
  border-radius: var(--radius);
  border: none;
  background: var(--gold);
  color: var(--bg);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 18px rgba(184, 116, 24, 0.4);
  transition: transform 0.12s;
}

.ob-launch-btn:active { transform: scale(0.97); }

.ob-done-note {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Keyboard-forward mode ───────────────────────────────────── */
body.keyboard-forward #bar-keyboard {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: var(--gold-glow);
  flex: 1.8;
  font-weight: 800;
}

/* ── Custom interest category placeholder ────────────────────── */
.custom-cat-placeholder {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 52px 28px;
  gap: 14px;
}

.ccp-icon  { font-size: 3rem; }

.ccp-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  text-transform: capitalize;
}

.ccp-body {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 260px;
}

/* ── Redo setup button (in Provider Settings) ────────────────── */
.setup-redo-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}

.setup-redo-btn:active {
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* ── Private sent — crisis box ───────────────────────────────── */
.ps-safety-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}

#ps-crisis-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0;
}

.ps-crisis-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.ps-crisis-link {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  transition: border-color 0.12s;
}

.ps-crisis-link:active { border-color: var(--gold); }

.ps-crisis-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
}

/* ── Password gate — learn more link ─────────────────────────── */
#pw-bottom-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.pw-link-sep {
  color: var(--text-dim);
  font-size: 0.78rem;
}

#pw-home-link,
#pw-learn-more {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}

#pw-home-link:active,
#pw-learn-more:active { color: var(--text-muted); }

/* ── About section in Provider Settings ──────────────────────── */
.setup-about-section .about-links-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.about-link-btn {
  flex: 1;
  min-width: 140px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  text-align: center;
  display: block;
  transition: border-color 0.12s, color 0.12s;
}

.about-link-btn:active { border-color: var(--gold); color: var(--gold-bright); }

.about-crisis-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.about-crisis-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.about-crisis-sep { color: var(--border); }

/* ── About / FAQ Modal ───────────────────────────────────────── */
#about-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 550;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
}

#about-inner {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  background: var(--surface-high);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#about-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

#about-logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#about-tagline {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 3px;
}

#about-header button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

#about-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.about-section { display: flex; flex-direction: column; gap: 10px; }

.about-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--gold-bright);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.about-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.about-crisis-intro { margin-bottom: 4px; }

/* ── FAQ accordion ───────────────────────────────────────────── */
.faq-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.faq-q {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  gap: 10px;
  transition: background 0.1s;
}

.faq-q:active { background: var(--surface2); }

.faq-chevron {
  flex-shrink: 0;
  font-size: 1.1rem;
  color: var(--text-dim);
  transition: transform 0.2s;
  display: inline-block;
}

.faq-open .faq-chevron { transform: rotate(90deg); }

.faq-a {
  max-height: 0;
  overflow: hidden;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.7;
  background: var(--surface2);
  padding: 0 16px;
  transition: max-height 0.25s ease, padding 0.2s ease;
}

.faq-open .faq-a {
  max-height: 300px;
  padding: 12px 16px 14px;
}

/* ── Crisis resource list in about modal ─────────────────────── */
.crisis-resource-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crisis-resource {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color 0.12s;
}

.crisis-resource:active { border-color: var(--gold); }

.cr-icon { font-size: 1.4rem; flex-shrink: 0; padding-top: 2px; }

.cr-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.cr-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

/* ── About contact button ────────────────────────────────────── */
.about-contact-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: border-color 0.12s, color 0.12s;
}

.about-contact-btn:active { border-color: var(--gold); color: var(--gold-bright); }

.about-version {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 4px;
}

/* ── Background Themes ───────────────────────────────────────── */
body.theme-sky {
  --bg:           #d4e8f5;
  --surface:      #eaf4ff;
  --surface-high: #f4faff;
  --surface2:     #d4e8f5;
  --border:       #a8c8e0;
  --border-light: #c0d8ec;
  --text:         #08182a;
  --text-muted:   #325870;
  --text-dim:     #80a8be;
}

body.theme-meadow {
  --bg:           #cfe4cc;
  --surface:      #e8f5e4;
  --surface-high: #f2faee;
  --surface2:     #cfe4cc;
  --border:       #a0c49c;
  --border-light: #bcd8b8;
  --text:         #0a1e0c;
  --text-muted:   #305a34;
  --text-dim:     #80a880;
}

body.theme-lavender {
  --bg:           #dcd4f0;
  --surface:      #f0ecfc;
  --surface-high: #f8f6ff;
  --surface2:     #dcd4f0;
  --border:       #b8acd8;
  --border-light: #cec4e8;
  --text:         #150c2c;
  --text-muted:   #483870;
  --text-dim:     #9888c0;
}

body.theme-minimal {
  --bg:           #eeeeee;
  --surface:      #f8f8f8;
  --surface-high: #ffffff;
  --surface2:     #eeeeee;
  --border:       #cccccc;
  --border-light: #e0e0e0;
  --text:         #111111;
  --text-muted:   #444444;
  --text-dim:     #999999;
}
