/* ---------- Visual system tokens ---------- */
  :root {
    /* Surfaces — warm off-white family */
    --surface-page: #F7F5EE;        /* canvas */
    --surface-raised: #FBFAF4;      /* cards / chart panel */
    --surface-rail: #F2EFE6;        /* copilot rail (slightly deeper) */
    --surface-sunken: #EEEAE0;      /* input wells */
    --surface-inverse: #1F2422;

    /* Ink — warm near-blacks, never pure black */
    --ink-1: #1B1F1D;               /* headlines */
    --ink-2: #3A413E;               /* body */
    --ink-3: #6A716D;               /* secondary */
    --ink-4: #94998F;               /* tertiary / hints */
    --ink-5: #B7B9AE;               /* faint scaffolding */

    /* Borders */
    --line-1: #E4DFD2;
    --line-2: #D9D3C2;
    --line-strong: #C7C0AC;

    /* Accent — deep muted teal. Opinionated. NOT navy. */
    --accent: #2F6661;
    --accent-deep: #234B47;
    --accent-soft: #DDE7E4;
    --accent-tint: #EDF2F0;
    --accent-ink: #1A3F3B;

    /* Status — muted */
    --amber: #B6873A;     /* clarification */
    --amber-soft: #F4EAD3;
    --green: #4F7A55;     /* confirmed */
    --green-soft: #E2ECDF;
    --red: #A8493D;       /* genuine flags only */
    --red-soft: #F1DDD7;

    /* Typography */
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --font-serif: "Newsreader", "Iowan Old Style", Georgia, serif;

    /* Spacing — loose end of standard */
    --pad-rail: 28px;
    --pad-chart: 40px;
    --gap-zone: 56px;       /* between major chart zones */
    --gap-section: 24px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Elevation — subtle */
    --shadow-1: 0 1px 0 rgba(40,40,30,0.025), 0 1px 2px rgba(40,40,30,0.04);
    --shadow-2: 0 1px 0 rgba(40,40,30,0.03), 0 4px 16px -6px rgba(40,40,30,0.08);
  }

  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  html { background: var(--surface-page); }
  body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink-2);
    background: var(--surface-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv11";
    text-rendering: optimizeLegibility;
  }

  /* ---------- App shell ---------- */
  .app {
    display: grid;
    grid-template-columns: minmax(360px, 30%) 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "rail chart"
      "footer footer";
    height: 100vh;
    min-height: 720px;
    width: 100vw;
    overflow: hidden;
  }

  /* =========================================================
     COPILOT RAIL
     ========================================================= */
  .rail {
    grid-area: rail;
    background: var(--surface-rail);
    border-right: 1px solid var(--line-2);
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .rail-head {
    padding: 22px var(--pad-rail) 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line-1);
  }
  .brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--ink-1);
    font-weight: 600;
    letter-spacing: -0.01em;
    font-size: 15px;
  }
  .brand-mark {
    width: 22px; height: 22px;
    border-radius: 7px;
    background: var(--accent);
    position: relative;
    display: grid; place-items: center;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 1px 2px rgba(31, 36, 34, 0.18);
  }
  .brand-mark::after {
    content: "";
    width: 9px; height: 9px;
    border-radius: 999px;
    background: var(--surface-page);
    box-shadow: 2px -2px 0 -1px var(--surface-page);
    transform: translate(0.5px, 0.5px);
  }
  .brand small {
    font-weight: 450;
    color: var(--ink-3);
    margin-left: 4px;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .head-actions { display: flex; align-items: center; gap: 4px; }
  .icon-btn {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    color: var(--ink-3);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  }
  .icon-btn:hover { background: rgba(31,36,34,0.045); color: var(--ink-1); border-color: var(--line-1); }
  .icon-btn svg { width: 16px; height: 16px; }

  .session-strip {
    padding: 12px var(--pad-rail);
    display: flex; align-items: center; gap: 10px;
    color: var(--ink-3);
    font-size: 12px;
    border-bottom: 1px solid var(--line-1);
  }
  .pulse {
    width: 7px; height: 7px; border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(79,122,85,0.45);
    animation: pulse 2.4s ease-out infinite;
    flex: none;
  }
  @keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(79,122,85,0.35); }
    70% { box-shadow: 0 0 0 8px rgba(79,122,85,0); }
    100% { box-shadow: 0 0 0 0 rgba(79,122,85,0); }
  }
  .session-strip .sep { color: var(--ink-5); }
  .new-session {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--line-2);
    color: var(--ink-2);
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
  }
  .new-session:hover { background: var(--surface-raised); border-color: var(--line-strong); }

  .rail-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px var(--pad-rail) 16px;
    display: flex;
    flex-direction: column;
    gap: 28px;
  }

  /* Empty-state greeting */
  .greeting {
    display: flex; flex-direction: column; gap: 10px;
  }
  .greeting h1 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 26px;
    line-height: 1.2;
    color: var(--ink-1);
    letter-spacing: -0.012em;
    margin: 0;
  }
  .greeting h1 em {
    font-style: italic;
    color: var(--accent-deep);
  }
  .greeting p {
    margin: 0;
    color: var(--ink-3);
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 38ch;
  }

  .examples-label {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
    font-weight: 500;
    margin-bottom: -6px;
  }
  .examples {
    display: flex; flex-direction: column; gap: 8px;
  }
  .example {
    text-align: left;
    background: var(--surface-raised);
    border: 1px solid var(--line-1);
    color: var(--ink-2);
    padding: 11px 13px;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.45;
    transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
    display: flex; align-items: flex-start; gap: 10px;
    box-shadow: var(--shadow-1);
  }
  .example:hover {
    border-color: var(--accent);
    background: #fff;
  }
  .example .arrow {
    color: var(--ink-4);
    margin-left: auto;
    flex: none;
    transition: transform 120ms ease, color 120ms ease;
  }
  .example:hover .arrow { color: var(--accent); transform: translateX(2px); }

  .helper {
    color: var(--ink-4);
    font-size: 12px;
    display: flex; align-items: center; gap: 8px;
  }
  .kbd {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--ink-3);
    background: var(--surface-raised);
    border: 1px solid var(--line-1);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
  }

  /* Composer */
  .composer-wrap {
    padding: 14px var(--pad-rail) 22px;
    border-top: 1px solid var(--line-1);
    background: var(--surface-rail);
  }
  .composer {
    background: var(--surface-raised);
    border: 1px solid var(--line-2);
    border-radius: 12px;
    padding: 4px 4px 4px 12px;
    display: flex; align-items: flex-end;
    gap: 6px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
    box-shadow: var(--shadow-1);
  }
  .composer:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47,102,97,0.10), var(--shadow-1);
  }
  .composer textarea {
    flex: 1;
    border: 0;
    background: transparent;
    resize: none;
    outline: none;
    font: inherit;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-1);
    padding: 9px 0 9px;
    min-height: 22px;
    max-height: 160px;
    font-family: var(--font-sans);
  }
  .composer textarea::placeholder { color: var(--ink-4); }
  .send-btn {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 0;
    background: var(--accent);
    color: #F7F5EE;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background 120ms ease, transform 120ms ease;
    flex: none;
    margin-bottom: 3px;
  }
  .send-btn:hover { background: var(--accent-deep); }
  .send-btn:active { transform: translateY(1px); }
  .send-btn[disabled] {
    background: var(--line-strong);
    cursor: not-allowed;
  }
  .send-btn svg { width: 14px; height: 14px; }

  /* =========================================================
     CHART
     ========================================================= */
  .chart {
    grid-area: chart;
    overflow-y: auto;
    background: var(--surface-page);
    position: relative;
  }
  .chart-inner {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 var(--pad-chart) 96px;
  }

  /* Banner */
  .banner {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 calc(var(--pad-chart) * -1);
    padding: 18px var(--pad-chart);
    background: linear-gradient(var(--surface-page) 75%, rgba(247,245,238,0));
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px 20px;
    flex-wrap: wrap;
  }
  .banner-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 240px; }
  .banner-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px dashed var(--line-strong);
    color: var(--ink-4);
    display: grid; place-items: center;
    background: var(--surface-raised);
    flex: none;
  }
  .banner-avatar svg { width: 16px; height: 16px; }
  .banner-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
  .banner-title {
    font-size: 14.5px;
    color: var(--ink-2);
    font-weight: 500;
    letter-spacing: -0.005em;
  }
  .banner-sub {
    font-size: 12px;
    color: var(--ink-4);
  }
  .banner-meta {
    display: flex; align-items: center; gap: 8px;
    color: var(--ink-4);
    font-size: 12px;
    flex-wrap: wrap;
    flex: 0 1 auto;
    justify-content: flex-end;
    min-width: 0;
  }
  .banner-text { flex: 1 1 0; min-width: 0; }
  .banner-title, .banner-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .banner-meta .chip-faint {
    border: 1px dashed var(--line-strong);
    color: var(--ink-4);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    background: transparent;
  }

  /* Zones */
  .zones {
    display: flex;
    flex-direction: column;
    gap: var(--gap-zone);
    padding-top: 8px;
  }
  .zone-head {
    display: flex; align-items: baseline; gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-1);
  }
  .zone-num {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-4);
    letter-spacing: 0.05em;
    flex: none;
  }
  .zone-title {
    font-size: 17px;
    color: var(--ink-1);
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0;
  }
  .zone-sub {
    font-size: 12.5px;
    color: var(--ink-4);
    margin-left: auto;
  }
  .zone-body {
    display: flex; flex-direction: column;
    gap: var(--gap-section);
  }

  /* Subsection */
  .sub {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 32px;
    padding: 4px 0;
  }
  .sub-label {
    font-size: 13px;
    color: var(--ink-2);
    font-weight: 500;
    padding-top: 2px;
  }
  .sub-label .hint {
    display: block;
    font-weight: 400;
    color: var(--ink-4);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.45;
  }
  .sub-body { min-width: 0; }

  /* Empty card / ghost */
  .ghost {
    border: 1px dashed var(--line-2);
    background: rgba(251, 250, 244, 0.5);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .ghost-row {
    display: flex; align-items: center; gap: 12px;
    color: var(--ink-4);
    font-size: 13px;
  }
  .ghost-row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; }
  .ghost-row .label-frag {
    color: var(--ink-3);
    font-weight: 500;
  }
  .ghost-row .frag-hint {
    color: var(--ink-4);
    font-size: 12px;
  }

  .field-stub {
    display: flex; gap: 10px; flex-wrap: wrap;
  }
  .stub-input {
    background: var(--surface-raised);
    border: 1px solid var(--line-1);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--ink-4);
    font-size: 13px;
    min-width: 140px;
    flex: 1;
  }
  .stub-input.tiny { flex: 0 0 80px; min-width: 80px; }

  /* (Calc placeholder styles retired — see calc-pane below.) */

  /* (Doc-draft placeholder styles retired — see docs-grid below.) */

  /* =========================================================
     FOOTER
     ========================================================= */
  .footer {
    grid-area: footer;
    background: var(--surface-inverse);
    color: #B7BAB1;
    border-top: 1px solid #14181666;
    font-size: 12px;
    padding: 11px 24px;
    display: flex; align-items: center; gap: 14px;
    line-height: 1.45;
  }
  .footer .badge {
    display: inline-flex; align-items: center; gap: 6px;
    color: #DDE0D6;
    font-weight: 500;
    letter-spacing: 0.01em;
    flex: none;
  }
  .footer .badge::before {
    content: "";
    width: 6px; height: 6px; border-radius: 50%;
    background: #BBA76B;
  }
  .footer .sep { color: #4B524F; flex: none; }
  .footer .body { color: #9DA197; }
  .footer .phi {
    margin-left: auto;
    flex: none;
    color: #D4B36C;
    font-weight: 500;
    letter-spacing: 0.01em;
  }
  @media (max-width: 1100px) {
    .footer .body { font-size: 11.5px; }
  }

  /* Scrollbar */
  .rail-body::-webkit-scrollbar, .chart::-webkit-scrollbar { width: 10px; }
  .rail-body::-webkit-scrollbar-thumb, .chart::-webkit-scrollbar-thumb {
    background: rgba(40,40,30,0.10);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  .rail-body::-webkit-scrollbar-thumb:hover, .chart::-webkit-scrollbar-thumb:hover {
    background: rgba(40,40,30,0.18);
    background-clip: padding-box;
    border: 2px solid transparent;
  }

  /* Selection */
  ::selection { background: var(--accent-soft); color: var(--accent-ink); }


/* =========================================================
   PATIENT INPUTS — interactive components
   ========================================================= */

/* Text + number inputs */
.input {
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--ink-1);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  outline: none;
  width: 100%;
}
.input::placeholder { color: var(--ink-4); }
.input:hover { border-color: var(--line-2); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
  background: #fff;
}
.input.tiny { width: 84px; }
.input.small { width: 120px; }
textarea.input {
  resize: vertical;
  min-height: 38px;
}

/* Field shell — input + unit toggle */
.unit-field {
  display: inline-flex;
  align-items: stretch;
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: 9px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  overflow: hidden;
  min-width: 168px;
}
.unit-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
  background: #fff;
}
.unit-field input {
  border: 0; outline: none; background: transparent;
  font: inherit; font-size: 13.5px;
  color: var(--ink-1);
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}
.unit-toggle {
  display: flex;
  border-left: 1px solid var(--line-1);
  background: var(--surface-rail);
}
.unit-toggle button {
  border: 0; background: transparent;
  font: inherit;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 0 9px;
  cursor: pointer;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  transition: color 120ms ease, background 120ms ease;
}
.unit-toggle button + button { border-left: 1px solid var(--line-1); }
.unit-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: #F7F5EE;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-deep);
}
.unit-toggle button[aria-pressed="true"]:hover { background: var(--accent-deep); color: #F7F5EE; }

/* Sex segmented */
.seg {
  display: inline-flex;
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0; background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}
.seg button:hover { color: var(--ink-1); }
.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: #F7F5EE;
  box-shadow: 0 1px 2px rgba(31,36,34,0.12);
}

/* BMI chip */
.bmi-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
}
.bmi-display .value {
  font-family: var(--font-mono);
  color: var(--ink-1);
  font-weight: 500;
  font-size: 14px;
}
.status-chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
  letter-spacing: 0.005em;
}
.status-chip.normal     { background: var(--green-soft); color: #2F5C3A; border-color: rgba(79,122,85,0.18); }
.status-chip.under      { background: var(--amber-soft); color: #7A5A22; border-color: rgba(182,135,58,0.22); }
.status-chip.over       { background: var(--amber-soft); color: #7A5A22; border-color: rgba(182,135,58,0.22); }
.status-chip.obese      { background: var(--red-soft); color: #7B3225; border-color: rgba(168,73,61,0.22); }
.status-chip.muted      { background: var(--surface-sunken); color: var(--ink-3); border-color: var(--line-1); }
.status-chip.geri       { background: var(--accent-tint); color: var(--accent-ink); border-color: rgba(47,102,97,0.18); }

/* Searchable dropdown — diagnosis */
.combo {
  position: relative;
}
.combo-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: 9px;
  padding: 8px 11px;
  cursor: text;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  min-height: 38px;
  font-size: 13.5px;
}
.combo-input:hover { border-color: var(--line-2); }
.combo-input.open, .combo-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
  background: #fff;
}
.combo-input input {
  flex: 1;
  border: 0; outline: none; background: transparent;
  font: inherit; font-size: 13.5px;
  color: var(--ink-1);
  min-width: 0;
}
.combo-input input::placeholder { color: var(--ink-4); }
.combo-input .caret {
  color: var(--ink-4);
  display: grid; place-items: center;
}
.combo-menu {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 10px 28px -12px rgba(40,40,30,0.22), 0 2px 6px rgba(40,40,30,0.06);
  padding: 6px;
  z-index: 20;
  max-height: 280px;
  overflow-y: auto;
}
.combo-option {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-1);
}
.combo-option:hover, .combo-option[aria-selected="true"] {
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.combo-option .tier {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.combo-option:hover .tier, .combo-option[aria-selected="true"] .tier { color: var(--accent); }
.combo-empty {
  padding: 12px; color: var(--ink-4); font-size: 13px; font-style: italic;
}

/* Diagnosis selected display */
.dx-display {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dx-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-1);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.dx-pill:hover {
  border-color: var(--accent);
  background: var(--surface-raised);
}
.dx-pill:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.18);
}
.dx-pill.open {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
}
.dx-pill-text {
  font-weight: 500;
  letter-spacing: -0.005em;
}
.dx-pill-caret {
  display: inline-grid; place-items: center;
  width: 14px; height: 14px;
  color: var(--ink-4);
  transition: transform 150ms ease, color 120ms ease;
}
.dx-pill:hover .dx-pill-caret { color: var(--accent); }
.dx-pill.open .dx-pill-caret { transform: rotate(180deg); color: var(--accent); }
.dx-pill .x {
  border: 0; background: var(--surface-sunken);
  width: 20px; height: 20px;
  border-radius: 50%;
  color: var(--ink-3);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 120ms ease, color 120ms ease;
}
.dx-pill .x:hover { background: var(--line-strong); color: var(--ink-1); }
.dx-pill .x:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.combo-option.is-current {
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.combo-option.is-current:hover, .combo-option.is-current[aria-selected="true"] {
  background: var(--accent-soft);
}

/* Tier chip — clearly distinct from dx pill */
.tier-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: help;
  border: 1px solid transparent;
}
.tier-chip::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 1px;
}
.tier-chip.deep      { background: var(--accent-tint); color: var(--accent-deep); border-color: rgba(47,102,97,0.22); }
.tier-chip.deep::before     { background: var(--accent); }
.tier-chip.standard  { background: var(--surface-sunken); color: var(--ink-2); border-color: var(--line-2); }
.tier-chip.standard::before { background: var(--ink-3); }
.tier-chip.fallback  { background: var(--amber-soft); color: #7A5A22; border-color: rgba(182,135,58,0.22); }
.tier-chip.fallback::before { background: var(--amber); }

/* Multi-select chips */
.chip-group {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  border: 1px solid var(--line-2);
  background: var(--surface-raised);
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 120ms ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--accent); color: var(--ink-1); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  color: #F7F5EE;
  border-color: var(--accent);
}
.chip[aria-pressed="true"]::before {
  content: "✓";
  font-size: 11px;
  margin-right: -2px;
}

/* Tri-state pill (food security) */
.tri {
  display: inline-flex;
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: 999px;
  padding: 3px;
}
.tri button {
  border: 0; background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.tri button:hover { color: var(--ink-1); }
.tri button[aria-pressed="true"] {
  color: #fff;
  font-weight: 500;
}
.tri button.secure[aria-pressed="true"]   { background: var(--green); }
.tri button.limited[aria-pressed="true"]  { background: var(--amber); }
.tri button.insecure[aria-pressed="true"] { background: var(--red); }

/* Toggle row */
.toggle-list {
  display: flex; flex-direction: column; gap: 2px;
}
.toggle-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-1);
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .label {
  color: var(--ink-2);
  font-size: 13px;
}
.toggle-row .label-hint {
  color: var(--ink-4);
  font-size: 12px;
  margin-left: 6px;
}
.toggle-row .right {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}
.toggle-row .lang-input {
  width: 160px;
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: 7px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-1);
  outline: none;
}
.toggle-row .lang-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
  background: #fff;
}

.switch {
  --sw-w: 32px; --sw-h: 18px;
  width: var(--sw-w); height: var(--sw-h);
  background: var(--line-strong);
  border-radius: 999px;
  border: 0;
  position: relative;
  cursor: pointer;
  transition: background 140ms ease;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #FBFAF4;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  transition: transform 140ms ease;
}
.switch[aria-pressed="true"] { background: var(--accent); }
.switch[aria-pressed="true"]::after { transform: translateX(14px); }

/* Banner — populated states */
.banner-avatar.populated {
  border: 1px solid var(--line-2);
  border-style: solid;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.banner-meta .chip {
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  cursor: default;
}
.banner-meta .chip-meta {
  background: var(--surface-raised);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  display: inline-flex; align-items: center; gap: 6px;
}
.banner-meta .chip-meta .lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}
.banner-meta .chip-meta .val {
  font-family: var(--font-mono);
  color: var(--ink-1);
  font-weight: 500;
}
.banner-meta .chip-bmi {
  background: #fff;
  border: 1px solid var(--line-2);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.banner-meta .chip-bmi .lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}
.banner-meta .chip-bmi .val {
  font-family: var(--font-mono);
  color: var(--ink-1);
  font-weight: 500;
}
.banner-meta .chip-bmi .status-chip {
  font-size: 10.5px;
  padding: 2px 7px;
}
.banner-meta .chip-dx {
  background: var(--accent);
  color: #F7F5EE;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--accent-deep);
  letter-spacing: 0.005em;
}

/* Reset/seed strip */
.workspace-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-tint); }

/* Subsection rows: vertical when input area is dense */
.row-stack {
  display: flex; flex-direction: column; gap: 14px;
}
.row-inline {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}

/* Tooltip-ish helper line for activity multiplier */
.activity-row {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
}
.activity-row select.input {
  width: 220px;
  padding-right: 32px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236A716D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.activity-row .multiplier {
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* Geriatric / age-based note */
.note-inline {
  font-size: 11.5px;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px;
}
.note-inline .glyph {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-deep);
  display: grid; place-items: center;
  font-size: 9px;
  font-weight: 600;
}

/* Small label above inline group */
.field-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
  margin-bottom: 6px;
  display: block;
}


/* ===================================================================
   Calculation Engine
   =================================================================== */

.calc-stack {
  display: flex; flex-direction: column;
  gap: 16px;
}

.calc-empty {
  display: flex; align-items: center; gap: 16px;
  padding: 22px 24px;
  border: 1px dashed var(--line-2);
  background: rgba(251, 250, 244, 0.5);
  border-radius: var(--radius-md);
  color: var(--ink-3);
}
.calc-empty-glyph {
  font-family: var(--font-serif, Newsreader, serif);
  font-size: 38px;
  color: var(--ink-5);
  line-height: 1;
}
.calc-empty-title {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.calc-empty-sub {
  color: var(--ink-4);
  font-size: 12.5px;
}

/* Pane (Energy / Protein / Fluids) */
.calc-pane {
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 22px 24px;
  display: flex; flex-direction: column;
  gap: 16px;
}
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.pane-title-wrap {
  display: flex; align-items: center; gap: 10px;
}
.pane-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.012em;
}
.badge-rec {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-ink);
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.badge-rec.geri {
  color: #6E5717;
  background: #FBF1D7;
  border-color: #ECDFB7;
}
.pane-controls {
  display: flex; align-items: center; gap: 8px;
}
.mini-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}

.pane-empty {
  padding: 14px 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  background: rgba(247,245,238,0.6);
  color: var(--ink-4);
  font-size: 13px;
}

/* Transparency block — calmer dark surface */
.transparency {
  background: #232826;
  border: 1px solid #2C322F;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.t-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 22px;
}
.t-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8A938E;
  font-weight: 500;
}
.t-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #DCE0D9;
  white-space: pre-wrap;
  word-break: break-word;
}
.t-row.result {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed #383E3B;
}
.t-row.result .t-label {
  color: #C7CDC6;
}
.t-result {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.t-result .num-mono {
  font-family: var(--font-mono);
  font-size: 17px;
  color: #F2EFE6;
  font-weight: 500;
}
.t-result .num-mono.big {
  font-size: 22px;
  letter-spacing: -0.01em;
}
.t-result .num-suffix {
  font-size: 12px;
  color: #9CA39E;
}
.t-result .num-aux {
  font-size: 11.5px;
  color: #8A938E;
  margin-left: 4px;
}

/* Inline editable number */
.editable {
  display: inline-flex; align-items: center; gap: 6px;
  position: relative;
}
.editable .num-input {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-1);
  background: var(--surface-raised);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 4px 8px;
  text-align: right;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.editable .num-input:hover { border-color: var(--line-strong); }
.editable .num-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
  background: #fff;
}
.editable .suffix {
  font-size: 12px;
  color: var(--ink-4);
}
.editable.overridden .num-input {
  border-color: #C99544;
  background: #FBF4E5;
  color: #5F4513;
}
.editable.overridden::after {
  content: "manually adjusted";
  position: absolute;
  bottom: -14px; left: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #A1751B;
  white-space: nowrap;
}
.reset-pin {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px;
  border: 0; background: transparent;
  color: #A1751B;
  cursor: pointer;
  border-radius: 4px;
}
.reset-pin:hover { background: #F2E6C8; color: #6E5717; }

/* Inside dark transparency block — invert input chrome */
.transparency .editable .num-input {
  background: #2A2F2C;
  border-color: #3A4140;
  color: #F2EFE6;
}
.transparency .editable .num-input:hover { border-color: #4D5552; }
.transparency .editable .num-input:focus {
  border-color: var(--accent);
  background: #1F2422;
  box-shadow: 0 0 0 2px rgba(47,102,97,0.30);
}
.transparency .editable .suffix { color: #9CA39E; }
.transparency .editable.overridden .num-input {
  background: #3A2F18;
  border-color: #C99544;
  color: #F1D49A;
}
.transparency .editable.overridden::after {
  color: #D9AC55;
}

/* Multipliers / TDEE row */
.multipliers {
  display: flex; flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}
.mult-row {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.mult-row .m-label {
  font-size: 13px;
  color: var(--ink-2);
  min-width: 220px;
}
.mult-row.tdee {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-1);
}
.mult-row.tdee .m-label {
  color: var(--ink-3);
  font-size: 12.5px;
}
.tdee-val {
  display: inline-flex; align-items: baseline; gap: 6px;
}
.tdee-val .num-mono {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--ink-1);
  font-weight: 500;
}
.tdee-val .num-suffix {
  font-size: 12px;
  color: var(--ink-4);
}

/* Adjustment row */
.adjustment-row {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}

/* Result bar — prominent final value */
.result-bar {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-md);
}
.result-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  font-weight: 500;
}
.result-value {
  display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-left: auto;
}
.big-num {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 500;
  color: var(--accent-ink);
  letter-spacing: -0.015em;
  line-height: 1;
}
.big-unit {
  font-size: 13px;
  color: var(--accent-ink);
  opacity: 0.75;
}
.result-note {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-ink);
  opacity: 0.65;
  margin-left: 8px;
}

/* Rationale row */
.rationale {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-page);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-3);
  font-style: italic;
}
.rationale .r-glyph {
  flex: none;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 50%;
  font-style: normal;
  font-family: var(--font-serif, Newsreader, serif);
  font-size: 12px;
  font-weight: 500;
}

/* CKD note */
.ckd-note {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: #FBF4E5;
  border: 1px solid #ECDFB7;
  border-radius: var(--radius-sm);
  color: #6E5717;
  font-size: 12.5px;
}
.ckd-note .warn-glyph {
  flex: none;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  background: #C99544;
  color: #FBF4E5;
  border-radius: 50%;
  font-weight: 600;
  font-size: 11.5px;
}

/* Citation card */
.citation {
  margin-top: 2px;
}
.cite-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 6px;
  transition: color 120ms ease, background 120ms ease;
}
.cite-btn:hover { color: var(--accent-ink); background: var(--accent-tint); }
.cite-btn .cite-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  border-left: 1px solid var(--line-2);
  padding-left: 8px;
  margin-left: 2px;
}
.citation.open .cite-btn { color: var(--accent-ink); }
.cite-body {
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--surface-page);
  border-left: 2px solid var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--ink-2);
  display: flex; flex-direction: column;
  gap: 6px;
}
.cite-full {
  font-family: var(--font-serif, Newsreader, serif);
  font-style: italic;
  color: var(--ink-2);
  line-height: 1.5;
}
.cite-note {
  color: var(--ink-3);
  font-size: 12px;
}

/* Adjustment notes block */
.adjustment-notes {
  background: #FBF4E5;
  border: 1px solid #ECDFB7;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 10px;
}
.an-head {
  display: flex; align-items: center; gap: 10px;
}
.an-glyph {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: #C99544;
  color: #FBF4E5;
  border-radius: 50%;
  font-size: 12px;
}
.an-title {
  font-size: 13.5px;
  font-weight: 500;
  color: #5F4513;
}
.an-sub {
  font-size: 12px;
  color: #8A6D2A;
}
.adjustment-notes textarea.input {
  background: #fff;
  border-color: #ECDFB7;
}
.adjustment-notes textarea.input:focus {
  border-color: #C99544;
  box-shadow: 0 0 0 3px rgba(201,149,68,0.18);
}


/* ===================================================================
   Documentation Drafts
   =================================================================== */

.docs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
  gap: 22px;
  align-items: start;
}
@media (max-width: 1280px) {
  .docs-grid { grid-template-columns: 1fr; }
}

.docs-col {
  display: flex; flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.docs-col-r {
  position: sticky;
  top: 18px;
  align-self: start;
}

/* Generic doc-card (re-introduced for the real Documentation zone) */
.doc-card {
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 20px 22px;
  display: flex; flex-direction: column;
  gap: 14px;
}
.doc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.doc-head-l { display: flex; align-items: center; gap: 12px; }
.doc-head-r { display: flex; align-items: center; gap: 14px; }
.doc-num {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}
.pes-card .doc-num {
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.doc-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.012em;
}
.doc-sub {
  font-size: 12px;
  color: var(--ink-4);
}
.doc-empty {
  padding: 14px 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  background: rgba(247,245,238,0.6);
  color: var(--ink-4);
  font-size: 13px;
}

.link-btn {
  background: transparent; border: 0;
  font: inherit; font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.link-btn:hover { color: var(--accent-deep); text-decoration: underline; }

/* ---------- PES Builder ---------- */

.pes-card {
  border-color: var(--line-2);
}

.pes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 1100px) { .pes-grid { grid-template-columns: 1fr; } }

.pes-field {
  display: flex; flex-direction: column;
  gap: 6px;
}
.pes-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pes-letter {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

/* P/E/S color palettes — calm, not loud */
.p-color .pes-letter   { background: #DDEAD9; color: #2E5B33; }
.e-color .pes-letter   { background: #DDE5EE; color: #314A66; }
.s-color .pes-letter   { background: #F1E5C7; color: #6E5717; }

.pes-help {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.4;
}

/* PES live preview */
.pes-preview {
  background: var(--surface-page);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.pes-preview-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.pes-preview-body {
  font-family: var(--font-serif, Newsreader, serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}
.pes-preview-body .pes-empty {
  font-style: italic;
  color: var(--ink-4);
  font-size: 14px;
}

/* PES blocks (color-coded) */
.pes-block {
  display: inline;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: normal;
}
.p-block {
  background: #E8F1E4;
  color: #2E5B33;
  border-color: #D4E3CE;
}
.e-block {
  background: #E5EDF6;
  color: #314A66;
  border-color: #D2DEEC;
}
.s-block {
  background: #FAEFD2;
  color: #6E5717;
  border-color: #ECDFB7;
}
.pes-conn {
  font-style: italic;
  font-weight: 500;
  color: var(--ink-3);
  margin: 0 4px;
}
.pes-block-period {
  color: var(--ink-3);
  margin-left: 2px;
}
.pes-block .pes-ph {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-style: italic;
  opacity: 0.55;
}

/* PES section read-only display (in section card #2) */
.pes-readout {
  margin: 0;
  font-family: var(--font-serif, Newsreader, serif);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* ---------- Estimated Needs section ---------- */
.needs-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  gap: 10px;
}
.needs-list li {
  display: grid;
  grid-template-columns: 90px auto 1fr;
  align-items: baseline;
  column-gap: 14px;
  padding: 10px 12px;
  background: var(--surface-page);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
}
.needs-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.needs-value {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink-1);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.needs-meta {
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
  text-wrap: pretty;
}
@media (max-width: 1100px) {
  .needs-list li { grid-template-columns: 80px auto; }
  .needs-meta { grid-column: 1 / -1; text-align: left; }
}

/* ---------- Interventions / Monitoring lists ---------- */
.iv-list, .me-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  gap: 10px;
}
.iv-row, .me-row {
  display: grid;
  grid-template-columns: 24px 1fr 24px;
  gap: 8px;
  align-items: start;
}
.iv-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  background: var(--surface-sunken);
  border-radius: 999px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  margin-top: 6px;
}
.me-bullet {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  color: var(--accent);
  font-size: 16px;
  margin-top: 4px;
}
.iv-text, .me-text {
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
.iv-x {
  background: transparent;
  border: 0;
  color: var(--ink-5);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  margin-top: 6px;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease;
}
.iv-x:hover { background: #F5E0D7; color: #8B3A1F; }

.iv-add {
  align-self: flex-start;
  background: transparent;
  border: 1px dashed var(--line-2);
  color: var(--ink-3);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.iv-add:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-tint);
}
.iv-add span {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
}

.me-targets {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-page);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
}
@media (max-width: 1100px) { .me-targets { grid-template-columns: 1fr; } }
.me-target {
  display: flex; flex-direction: column; gap: 4px;
}
.me-target .me-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}

/* ---------- Full Note Output panel ---------- */
.note-panel {
  background: #232826;
  border: 1px solid #2C322F;
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  display: flex; flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-1);
  max-height: calc(100vh - 60px);
}
.np-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.np-head-l { display: flex; flex-direction: column; gap: 2px; }
.np-title {
  color: #F2EFE6;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.np-sub {
  color: #8A938E;
  font-size: 11.5px;
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent);
  color: #F7F5EE;
  border: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.copy-btn:hover:not([disabled]) { background: var(--accent-deep); }
.copy-btn:active:not([disabled]) { transform: translateY(1px); }
.copy-btn[disabled] {
  background: #3A4140;
  color: #6E7470;
  cursor: not-allowed;
}
.copy-btn.copied {
  background: #4F7A55;
  animation: cp-pulse 220ms ease;
}
@keyframes cp-pulse {
  0% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.np-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  color: #8A938E;
  font-family: var(--font-mono);
}
.np-meta .np-dot { color: #4D5552; }
.np-body {
  margin: 0;
  background: #1B1F1D;
  border: 1px solid #2C322F;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: #DCE0D9;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 320px;
  max-height: calc(100vh - 200px);
}
.np-body:empty::before {
  content: "Note will assemble automatically as you fill out the chart and PES statement above.";
  color: #6E7470;
  font-style: italic;
  font-family: var(--font-sans);
  font-size: 13px;
}

/* =========================================================
   COPILOT — message bubbles & chips
   ========================================================= */
.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 4px;
}
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.55;
}
.msg-user {
  flex-direction: row-reverse;
}
.msg-user .msg-body {
  background: var(--accent-tint);
  color: var(--accent-ink);
  border: 1px solid rgba(47,102,97,0.18);
  padding: 9px 13px;
  border-radius: 14px 14px 4px 14px;
  max-width: 86%;
}
.msg-assistant .msg-body {
  color: var(--ink-1);
  max-width: 92%;
}
.msg-glyph {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface-page);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
  margin-top: 1px;
  line-height: 1;
}
.msg-text { white-space: pre-wrap; }
.msg-cite {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-4);
  font-style: italic;
  letter-spacing: 0.005em;
}
.msg-chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.msg-chip {
  background: var(--surface-raised);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  padding: 5px 11px;
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}
.msg-chip:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.helper kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
}

/* =========================================================
   ABOUT PANEL — slide-in side panel (NOT a modal)
   ========================================================= */
.about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31,36,34,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 40;
}
.about-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.about-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 92vw);
  background: var(--surface-raised);
  border-left: 1px solid var(--line-2);
  box-shadow: -16px 0 48px -16px rgba(40,40,30,0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(.2,.7,.2,1);
  z-index: 41;
}
.about-panel.open { transform: translateX(0); }

.about-head {
  padding: 22px 24px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line-1);
}
.about-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
  margin-bottom: 4px;
}
.about-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 24px;
  color: var(--ink-1);
  letter-spacing: -0.012em;
}
.about-nav {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line-1);
  background: var(--surface-rail);
}
.about-nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-3);
  padding: 5px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.about-nav-item:hover { color: var(--ink-1); background: var(--surface-raised); }
.about-nav-item.active {
  background: var(--accent-tint);
  color: var(--accent-ink);
  border-color: rgba(47,102,97,0.22);
}
.about-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px 32px;
  scroll-behavior: smooth;
}
.about-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line-1);
}
.about-section:last-of-type { border-bottom: 0; }
.about-section h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 18px;
  color: var(--ink-1);
  margin: 0 0 12px;
  letter-spacing: -0.005em;
}
.about-section h4 {
  font-size: 13px;
  color: var(--ink-1);
  font-weight: 600;
  margin: 18px 0 6px;
  letter-spacing: -0.005em;
}
.about-section p {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0 0 10px;
}
.about-section ul {
  margin: 0 0 8px;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.65;
}
.about-section li { margin-bottom: 6px; }
.about-section .muted {
  color: var(--ink-4);
  font-size: 12.5px;
  margin-top: 6px;
}
.about-section .cite-list li {
  font-size: 12.5px;
  color: var(--ink-3);
  font-family: var(--font-sans);
}
.about-section .cite-list em { color: var(--ink-2); }

.method-block {
  padding: 12px 0;
  border-top: 1px dashed var(--line-1);
}
.method-block:first-child { border-top: 0; padding-top: 0; }

.tier-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.tier-card {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--line-1);
  background: var(--surface-rail);
}
.tier-card .tier-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.tier-card.tier-deep { background: var(--accent-tint); border-color: rgba(47,102,97,0.18); }
.tier-card.tier-deep .tier-label { color: var(--accent-ink); }
.tier-card.tier-fallback { background: var(--amber-soft); border-color: rgba(182,135,58,0.22); }
.tier-card.tier-fallback .tier-label { color: #7A5A22; }
.tier-card ul { margin: 0; padding-left: 18px; font-size: 13px; }
.tier-card li { margin-bottom: 4px; }

.dial {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  align-items: flex-start;
}
.dial + .dial { border-top: 1px dashed var(--line-1); }
.dial-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-deep);
  background: var(--accent-tint);
  padding: 4px 8px;
  border-radius: 6px;
  flex: none;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.dial-body {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}
.dial-body strong { color: var(--ink-1); }

.about-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--ink-4);
}
.about-foot .badge {
  background: var(--surface-sunken);
  color: var(--ink-3);
  border: 1px solid var(--line-2);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10.5px;
}

/* =========================================================
   FLAGS PANEL — clinical context flags
   ========================================================= */
.flags-panel {
  margin: 16px 0 28px;
  padding: 16px 18px;
  background: var(--surface-raised);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}
.flags-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.flags-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
}
.flags-count {
  background: var(--accent-tint);
  color: var(--accent-deep);
  border: 1px solid rgba(47,102,97,0.18);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.flags-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flag-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-1);
  background: var(--surface-rail);
  align-items: flex-start;
}
.flag-warn { border-color: rgba(168,73,61,0.22); background: var(--red-soft); }
.flag-info { border-color: rgba(47,102,97,0.18); background: var(--accent-tint); }
.flag-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex: none;
  background: rgba(255,255,255,0.6);
}
.flag-icon svg { width: 15px; height: 15px; }
.flag-warn .flag-icon { color: var(--red); }
.flag-info .flag-icon { color: var(--accent-deep); }
.flag-body { flex: 1; min-width: 0; }
.flag-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.flag-text {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 8px;
}
.flag-cite {
  font-size: 11.5px;
  color: var(--ink-4);
  font-style: italic;
  margin-top: 6px;
}
.flag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.flag-chip {
  background: var(--surface-raised);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  padding: 5px 11px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.flag-chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: #fff;
}
.flag-chip.primary {
  background: var(--accent);
  color: var(--surface-page);
  border-color: var(--accent);
}
.flag-chip.primary:hover {
  background: var(--accent-deep);
  color: var(--surface-page);
}

/* ---------- Hover tooltips (calm, no animation) ---------- */
[data-tip] {
  position: relative;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  width: max-content;
  max-width: 240px;
  padding: 6px 9px;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 400;
  color: var(--surface-raised);
  background: var(--surface-inverse);
  border: 1px solid var(--ink-2);
  border-radius: 6px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  box-shadow: 0 6px 16px -8px rgba(0,0,0,0.25);
  transition: opacity 0s linear 500ms, visibility 0s linear 500ms;
}
/* Caret pointing at the element (default: tip below element, caret on top of tip) */
[data-tip]::before {
  content: "";
  position: absolute;
  top: calc(100% + 3px);
  right: 12px;
  z-index: 1001;
  width: 10px;
  height: 10px;
  background: var(--surface-inverse);
  border-left: 1px solid var(--ink-2);
  border-top: 1px solid var(--ink-2);
  transform: rotate(45deg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0s linear 500ms, visibility 0s linear 500ms;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after,
[data-tip]:hover::before,
[data-tip]:focus-visible::before {
  opacity: 1;
  visibility: visible;
}
[data-tip-placement="top"]::after {
  top: auto;
  bottom: calc(100% + 8px);
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}
[data-tip-placement="top"]::before {
  top: auto;
  bottom: calc(100% + 3px);
  right: auto;
  left: 50%;
  transform: translate(-50%, 0) rotate(225deg);
}
[data-tip-placement="bottom-left"]::after {
  right: auto;
  left: 0;
}
[data-tip-placement="bottom-left"]::before {
  right: auto;
  left: 12px;
}

/* Onboarding state — show automatically without hover */
[data-tip].tip-onboard::after,
[data-tip].tip-onboard::before {
  opacity: 1;
  visibility: visible;
  transition: none;
}
[data-tip].tip-onboard.tip-onboard-hide::after,
[data-tip].tip-onboard.tip-onboard-hide::before {
  opacity: 0;
  transition: opacity 400ms ease-out, visibility 0s linear 400ms;
}
