﻿/* ── TOKENS ──────────────────────────────────────────── */
:root {
  --font: 'Sora', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --bg:        #f8f8fc;
  --bg2:       #ffffff;
  --bg3:       #f0f0f5;
  --border:    #e5e5eb;
  --text:      #1a1a2e;
  --text2:     #52526a;
  --text3:     #a0a0b8;
  --accent:    #005eb8;
  --accent2:   #0048a3;
  --accent-soft: #e8f0fd;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --sidebar-w: 268px;
  --diag-w:    308px;
  --c-emergency: #e02b2b;
  --c-urgent_gp: #ea580c;
  --c-gp:        #d97706;
  --c-pharmacy:  #2563eb;
  --c-self_care: #16a34a;
  /* Aliases used by login page */
  --bg-primary:    var(--bg);
  --bg-secondary:  var(--bg2);
  --text-primary:  var(--text);
  --text-secondary:var(--text2);
  --text-muted:    var(--text3);
  --accent-faint:  var(--accent-soft);
}
[data-theme="dark"] {
  --bg:     #0e0e14;
  --bg2:    #17171f;
  --bg3:    #22222c;
  --border: #2e2e3a;
  --text:   #f0f0f8;
  --text2:  #9090a8;
  --text3:  #55556a;
  --accent-soft: #1a2a45;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.45);
  /* Aliases used by login page */
  --bg-primary:    var(--bg);
  --bg-secondary:  var(--bg2);
  --text-primary:  var(--text);
  --text-secondary:var(--text2);
  --text-muted:    var(--text3);
  --accent-faint:  var(--accent-soft);
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  display: flex; height: 100dvh; overflow: hidden; font-size: 14px;
  transition: background .25s, color .25s;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
textarea { font-family: var(--font); }
a { color: var(--accent); }

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: transform .28s cubic-bezier(.4,0,.2,1), width .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden; z-index: 200;
}
.sidebar.collapsed { width: 0; }

.sidebar-header { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-icon-wrap {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #005eb8 0%, #0080ff 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0,94,184,.35);
  flex-shrink: 0;
}
.brand-icon { width: 17px; height: 17px; stroke: #fff; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.4px; }

.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 9px 14px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #0080ff 100%);
  color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,94,184,.3);
  transition: opacity .15s, transform .1s;
}
.new-chat-btn:hover { opacity: .9; }
.new-chat-btn:active { transform: scale(.97); }
.new-chat-btn svg { width: 15px; height: 15px; stroke: #fff; flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.nav-label { font-size: 10px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--text3); margin-bottom: 2px; }

.info-card { background: var(--bg3); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.info-row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text2); }
.info-row svg { width: 14px; height: 14px; flex-shrink: 0; stroke: var(--accent); }

.urgency-guide { display: flex; flex-direction: column; gap: 7px; }
.ug-row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text2); }
.ug-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ug-row.emergency .ug-dot { background: var(--c-emergency); box-shadow: 0 0 0 3px rgba(224,43,43,.15); }
.ug-row.urgent_gp .ug-dot { background: var(--c-urgent_gp); box-shadow: 0 0 0 3px rgba(234,88,12,.15); }
.ug-row.gp .ug-dot { background: var(--c-gp); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.ug-row.pharmacy .ug-dot { background: var(--c-pharmacy); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.ug-row.self_care .ug-dot { background: var(--c-self_care); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.theme-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 13px; font-weight: 500;
  transition: background .15s;
}
.theme-btn:hover { background: var(--bg3); }
.theme-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.disclaimer-small { font-size: 10px; color: var(--text3); line-height: 1.5; }

/* ── OVERLAY (mobile) ────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 150; backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
.overlay.active { display: block; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* ── MAIN ────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; height: 56px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; display: block; }
.topbar-title { font-weight: 600; font-size: 14px; letter-spacing: -.2px; }

.analysis-toggle-btn { display: flex; }

.pipeline-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-dot.idle { background: var(--bg3); }
.status-dot.processing { background: #f59e0b; animation: pulse 1s ease-in-out infinite; }
.status-dot.done { background: var(--c-self_care); }
.status-dot.error { background: var(--c-emergency); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.chat-area { flex: 1; overflow-y: auto; padding: 28px 20px 16px; scroll-behavior: smooth; }
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* Welcome */
.welcome { max-width: 540px; margin: 32px auto 0; text-align: center; padding: 0 8px; }
.welcome-icon {
  width: 68px; height: 68px; border-radius: 22px;
  background: linear-gradient(135deg, #005eb8 0%, #0080ff 100%);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 22px;
  box-shadow: 0 8px 24px rgba(0,94,184,.28);
}
.welcome-icon svg { width: 32px; height: 32px; stroke: #fff; }
.welcome h1 { font-size: 24px; font-weight: 700; margin-bottom: 10px; letter-spacing: -.4px; }
.welcome p { color: var(--text2); font-size: 14px; line-height: 1.7; margin-bottom: 28px; }
.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  padding: 8px 16px; border-radius: 50px; font-size: 13px;
  background: var(--bg2); border: 1.5px solid var(--border);
  color: var(--text2); transition: all .18s; font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.chip:hover {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Messages */
.messages { max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.msg { display: flex; gap: 12px; animation: fadeUp .3s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

.msg-avatar {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.msg-avatar svg { width: 16px; height: 16px; }
.msg.user .msg-avatar { background: var(--bg3); border: 1px solid var(--border); }
.msg.user .msg-avatar svg { stroke: var(--text2); }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #005eb8 0%, #0080ff 100%); }
.msg.assistant .msg-avatar svg { stroke: #fff; }
.msg.system-block .msg-avatar { background: linear-gradient(135deg, #e02b2b, #f87171); }
.msg.system-block .msg-avatar svg { stroke: #fff; }

.msg-body { flex: 1; padding-top: 4px; }
.msg-role { font-size: 11px; font-weight: 700; color: var(--text3); margin-bottom: 6px; letter-spacing: .5px; text-transform: uppercase; }
.msg-text { line-height: 1.75; color: var(--text); }
.msg-text p { margin-bottom: 10px; }
.msg-text p:last-child { margin-bottom: 0; }

.intervention-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; margin-bottom: 9px;
}
.intervention-badge.PASS { background: #dcfce7; color: #15803d; }
.intervention-badge.FLAG { background: #fef9c3; color: #b45309; }
.intervention-badge.OVERRIDE,
.intervention-badge.EMERGENCY_OVERRIDE,
.intervention-badge.HIGH_OVERRIDE { background: #fee2e2; color: #dc2626; }
[data-theme="dark"] .intervention-badge.PASS { background: #14532d; color: #86efac; }
[data-theme="dark"] .intervention-badge.FLAG { background: #3f3009; color: #fde68a; }
[data-theme="dark"] .intervention-badge.OVERRIDE,
[data-theme="dark"] .intervention-badge.EMERGENCY_OVERRIDE,
[data-theme="dark"] .intervention-badge.HIGH_OVERRIDE { background: #450a0a; color: #fca5a5; }

.extracted-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.ext-chip {
  padding: 3px 10px; border-radius: 20px; font-size: 11px;
  font-family: var(--mono); background: var(--accent-soft);
  color: var(--accent); border: 1px solid rgba(0,94,184,.15);
}

.thinking { display: flex; gap: 12px; }
.thinking .msg-avatar { background: linear-gradient(135deg, #005eb8 0%, #0080ff 100%); }
.thinking .msg-avatar svg { stroke: #fff; }
.thinking-dots { display: flex; align-items: center; gap: 5px; padding-top: 12px; }
.thinking-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3); animation: bounce .9s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .17s; }
.thinking-dots span:nth-child(3) { animation-delay: .34s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-7px)} }

/* Input */
.input-area {
  padding: 12px 20px 18px; background: var(--bg2);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.input-box {
  max-width: 700px; margin: 0 auto 8px;
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 10px 10px 16px;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--shadow-sm);
}
.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,94,184,.1), var(--shadow-sm);
}
#userInput {
  flex: 1; resize: none; border: none; background: transparent;
  color: var(--text); font-size: 14px; line-height: 1.55;
  max-height: 160px; outline: none;
}
#userInput::placeholder { color: var(--text3); }
.send-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #0080ff 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .1s, box-shadow .15s; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,94,184,.3);
}
.send-btn:hover:not(:disabled) { opacity: .9; box-shadow: 0 4px 12px rgba(0,94,184,.4); }
.send-btn:active:not(:disabled) { transform: scale(.92); }
.send-btn:disabled { background: var(--bg3); box-shadow: none; }
.send-btn svg { width: 15px; height: 15px; stroke: #fff; }
.send-btn:disabled svg { stroke: var(--text3); }
.input-notice { max-width: 700px; margin: 0 auto; font-size: 11px; color: var(--text3); text-align: center; line-height: 1.5; }

/* ── DIAGNOSIS PANEL ─────────────────────────────────── */
.diag-panel {
  width: var(--diag-w); background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.diag-panel.hidden { width: 0; }
.diag-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; flex-shrink: 0; letter-spacing: -.1px;
}
.diag-header button {
  width: 28px; height: 28px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center;
  color: var(--text3); transition: background .15s;
}
.diag-header button:hover { background: var(--bg3); color: var(--text); }
.diag-header button svg { width: 14px; height: 14px; display: block; }
.diag-content { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.diag-content::-webkit-scrollbar { width: 3px; }
.diag-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.diag-empty { font-size: 12px; color: var(--text3); text-align: center; margin-top: 24px; line-height: 1.6; }

/* Condition card */
.cond-card {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 14px;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.cond-card:hover { box-shadow: var(--shadow-md); }
.cond-card.top-pick { border-left: 3px solid var(--accent); background: var(--bg2); }
.cond-name-row { display: flex; align-items: flex-start; gap: 7px; flex-wrap: wrap; }
.cond-name { font-size: 13px; font-weight: 700; line-height: 1.4; flex: 1; }

.kb-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap; flex-shrink: 0;
}
.kb-badge.verified { background: #dcfce7; color: #15803d; }
.kb-badge.unverified { background: #fef9c3; color: #a16207; }
[data-theme="dark"] .kb-badge.verified { background: #14532d; color: #4ade80; }
[data-theme="dark"] .kb-badge.unverified { background: #3f3009; color: #fbbf24; }

.cond-prob-row { display: flex; align-items: center; gap: 9px; }
.prob-bar-bg { flex: 1; height: 5px; background: var(--bg3); border-radius: 10px; overflow: hidden; }
.prob-bar { height: 100%; border-radius: 10px; transition: width .9s cubic-bezier(.4,0,.2,1); }
.prob-label { font-size: 11px; font-family: var(--mono); font-weight: 700; width: 34px; text-align: right; flex-shrink: 0; }
.cond-reasoning { font-size: 12px; color: var(--text2); line-height: 1.55; }

.cond-urgency {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 10px; border-radius: 20px; align-self: flex-start;
}
.cond-urgency::before { content:''; width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.cond-urgency.emergency { background: #fee2e2; color: var(--c-emergency); }
.cond-urgency.emergency::before { background: var(--c-emergency); }
.cond-urgency.urgent_gp { background: #ffedd5; color: var(--c-urgent_gp); }
.cond-urgency.urgent_gp::before { background: var(--c-urgent_gp); }
.cond-urgency.gp { background: #fef3c7; color: var(--c-gp); }
.cond-urgency.gp::before { background: var(--c-gp); }
.cond-urgency.pharmacy { background: #dbeafe; color: var(--c-pharmacy); }
.cond-urgency.pharmacy::before { background: var(--c-pharmacy); }
.cond-urgency.self_care { background: #dcfce7; color: var(--c-self_care); }
.cond-urgency.self_care::before { background: var(--c-self_care); }
[data-theme="dark"] .cond-urgency.emergency { background: #450a0a; }
[data-theme="dark"] .cond-urgency.urgent_gp { background: #431407; }
[data-theme="dark"] .cond-urgency.gp { background: #3f3009; }
[data-theme="dark"] .cond-urgency.pharmacy { background: #1e3a5f; }
[data-theme="dark"] .cond-urgency.self_care { background: #14532d; }

.cond-next {
  font-size: 11px; color: var(--text2);
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 8px 10px; line-height: 1.55;
}
.cond-next strong { color: var(--text); }

.nhs-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--accent);
  text-decoration: none; padding: 6px 11px;
  background: var(--accent-soft); border-radius: var(--radius-sm);
  transition: background .15s, transform .1s;
  align-self: flex-start;
}
.nhs-link:hover { background: rgba(0,94,184,.15); transform: translateY(-1px); }
.nhs-link svg { flex-shrink: 0; }
[data-theme="dark"] .nhs-link { color: #60a5fa; background: rgba(96,165,250,.1); }
[data-theme="dark"] .nhs-link:hover { background: rgba(96,165,250,.18); }

/* Pipeline trace */
.pipeline-trace { background: var(--bg3); border-radius: var(--radius-sm); padding: 11px 13px; display: flex; flex-direction: column; gap: 7px; }
.pt-title { font-size: 10px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--text3); margin-bottom: 2px; }
.pt-row { display: flex; align-items: center; gap: 8px; font-size: 11px; font-family: var(--mono); }
.pt-label { color: var(--text3); width: 120px; flex-shrink: 0; }
.pt-val { font-weight: 700; }
.pt-val.PASS,.pt-val.SKIPPED { color: var(--c-self_care); }
.pt-val.FLAG { color: var(--c-gp); }
.pt-val.OVERRIDE,.pt-val.EMERGENCY_OVERRIDE,.pt-val.HIGH_OVERRIDE { color: var(--c-emergency); }
.pt-check { font-size: 10px; padding: 4px 8px; border-radius: 6px; font-family: var(--mono); line-height: 1.4; }
.pt-check.hallucination { background: #fff7ed; color: #9a3412; }
.pt-check.safety { background: #fef2f2; color: #991b1b; }
[data-theme="dark"] .pt-check.hallucination { background: #431407; color: #fdba74; }
[data-theme="dark"] .pt-check.safety { background: #450a0a; color: #fca5a5; }

/* Extracted panel */
.extracted-section { display: flex; flex-direction: column; gap: 6px; }
.ext-title { font-size: 10px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--text3); margin-bottom: 2px; }
.ext-item { display: flex; gap: 6px; font-size: 12px; }
.ext-key { color: var(--text3); width: 80px; flex-shrink: 0; text-transform: capitalize; }
.ext-val { color: var(--text2); }

/* ── MOBILE BOTTOM NAV ───────────────────────────────── */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: 62px; background: var(--bg2); border-top: 1px solid var(--border);
  z-index: 300; align-items: center; justify-content: space-around;
  padding: 0 8px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.mob-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 18px; border-radius: var(--radius-sm);
  color: var(--text3); font-size: 10px; font-weight: 600;
  transition: background .15s, color .15s; flex: 1;
}
.mob-nav-btn:hover, .mob-nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.mob-nav-btn svg { width: 20px; height: 20px; }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 860px) {
  .analysis-toggle-btn { display: flex; }

  .diag-panel {
    position: fixed !important; bottom: 0; left: 0; right: 0;
    width: 100% !important; max-height: 82dvh;
    border-left: none; border-top: 1.5px solid var(--border);
    border-radius: 24px 24px 0 0;
    z-index: 250;
    transition: transform .32s cubic-bezier(.4,0,.2,1);
    transform: translateY(100%);
    box-shadow: var(--shadow-lg);
  }
  .diag-panel:not(.hidden) { transform: translateY(0); }
  .diag-panel.hidden { transform: translateY(100%) !important; }

  .diag-header { position: relative; padding: 22px 16px 14px; }
  .diag-header::before {
    content: ''; position: absolute; top: 10px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px; background: var(--border); border-radius: 10px;
  }

  .mobile-nav { display: flex; }
  body { padding-bottom: 62px; }
}

@media (max-width: 680px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 200; width: 88vw !important;
    transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-105%); width: 88vw !important; }

  .topbar { padding: 0 14px; }
  .chat-area { padding: 20px 14px 12px; }
  .input-area { padding: 10px 12px 14px; }
  .messages { gap: 16px; }
  .welcome { margin-top: 18px; }
  .welcome h1 { font-size: 20px; }
  .welcome-chips { gap: 6px; }
  .chip { font-size: 12px; padding: 7px 13px; }
  .input-box { border-radius: var(--radius-sm); }
}

@media (min-width: 861px) {
  .mobile-nav { display: none !important; }
  body { padding-bottom: 0 !important; }
  .diag-panel {
    position: static !important; transform: none !important;
    border-radius: 0; max-height: none;
    border-top: none; border-left: 1px solid var(--border);
    transition: width .28s cubic-bezier(.4,0,.2,1);
  }
  .diag-panel.hidden { width: 0 !important; transform: none !important; }
}

/* ── Evaluation Metrics ──────────────────────────────────── */
.eval-metrics {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.eval-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.eval-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.eval-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
}
.eval-bar-bg {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.eval-bar {
  height: 100%;
  border-radius: 2px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.eval-details {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.eval-detail {
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  cursor: help;
}
.eval-mapping {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── KB Verification Rate summary ────────────────────────── */
.kb-ver-summary {
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.kv-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.kv-bar-bg {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.kv-bar {
  height: 100%;
  border-radius: 2px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.kv-detail {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kv-pct {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 12px;
}

/* ── Symptom Recall & Precision ──────────────────────────── */
.sym-metrics {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.sym-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sym-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sym-f1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
}
.sym-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.sym-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
  width: 58px;
  flex-shrink: 0;
  cursor: help;
}
.sym-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.sym-bar {
  height: 100%;
  border-radius: 2px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.sym-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 32px;
  text-align: right;
}
.sym-detail {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Topbar User Badge ───────────────────────────────────── */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12.5px;
  color: var(--text2);
  background: var(--bg3);
  font-weight: 500;
}
.topbar-user svg { color: var(--text3); flex-shrink: 0; }
.topbar-logout-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s;
  margin-left: 4px;
}
.topbar-logout-btn:hover {
  color: #dc2626;
  border-color: rgba(220,38,38,.35);
  background: rgba(220,38,38,.06);
}

/* ── User Info Badge ─────────────────────────────────────── */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-primary);
}
.user-info span {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color .2s, background .2s;
}
.logout-btn:hover {
  color: #dc2626;
  background: rgba(220,38,38,.08);
}

/* ── Daily Usage Counter ─────────────────────────────────── */
.usage-counter {
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.usage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.usage-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.usage-fraction {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}
.usage-bar-bg {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 5px;
}
.usage-bar {
  height: 100%;
  border-radius: 2px;
  background: #16a34a;
  transition: width .4s ease, background .3s;
}
.usage-detail {
  font-size: 11px;
  color: var(--text-muted);
}
