/* DM Sans — Concept Dentistry body & web font (self-hosted, SIL Open Font License) */
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 100 1000; font-display: swap; src: url("/fonts/dm-sans-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-style: italic; font-weight: 100 1000; font-display: swap; src: url("/fonts/dm-sans-latin-wght-italic.woff2") format("woff2"); }

:root {
  /* Concept Dentistry brand palette (Brand Guidelines, July 2023) */
  --logo-blue: #185191;   /* PMS 7686 C */
  --logo-gray: #7E868C;   /* PMS 430 C */
  --navy: #012755;
  --dark-navy: #00192B;
  --light-blue: #678AB4;
  --light-gray: #DDDBD6;
  --dark-gray: #2F3438;
  --frosted-glass: #BDCBC7;
  --wood-grain: #E1C8B4;
  --leather: #7B3C1C;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f4f1;
  --ink: var(--dark-gray);
  --ink-2: #454b50;
  --heading: var(--logo-blue);
  --muted: #6b7379;
  --line: var(--light-gray);
  --accent: var(--logo-blue);
  --accent-deep: var(--navy);
  --accent-ink: #ffffff;
  --accent-soft: #edf1f7;
  --bubble: var(--logo-blue);
  --bubble-ink: #ffffff;
  --warn-bg: #faf4ee;
  --warn-line: var(--wood-grain);
  --warn-ink: var(--leather);
  --danger: var(--leather);
  --shadow: 0 1px 2px rgba(0, 25, 43, .05), 0 10px 30px rgba(0, 25, 43, .07);
  --radius: 0;
  --sans: "DM Sans", "Montserrat", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--dark-navy);
    --surface: #04233d;
    --surface-2: #0a2d4b;
    --ink: #f2f4f5;
    --ink-2: #d5dcdf;
    --heading: #ffffff;
    --muted: var(--frosted-glass);
    --line: #173b5c;
    --accent: #8fabcf;
    --accent-deep: #b3c7e0;
    --accent-ink: var(--dark-navy);
    --accent-soft: #0f3456;
    --bubble: var(--logo-blue);
    --bubble-ink: #ffffff;
    --warn-bg: #2a2118;
    --warn-line: #7a5a3c;
    --warn-ink: var(--wood-grain);
    --danger: #e7b89c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-feature-settings: 'lnum';
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }

/* ---------- Brand (approved logo artwork only) ---------- */
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; color: inherit; text-decoration: none; }
.brand img { display: block; }
.brand .logo-h { height: 50px; width: auto; }   /* ~250px wide, well above the 90px minimum */
.brand .rule { width: 1px; height: 34px; background: var(--line); }
.subtitle { font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.brand-stack { display: flex; flex-direction: column; align-items: center; gap: 22px; margin-bottom: 34px; }
.brand-stack .logo-s { width: 200px; height: auto; }
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) { .logo-light { display: none !important; } .logo-dark { display: block !important; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 0;
  box-shadow: var(--shadow); padding: 40px 32px 32px;
}
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; letter-spacing: .02em; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 0;
  border: 1px solid var(--line); background: var(--bg);
  transition: border-color .15s, background .15s;
}
.field input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 0; padding: 11px 18px;
  font-weight: 500; font-size: 14px; letter-spacing: .01em;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; margin-top: 8px; padding: 15px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; border: 2px solid var(--accent); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; border: 2px solid var(--accent); color: var(--accent); padding: 8px 14px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.btn-ghost:hover { background: var(--accent); color: var(--accent-ink); }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 10px 0 0; text-align: center; }
.fine { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; line-height: 1.5; }

/* ---------- App shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(24px, env(safe-area-inset-left)) 12px max(24px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 0; border: 1px solid var(--line); background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: 46px; z-index: 20; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 0;
  box-shadow: var(--shadow); padding: 6px;
}
.menu-panel .who { padding: 8px 10px 10px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-panel a, .menu-panel button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 0;
  border: 0; background: none; font-size: 14px; color: var(--ink); text-decoration: none;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }

.seg {
  display: inline-flex; padding: 3px; border-radius: 0; background: var(--surface-2); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: none; padding: 6px 11px; border-radius: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Conversation ---------- */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.thread { max-width: 760px; margin: 0 auto; padding: 28px 16px 24px; }

.welcome { text-align: center; padding: 24vh 0 24px; }
.welcome h1 { font: 700 clamp(26px, 4.4vw, 38px)/1.15 var(--sans); color: var(--heading); margin: 0 0 12px; letter-spacing: -.01em; }
.welcome .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.welcome p { color: var(--muted); margin: 0 auto; max-width: 440px; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; margin-top: 34px; text-align: left; }
.suggestion {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 0; padding: 14px 16px;
  font-size: 14px; color: var(--ink-2); line-height: 1.45; text-align: left; transition: border-color .15s, transform .15s;
}
.suggestion:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.msg { margin: 0 0 26px; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  background: var(--bubble); color: var(--bubble-ink); padding: 12px 18px; border-radius: 0;
  max-width: 85%; white-space: pre-wrap; word-wrap: break-word;
}
.msg-bot .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.msg-bot .card p { margin: 0 0 10px; }
.msg-bot .card p:last-child, .msg-bot .card ul:last-child, .msg-bot .card ol:last-child { margin-bottom: 0; }
.msg-bot .card ul, .msg-bot .card ol { margin: 4px 0 12px; padding-left: 20px; }
.msg-bot .card li { margin: 3px 0; }
.msg-bot .card strong { font-weight: 600; }
.msg-bot .card code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 0; }
.msg-bot .card h3, .msg-bot .card h4 { font: 600 15px/1.4 var(--sans); margin: 12px 0 6px; }
.msg-bot .card .label { color: var(--accent); font-weight: 600; letter-spacing: .01em; }
.msg-bot .card table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0 12px; }
.msg-bot .card th, .msg-bot .card td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.msg-bot .card .source { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 12px; }
.flag {
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
  border-radius: 0; padding: 10px 12px; margin: 12px 0 0; font-size: 14px;
}
.pending { background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 0; letter-spacing: .06em; }
.not-covered { color: var(--ink-2); }
.msg-tools { display: flex; gap: 4px; margin-top: 6px; padding-left: 4px; }
.tool {
  border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 5px 8px; border-radius: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.tool:hover { background: var(--surface-2); color: var(--ink-2); }
.tool svg { width: 14px; height: 14px; }
.tool.done { color: var(--accent); }

.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }
.error-card { border-color: var(--danger) !important; color: var(--danger); }

/* ---------- Composer ---------- */
.composer-wrap {
  border-top: 1px solid var(--line); background: var(--bg);
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
}
.composer { max-width: 760px; margin: 0 auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow); transition: border-color .15s;
}
.composer-box:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: 0; background: none; resize: none; outline: none;
  padding: 8px 0; max-height: 180px; min-height: 24px; line-height: 1.5; font-size: 16px;
}
.send {
  width: 40px; height: 40px; flex: none; border-radius: 0; border: 0;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; transition: opacity .15s;
}
.send:disabled { opacity: .3; cursor: default; }
.send svg { width: 18px; height: 18px; }
.composer-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; padding: 0 4px; }
.privacy { font-size: 12px; color: var(--muted); }
.phi-warn {
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
  border-radius: 0; padding: 10px 12px; font-size: 13px; margin-bottom: 10px;
}

/* ---------- Review page ---------- */
.review { max-width: 1000px; margin: 0 auto; padding: 28px 16px 60px; }
.review h1 { font: 700 32px/1.2 var(--sans); color: var(--heading); margin: 0 0 8px; letter-spacing: -.01em; }
.review .lede { color: var(--muted); margin: 0 0 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 16px 18px; }
.stat .n { font: 600 30px/1 var(--sans); color: var(--accent); }
.stat .k { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-top: 8px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 14px 16px; margin-bottom: 10px; }
.entry .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.entry .q { font-weight: 500; }
.entry details { margin-top: 8px; font-size: 13.5px; color: var(--ink-2); }
.entry details summary { cursor: pointer; color: var(--muted); }
.entry pre { white-space: pre-wrap; font: inherit; margin: 8px 0 0; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); border-radius: 0; padding: 12px 14px; margin-bottom: 20px; font-size: 14px; }

@media (max-width: 560px) {
  .brand .logo-h { height: 40px; }
  .brand .rule, .topbar .subtitle { display: none; }
  .topbar .seg-top { display: none; }
  .composer-meta .seg { display: inline-flex; }
  .msg-bot .card { padding: 16px; }
}
@media (min-width: 561px) {
  .composer-meta .seg { display: none; }
}

.report-body h2 { font-size: 17px; color: var(--heading); margin: 20px 0 8px; }
.report-body h2:first-child { margin-top: 0; }
.report-body ul, .report-body ol { padding-left: 20px; }

.who { max-width: 360px; margin: 26px auto 0; text-align: left; }
.who label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; text-align: center; }
.who-row { display: flex; gap: 8px; }
.who-row input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 0; font-size: 16px; }
.who-row input:focus { outline: none; border-color: var(--accent); }
.who-row .btn-primary { width: auto; margin: 0; padding: 12px 22px; }
.composer textarea:disabled { cursor: not-allowed; }
