/* ---------- Visual system tokens ---------- */
  :root {
    /* Surfaces — warm off-white family */
    --surface-page: #F7F5EE;        /* canvas */
    --page-bg: var(--surface-page);  /* page background layer (gradient themes override) */
    --surface-raised: #FBFAF4;      /* cards / chart panel */
    --surface-rail: #F2EFE6;        /* copilot rail (slightly deeper) */
    --surface-sunken: #EEEAE0;      /* input wells */
    --surface-inverse: #1F2422;
    --surface-dark: #232826;        /* note output + formula blocks */
    --surface-darker: #1B1F1D;
    --line-dark: #2C322F;

    /* 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. */
    --rd-accent: #2F6661;
    --rd-accent-deep: #234B47;
    --rd-accent-soft: #DDE7E4;
    --rd-accent-tint: #EDF2F0;
    --rd-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(--page-bg); background-attachment: fixed; }
  body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink-2);
    background: var(--page-bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv11";
    text-rendering: optimizeLegibility;
  }

  /* ---------- App shell ---------- */
  /* v1c Epic 1 — persistent summary column added as 3rd grid area */
  .app {
    display: grid;
    grid-template-columns: minmax(320px, 26%) 1fr minmax(300px, 440px);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "topbar topbar topbar"
      "rail chart summary"
      "footer footer footer";
    height: 100vh;
    height: 100dvh;
    min-height: 720px;
    width: 100%;
    overflow: hidden;
    transition: grid-template-columns 260ms cubic-bezier(.2,.7,.2,1);
  }
  /* Copilot drawer collapsed (default): rail track goes to 0 → layout reads "chart summary" */
  .app.rail-closed {
    grid-template-columns: 0 1fr minmax(300px, 440px);
  }
  @media (max-width: 1279.98px) {
    .app { grid-template-columns: minmax(320px, 26%) 1fr minmax(300px, 340px); }
    .app.rail-closed { grid-template-columns: 0 1fr minmax(300px, 340px); }
  }
  @media (max-width: 1200px) {
    .app {
      grid-template-columns: minmax(320px, 30%) 1fr;
      grid-template-rows: auto 1fr auto auto;
      grid-template-areas:
        "topbar topbar"
        "rail chart"
        "summary summary"
        "footer footer";
    }
    .app.rail-closed {
      grid-template-columns: 0 1fr;
    }
  }

  /* <1024px: strict stack — topbar, chart, footer. Summary lives in a bottom bar + sheet. Rail overlays. */
  @media (max-width: 1023.98px) {
    .app, .app.rail-closed, .app.rail-open {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto auto auto;
      grid-template-areas: "topbar" "chart" "footer";
      height: auto; min-height: 100dvh; overflow: visible;
      padding-bottom: 56px;
    }
    .app.rail-open .chart { display: block; }
    .app > .summary { display: none !important; }
    .chart { overflow: visible; max-height: none; }
    .rail { position: fixed; inset: 0; top: 0; z-index: 60; width: 100%; height: 100dvh; border-right: 0; }
    .rail-closed .rail { display: none; }
    .app .rail-fab { z-index: 70; bottom: calc(56px + 14px + env(safe-area-inset-bottom)); }
    .footer .body { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; cursor: pointer; flex: 1 1 100%; }
    .footer .body.expanded { -webkit-line-clamp: unset; display: block; }
    .note-inline { display: none; }
    /* bottom bar */
    .msum-bar { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(56px + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom) 16px; grid-template-columns: 1fr 1fr 1fr auto; align-items: center; gap: 8px; background: var(--surface-raised); border-top: 1px solid var(--line-2); box-shadow: 0 -6px 18px rgba(0,0,0,.06); font: inherit; color: var(--ink-1); text-align: left; cursor: pointer; }
    .msum-item { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
    .msum-k { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-4); }
    .msum-v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .msum-v em { font-style: normal; font-weight: 400; font-size: 11px; color: var(--ink-4); margin-left: 3px; }
    .msum-chev { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink-3); border-radius: 50%; }
    /* sheet */
    .msum-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(20,24,22,.35); opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
    .msum-scrim.open { opacity: 1; pointer-events: auto; }
    .msum-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; height: 85dvh; display: flex; flex-direction: column; background: var(--surface-raised); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.18); transform: translateY(105%); transition: transform 260ms cubic-bezier(.2,.8,.2,1); touch-action: none; }
    .msum-sheet.open { transform: translateY(0); }
    .msum-handle { position: relative; flex: none; height: 44px; display: grid; place-items: center; cursor: grab; }
    .msum-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
    .msum-close { position: absolute; right: 8px; top: 4px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-3); display: grid; place-items: center; cursor: pointer; border-radius: 50%; }
    .msum-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding-bottom: env(safe-area-inset-bottom); }
    .msum-body .summary { display: block !important; position: static; border: 0; max-height: none !important; overflow: visible; }
    .msum-body .summary-inner { overflow: visible; max-height: none; min-height: 0; flex-direction: column; gap: 14px; padding: 4px 16px 20px; }
    .msum-body .sm-group { min-width: 0; flex: none; }
    .msum-note { padding: 0 16px 24px; }
    .msum-note .note-panel { max-height: none; }
    .msum-note .np-head { position: sticky; top: 0; z-index: 2; background: var(--surface-dark); border-bottom: 1px solid var(--line-dark); }
    .msum-note .np-body { max-height: none; }
    .footer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  }
  @media (min-width: 1024px) { .msum-bar, .msum-sheet, .msum-scrim { display: none !important; } }

  /* =========================================================
     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;
    overflow: hidden;
    transition: opacity 200ms ease;
  }
  .rail-closed .rail { opacity: 0; pointer-events: none; border-right-color: transparent; }
  .rail-closed .rail > * { visibility: hidden; }

  /* Drawer toggle — lives in the top bar, far left next to the brand */
  .rail-toggle {
    position: relative;
    z-index: 8;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: var(--surface-raised);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    color: var(--ink-3);
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  }
  .rail-toggle:hover { color: var(--rd-accent-deep); border-color: var(--rd-accent); background: var(--rd-accent-tint); }
  .rail-toggle svg { width: 17px; height: 17px; }
  .rail-toggle[aria-expanded="true"] { color: var(--rd-accent-deep); background: var(--rd-accent-tint); border-color: var(--rd-accent-soft); }
  .rail-toggle .rt-dot {
    position: absolute; top: 7px; right: 7px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--rd-accent);
  }

  .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;
    display: block; flex: none;
    filter: drop-shadow(0 1px 2px rgba(31, 36, 34, 0.18));
  }
  .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);
  }
  /* v1f — top bar */
  .topbar {
    grid-area: topbar;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 10px 16px 10px 12px;
    background: var(--surface-rail);
    border-bottom: 1px solid var(--line-2);
    min-height: 54px;
  }
  .topbar-l, .topbar-r { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .topbar .brand, .topbar .btn-ghost, .topbar .session-strip > span, .topbar .case-status { white-space: nowrap; }
  .topbar .session-strip { padding: 0; border-bottom: 0; }
  .topbar .new-session { margin-left: 4px; }
  .session-saved.saved { color: #3F6A46; }
  .session-saved.dirty { color: #8A6D2A; }
  .rail-head--slim {
    padding: 14px var(--pad-rail) 12px;
  }
  .rail-label {
    font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--ink-3); font-weight: 500;
  }
  .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(--rd-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(--rd-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(--rd-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(--rd-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(--rd-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(--rd-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: transparent;
    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(--rd-accent-soft); color: var(--rd-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(--rd-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(--rd-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-field input::placeholder { color: var(--ink-4); opacity: 1; }
.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(--rd-accent);
  color: #F7F5EE;
  font-weight: 600;
  /* v1c Epic 2/3 — stronger active affordance: dual inset ring + top edge highlight */
  box-shadow:
    inset 0 0 0 1px var(--rd-accent-deep),
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 0 0 2px var(--rd-accent-soft);
  position: relative;
  z-index: 1;
}
.unit-toggle button[aria-pressed="true"]:hover { background: var(--rd-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, box-shadow 120ms ease;
}
.seg button:hover { color: var(--ink-1); }
.seg button[aria-pressed="true"] {
  background: var(--rd-accent);
  color: #F7F5EE;
  font-weight: 600;
  /* v1c Epic 2 — stronger active affordance */
  box-shadow:
    0 1px 2px rgba(31,36,34,0.12),
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 0 0 2px var(--rd-accent-soft);
  position: relative;
  z-index: 1;
}
.seg button[aria-pressed="true"]:hover { background: var(--rd-accent-deep); color: #F7F5EE; }

/* 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(--rd-accent-tint); color: var(--rd-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(--rd-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(--rd-accent-tint);
  color: var(--rd-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(--rd-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(--rd-accent);
  background: var(--surface-raised);
}
.dx-pill:focus-visible {
  outline: none;
  border-color: var(--rd-accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.18);
}
.dx-pill.open {
  border-color: var(--rd-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(--rd-accent); }
.dx-pill.open .dx-pill-caret { transform: rotate(180deg); color: var(--rd-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(--rd-accent);
  outline-offset: 1px;
}
.combo-option.is-current {
  background: var(--rd-accent-tint);
  color: var(--rd-accent-ink);
}
.combo-option.is-current:hover, .combo-option.is-current[aria-selected="true"] {
  background: var(--rd-accent-soft);
}

/* Tier chip — clearly distinct from dx pill */
.tier-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px;
  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(--rd-accent-tint); color: var(--rd-accent-deep); border-color: rgba(47,102,97,0.22); }
.tier-chip.deep::before     { background: var(--rd-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(--rd-accent); color: var(--ink-1); }
.chip[aria-pressed="true"] {
  background: var(--rd-accent);
  color: #F7F5EE;
  border-color: var(--rd-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(--rd-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(--rd-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(--rd-accent-tint);
  color: var(--rd-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(--rd-accent);
  color: #F7F5EE;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--rd-accent-deep);
  letter-spacing: 0.005em;
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-block;
}
.banner-meta { flex-wrap: nowrap; }

/* 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(--rd-accent); color: var(--rd-accent-deep); background: var(--rd-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(--rd-accent-tint);
  color: var(--rd-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(--rd-accent-ink);
  background: var(--rd-accent-tint);
  border: 1px solid var(--rd-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: var(--surface-dark);
  border: 1px solid var(--line-dark);
  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(--rd-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(--rd-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(--rd-accent-tint);
  border: 1px solid var(--rd-accent-soft);
  border-radius: var(--radius-md);
}
.result-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rd-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(--rd-accent-ink);
  letter-spacing: -0.015em;
  line-height: 1;
}
.big-unit {
  font-size: 13px;
  color: var(--rd-accent-ink);
  opacity: 0.75;
}
.result-note {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--rd-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(--rd-accent-soft);
  color: var(--rd-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(--rd-accent-ink); background: var(--rd-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(--rd-accent-ink); }
.cite-body {
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--surface-page);
  border-left: 2px solid var(--rd-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: 1fr;
  gap: 22px;
  align-items: start;
}
/* Inline note (below Monitoring) only when the rail can't host it */
.note-inline { display: none; }
@media (min-width: 1024px) and (max-width: 1279.98px) {
  .note-inline { display: block; }
  .note-inline .note-panel { max-height: none; }
  .note-inline .np-body { max-height: 60vh; }
}

.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(--rd-accent-tint);
  color: var(--rd-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(--rd-accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.link-btn:hover { color: var(--rd-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(--rd-accent);
  font-size: 16px;
  margin-top: 4px;
}
.iv-text, .me-text {
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
.line-display {
  display: block; width: 100%; min-width: 0;
  text-align: left; font: inherit; font-size: 13px; line-height: 1.5;
  color: var(--ink-1); background: transparent;
  border: 1px solid transparent; border-radius: 8px;
  padding: 8px 11px; margin: 0; cursor: text;
  white-space: normal; overflow-wrap: anywhere;
  transition: background 120ms ease, border-color 120ms ease;
}
.line-display:hover { background: var(--surface-raised); border-color: var(--line-1); }
.line-display:focus-visible { outline: none; border-color: var(--rd-accent); box-shadow: 0 0 0 3px rgba(47,102,97,0.12); }
.line-display.is-empty { color: var(--ink-4); font-style: italic; }
.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(--rd-accent);
  color: var(--rd-accent-ink);
  background: var(--rd-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;
  white-space: nowrap;
  line-height: 16px;
  height: 16px;
}

/* ---------- Full Note Output panel ---------- */
.note-panel {
  background: var(--surface-dark);
  border: 1px solid var(--line-dark);
  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(--rd-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(--rd-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: var(--surface-darker);
  border: 1px solid var(--line-dark);
  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(--rd-accent-tint);
  color: var(--rd-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(--rd-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(--rd-accent);
  background: var(--rd-accent-tint);
  color: var(--rd-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(--rd-accent-tint);
  color: var(--rd-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(--rd-accent-tint); border-color: rgba(47,102,97,0.18); }
.tier-card.tier-deep .tier-label { color: var(--rd-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(--rd-accent-deep);
  background: var(--rd-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(--rd-accent-tint);
  color: var(--rd-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(--rd-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(--rd-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(--rd-accent);
  color: var(--rd-accent-ink);
  background: #fff;
}
.flag-chip.primary {
  background: var(--rd-accent);
  color: var(--surface-page);
  border-color: var(--rd-accent);
}
.flag-chip.primary:hover {
  background: var(--rd-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;
}

/* =========================================================
   v1c Epic 5.1 — kcal/kg secondary line in Energy result bar
   ========================================================= */
.result-value .result-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.005em;
}

/* =========================================================
   v1c Epic 4 — Copilot confirm card + undo chip
   ========================================================= */
.copilot-confirm {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--line-2);
  border-radius: 10px;
}
.confirm-changes {
  list-style: none;
  margin: 0 0 10px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.confirm-changes li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  line-height: 1.4;
}
.cc-field {
  color: var(--ink-3);
  flex: none;
  font-weight: 500;
}
.cc-diff {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  text-align: right;
}
.cc-from {
  color: var(--ink-4);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.cc-sep {
  color: var(--ink-4);
}
.cc-to {
  color: var(--ink-1);
  font-weight: 500;
}
.confirm-actions {
  display: flex;
  gap: 6px;
}
.msg-chip.primary {
  background: var(--rd-accent);
  color: #F7F5EE;
  border-color: var(--rd-accent-deep);
}
.msg-chip.primary:hover {
  background: var(--rd-accent-deep);
  color: #F7F5EE;
  border-color: var(--rd-accent-deep);
}
.confirm-status {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-4);
  font-style: italic;
}
.confirm-status.applied { color: var(--rd-accent-deep); font-style: normal; }

.msg-undo {
  margin-top: 8px;
}
.undo-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  padding: 4px 9px;
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.undo-chip:hover {
  color: var(--rd-accent-ink);
  border-color: var(--rd-accent);
  background: var(--rd-accent-tint);
}

/* =========================================================
   v1c Epic 1 — Persistent summary column
   ========================================================= */
.summary {
  grid-area: summary;
  background: var(--surface-raised, #F5F3EA);
  border-left: 1px solid var(--line-2);
  overflow: hidden;
  min-width: 0;
  display: flex; flex-direction: column;
}
.summary-inner { flex: 0 1 auto; overflow-y: auto; min-height: 160px; }
.summary-note {
  flex: 1 1 0; min-height: 240px; min-width: 0;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line-2);
  display: flex; flex-direction: column;
}
.summary-note .note-panel {
  flex: 1 1 auto; min-height: 0; max-height: none;
  margin-top: 14px; padding: 14px 14px 12px;
}
.summary-note .np-head { position: sticky; top: 0; }
.summary-note .np-body { flex: 1 1 auto; min-height: 0; max-height: none; font-size: 11.5px; }
@media (min-width: 1024px) and (max-width: 1279.98px) { .summary-note { display: none; } .summary { overflow-y: auto; display: block; } }
.summary-inner {
  padding: 22px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sm-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-1);
}
.sm-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sm-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-1);
}
.sm-note {
  margin: 4px 0 0 0;
  font-size: 11.5px;
  color: var(--ink-4);
}
.sm-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sm-group-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.sm-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  line-height: 1.4;
  padding: 3px 0;
}
.sm-row.sub { padding-top: 0; }
.sm-row.big { padding: 6px 0 2px; align-items: baseline; }
.sm-k {
  color: var(--ink-3);
  flex: none;
}
.sm-v {
  color: var(--ink-1);
  text-align: right;
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sm-dash { color: var(--ink-4); }
.sm-sub {
  color: var(--ink-4);
  font-size: 11.5px;
}
.sm-num {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.sm-unit {
  font-size: 11.5px;
  color: var(--ink-4);
}
.sm-bmi-num {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink-1);
}
.sm-chips {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sm-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-page);
  border: 1px solid var(--line-1);
  color: var(--ink-2);
}
.sm-results {
  padding: 12px;
  background: var(--surface-page);
  border: 1px solid var(--line-1);
  border-radius: 10px;
}

/* Responsive: below 1200px the column reflows to a horizontal strip */
@media (max-width: 1200px) {
  .app { min-height: 0; }
  .rail-fab { left: auto; right: 18px; }
  .summary {
    border-left: 0;
    border-top: 1px solid var(--line-2);
    max-height: 260px;
  }
  .summary-inner {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 14px 18px;
    align-items: flex-start;
  }
  .sm-head {
    border-bottom: 0;
    padding-bottom: 0;
    flex: 0 0 auto;
  }
  .sm-title { font-size: 13px; }
  .sm-note { display: none; }
  .sm-group { min-width: 160px; flex: 1 1 160px; }
  .sm-results { flex: 1 1 260px; }
}


/* =========================================================
   v1f — Case bar (Save · New case · Open) in chart header
   ========================================================= */
.casebar {
  display: flex; align-items: center; gap: 8px;
  position: relative;
  flex-wrap: wrap;
}
.case-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  color: var(--ink-4);
  white-space: nowrap;
}
.case-status .case-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line-strong);
}
.case-status.saved { color: #3F6A46; }
.case-status.saved .case-dot { background: var(--green); }
.case-status.dirty { color: #8A6D2A; }
.case-status.dirty .case-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(182,135,58,0.15); }

.case-label {
  background: transparent; border: 1px dashed transparent;
  font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--ink-2);
  padding: 4px 8px; border-radius: 6px;
  cursor: text; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease;
}
.case-label:hover { border-color: var(--line-2); background: var(--surface-raised); }
.case-label-input {
  font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--ink-1);
  background: #fff; border: 1px solid var(--rd-accent);
  box-shadow: 0 0 0 3px rgba(47,102,97,0.12);
  border-radius: 6px; padding: 4px 8px; width: 240px; outline: none;
}

.case-save.is-dirty {
  background: var(--rd-accent); color: #F7F5EE; border-color: var(--rd-accent-deep);
}
.case-save.is-dirty:hover { background: var(--rd-accent-deep); color: #F7F5EE; }
.case-save[disabled] { opacity: 0.5; cursor: default; }
.case-save[disabled]:hover { background: transparent; color: var(--ink-2); border-color: var(--line-2); }

.case-menu-wrap { position: relative; }
.case-open { gap: 6px; }
.case-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 300px; max-width: 380px; max-height: 320px; overflow-y: auto;
  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: 30;
}
.case-menu-empty { padding: 12px; color: var(--ink-4); font-size: 12.5px; font-style: italic; }
.case-id { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.case-num {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  color: var(--rd-accent-deep); background: var(--rd-accent-tint);
  border: 1px solid var(--rd-accent-soft); border-radius: 5px; padding: 2px 6px;
}
.case-menu-note {
  margin: 6px -6px -6px; padding: 8px 12px;
  border-top: 1px solid var(--line-1);
  background: var(--surface-page);
  color: var(--ink-4); font-size: 11.5px;
  border-radius: 0 0 10px 10px;
}
.topbar .casebar { flex-wrap: nowrap; }
.topbar .case-label { max-width: 200px; }
.case-item {
  display: grid; grid-template-columns: 1fr 24px; align-items: center; gap: 4px;
  border-radius: 6px;
}
.case-item:hover { background: var(--rd-accent-tint); }
.case-item.is-current { background: var(--rd-accent-tint); }
.case-item-main {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: transparent; border: 0; font: inherit; text-align: left;
  padding: 8px 10px; cursor: pointer; min-width: 0; color: var(--ink-1);
}
.case-item-label { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.case-item-date { font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }
.case-item-x {
  background: transparent; border: 0; color: var(--ink-5);
  font-size: 16px; line-height: 1; cursor: pointer;
  width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center;
}
.case-item-x:hover { background: #F5E0D7; color: #8B3A1F; }


/* =========================================================
   Top bar — mobile breakpoint (≤640px)
   ========================================================= */
.overflow-wrap { display: none; position: relative; }
.overflow-menu { right: 0; min-width: 240px; }
.overflow-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; font: inherit; font-size: 13px;
  color: var(--ink-1); padding: 9px 10px; border-radius: 6px; cursor: pointer;
}
.overflow-item:hover { background: var(--rd-accent-tint); color: var(--rd-accent-ink); }
.overflow-item[disabled] { color: var(--ink-4); cursor: default; }
.overflow-item[disabled]:hover { background: transparent; color: var(--ink-4); }
.overflow-back { color: var(--ink-3); font-size: 12px; }
.overflow-sep { height: 1px; background: var(--line-1); margin: 4px 0; }

@media (max-width: 640px) {
  .topbar { padding: 8px 10px; min-height: 50px; gap: 8px; }
  .topbar .brand-word,
  .topbar .session-started,
  .topbar .head-actions,
  .topbar .casebar > .btn-ghost,
  .topbar .casebar > .case-menu-wrap { display: none; }
  .overflow-wrap { display: block; }
  .topbar-r { flex: 1 1 auto; justify-content: flex-end; }
  .topbar .session-strip { flex: 1 1 auto; min-width: 0; }
  .topbar .session-strip .pulse { display: none; }
  .topbar .casebar {
    display: grid;
    grid-template-areas: "id" "status";
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1px; flex: 1 1 auto; min-width: 0;
  }
  .topbar .casebar .case-id { grid-area: id; display: flex; min-width: 0; }
  .topbar .casebar .case-id .case-label { flex: 1 1 auto; min-width: 0; max-width: none; padding: 2px 4px; }
  .topbar .casebar .case-id .case-label-input { width: 100%; min-width: 0; }
  .topbar .casebar .case-status { grid-area: status; font-size: 10.5px; padding-left: 4px; }
  .topbar .casebar .case-status .case-dot { width: 5px; height: 5px; }
}


/* Greeting after wordmark */
.brand-greet { font-weight: 400; color: var(--ink-4); font-size: 13px; margin-left: 6px; white-space: nowrap; }
@media (max-width: 640px) { .topbar .brand-greet { display: none; } }

/* Sample-patient nudge — gentle pulse until first click (rd:sampleSeen) */
.btn-ghost.is-nudge { border-color: var(--rd-accent-soft); animation: nudge-pulse 3.2s cubic-bezier(.2,.6,.3,1) infinite; }
@keyframes nudge-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47,102,97,0.32); }
  70%  { box-shadow: 0 0 0 10px rgba(47,102,97,0); }
  100% { box-shadow: 0 0 0 10px rgba(47,102,97,0); }
}
.btn-ghost.is-nudge:hover { animation: none; }


/* =========================================================
   Floating copilot toggle (bottom-left) + 3-zone top bar
   ========================================================= */
.topbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
.topbar-m { display: flex; align-items: center; justify-content: center; min-width: 0; }
.topbar-m .session-strip { min-width: 0; }
.topbar-case-actions { display: flex; align-items: center; gap: 8px; }
/* The CaseBar in the middle keeps status + #num + label only; its own buttons live on the right now */
.topbar .casebar > .btn-ghost, .topbar .casebar > .case-menu-wrap { display: none; }

.rail-fab {
  position: fixed; left: 18px; bottom: 58px; z-index: 40;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--rd-accent); color: #F7F5EE;
  border: 1px solid var(--rd-accent-deep);
  box-shadow: 0 6px 18px -6px rgba(31,36,34,0.35), 0 1px 2px rgba(31,36,34,0.18);
  cursor: pointer;
  transition: background 120ms ease, transform 160ms ease, left 260ms cubic-bezier(.2,.7,.2,1);
}
.rail-fab:hover { background: var(--rd-accent-deep); transform: translateY(-1px); }
.rail-fab:active { transform: translateY(0); }
.rail-fab svg { width: 20px; height: 20px; }
.rail-fab .rt-dot {
  position: absolute; top: 9px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber); border: 2px solid var(--rd-accent);
}
.rail-open .rail-fab { background: var(--surface-raised); color: var(--ink-2); border-color: var(--line-2); }
.rail-open .rail-fab:hover { background: #fff; color: var(--ink-1); }

@media (max-width: 640px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .topbar-case-actions { display: none; }
  /* Rail opens full-width on mobile */
  .app.rail-open { grid-template-columns: 1fr 0; }
  .app.rail-open .chart, .app.rail-open .summary { display: none; }
  .rail-fab { left: auto; right: 14px; bottom: calc(54px + env(safe-area-inset-bottom)); }
}

/* =========================================================
   Mobile layout (≤760px) — single column, stacked labels
   ========================================================= */
@media (max-width: 760px) {
  :root { --pad-rail: 16px; --pad-chart: 16px; --gap-zone: 40px; --gap-section: 18px; }
  .app { min-height: 0; }
  .app.rail-open .chart, .app.rail-open .summary { display: block; }
  .rail { border-right: 0; }
  .chart-inner { padding-bottom: 120px; }
  .banner { padding: 12px var(--pad-chart); gap: 10px; }
  .banner-meta { justify-content: flex-start; }
  .zone-head { flex-wrap: wrap; gap: 8px 12px; margin-bottom: 16px; }
  .zone-title { font-size: 16px; }
  .zone-sub { margin-left: 0; flex-basis: 100%; }
  .sub { grid-template-columns: 1fr; gap: 10px; }
  .sub-label .hint { margin-top: 2px; }
  .pes-grid, .me-targets { grid-template-columns: 1fr; }
  .needs-list li { grid-template-columns: 72px 1fr; }
  .summary { max-height: none; }
  .summary-inner { flex-direction: column; gap: 14px; padding: 16px var(--pad-chart) 20px; }
  .sm-group { min-width: 0; flex: none; }
  .note-inline .np-body { max-height: 50vh; }
  .footer { flex-wrap: wrap; gap: 6px 12px; padding: 10px var(--pad-chart) calc(10px + env(safe-area-inset-bottom)); }
  .footer .body { font-size: 11px; }
  .about-panel { width: 100vw; }
  .case-menu { position: fixed; left: 10px; right: 10px; top: 60px; min-width: 0; max-width: none; }
  .overflow-menu { right: 0; }
  input, select, textarea { font-size: 16px; }
  .stub-input { min-width: 0; }
}


/* =========================================================
   Themes — override surfaces, ink, lines, accent, rail only.
   Status colors (amber/green/red) intentionally untouched.
   ========================================================= */
:root[data-theme="slate"] {
  --surface-page: #F4F5F7; --surface-raised: #FAFBFC; --surface-rail: #E9EBEF; --surface-sunken: #E3E6EB;
  --ink-1: #1A1C20; --ink-2: #3A3E46; --ink-3: #6A7080; --ink-4: #949AA8; --ink-5: #B9BEC9;
  --line-1: #E1E4EA; --line-2: #D4D8E0; --line-strong: #C1C6D0;
  --rd-accent: #4A5BA6; --rd-accent-deep: #37448A; --rd-accent-soft: #DCE0F0; --rd-accent-tint: #EDEFF8; --rd-accent-ink: #2C3670;
}
:root[data-theme="paper"] {
  --surface-page: #FFFFFF; --surface-raised: #FFFFFF; --surface-rail: #F7F7F7; --surface-sunken: #F0F0F0;
  --ink-1: #2B2520; --ink-2: #4A423B; --ink-3: #76695F; --ink-4: #9E9288; --ink-5: #C4BBB3;
  --line-1: #ECE8E4; --line-2: #E0DAD4; --line-strong: #CFC7BF;
  --rd-accent: #B85C38; --rd-accent-deep: #94472A; --rd-accent-soft: #F1DDD3; --rd-accent-tint: #F9EFEA; --rd-accent-ink: #7A3A21;
}
:root[data-theme="dusk"] {
  --page-bg: linear-gradient(160deg, #F6F1EE 0%, #ECE6F0 55%, #E4E8F2 100%);
  --surface-page: #FBF9F8; --surface-raised: #FBF9F8; --surface-rail: #F2EFF0; --surface-sunken: #EDE9EC;
  --ink-1: #2A2530; --ink-2: #453E4C; --ink-3: #6F6777; --ink-4: #97909E; --ink-5: #BCB6C2;
  --line-1: #EEE9EE; --line-2: #E4DEE6; --line-strong: #D3CCD6;
  --rd-accent: #6B4E7A; --rd-accent-deep: #543C61; --rd-accent-soft: #E6DCEB; --rd-accent-tint: #F3EEF6; --rd-accent-ink: #46304F;
}
:root[data-theme="tide"] {
  --page-bg: linear-gradient(160deg, #EEF6F5 0%, #E6F0F3 50%, #E9EEF8 100%);
  --surface-page: #F8FBFB; --surface-raised: #F8FBFB; --surface-rail: #EEF3F4; --surface-sunken: #E8EFF0;
  --ink-1: #1F2B2E; --ink-2: #3B4A4E; --ink-3: #66767A; --ink-4: #8F9DA1; --ink-5: #B5C0C3;
  --line-1: #E6EEEF; --line-2: #DAE5E7; --line-strong: #C7D5D8;
  --rd-accent: #2E6E73; --rd-accent-deep: #22555A; --rd-accent-soft: #D6E6E7; --rd-accent-tint: #EAF2F3; --rd-accent-ink: #1B4448;
}
/* Gradient themes: the top bar, rail, summary, and footer are solid; only the page canvas shows the gradient */
:root[data-theme="dusk"] .topbar, :root[data-theme="tide"] .topbar,
:root[data-theme="dusk"] .summary, :root[data-theme="tide"] .summary { background: var(--surface-rail); }
:root[data-theme="night"] {
  --surface-page: #16181C; --surface-raised: #1E2126; --surface-rail: #1B1E22; --surface-sunken: #24282E; --surface-inverse: #0F1114;
  --surface-dark: #262A31; --surface-darker: #1F2329; --line-dark: #333944;
  --ink-1: #E8E6E1; --ink-2: #C9C7C1; --ink-3: #9A9891; --ink-4: #737169; --ink-5: #55534D;
  --line-1: #2A2E35; --line-2: #343941; --line-strong: #454B55;
  --rd-accent: #7FA88F; --rd-accent-deep: #6A9179; --rd-accent-soft: #2D3B33; --rd-accent-tint: #222C26; --rd-accent-ink: #B7D3C0;
  --shadow-1: 0 1px 0 rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.35);
  --shadow-2: 0 1px 0 rgba(0,0,0,0.3), 0 4px 16px -6px rgba(0,0,0,0.5);
}
/* Night: a few hard-coded light fills need to follow the surfaces */
:root[data-theme="night"] .combo-menu,
:root[data-theme="night"] .case-menu,
:root[data-theme="night"] .dx-pill,
:root[data-theme="night"] .chip-bmi,
:root[data-theme="night"] .case-label-input,
:root[data-theme="night"] .input:focus,
:root[data-theme="night"] .composer:focus-within,
:root[data-theme="night"] .unit-field:focus-within,
:root[data-theme="night"] .combo-input.open,
:root[data-theme="night"] .combo-input:focus-within,
:root[data-theme="night"] .example:hover,
:root[data-theme="night"] .adjustment-notes textarea.input { background: var(--surface-raised); }
:root[data-theme="night"] .seg button[aria-pressed="true"],
:root[data-theme="night"] .unit-toggle button[aria-pressed="true"],
:root[data-theme="night"] .chip[aria-pressed="true"],
:root[data-theme="night"] .chip-dx,
:root[data-theme="night"] .copy-btn,
:root[data-theme="night"] .send-btn,
:root[data-theme="night"] .rail-fab,
:root[data-theme="night"] .case-save.is-dirty { color: #16181C; }

/* Settings panel — theme rows */
.settings-help { margin: 0 0 12px; color: var(--ink-3); font-size: 12.5px; line-height: 1.5; }
.theme-list { display: flex; flex-direction: column; gap: 8px; }
.theme-row {
  display: grid; grid-template-columns: auto 1fr 18px; align-items: center; gap: 12px;
  width: 100%; text-align: left; font: inherit;
  background: var(--surface-raised); color: var(--ink-1);
  border: 1px solid var(--line-1); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.theme-row:hover { border-color: var(--line-strong); }
.theme-row.is-active { border-color: var(--rd-accent); box-shadow: 0 0 0 2px var(--rd-accent-soft); }
.theme-swatches { display: inline-flex; gap: 3px; }
.theme-sw { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.08); }
.theme-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.theme-name { font-size: 13.5px; font-weight: 500; }
.theme-default { font-weight: 400; color: var(--ink-4); font-size: 12px; }
.theme-note { font-size: 12px; color: var(--ink-3); }
.theme-check { width: 18px; height: 18px; color: var(--rd-accent); }
