:root {
  --bg: #15261C;
  --app-bg: #13211A;
  --bg-soft: #1E3328;
  --surface: #18271D;
  --surface-2: #1F3025;
  --ink: #F1F2EC;
  --ink-2: #AAB9B0;
  --ink-3: #7E9C8C;
  --line: #2A3A30;
  --accent: #C8A038;
  --accent-hover: #DDB44A;
  --accent-soft: rgba(200, 160, 56, 0.15);
  --user-bubble: #26392D;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 44px rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --display: "Playfair Display", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --serif: "Source Serif 4", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  --topbar-h: 56px;
  --disclaimer-h: 36px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--app-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  padding-top: var(--topbar-h);
  padding-bottom: var(--disclaimer-h);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea { font-family: inherit; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--app-bg);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #DDB44A, #C8A038);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.25);
}
.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0;
  color: var(--ink);
}
.new-chat {
  font-size: 13px;
  color: var(--ink-2);
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all .15s ease;
}
.new-chat:hover { background: var(--surface); color: var(--ink); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.topbar-btn:hover { background: var(--surface); color: var(--ink); }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}
.link-btn:hover { opacity: 0.8; }

.restore-banner {
  max-width: 760px;
  margin: 8px auto 0;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
}

/* ===== Chat shell ===== */
.chat-shell {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 56px 8px 32px;
}
.hero.collapsed { display: none; }
.hero h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 40px;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  color: var(--ink);
}
.hero .accent { color: var(--accent); font-style: italic; }
.hero h1 .accent { white-space: nowrap; }
.hero-br { display: none; }
.hero-sub {
  color: var(--ink-2);
  font-size: 15px;
  margin: 0;
}

/* ===== Messages ===== */
.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 12px 0 32px;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }
.bubble {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15.5px;
  line-height: 1.65;
  word-wrap: break-word;
}
.msg.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
}
.msg.assistant .bubble {
  background: transparent;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  padding-left: 0;
  padding-right: 0;
  max-width: 100%;
}
.msg.assistant .bubble.thinking {
  color: var(--ink-3);
  font-style: italic;
}
.msg.assistant .bubble .cursor {
  display: inline-block;
  width: 8px;
  height: 18px;
  background: var(--accent);
  vertical-align: -3px;
  margin-left: 2px;
  animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ===== Composer ===== */
.composer-wrap {
  position: sticky;
  bottom: var(--disclaimer-h);
  background: linear-gradient(to top, var(--app-bg) 62%, rgba(21, 38, 28, 0));
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  z-index: 5;
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 10px 10px 10px 18px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: border-color .15s ease;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
  max-height: 200px;
  padding: 8px 0;
  color: var(--ink);
}
.composer textarea::placeholder { color: var(--ink-3); }

.composer-actions { display: flex; gap: 6px; align-items: center; }
.mic-btn, .send-btn {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all .15s ease;
}
.mic-btn { color: var(--ink-2); }
.mic-btn:hover { background: var(--bg-soft); color: var(--ink); }
.mic-btn.recording {
  color: #14130C;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

/* ===== Push-to-talk mode ===== */
.ptt-btn {
  display: none;
  flex: 1;
  height: 44px;
  border-radius: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: background .12s ease, transform .08s ease;
}
.composer.ptt-mode textarea { display: none; }
.composer.ptt-mode .ptt-btn { display: inline-flex; }
.composer.ptt-mode #uploadBtn,
.composer.ptt-mode #sendBtn { display: none; }
.composer.ptt-mode { align-items: center; }
.ptt-btn.pressing {
  background: var(--accent);
  color: #14130C;
  transform: scale(0.985);
}
.ptt-btn .ptt-label::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 1px;
}
.ptt-btn.pressing .ptt-label::before {
  background: #14130C;
  animation: pulseDot 1s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.7); }
}

/* mic-btn icon swap: show keyboard when in PTT mode */
.mic-btn .icon-keyboard { display: none; }
.composer.ptt-mode .mic-btn .icon-mic { display: none; }
.composer.ptt-mode .mic-btn .icon-keyboard { display: block; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 160, 56, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(200, 160, 56, 0); }
}
.send-btn {
  background: var(--accent);
  color: #14130C;
}
.send-btn:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}
.send-btn:not(:disabled):hover { background: var(--accent-hover); }

/* ===== Chips ===== */
.chips {
  max-width: 760px;
  margin: 12px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chips.hidden { display: none; }

/* ===== Chips: home (centred) vs docked (above the composer) ===== */
.chips-home { width: 100%; display: flex; justify-content: center; }
.chips-home:empty, .chips-dock:empty { display: none; }
.chips-dock { max-width: 760px; margin: 0 auto 10px; }

/* Home / empty state: float the hero + chips into the vertical middle so the
   conversation starters are the first thing a visitor sees. */
body:not(.chat-started) .chat-shell { justify-content: center; }
body:not(.chat-started) .messages { flex: 0 0 auto; }
body:not(.chat-started) .chips-home .chips { margin: 22px auto 0; }
body:not(.chat-started) .chip { font-size: 14px; padding: 9px 17px; }

/* Started state: chips become a slim scrollable row right above the composer. */
body.chat-started .chips {
  margin: 0;
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
body.chat-started .chips::-webkit-scrollbar { display: none; }
body.chat-started .chips-dock .chip { flex-shrink: 0; }
.chip {
  font-size: 13px;
  color: var(--ink-2);
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  transition: all .15s ease;
  white-space: nowrap;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.chip-cta {
  background: var(--accent);
  border-color: var(--accent);
  color: #14130C;
  font-weight: 600;
}
.chip-cta:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #14130C;
}

/* ===== Landing start orb (home CTA) ===== */
/* Landing + intake are input-free: the composer only appears once the user
   chooses to enter the open AI consultation (body.consulting). */
body:not(.consulting) .composer-wrap { display: none; }
body:not(.consulting) .messages { padding-bottom: 44px; }
.chips:empty { display: none; }

.start-orb-wrap {
  display: flex;
  justify-content: center;
  margin-top: 42px;
}
.start-orb {
  position: relative;
  width: 224px;
  height: 224px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 36%, rgba(200, 160, 56, 0.22), transparent 60%),
    radial-gradient(circle at 50% 54%, #20342A 0%, #1A2B21 68%, #142219 100%);
  border: 1px solid rgba(200, 160, 56, 0.34);
  box-shadow:
    0 0 0 1px rgba(200, 160, 56, 0.10),
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.start-orb:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: rgba(200, 160, 56, 0.6);
  box-shadow:
    0 0 0 1px rgba(200, 160, 56, 0.18),
    0 24px 64px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.start-orb:active { transform: scale(0.99); }
.orb-ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid rgba(200, 160, 56, 0.45);
  animation: orbPulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes orbPulse {
  0%   { transform: scale(0.92); opacity: 0.7; }
  70%  { transform: scale(1.13); opacity: 0; }
  100% { opacity: 0; }
}
.orb-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.orb-heart {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
  animation: heartBeat 1.7s ease-in-out infinite;
}
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.17); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.12); }
  56%      { transform: scale(1); }
}
.orb-label {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.orb-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}

/* ===== Post-plan consultation CTA ===== */
.consult-cta {
  align-self: stretch;
  margin: 6px 0 4px;
  background:
    radial-gradient(120% 150% at 50% 0%, rgba(200, 160, 56, 0.13), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  animation: stepIn .3s ease-out;
}
.consult-cta-text {
  font-family: var(--serif);
  font-size: 15.5px;
  color: var(--ink);
  line-height: 1.5;
  max-width: 460px;
}
.consult-cta-btn {
  background: var(--accent);
  color: #14130C;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 26px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .08s ease;
}
.consult-cta-btn:hover { background: var(--accent-hover); }
.consult-cta-btn:active { transform: scale(0.97); }

@media (max-width: 640px) {
  :root { --disclaimer-h: 54px; }
  .disclaimer-bar { font-size: 11px; padding: 6px 12px; }
  .start-orb { width: 190px; height: 190px; }
  .orb-label { font-size: 19px; }
}

.footer-note {
  max-width: 760px;
  margin: 10px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ===== Always-on medical disclaimer bar (every page, every state) ===== */
.disclaimer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  min-height: var(--disclaimer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 18px;
  text-align: center;
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.32;
  color: var(--ink-2);
  background: rgba(15, 26, 19, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: left .24s cubic-bezier(.4, 0, .2, 1);
}

/* ===== Reasoning steps (Stage 2) ===== */
.reasoning {
  font-family: var(--sans);
  font-size: 13.5px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 14px;
  color: var(--ink-2);
}
.reasoning-head {
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.reasoning-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  line-height: 1.5;
  animation: stepIn .25s ease-out;
}
.reasoning-arrow {
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: none; }
}

/* ===== Inline chips (assistant suggested next steps) ===== */
.inline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.inline-chip {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent-soft);
  padding: 7px 14px;
  border-radius: 999px;
  transition: all .15s ease;
  white-space: nowrap;
}
.inline-chip:hover {
  background: var(--accent);
  color: #14130C;
  border-color: var(--accent);
}
.inline-chip.input-chip { border-style: dashed; }

/* Inline "type your own answer" box, revealed by tapping a ✎ input chip. */
.chip-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 2px;
}
.chip-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  padding: 9px 15px;
  outline: none;
}
.chip-input:focus { border-color: var(--accent); }
.chip-input-send {
  flex: 0 0 auto;
  width: 40px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #14130C;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: filter .15s ease;
}
.chip-input-send:hover { filter: brightness(1.06); }

.prose.error { color: #b94a3a; font-style: italic; }

/* ===== Markdown elements inside .prose ===== */
.prose p { margin: 0 0 12px; }
.prose p:last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 16px 0 8px;
  line-height: 1.3;
  color: var(--ink);
}
.prose h1 { font-size: 22px; }
.prose h2 { font-size: 19px; }
.prose h3 { font-size: 17px; }
.prose h4, .prose h5, .prose h6 { font-size: 15.5px; }
.prose ul, .prose ol { margin: 6px 0 12px; padding-left: 22px; }
.prose li { margin: 2px 0; line-height: 1.55; }
.prose li > p { margin: 0 0 4px; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.prose a:hover { text-decoration-thickness: 2px; }
.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}
.prose pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
.prose blockquote {
  margin: 10px 0 14px;
  padding: 4px 14px;
  border-left: 3px solid var(--accent-soft);
  color: var(--ink-2);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

/* ===== Risk6 cards (Stage 3 structured report) ===== */
.risk6-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 4px;
  font-family: var(--sans);
}
.risk-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: stepIn .28s ease-out;
}
.risk-card.risk-low      { border-left-color: #4f9d7a; }
.risk-card.risk-moderate { border-left-color: #d9a13a; }
.risk-card.risk-high     { border-left-color: #c54a3a; }
.risk-card.risk-unknown  { border-left-color: var(--ink-3); opacity: .82; }
.risk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.risk-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.risk-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
}
.risk-card.risk-low      .risk-badge { background: rgba(79, 157, 122, 0.18); color: #7FCBA1; }
.risk-card.risk-moderate .risk-badge { background: rgba(217, 161, 58, 0.18); color: #E2B557; }
.risk-card.risk-high     .risk-badge { background: rgba(197, 74, 58, 0.20); color: #E59182; }
.risk-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.risk-score {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
  flex-shrink: 0;
  min-width: 56px;
}
.risk-unit {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  margin-left: 2px;
}
.risk-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.risk-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--ink-3);
  border-radius: 999px;
  transition: width .45s ease-out;
}
.risk-card.risk-low      .risk-bar-fill { background: #4f9d7a; }
.risk-card.risk-moderate .risk-bar-fill { background: #d9a13a; }
.risk-card.risk-high     .risk-bar-fill { background: #c54a3a; }
.risk-note {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.45;
}
.risk-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.risk-source-chip {
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 999px;
}

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

/* ===== Action cards (Stage 4) ===== */
.actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 4px;
  font-family: var(--sans);
}
.actions-head {
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  animation: stepIn .28s ease-out;
}
.action-card.action-book      { border-left-color: #c54a3a; }
.action-card.action-calendar  { border-left-color: #d9a13a; }
.action-card.action-search    { border-left-color: #4f9d7a; }
.action-card.action-subscribe { border-left-color: #6a82c9; }
.action-card.action-info      { border-left-color: var(--ink-3); }
.action-left {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.action-emoji {
  font-size: 22px;
  line-height: 1;
}
.action-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.action-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-value {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
}
.action-btn {
  flex-shrink: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  transition: background .15s ease, transform .08s ease;
}
.action-btn:hover { background: var(--accent); }
.action-btn:active { transform: scale(0.96); }

@media (max-width: 640px) {
  .action-card { padding: 10px; gap: 10px; }
  .action-emoji { font-size: 20px; }
  .action-title { font-size: 13px; }
  .action-value { font-size: 12px; }
  .action-btn { padding: 6px 11px; font-size: 12px; }
}

/* ===== Inline appointment-request flow (book action cards) ===== */
.action-card { flex-wrap: wrap; }
.booking-panel {
  flex-basis: 100%;
  width: 100%;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--sans);
  animation: stepIn .2s ease-out;
}
.booking-label { font-size: 12.5px; color: var(--ink-2); }
.booking-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-soft);
  outline: none;
}
.booking-input:focus { border-color: var(--accent); background: var(--surface); }
.booking-actions { display: flex; gap: 8px; }
.booking-confirm {
  background: var(--accent);
  color: #14130C;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  transition: background .15s ease;
}
.booking-confirm:hover { background: var(--accent-hover); }
.booking-confirm:disabled { background: var(--line); color: var(--ink-3); cursor: not-allowed; }
.booking-cancel {
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.booking-cancel:hover { background: var(--surface); color: var(--ink); }
.booking-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.booking-ok {
  font-size: 13px;
  color: #7FCBA1;
  background: rgba(79, 157, 122, 0.14);
  border: 1px solid rgba(79, 157, 122, 0.34);
  border-radius: 10px;
  padding: 9px 12px;
  line-height: 1.45;
}
.booking-error {
  font-size: 13px;
  color: #E59182;
  background: rgba(197, 74, 58, 0.14);
  border: 1px solid rgba(197, 74, 58, 0.34);
  border-radius: 10px;
  padding: 9px 12px;
}
.action-card.booked { opacity: .92; }

/* Time-slot chooser (shown before submitting a booking) */
.slot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.slot-btn {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
  white-space: nowrap;
}
.slot-btn:hover { border-color: var(--accent); color: var(--accent); }
.slot-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #14130C;
}
.slot-more {
  align-self: flex-start;
  font-size: 12.5px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 2px 2px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.slot-more:hover { opacity: .8; }

/* Hospital-confirmation notification card (in patient chat) */
.booking-notif {
  font-family: var(--sans);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: stepIn .28s ease-out;
}
.booking-notif-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.booking-notif-body {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ===== File upload pill ===== */
.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ink);
  max-width: 100%;
}
.file-pill .file-icon { font-size: 16px; }
.file-pill .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}
.file-status {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
}
.file-status.error { color: #b94a3a; }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .brand-name { font-size: 16px; }
  .chat-shell { padding: 0 16px; }
  .hero { padding: 36px 4px 20px; }
  .hero h1 { font-size: 28px; }
  .hero-br { display: inline; }
  .hero-sub { font-size: 14px; }
  .msg.assistant .bubble { font-size: 16px; }
  .bubble { font-size: 15px; max-width: 92%; }
  .composer-wrap { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 22px; padding: 8px 8px 8px 14px; }
  .composer textarea { font-size: 16px; }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0 2px 4px;
    margin-top: 10px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  /* Home/empty state on phones: do NOT horizontal-scroll — wrap the chips onto
     multiple centred rows so they all fit. (The nowrap scroll above is only for
     the slim docked row above the composer once a chat has started.) */
  body:not(.chat-started) .chips {
    flex-wrap: wrap;
    overflow-x: visible;
    justify-content: center;
    padding: 0 6px;
    row-gap: 10px;
  }
  body:not(.chat-started) .chip {
    flex-shrink: 1;
    font-size: 12px;
    padding: 7px 12px;
    white-space: nowrap;
  }
  .footer-note { font-size: 11px; padding: 0 8px; }
}

/* ===== Left sidebar (Claude-style navigation) ===== */
:root { --sidebar-w: 264px; }

.nav-no-anim, .nav-no-anim * { transition: none !important; }
body { transition: padding-left .24s cubic-bezier(.4, 0, .2, 1); }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--app-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform .24s cubic-bezier(.4, 0, .2, 1);
  overflow-y: auto;
}
body.nav-open .sidebar { transform: translateX(0); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(40, 60, 50, 0.38);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 150;
}
body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 2px 0 4px;
  margin-bottom: 4px;
}
.sb-collapse, .nav-toggle {
  width: 34px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--ink-2);
  transition: background .15s ease, color .15s ease;
}
.sb-collapse:hover, .nav-toggle:hover { background: var(--accent-soft); color: var(--ink); }

.sidebar-newchat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--accent);
  color: #14130C;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .08s ease;
}
.sidebar-newchat:hover { background: var(--accent-hover); }
.sidebar-newchat:active { transform: scale(.985); }
.sidebar-newchat svg { flex-shrink: 0; }

.sb-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.sb-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px 12px 4px;
}
.sb-recent { display: flex; flex-direction: column; gap: 2px; }
.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
  text-align: left;
  width: 100%;
  background: none;
  transition: background .15s ease, color .15s ease;
}
.sb-link:hover { background: var(--accent-soft); color: var(--ink); }
.sb-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sb-link svg { flex-shrink: 0; opacity: .85; }

.sb-spacer { flex: 1; min-height: 12px; }

.sb-account {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sb-auth-actions { display: flex; flex-direction: column; gap: 8px; }
.sb-signin {
  display: block;
  text-align: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #14130C;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.sb-signin:hover { background: var(--accent-hover); }
.sb-create {
  display: block;
  text-align: center;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13.5px;
  text-decoration: none;
}
.sb-create:hover { background: var(--surface); color: var(--ink); }

.sb-user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 8px; }
.sb-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #DDB44A, #C8A038);
  color: #14130C;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.sb-user-meta { min-width: 0; flex: 1; }
.sb-user-name { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout {
  width: 100%;
  text-align: center;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
}
.sb-logout:hover { background: var(--surface); color: var(--ink); }

.topbar-left { display: flex; align-items: center; gap: 8px; }

/* Desktop: sidebar pushes content instead of overlaying */
@media (min-width: 900px) {
  .topbar { transition: left .24s cubic-bezier(.4, 0, .2, 1); }
  body.nav-open { padding-left: var(--sidebar-w); }
  body.nav-open .topbar { left: var(--sidebar-w); }
  body.nav-open .disclaimer-bar { left: var(--sidebar-w); }
  body.nav-open .sidebar-backdrop { opacity: 0; pointer-events: none; }
  body.nav-open .topbar .brand { display: none; }
}

@media (max-width: 899px) {
  .sidebar { box-shadow: var(--shadow-md); }
}
