/* EMedic AI design system */
:root {
  --bg: #f3f8f8;
  --bg-2: #e8f1f2;
  --surface: #ffffff;
  --surface-2: #f5f9fa;
  --ink: #0f1f2a;
  --muted: #5b6b78;
  --line: #dde8ea;
  --brand: #0f766e;
  --brand-2: #0e7490;
  --brand-3: #34d399;
  --brand-ink: #ffffff;
  --grad: linear-gradient(135deg, #0f766e 0%, #0e7490 55%, #1d4ed8 100%);
  --user-ink: #ffffff;
  --bot: #eef5f6;
  --agent: #e8f7ef;
  --agent-line: #1f9d5c;
  --warn: #d4493a;
  --ok: #1f9d5c;
  --amber: #c98400;
  --shadow-sm: 0 1px 2px rgba(23, 21, 43, 0.06);
  --shadow: 0 24px 60px -20px rgba(8, 80, 100, 0.35), 0 8px 20px -10px rgba(23, 21, 43, 0.12);
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Dark theme: follows the system unless the user picked one (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1419;
    --bg-2: #0f1c22;
    --surface: #12212a;
    --surface-2: #182a34;
    --ink: #e8f1f3;
    --muted: #93a8b3;
    --line: #253b46;
    --bot: #1a2e38;
    --agent: #15302a;
    --agent-line: #4cd492;
    --warn: #ff8a7a;
    --ok: #4cd492;
    --amber: #ffc861;
    --brand: #2dd4bf;
    --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), 0 8px 20px -10px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1419;
  --bg-2: #0f1c22;
  --surface: #12212a;
  --surface-2: #182a34;
  --ink: #e8f1f3;
  --muted: #93a8b3;
  --line: #253b46;
  --bot: #1a2e38;
  --agent: #15302a;
  --agent-line: #4cd492;
  --warn: #ff8a7a;
  --ok: #4cd492;
  --amber: #ffc861;
  --brand: #2dd4bf;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), 0 8px 20px -10px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
html.theme-anim, html.theme-anim * { transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease !important; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }

/* Soft aurora behind the app */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.45; animation: drift 18s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { width: 520px; height: 520px; background: #0e7490; top: -160px; left: -120px; }
.aurora span:nth-child(2) { width: 460px; height: 460px; background: #34d399; bottom: -180px; right: -100px; animation-delay: -6s; opacity: 0.3; }
.aurora span:nth-child(3) { width: 380px; height: 380px; background: #1d4ed8; top: 40%; left: 45%; animation-delay: -12s; opacity: 0.22; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.1); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .aurora span { opacity: 0.25; } }
:root[data-theme="dark"] .aurora span { opacity: 0.25; }

/* ---------- Brand mark ---------- */
.mark { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 16px -6px rgba(15, 118, 110, 0.7); flex: none; }
.mark svg { width: 62%; height: 62%; }

/* ---------- Top nav ---------- */
.nav { max-width: 1200px; margin: 0 auto; padding: 20px 28px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand small { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.nav .spacer { flex: 1; }
.ghost-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; box-shadow: var(--shadow-sm); transition: transform 0.2s var(--ease), border-color 0.2s; }
.ghost-btn:hover { transform: translateY(-1px); border-color: var(--brand); }

/* ---------- Student page ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 12px 28px 40px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px); gap: 56px; align-items: center; min-height: calc(100vh - 80px); }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--muted); box-shadow: var(--shadow-sm); }
.badge b { background: var(--grad); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 11px; letter-spacing: 0.04em; }
.hero h1 { font-size: clamp(34px, 4.4vw, 54px); line-height: 1.05; margin: 20px 0 18px; letter-spacing: -0.035em; font-weight: 800; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero > p { color: var(--muted); font-size: 17.5px; max-width: 48ch; margin: 0; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 32px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px; background: var(--surface-2); color: var(--brand); }
.feature .ic svg { width: 19px; height: 19px; }
.feature b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.feature small { color: var(--muted); font-size: 13px; line-height: 1.45; display: block; }
.stats { display: flex; gap: 32px; margin-top: 28px; }
.stats div { font-size: 13px; color: var(--muted); }
.stats b { display: block; font-size: 24px; color: var(--ink); letter-spacing: -0.02em; }

/* ---------- Chat card ---------- */
.chat { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; height: min(740px, calc(100vh - 110px)); min-height: 520px; overflow: hidden; }
.chat-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--grad); color: #fff; overflow: hidden; }
.chat-head::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% -40%, rgba(255, 255, 255, 0.35), transparent 55%); pointer-events: none; }
.avatar { position: relative; width: 42px; height: 42px; border-radius: 14px; background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.35); display: grid; place-items: center; flex: none; backdrop-filter: blur(6px); }
.avatar svg { width: 24px; height: 24px; }
.avatar .dot { position: absolute; right: -3px; bottom: -3px; border: 2.5px solid #0e7a8a; width: 13px; height: 13px; }
.chat-head .name { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; }
.chat-head .status { font-size: 12.5px; opacity: 0.9; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #34d97b; display: inline-block; }
.dot.waiting { background: #ffc44d; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.new-chat { position: relative; z-index: 1; margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.35); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; transition: background 0.2s; }
.new-chat:hover { background: rgba(255, 255, 255, 0.28); }
.new-chat svg { width: 14px; height: 14px; }

.log { flex: 1; overflow-y: auto; padding: 20px 18px 12px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.msg { max-width: 84%; padding: 11px 15px; border-radius: var(--radius); overflow-wrap: anywhere; animation: pop 0.38s var(--ease) both; font-size: 14.5px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 8px; padding-left: 18px; }
.msg li { margin: 2px 0; }
.msg.user { align-self: flex-end; background: var(--grad); color: var(--user-ink); border-bottom-right-radius: 6px; box-shadow: 0 8px 18px -10px rgba(15, 118, 110, 0.8); }
.msg.bot { position: relative; align-self: flex-start; background: var(--bot); border-bottom-left-radius: 6px; margin-left: 36px; }
.msg.bot::before { content: ""; position: absolute; left: -36px; bottom: 0; width: 28px; height: 28px; border-radius: 9px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 5H7v14h9'/%3E%3Cpath d='M7 12h3l1.2-2.8 1.9 5.6 1.2-2.8H17'/%3E%3C/svg%3E") center / 62% no-repeat, var(--grad); }
.msg.agent { align-self: flex-start; background: var(--agent); border: 1px solid color-mix(in srgb, var(--agent-line) 35%, transparent); border-bottom-left-radius: 6px; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--agent-line); margin-bottom: 3px; }
.msg.system { align-self: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; text-align: center; padding: 5px 12px; border-radius: 999px; }
.msg.bot.emergency { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--warn) 55%, transparent); }
.msg.bot.emergency::before { background: var(--warn); }
.general-note { margin-top: 10px; font-size: 11.5px; font-weight: 600; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.sos-strip { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; font-size: 12.5px; background: color-mix(in srgb, var(--warn) 8%, var(--surface)); color: var(--ink); border-bottom: 1px solid var(--line); }
.sos-strip b { color: var(--warn); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sources span { font-size: 11.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; color: var(--muted); }

.options { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 94%; margin-left: 36px; animation: pop 0.4s 0.08s var(--ease) both; }
.options button { background: var(--surface); color: var(--brand); border: 1.5px solid color-mix(in srgb, var(--brand) 40%, var(--line)); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; transition: all 0.2s var(--ease); }
.options button:hover, .options button:focus-visible { background: var(--brand); border-color: var(--brand); color: #fff; outline: none; transform: translateY(-1px); }

.summary { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 13.5px; }
.summary .row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.pill.high { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.summary ul { margin: 4px 0 0; padding-left: 18px; }
.summary .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; margin-top: 8px; }

.typing { align-self: flex-start; background: var(--bot); border-radius: var(--radius); border-bottom-left-radius: 6px; padding: 14px 16px; display: flex; gap: 5px; margin-left: 36px; animation: pop 0.3s var(--ease) both; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.composer input { flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 14px; padding: 12px 15px; font: inherit; transition: border-color 0.2s, box-shadow 0.2s; }
.composer input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.send { width: 48px; flex: none; border: 0; border-radius: 14px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 18px -8px rgba(15, 118, 110, 0.9); transition: transform 0.2s var(--ease), opacity 0.2s; }
.send:hover { transform: translateY(-1px) scale(1.03); }
.send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.send svg { width: 20px; height: 20px; }
.footnote { text-align: center; font-size: 11.5px; color: var(--muted); padding: 0 12px 12px; background: var(--surface); }

/* Entrance after the splash: each element rises in turn */
.reveal { opacity: 0; transform: translateY(18px); }
body.ready .reveal { opacity: 1; transform: none; transition: opacity 0.7s var(--ease), transform 0.8s var(--ease); transition-delay: calc(var(--i, 0) * 80ms); }
body.ready .chat.reveal { transition-duration: 0.9s, 1s; }
.chat.reveal { transform: translateY(30px) scale(0.96); }

@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; gap: 24px; padding: 8px 16px 24px; min-height: 0; }
  .nav { padding: 16px; }
  .hero h1 { margin: 14px 0 10px; }
  .features, .stats { display: none; }
  .chat { height: calc(100vh - 210px); }
  .ghost-btn span { display: none; }
}

/* ---------- Splash / loading screen ---------- */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 0%, #0b4f5c 0%, #071c2b 55%, #040d16 100%); color: #fff; clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); transition: clip-path 0.9s cubic-bezier(0.7, 0, 0.2, 1); overflow: hidden; }
.splash.leaving { clip-path: circle(0px at var(--x, 50%) var(--y, 50%)); }
.splash .orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; animation: drift 9s ease-in-out infinite alternate; }
.splash .orb.a { width: 420px; height: 420px; background: #0f766e; top: -120px; left: -100px; }
.splash .orb.b { width: 380px; height: 380px; background: #34d399; bottom: -140px; right: -80px; animation-delay: -3s; opacity: 0.35; }
.splash .orb.c { width: 300px; height: 300px; background: #2563eb; top: 55%; left: 20%; animation-delay: -6s; opacity: 0.35; }
.splash .grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(circle at 50% 50%, black 0%, transparent 65%); }
.splash-inner { position: relative; text-align: center; transition: transform 0.7s var(--ease), opacity 0.5s; }
.splash.leaving .splash-inner { transform: scale(0.85); opacity: 0; }

.logo-big { position: relative; width: 116px; height: 116px; margin: 0 auto 28px; }
.logo-big .ring { position: absolute; inset: -14px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.14); border-top-color: #5eead4; border-right-color: #34d399; animation: spin 1.6s linear infinite; }
.logo-big .ring.r2 { inset: -28px; border-color: rgba(255, 255, 255, 0.06); border-bottom-color: rgba(192, 86, 232, 0.8); animation-duration: 2.6s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo-big .tile { position: absolute; inset: 0; border-radius: 32px; background: var(--grad); box-shadow: 0 20px 60px -10px rgba(14, 116, 144, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35); display: grid; place-items: center; animation: tileIn 0.9s var(--ease) both; }
@keyframes tileIn { from { transform: scale(0.4) rotate(-20deg); opacity: 0; } }
.logo-big svg { width: 60px; height: 60px; overflow: visible; }
.logo-big .bubble { stroke-dasharray: 80; stroke-dashoffset: 80; animation: draw 1.1s 0.35s var(--ease) forwards; }
.logo-big .spark { transform-origin: 12px 12px; transform: scale(0); animation: sparkIn 0.6s 1.1s var(--ease) forwards, twinkle 2.4s 1.7s ease-in-out infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes sparkIn { to { transform: scale(1); } }
@keyframes twinkle { 50% { transform: scale(0.75) rotate(45deg); } }

.wordmark { font-size: clamp(44px, 8vw, 72px); font-weight: 800; letter-spacing: -0.045em; margin: 0; line-height: 1; }
.wordmark span { display: inline-block; opacity: 0; transform: translateY(0.5em); animation: letter 0.7s var(--ease) forwards; animation-delay: calc(0.5s + var(--i) * 0.045s); }
.wordmark .pal { background: linear-gradient(90deg, #5eead4, #34d399); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes letter { to { opacity: 1; transform: none; } }
.splash .tagline { margin: 14px 0 0; color: rgba(255, 255, 255, 0.65); font-size: 15.5px; opacity: 0; animation: fadeUp 0.8s 1.05s var(--ease) forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.loader { width: min(300px, 70vw); margin: 40px auto 0; opacity: 0; animation: fadeUp 0.6s 1.25s var(--ease) forwards; }
.bar { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; border-radius: 4px; background: linear-gradient(90deg, #5eead4, #34d399); box-shadow: 0 0 12px #0e7490; transition: width 0.55s var(--ease); }
.step { display: flex; justify-content: space-between; margin-top: 12px; font-size: 12.5px; color: rgba(255, 255, 255, 0.6); font-variant-numeric: tabular-nums; }
.step span { transition: opacity 0.25s; }
.skip { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); font-size: 12px; color: rgba(255, 255, 255, 0.4); background: none; border: 0; }
.skip:hover { color: rgba(255, 255, 255, 0.8); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition: none !important; }
}

/* ---------- Staff console ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.topbar h1 small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.topbar label { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; font-weight: 600; }
.topbar input { border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); padding: 7px 10px; font: inherit; width: 140px; }
.console-body { display: grid; grid-template-columns: 330px minmax(0, 1fr) 330px; height: calc(100vh - 63px); }
.panel { overflow-y: auto; background: var(--surface); }
.queue { border-right: 1px solid var(--line); }
.side { border-left: 1px solid var(--line); padding-bottom: 20px; }
.queue h2, .side h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 18px 16px 10px; }
.item { display: block; width: calc(100% - 16px); margin: 0 8px 6px; text-align: left; background: none; border: 1px solid transparent; border-radius: 14px; padding: 12px; color: inherit; transition: background 0.2s, border-color 0.2s; }
.item:hover { background: var(--surface-2); }
.item.active { background: var(--surface-2); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.item .top { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.item .issue { font-weight: 700; font-size: 14px; }
.item .last { font-size: 12.5px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pill.waiting { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: color-mix(in srgb, var(--amber) 12%, var(--surface)); }
.pill.human { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.when { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.empty { padding: 30px 16px; color: var(--muted); text-align: center; font-size: 14px; }
.convo { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.convo .log { background: transparent; }
.convo .msg.bot { background: var(--surface); margin-left: 0; align-self: flex-end; border-bottom-left-radius: var(--radius); border-bottom-right-radius: 6px; }
.convo .msg.bot::before { display: none; }
.convo .msg.user { align-self: flex-start; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: none; border-bottom-right-radius: var(--radius); border-bottom-left-radius: 6px; }
.convo .msg.agent { align-self: flex-end; border-bottom-left-radius: var(--radius); border-bottom-right-radius: 6px; }
.side .card { margin: 0 16px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px; font-size: 13.5px; }
.side .card .summary { margin: 0; background: transparent; border: 0; padding: 0; }
.side .actions { display: grid; gap: 8px; margin: 0 16px; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 700; background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(15, 118, 110, 0.9); transition: transform 0.2s var(--ease); }
.btn:hover { transform: translateY(-1px); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; padding: 40px; text-align: center; margin: auto; }
.canned { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; background: var(--surface); border-top: 1px solid var(--line); }
.canned button { font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 4px 11px; }
.canned button:hover { border-color: var(--brand); color: var(--brand); }
.canned + .composer { border-top: 0; }

.sign-out { padding: 7px 14px; font-size: 13px; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar label { margin-left: 0; order: 3; }
  .topbar .sign-out { margin-left: auto; }
}
.login { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 32px 28px; display: grid; gap: 12px; text-align: center; justify-items: center; animation: pop 0.5s var(--ease) both; }
.login-card .mark { width: 52px; height: 52px; border-radius: 16px; }
.login-card h1 { margin: 6px 0 0; font-size: 22px; letter-spacing: -0.02em; }
.login-card p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.login-card input { width: 100%; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 12px; padding: 12px 14px; font: inherit; text-align: center; }
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.login-card .btn { width: 100%; padding: 12px; }
.login-error { color: var(--warn); font-size: 13px; font-weight: 600; }
.login-card.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

@media (max-width: 1000px) {
  .console-body { grid-template-columns: 1fr; height: auto; }
  .queue, .side { border: 0; border-bottom: 1px solid var(--line); }
  .convo { height: 70vh; }
}

/* ---------- Public health library pages ---------- */
.doc-page { background: var(--bg); }
.doc { max-width: 760px; margin: 0 auto; padding: 40px 20px 60px; }
.doc h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -0.03em; margin: 8px 0 18px; }
.doc h2 { font-size: 20px; margin: 32px 0 8px; letter-spacing: -0.01em; }
.doc h2 a { color: var(--ink); text-decoration: none; }
.doc h2 a:hover { color: var(--brand); }
.doc section { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px 20px 14px; margin: 14px 0; }
.doc ul { padding-left: 20px; }
.doc li { margin: 4px 0; }
.doc-crumb { font-size: 13px; font-weight: 600; }
.doc-foot { margin-top: 40px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }

/* ---------- Requests panel (nurse console) ---------- */
.req { margin: 0 8px 6px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; }
.req .top { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.req .ref { font-weight: 800; font-size: 13.5px; white-space: nowrap; }
.req .top .pill { white-space: normal; text-align: center; }
.req .line { color: var(--muted); }
.req .acts { display: flex; gap: 6px; margin-top: 8px; }
.req .acts button { flex: 1; font-size: 12.5px; font-weight: 700; padding: 6px 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.req .acts button.approve { background: var(--ok); border-color: var(--ok); color: #fff; }
.req .acts button:hover { filter: brightness(1.05); transform: translateY(-1px); }
.tabs { display: flex; gap: 4px; margin: 14px 12px 10px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13px; padding: 7px; border-radius: 9px; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tabs .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; }
.msg.bot.update { border: 1.5px solid color-mix(in srgb, var(--brand) 45%, transparent); }

/* Schedule tab: nurses open the appointment times patients can book */
.sched-add { margin: 0 8px 10px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.sched-title { font-weight: 800; font-size: 13.5px; }
.sched-help { margin: 4px 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.sched-fields { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 6px; }
.sched-fields input { width: 100%; min-width: 0; font: inherit; font-size: 13px; padding: 8px 9px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); color-scheme: light dark; }
.sched-fields input:focus { outline: none; border-color: var(--brand); }
.sched-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.sched-buttons .btn { padding: 8px 10px; font-size: 12.5px; border-radius: 10px; }
.sched-msg { margin-top: 8px; font-size: 12.5px; color: var(--ok); }
.sched-msg.err { color: var(--warn); }
.sched-day { margin: 12px 16px 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.slot { display: flex; align-items: center; gap: 8px; margin: 0 8px 4px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.slot .t { font-weight: 800; min-width: 70px; }
.slot .who { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.booked { background: color-mix(in srgb, var(--ok) 8%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.slot.booked .who { color: var(--ok); font-weight: 700; }
.slot .rm { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 16px; line-height: 1; }
.slot .rm:hover { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.theme-btn { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); }
.theme-btn:hover { color: var(--ink); }
.theme-btn svg { width: 18px; height: 18px; }
.cite { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin: 0 1px; border-radius: 5px; font-size: 10px; font-weight: 800; line-height: 1; vertical-align: super; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.hint { display: grid; justify-items: center; gap: 6px; max-width: 340px; line-height: 1.5; }
.hint b { color: var(--ink); font-size: 15px; }
.hint-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; margin-bottom: 6px; background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); }
.hint-icon svg { width: 26px; height: 26px; }

/* Accessibility options set in the patient chat's Settings also apply here. */
:root.hc.hc { --muted: color-mix(in srgb, var(--ink) 88%, var(--bg)); --line: color-mix(in srgb, var(--ink) 45%, var(--bg)); }
html.hc a { text-decoration: underline; }
html.hc :focus-visible { outline: 3px solid var(--brand) !important; outline-offset: 2px; }
:root.readable.readable { font-family: "Atkinson Hyperlegible", "Plus Jakarta Sans", system-ui, sans-serif; }
html.rm *, html.rm *::before, html.rm *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
.sched-fields .span2 { grid-column: 1 / -1; width: 100%; min-width: 0; font: inherit; font-size: 13px; padding: 8px 9px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
