/* ════════════════════════════════════════════════════════════════
   DentScan AI — "CLINICAL INTELLIGENCE" design system
   Medical blue + mint · Overjet-inspired · bento · Bai Jamjuree / IBM Plex
   ════════════════════════════════════════════════════════════════ */
:root {
  /* primary = medical blue */
  --blue: #1e6fd9;
  --blue-d: #1552ad;
  --blue-l: #4d90ea;
  --blue-soft: #eaf2fe;
  /* healthy = mint-teal · findings = amber/coral */
  --mint: #0fb5ae;
  --mint-d: #0a8b85;
  --amber: #f59e0b;
  --coral: #ef4444;
  --purple: #7c6ff0;
  --pink: #ec4899;
  /* neutrals */
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --text: #0c1b33;
  --text-2: #5a6b85;
  --border: #e2e9f4;
  --hair: #edf2f9;
  --shadow: 0 2px 8px rgba(20,50,110,.05), 0 8px 24px rgba(20,50,110,.06);
  --shadow-lg: 0 8px 24px rgba(20,50,110,.10), 0 20px 48px rgba(20,50,110,.12);
  --ring: 0 0 0 3px rgba(30,111,217,.18);
  --radius: 16px;
  --radius-sm: 11px;
  /* aliases kept so legacy rules resolve to the new blue system */
  --teal: var(--blue);
  --teal-d: var(--blue-d);
  --teal-l: var(--blue-l);
  --font: 'IBM Plex Sans Thai', 'Bai Jamjuree', system-ui, sans-serif;
  --display: 'Bai Jamjuree', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'Bai Jamjuree', ui-monospace, monospace;
  /* blueprint dot-grid texture */
  --grid: radial-gradient(circle at 1px 1px, rgba(30,111,217,.10) 1px, transparent 0);
}
[data-theme="dark"] {
  --blue: #4d90ea;
  --blue-d: #1e6fd9;
  --blue-l: #7db0f2;
  --blue-soft: #12274a;
  --mint: #22c9c1;
  --bg: #070f1f;
  --surface: #0d1a30;
  --surface-2: #12233f;
  --text: #e8eff9;
  --text-2: #8ea3c4;
  --border: #1d3152;
  --hair: #162740;
  --shadow: 0 2px 10px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.30);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  --ring: 0 0 0 3px rgba(77,144,234,.28);
  --grid: radial-gradient(circle at 1px 1px, rgba(120,170,255,.10) 1px, transparent 0);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
::selection { background: var(--blue); color: #fff; }

/* reusable ALL-CAPS clinical micro-label */
.eyebrow, .section-title::before {
  font-family: var(--mono);
  font-size: 11px; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--blue);
}

/* ── Sidebar ── */
.sidebar {
  width: 264px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 26px 16px;
  position: fixed;
  height: 100vh;
  z-index: 50;
  background-image: var(--grid);
  background-size: 22px 22px;
  transition: transform .3s, background .3s;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-logo {
  font-size: 30px; width: 50px; height: 50px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--blue-l), var(--blue-d));
  border-radius: 15px; box-shadow: 0 6px 16px rgba(30,111,217,.35);
  position: relative;
}
.brand-logo::after {
  content: ""; position: absolute; inset: 0; border-radius: 15px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -.4px; }
.brand-name .accent { color: var(--blue); }
.brand-sub { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: none; background: none;
  color: var(--text-2); font-family: var(--font); font-size: 14.5px; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all .18s; text-align: left; width: 100%; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--blue), var(--blue-d));
  color: #fff; box-shadow: 0 6px 18px rgba(30,111,217,.30);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--blue);
}
.nav-item:disabled { opacity: .4; cursor: not-allowed; }
.nav-ico { font-size: 17px; }

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; }
.model-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm); font-family: var(--mono);
  font-size: 11px; letter-spacing: .04em; color: var(--text-2);
}
.model-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber); flex-shrink: 0;
}
.model-badge.live .dot { background: var(--mint); box-shadow: 0 0 0 4px rgba(15,181,174,.18); }
.model-badge.mock .dot { background: var(--amber); }
.foot-controls { display: flex; gap: 8px; }
.ctl-btn {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; color: var(--text); transition: all .18s;
}
.ctl-btn:hover { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

.menu-fab {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 60;
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: var(--blue); color: #fff; font-size: 20px; cursor: pointer;
  box-shadow: var(--shadow);
}

/* ── Main ── */
.main { margin-left: 264px; flex: 1; padding: 34px 44px; max-width: 1220px; }
.page { display: none; }
.page.active { display: block; animation: pageIn .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-title { font-family: var(--display); font-size: 30px; font-weight: 700; margin-bottom: 22px; letter-spacing: -.6px; }
.section-title {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  margin: 38px 0 18px; display: flex; align-items: center; gap: 12px;
}

/* ── Hero ── */
.hero {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 36px;
  align-items: center; margin-bottom: 36px;
}
.hero-text h1 { font-family: var(--display); font-size: 40px; font-weight: 700; line-height: 1.12; letter-spacing: -1.2px; margin-bottom: 18px; }
.hero-text p { color: var(--text-2); font-size: 16px; line-height: 1.75; margin-bottom: 26px; max-width: 52ch; }
.disclaimer-sm { font-size: 12.5px; color: var(--text-2); margin-top: 18px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); border-left: 3px solid var(--amber); }
.hero-card { display: grid; place-items: center; }
.hero-xray {
  width: 100%; aspect-ratio: 1; max-width: 300px;
  background:
    linear-gradient(140deg, var(--blue-d), var(--blue) 60%, var(--mint));
  border-radius: 30px; display: grid; place-items: center;
  position: relative; overflow: hidden;
  box-shadow: 0 20px 50px rgba(30,111,217,.35);
}
.hero-xray::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.16) 1px, transparent 0);
  background-size: 20px 20px;
}
.hero-xray::after {
  content: "◵ ◵ ◵"; position: absolute; bottom: 14px; left: 0; right: 0;
  text-align: center; font-family: var(--mono); font-size: 10px;
  letter-spacing: .3em; color: rgba(255,255,255,.6);
}
.hero-tooth { font-size: 116px; filter: drop-shadow(0 8px 16px rgba(0,0,0,.28)); z-index: 1; }
.scan-line {
  position: absolute; left: 8%; right: 8%; height: 3px; z-index: 1;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  box-shadow: 0 0 14px 2px rgba(255,255,255,.7);
  animation: scan 2.8s ease-in-out infinite; opacity: .9; border-radius: 3px;
}
@keyframes scan { 0%,100% { top: 12%; } 50% { top: 86%; } }

/* ── Stat grid (bento) ── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; text-align: center;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; position: relative;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 22px; right: 22px; height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--mint)); border-radius: 0 0 3px 3px;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-num { display: block; font-family: var(--display); font-size: 34px; font-weight: 700; color: var(--blue); letter-spacing: -.5px; }
.stat-lbl { font-size: 12.5px; color: var(--text-2); }

/* ── Disease grid ── */
.disease-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 16px; }
.disease-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  cursor: pointer; transition: all .2s; border-top: 3px solid var(--blue);
}
.disease-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-top-color: var(--mint); }
.disease-card .dc-ico { font-size: 28px; }
.disease-card h4 { font-family: var(--display); font-size: 17px; font-weight: 600; margin: 10px 0 6px; }
.disease-card p { font-size: 13px; color: var(--text-2); line-height: 1.6; }

/* ── Cards / Analyze ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.card h3 { font-family: var(--display); font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.analyze-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.muted-sm { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  min-height: 240px; display: grid; place-items: center;
  cursor: pointer; transition: all .2s; overflow: hidden; position: relative;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--blue-soft); }
.dz-empty { text-align: center; color: var(--text-2); padding: 20px; }
.dz-ico { font-size: 44px; display: block; margin-bottom: 12px; }
.dz-hint { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; opacity: .7; }
.dz-preview { width: 100%; height: 100%; object-fit: contain; max-height: 320px; }

.sample-row { margin-top: 16px; font-size: 13px; color: var(--text-2); }
.sample-thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.sample-thumbs img {
  width: 72px; height: 44px; object-fit: cover; border-radius: 8px;
  cursor: pointer; border: 2px solid transparent; transition: all .2s;
}
.sample-thumbs img:hover { border-color: var(--blue); transform: scale(1.05); }
.sample-thumbs .samp { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 0; }
.sample-thumbs .samp img { width: 72px; height: 48px; }
.samp-cap { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .04em;
  padding: 1px 8px; border-radius: 8px; }
.samp-cap.bad { background: rgba(239,68,68,.15); color: var(--coral); }
.samp-cap.ok { background: rgba(15,181,174,.15); color: var(--mint-d); }

/* symptom switches */
.symptom-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.sw { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.sw input { display: none; }
.sw-track {
  width: 42px; height: 24px; border-radius: 12px; background: var(--border);
  position: relative; transition: background .2s; flex-shrink: 0;
}
.sw-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sw input:checked + .sw-track { background: var(--blue); }
.sw input:checked + .sw-track::after { transform: translateX(18px); }
.dur-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 14px; flex-wrap: wrap; }
.dur-row select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: var(--font); cursor: pointer;
}
.dur-row select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }

/* buttons */
.btn-primary {
  padding: 13px 26px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue), var(--blue-d));
  color: #fff; font-family: var(--font); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .2s; box-shadow: 0 6px 18px rgba(30,111,217,.28);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(30,111,217,.38); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary.full { width: 100%; }

/* processing */
.processing { text-align: center; padding: 50px 20px; }
.proc-ring {
  width: 64px; height: 64px; margin: 0 auto 20px;
  border: 5px solid var(--surface-2); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.proc-steps { display: flex; flex-direction: column; gap: 8px; max-width: 360px; margin: 20px auto 0; }
.proc-step { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); opacity: .4; transition: opacity .3s; }
.proc-step.done { opacity: 1; color: var(--text); }
.proc-step.done .ps-ico { color: var(--mint); }

/* ── Result ── */
.result-summary {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; margin-bottom: 24px;
}
.verdict-card { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.verdict-badge {
  display: inline-block; padding: 8px 20px; border-radius: 20px;
  font-weight: 600; font-size: 15px; margin: 4px auto;
}
.verdict-badge.normal { background: rgba(15,181,174,.15); color: var(--mint-d); }
.verdict-badge.warn { background: rgba(245,158,11,.15); color: var(--amber); }
.verdict-badge.alert { background: rgba(239,68,68,.15); color: var(--coral); }
.verdict-big { font-size: 52px; }

.prob-list { display: flex; flex-direction: column; gap: 14px; }
.prob-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.prob-val { font-family: var(--mono); font-weight: 600; }
.prob-bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.prob-fill { height: 100%; border-radius: 6px; transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* heatmap / explainability overlay controls */
.heatmap-section { margin: 24px 0; }
.heatmap-toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.heatmap-toolbar .hm-legend { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.hm-legend .hm-scale { width: 96px; height: 8px; border-radius: 4px; background: linear-gradient(90deg,#2b3a67,#1e6fd9,#0fb5ae,#f59e0b,#ef4444); }
.heatmap-toolbar .hm-slider { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.hm-slider input[type=range] { accent-color: var(--blue); width: 120px; }
.heatmap-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 16px; }
.heatmap-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.heatmap-item .hm-canvas { position: relative; line-height: 0; background: #000; }
.heatmap-item img { width: 100%; display: block; }
.heatmap-item .hm-base { width: 100%; height: auto; display: block; }
.heatmap-item .hm-over { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: fill; transition: opacity .15s ease; pointer-events: none; }
.heatmap-item .hm-cap { padding: 12px 16px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.heatmap-item .hm-cap .hm-pct { font-family: var(--mono); margin-left: auto; color: var(--text-2); }

.report-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-top: 20px; line-height: 1.8; }
.report-card h3 { font-family: var(--display); margin-bottom: 14px; color: var(--blue); }
.fusion-note { font-size: 13px; color: var(--text-2); padding: 8px 14px; background: var(--surface-2); border-radius: 10px; margin-top: 8px; border-left: 3px solid var(--purple); }
.report-src { font-size: 12px; font-weight: 400; color: var(--text-2); margin-left: 8px; }
.report-loading { color: var(--blue); font-size: 14px; margin-bottom: 10px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.report-urgency { display: inline-block; padding: 6px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; }
.report-urgency.normal { background: rgba(15,181,174,.15); color: var(--mint-d); }
.report-urgency.warn { background: rgba(245,158,11,.15); color: var(--amber); }
.report-urgency.alert { background: rgba(239,68,68,.15); color: var(--coral); }
.report-block { margin: 12px 0; }
.report-block strong { color: var(--blue); font-size: 14px; }
.report-block p { margin-top: 4px; }
.report-block ul { margin: 6px 0 0 20px; }
.report-block summary { cursor: pointer; }
.report-disc { font-size: 12px; color: var(--text-2); margin-top: 14px; padding: 10px; background: var(--surface-2); border-radius: 10px; }

.result-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ── History ── */
.history-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 16px; }
.history-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .2s, box-shadow .2s; }
.history-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.history-card img { width: 100%; height: 120px; object-fit: cover; }
.history-card .hc-body { padding: 14px; }
.history-card .hc-date { font-family: var(--mono); font-size: 11px; color: var(--text-2); }
.history-card .hc-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 11px; padding: 3px 10px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.tag.hit { background: rgba(239,68,68,.15); color: var(--coral); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-state .es-ico { font-size: 56px; display: block; margin-bottom: 16px; opacity: .5; }

/* ── Info ── */
.info-group-label { margin: 0 0 14px; }
.info-group-label .eyebrow { font-size: 12.5px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 18px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border-top: 3px solid var(--blue); }
.info-card .ic-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.info-card .ic-ico { font-size: 26px; }
.info-card h4 { font-family: var(--display); font-size: 17px; font-weight: 600; }
.info-card .ic-section { margin-top: 12px; }
.info-card .ic-section strong { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); display: block; margin-bottom: 4px; }
.info-card p, .info-card li { font-size: 13px; color: var(--text-2); line-height: 1.7; }
.info-card ul { padding-left: 18px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 70px 20px 30px; }
  .menu-fab { display: block; }
  .hero, .analyze-layout, .result-summary { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
}

/* ════ XAI / Charts / Risk gauge ════ */
.gauge-wrap { position: relative; width: 180px; height: 110px; }
.gauge-center { position: absolute; inset: 0; top: 26px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; }
.gauge-pct { font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1; }
.gauge-unit { font-size: 16px; font-weight: 600; color: var(--text-2); margin-top: -4px; }
.gauge-lbl { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; margin-top: 6px; }
.xai-card .xai-chart-box { height: 190px; margin: 8px 0 14px; }
.prob-list.compact .prob-row { margin-bottom: 8px; }
.prob-list.compact .prob-head { font-size: 13px; }

/* ════ Report head + download ════ */
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.btn-ghost { background: var(--surface-2); color: var(--blue); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 10px; font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .2s; }
.btn-ghost:hover { background: var(--blue); color: #fff; border-color: var(--blue); transform: translateY(-1px); }

/* ════ AI Chat ════ */
.chat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-top: 18px; }
.chat-card h3 { font-family: var(--display); font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.chat-log { display: flex; flex-direction: column; gap: 12px; max-height: 340px; overflow-y: auto; padding: 4px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-end; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-av { font-size: 20px; flex-shrink: 0; width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--surface-2); border-radius: 50%; }
.chat-bub { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.6;
  background: var(--surface-2); color: var(--text); position: relative; animation: pop .25s ease; }
.chat-msg.ai .chat-bub { border-bottom-left-radius: 5px; }
.chat-msg.user .chat-bub { border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, var(--blue), var(--blue-d)); color: #fff; }
.chat-src { font-size: 11px; opacity: .55; margin-left: 6px; }
.chat-bub.typing { display: flex; gap: 5px; padding: 14px 16px; }
.chat-bub.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2);
  animation: blink 1.2s infinite both; }
.chat-bub.typing span:nth-child(2) { animation-delay: .2s; }
.chat-bub.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.25;transform:translateY(0)} 40%{opacity:1;transform:translateY(-3px)} }
@keyframes pop { from{opacity:0;transform:scale(.92)} to{opacity:1;transform:scale(1)} }
.chat-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 12px; }
.quick-chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--blue);
  padding: 7px 13px; border-radius: 20px; font-family: var(--font); font-size: 12.5px; cursor: pointer; transition: .2s; }
.quick-chip:hover { background: var(--blue); color: #fff; border-color: var(--blue); transform: translateY(-1px); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px;
  font-family: var(--font); font-size: 14px; background: var(--surface-2); color: var(--text); outline: none; transition: .2s; }
.chat-form input:focus { border-color: var(--blue); box-shadow: var(--ring); background: var(--surface); }
.chat-send { width: 48px; padding: 0; font-size: 18px; flex-shrink: 0; }

/* ════ Reveal animation ════ */
.reveal { animation: revealUp .5s ease both; }
.reveal:nth-child(2) { animation-delay: .08s; }
.reveal:nth-child(3) { animation-delay: .16s; }
.reveal:nth-child(4) { animation-delay: .24s; }
@keyframes revealUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
@keyframes pageIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ════ Print (download PDF) ════ */
@media print {
  body.printing .sidebar, body.printing .menu-fab, body.printing .result-actions,
  body.printing .chat-card, body.printing .chat-quick, body.printing #dlReport,
  body.printing .heatmap-toolbar, body.printing .xai-chart-box { display: none !important; }
  body.printing { display: block; background: #fff; color: #000; }
  body.printing .main { margin: 0; padding: 0; }
  body.printing .page:not(.active) { display: none; }
  body.printing .card, body.printing .report-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body.printing .result-summary { display: block; }
}

/* ════ Responsive (chat) ════ */
@media (max-width: 900px) {
  .chat-bub { max-width: 85%; }
  .xai-card .xai-chart-box { height: 220px; }
}

/* ════ Ask page (standalone chat) ════ */
.page-sub { color: var(--text-2); font-size: 14px; margin: -8px 0 18px; max-width: 720px; }
.ask-wrap { max-width: 820px; }
.chat-log.tall { max-height: 460px; min-height: 320px; }
.ask-disc { font-size: 12px; color: var(--text-2); margin-top: 12px; text-align: center; }
.cl-li { padding-left: 4px; }

/* ════ About — project dashboard ════ */
#aboutContent { max-width: 1000px; }
.about-hero { background: linear-gradient(140deg, var(--blue-d), var(--blue) 65%, var(--mint-d)); color: #fff;
  border-radius: var(--radius); padding: 34px 32px; box-shadow: var(--shadow-lg); margin-bottom: 22px; position: relative; overflow: hidden; }
.about-hero::before { content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.12) 1px, transparent 0); background-size: 22px 22px; }
.ah-badge { display: inline-block; background: rgba(255,255,255,.2); padding: 6px 14px; border-radius: 20px;
  font-family: var(--mono); font-weight: 600; font-size: 12px; letter-spacing: .08em; margin-bottom: 14px; position: relative; }
.about-hero h1 { font-family: var(--display); font-size: 28px; line-height: 1.3; margin-bottom: 12px; position: relative; }
.about-hero > p { font-size: 15px; line-height: 1.8; opacity: .95; max-width: 760px; position: relative; }
.ah-stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 22px; position: relative; }
.ah-stats div { display: flex; flex-direction: column; }
.ah-stats b { font-family: var(--display); font-size: 28px; font-weight: 700; }
.ah-stats span { font-size: 12.5px; opacity: .9; }

.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.about-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); }
.about-card.wide { grid-column: 1 / -1; margin-bottom: 18px; }
.about-card h3 { font-family: var(--display); font-size: 18px; margin-bottom: 14px; }
.about-card p { font-size: 14px; line-height: 1.85; color: var(--text-2); }
.about-note { font-size: 12.5px !important; color: var(--text-2); margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--border); }

.pipe-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 14px; }
.pipe-step { display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  background: var(--surface-2); border-radius: var(--radius-sm); transition: .2s; }
.pipe-step:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pipe-ico { font-size: 26px; flex-shrink: 0; }
.pipe-body { display: flex; flex-direction: column; gap: 3px; }
.pipe-body b { font-size: 14px; }
.pipe-body span { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }

.metric-list { display: flex; flex-direction: column; gap: 12px; }
.metric-row { display: grid; grid-template-columns: 110px 1fr 38px; align-items: center; gap: 10px; }
.m-name { font-size: 13px; }
.m-bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.m-fill { height: 100%; border-radius: 6px; transition: width .8s ease; }
.m-val { font-family: var(--mono); font-size: 13px; font-weight: 600; text-align: right; }

.adis-cat { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-2); margin: 0 0 10px; }
.about-dis-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 12px; }
.adis { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface-2);
  border-radius: var(--radius-sm); }
.adis b { font-size: 14px; }
.adis span { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }

.tech-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tech-tag { background: var(--surface-2); color: var(--blue); border: 1px solid var(--border);
  padding: 6px 13px; border-radius: 20px; font-family: var(--mono); font-size: 12px; font-weight: 500; }
.about-ul { padding-left: 18px; }
.about-ul li { font-size: 13.5px; color: var(--text-2); line-height: 1.9; }

.team-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.team-mem { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 18px 24px; flex: 1; min-width: 160px; }
.tm-av { font-size: 36px; }
.team-mem b { font-size: 14px; }
.team-mem span { font-size: 12px; color: var(--text-2); }

.about-cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-hero h1 { font-size: 22px; }
  .ah-stats { gap: 18px; }
}

/* ── modality switch (X-ray ↔ intraoral photo) ── */
.modality-switch { display: flex; gap: 12px; margin: 0 0 20px; }
.mod-btn {
  flex: 1; display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  font-family: var(--font); transition: all .18s ease; position: relative; overflow: hidden;
}
.mod-btn:hover { border-color: var(--blue-l); color: var(--text); }
.mod-btn.active {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-d));
  box-shadow: 0 6px 18px rgba(30,111,217,.28);
}
.mod-btn .mod-ico { font-size: 26px; line-height: 1; }
.mod-btn .mod-txt { display: flex; flex-direction: column; gap: 2px; }
.mod-btn .mod-txt b { font-family: var(--display); font-size: 15px; font-weight: 600; }
.mod-btn .mod-txt small { font-family: var(--mono); font-size: 11px; letter-spacing: .03em; opacity: .8; }
@media (max-width: 640px) {
  .modality-switch { flex-direction: column; }
  .mod-btn .mod-txt small { font-size: 10.5px; }
}

/* ── live camera capture ── */
#applianceForm {
  margin: 16px 0 18px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
}
#applianceForm[hidden], #bracesDetails[hidden] { display: none; }
#applianceForm > label, #bracesDetails > label { display: block; line-height: 1.5; }
#applianceForm input[type="checkbox"] { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--blue); }
#bracesDetails { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; margin: 14px 0; }
#bracesDetails > label { font-size: 13px; font-weight: 600; }
#bracesDetails > label:last-child { grid-column: 1 / -1; font-weight: 400; margin-top: 4px; }
#bracesDetails select { width: 100%; min-width: 0; padding: 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
#applianceForm .muted-sm { margin: 10px 0 0; line-height: 1.6; }
@media (max-width: 640px) { #bracesDetails { grid-template-columns: 1fr; } }
.cam-row { margin-top: 14px; }
.btn-cam {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font); font-size: 14.5px; font-weight: 600;
  color: var(--blue); background: var(--blue-soft);
  border: 1.5px solid var(--blue); transition: all .18s;
}
.btn-cam:hover { background: var(--blue); color: #fff; transform: translateY(-1px); }
.cam-stage { margin-top: 14px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: #000; }
.cam-stage video { width: 100%; display: block; max-height: 360px; object-fit: cover; background: #000; }
.cam-controls { display: flex; gap: 10px; padding: 12px; background: var(--surface); }
.cam-controls .btn-primary { flex: 1; }
.cam-controls .btn-ghost { flex: 0 0 auto; }

/* Attribution controls preserve source-image geometry. */
.hm-actions { display:flex; flex-wrap:wrap; gap:12px; padding:12px 16px; }
.hm-actions a { color:var(--blue); font-size:13px; text-decoration:underline; }
.hm-note { font-size:12px; line-height:1.7; color:var(--text-2); padding:8px 16px; }
.hm-legend .hm-scale { background:linear-gradient(90deg,#172554,#facc15,#dc2626); }
