/* =========================================================
   PAT Note Writer — Pre-Admission Testing note builder
   v0.5 redesign. Built on the AFD design-system tokens:
   off-white canvas, warm ink, hairlines, soft pastel orbs.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=EB+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&display=swap');

:root {
  /* Brand / ink */
  --color-primary:        #292524;
  --color-primary-active: #0c0a09;
  --color-ink:            #0c0a09;

  /* Text */
  --color-body:           #4e4e4e;
  --color-body-strong:    #292524;
  --color-muted:          #777169;
  --color-muted-soft:     #a8a29e;
  --color-on-primary:     #ffffff;

  /* Surfaces */
  --color-canvas:         #f5f5f5;
  --color-canvas-soft:    #fafafa;
  --color-surface-card:   #ffffff;
  --color-surface-strong: #f0efed;
  --color-surface-dark:   #0c0a09;

  /* Hairlines */
  --color-hairline:        #e7e5e4;
  --color-hairline-soft:   #f0efed;
  --color-hairline-strong: #d6d3d1;

  /* Atmospheric orbs */
  --orb-mint:     radial-gradient(closest-side, rgba(167,229,211,0.85), rgba(167,229,211,0));
  --orb-peach:    radial-gradient(closest-side, rgba(244,197,168,0.85), rgba(244,197,168,0));
  --orb-lavender: radial-gradient(closest-side, rgba(200,184,224,0.85), rgba(200,184,224,0));
  --orb-sky:      radial-gradient(closest-side, rgba(168,200,232,0.85), rgba(168,200,232,0));
  --orb-rose:     radial-gradient(closest-side, rgba(232,184,196,0.85), rgba(232,184,196,0));

  /* Semantic — used sparingly per design system */
  --color-success: #16a34a;
  --color-error:   #dc2626;
  --clinical-warn:  #c2701e;
  --clinical-alert: #dc2626;
  --clinical-ok:    #16a34a;

  /* Tier-band fills (low-saturation) */
  --tier-green-bg:  #eaf6ee;
  --tier-green-tx:  #1d4d2b;
  --tier-yellow-bg: #fff8e1;
  --tier-yellow-tx: #7a4a10;
  --tier-red-bg:    #fdecec;
  --tier-red-tx:    #7a1414;

  /* Type */
  --font-display: 'EB Garamond', 'Times New Roman', serif;
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;

  /* Radii */
  --radius-pill: 9999px;
  --radius-xl:   16px;
  --radius-lg:   12px;
  --radius-md:   8px;
  --radius-xs:   4px;

  /* Shadow */
  --shadow-soft: 0 4px 16px rgba(0,0,0,0.04);

  /* ---- Single accent: muted terracotta (sleek, warm, tech-editorial) ---- */
  --color-accent:        #bf5a39;   /* primary accent */
  --color-accent-strong: #a1482c;   /* hover / active */
  --color-accent-soft:   #f6ece6;   /* warm tint surface */
  --color-accent-border: #ecd7cb;   /* tinted border/ring */
  --color-accent-ink:    #8a3f27;   /* accent text on light */

  /* One accent everywhere — no per-module colors. Phase vars alias the accent
     so any component that references --phase stays on the single accent. */
  --phase:        var(--color-accent);
  --phase-soft:   var(--color-accent-soft);
  --phase-border: var(--color-accent-border);
  --phase-pre:    var(--color-accent);  --phase-pre-soft:   var(--color-accent-soft);  --phase-pre-border:   var(--color-accent-border);
  --phase-intra:  var(--color-accent);  --phase-intra-soft: var(--color-accent-soft);  --phase-intra-border: var(--color-accent-border);
  --phase-post:   var(--color-accent);  --phase-post-soft:  var(--color-accent-soft);  --phase-post-border:  var(--color-accent-border);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 400; line-height: 1.5;
  letter-spacing: 0.12px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--color-ink); text-decoration: underline;
    text-decoration-color: var(--color-hairline-strong);
    text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--color-ink); opacity: 0.92; }

code, pre, kbd {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--color-surface-strong);
  border-radius: var(--radius-xs); padding: 1px 5px;
}

p { margin: 0 0 0.75em; color: var(--color-body); }
strong { font-weight: 500; color: var(--color-body-strong); }
em { font-family: var(--font-display); font-style: italic; font-weight: 300; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.row { display: flex; align-items: center; gap: 16px; justify-content: space-between; }

/* =====================================================
   Header
   ===================================================== */
header.site {
  background: rgba(245,245,245,0.82);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--color-hairline-soft);
  height: 64px; display: flex; align-items: center;
  position: sticky; top: 0; z-index: 50;
}
.brand-block { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-block .brand, .brand-block .sub { white-space: nowrap; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9999px;
  background:
    radial-gradient(closest-side at 30% 30%, rgba(20,20,20,0.92), rgba(20,20,20,0) 72%),
    radial-gradient(closest-side at 75% 72%, rgba(200,38,38,0.85), rgba(200,38,38,0) 72%),
    var(--color-surface-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 300; font-size: 17px;
  color: var(--color-ink);
}
.brand-block .brand {
  display: block;
  font-family: var(--font-display); font-weight: 300; font-size: 19px;
  letter-spacing: -0.2px; color: var(--color-ink); line-height: 1.1;
}
.brand-block .sub {
  display: block;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  letter-spacing: 0.5px; color: var(--color-muted);
  margin-top: 2px;
}
nav.top { display: flex; gap: 4px; align-items: center; }
nav.top a {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  color: var(--color-body); text-decoration: none;
  padding: 8px 14px; border-radius: 9999px;
  letter-spacing: 0.1px;
}
nav.top a:hover { background: var(--color-surface-strong); color: var(--color-ink); }
nav.top a.active { background: var(--color-ink); color: #fff; }

.menu-toggle {
  display: none; background: none; border: 0; font-size: 22px;
  color: var(--color-ink); cursor: pointer; padding: 4px 10px;
}

/* =====================================================
   Dashboard head
   ===================================================== */
.dashboard-head {
  background: var(--color-canvas);
  padding: 36px 0 24px;
  position: relative;
  overflow: hidden;
}
.dashboard-head::before {
  content: ''; position: absolute;
  top: -120px; right: -160px;
  width: 720px; height: 720px;
  background:
    radial-gradient(closest-side, rgba(20,20,20,0.16), rgba(20,20,20,0) 70%),
    radial-gradient(closest-side, rgba(120,120,120,0.12), rgba(120,120,120,0) 70%);
  pointer-events: none;
  filter: blur(8px);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-24px, 16px) scale(1.04); }
}

.page-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-ink); flex-shrink: 0;
  position: relative;
  padding: 0;
}
button.page-icon:hover { background: var(--color-surface-strong); border-color: var(--color-hairline-strong); }
button.page-icon:active { transform: scale(0.97); }
button.page-icon:focus-visible { outline: 2px solid var(--color-ink); outline-offset: 2px; }
.page-icon svg { width: 22px; height: 22px; stroke-width: 1.6; }
/* collapse caret badge */
.page-icon-caret {
  position: absolute; right: -6px; bottom: -6px;
  width: 18px; height: 18px; border-radius: 9999px;
  background: var(--color-ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-canvas);
  transition: transform 260ms ease;
}
.page-icon-caret svg { width: 11px; height: 11px; stroke-width: 2.4; }
.dashboard-head.collapsed .page-icon-caret { transform: rotate(-90deg); }

/* collapsible directions */
.intro-collapsible {
  overflow: hidden;
  max-height: 600px;
  opacity: 1;
  transition: max-height 340ms cubic-bezier(0.4,0,0.2,1), opacity 200ms ease, margin 340ms ease;
}
.intro-collapsible-inner { min-height: 0; }
.dashboard-head.collapsed .intro-collapsible {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

.crumb {
  font-family: var(--font-sans); font-size: 11px;
  font-weight: 600; letter-spacing: 0.96px; text-transform: uppercase;
  color: var(--color-muted); margin-bottom: 8px;
}

.dashboard-head h1 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 38px; line-height: 1.08;
  letter-spacing: -0.5px; color: var(--color-ink);
  margin: 0 0 12px;
}
.dashboard-head p {
  font-family: var(--font-sans); font-size: 14.5px; line-height: 1.6;
  color: var(--color-body); letter-spacing: 0.1px;
  max-width: 920px;
}

/* Intro lists in dashboard-head */
.dashboard-head .intro-lede { margin: 0 0 14px; max-width: 920px; }
.dashboard-head .intro-steps {
  list-style: none; padding: 0; margin: 8px 0 0;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 760px;
}
.dashboard-head .intro-steps li {
  display: flex; align-items: flex-start; gap: 14px;
  font-family: var(--font-sans); font-size: 14.5px; line-height: 1.55;
  color: var(--color-body); letter-spacing: 0.1px;
}
.dashboard-head .intro-steps .step-num {
  flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 9999px;
  background: var(--color-ink); color: #fff;
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.dashboard-head .intro-steps strong { color: var(--color-ink); font-weight: 600; }
.dashboard-head .intro-bullets {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-width: 760px;
}
.dashboard-head .intro-bullets li {
  position: relative; padding-left: 18px;
  font-family: var(--font-sans); font-size: 14.5px; line-height: 1.55;
  color: var(--color-body); letter-spacing: 0.1px;
}
.dashboard-head .intro-bullets li::before {
  content: ''; position: absolute;
  left: 4px; top: 0.65em;
  width: 5px; height: 5px;
  border-radius: 9999px;
  background: var(--color-ink);
}
.dashboard-head .intro-note-row {
  margin: 22px 0 0; max-width: 920px;
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: stretch;
}
.dashboard-head .intro-note {
  flex: 1 1 320px; margin: 0;
  text-align: left;
  padding: 14px 18px;
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  font-size: 13.5px; line-height: 1.55;
}
.dashboard-head .intro-note--center { text-align: center; }
.dashboard-head .intro-note--center .intro-bullets { align-items: center; }
.dashboard-head .intro-note--center .intro-bullets li { padding-left: 0; }
.dashboard-head .intro-note--center .intro-bullets li::before { display: none; }
.dashboard-head .intro-note code {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--color-surface-strong);
  padding: 1px 6px; border-radius: var(--radius-xs);
  color: var(--color-ink);
}

/* Patient stub row */
.patient-stub {
  display: grid; grid-template-columns: 1fr 110px 1fr 2fr;
  gap: 16px;
  margin-top: 28px; padding: 18px 22px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  position: relative; z-index: 1;
}
.patient-stub label {
  display: block;
  font-family: var(--font-sans); font-size: 11px;
  color: var(--color-muted); letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.patient-stub input, .patient-stub select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 14px; color: var(--color-ink);
  letter-spacing: 0.1px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.patient-stub input:focus, .patient-stub select:focus {
  border-color: var(--color-ink);
  background: #fff;
}

/* =====================================================
   Calculator category pipeline (horizontal nav)
   ===================================================== */
.calc-nav {
  display: flex; flex-wrap: nowrap; align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 10px 12px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  overflow: visible; /* keep hover dropdowns fully visible */
}
.calc-nav-eye {
  font-family: var(--font-sans); font-size: 10px; font-weight: 600;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--color-muted-soft);
  margin-right: 8px; padding-left: 2px;
  align-self: center;
}
.cat-arrow {
  color: var(--color-hairline-strong); font-size: 14px;
  user-select: none; padding: 0; flex-shrink: 0;
}
.calc-nav-eye { flex-shrink: 0; }

.cat { position: relative; flex-shrink: 0; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent;
  border-radius: 9999px;
  padding: 7px 12px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--color-body); cursor: pointer; letter-spacing: 0.1px;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.cat-btn:hover { background: var(--color-surface-strong); color: var(--color-ink); }
.cat.has-active .cat-btn { background: var(--color-ink); color: #fff; }
.cat.has-active .cat-btn:hover { color: #fff; }

/* category-level completion check (all calcs in the group done) */
.cat-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 0; height: 14px; overflow: hidden;
  color: var(--color-success);
  transition: width 140ms ease;
}
.cat.cat-done .cat-check { width: 15px; }
.cat.cat-done.has-active .cat-check { color: #fff; }
.cat-check::before {
  content: ''; display: block;
  width: 5px; height: 9px;
  border: solid currentColor; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-bottom: 2px;
}

/* dropdown menu */
.cat-menu {
  position: absolute; top: calc(100% + 9px); left: 0; z-index: 50;
  min-width: 210px; width: max-content; max-width: 340px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 0s linear 140ms;
}
/* invisible bridge so the gap doesn't drop the hover */
.cat-menu::before {
  content: ''; position: absolute; left: 0; right: 0; top: -10px; height: 10px;
}
.cat:hover .cat-menu, .cat:focus-within .cat-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
  transition: opacity 140ms ease, transform 140ms ease, visibility 0s;
}

.calc-tab {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  color: var(--color-body); cursor: pointer;
  letter-spacing: 0.1px;
  text-align: left; width: 100%;
  transition: background 120ms ease, color 120ms ease;
}
.calc-tab:hover { background: var(--color-surface-strong); color: var(--color-ink); }
.calc-tab.active { background: var(--color-ink); color: #fff; }
.calc-tab.active .t-badge { color: rgba(255,255,255,0.7); }
/* green checkmark when a calculator is complete */
.calc-tab .t-check {
  width: 16px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-success); opacity: 0;
  transition: opacity 120ms ease;
}
.calc-tab.done .t-check { opacity: 1; }
.calc-tab.done.active .t-check { color: #fff; }
.calc-tab .t-check::before {
  content: ''; display: block;
  width: 5px; height: 9px;
  border: solid currentColor; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-bottom: 2px;
}
.calc-tab .t-name { min-width: 0; white-space: nowrap; }
.calc-tab .t-badge {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 11px; font-weight: 500;
  color: var(--color-muted);
  justify-self: end;
  white-space: nowrap;
}

/* =====================================================
   Main: dash-layout
   ===================================================== */
main { padding: 32px 0 64px; }
.dash-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  align-items: start;
}
.calc-nav { grid-column: 1 / -1; }
.dash-inputs { grid-column: 1; }
.dash-output { grid-column: 2; }

/* Cards (panel + output) */
.dash-inputs, .dash-output {
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  padding: 28px 30px;
}

/* Panel head */
.dash-panel { display: none; }
.dash-panel.active { display: block; animation: fade-in 200ms ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.panel-head { margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--color-hairline-soft); }
.ptitle {
  font-family: var(--font-display); font-weight: 300;
  font-size: 24px; line-height: 1.2; letter-spacing: -0.2px;
  color: var(--color-ink);
}
.psub {
  font-family: var(--font-sans); font-size: 13px;
  color: var(--color-muted); margin-top: 4px;
  letter-spacing: 0.1px;
}

/* Fields */
.body { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  color: var(--color-ink); letter-spacing: 0.1px;
  line-height: 1.4;
}
.field-help {
  font-family: var(--font-sans); font-size: 12px;
  color: var(--color-muted); line-height: 1.5;
  letter-spacing: 0.1px;
  margin-bottom: 2px;
}
/* Mallampati classification diagram + per-class captions */
.mallampati-figure { margin: 18px 0 0; }
.mallampati-figure img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: #fff;
}
.mallampati-captions {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0 12px; margin-top: 10px;
}
.mallampati-captions p {
  margin: 0; text-align: center; text-wrap: balance;
  font-family: var(--font-sans); font-size: 11.5px; line-height: 1.45;
  color: var(--color-body); letter-spacing: 0.1px;
}
.field input[type=number], .field input[type=text], .field input[type=date],
.field select, .field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  padding: 0 14px;
  height: 40px;
  font-family: var(--font-sans); font-size: 14px; color: var(--color-ink);
  letter-spacing: 0.1px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.field textarea { padding: 12px 14px; height: 180px; resize: vertical; line-height: 1.55; font-family: var(--font-mono); font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--color-ink); background: #fff;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.row-2 > *, .row-3 > * { min-width: 0; }
.row-2 > .field, .row-3 > .field { justify-content: space-between; }

/* Segmented Yes/No-like button groups */
.field-opts {
  display: inline-flex; flex-wrap: wrap; gap: 6px;
}
/* Stacked variant for long option labels (e.g., ECOG) */
.field-opts--stack { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; }
.field-opts--stack button { text-align: left; border-radius: var(--radius-md); }
.field-opts button {
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: 9999px;
  padding: 7px 14px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--color-body); cursor: pointer;
  letter-spacing: 0.1px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.field-opts button:hover { border-color: var(--color-hairline-strong); color: var(--color-ink); }
.field-opts button.on {
  background: var(--color-ink); color: #fff; border-color: var(--color-ink);
}
.field-opts button:active { transform: scale(0.99); }

/* Checkboxes */
.chk {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 13.5px;
  color: var(--color-ink); cursor: pointer;
  border: 1px solid transparent;
  letter-spacing: 0.1px;
}
.chk:hover { background: var(--color-surface-strong); }
.chk input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--color-hairline-strong);
  border-radius: var(--radius-xs);
  background: var(--color-surface-card);
  cursor: pointer; flex-shrink: 0;
  position: relative;
}
.chk input[type=checkbox]:checked {
  background: var(--color-ink); border-color: var(--color-ink);
}
.chk input[type=checkbox]:checked::after {
  content: ''; position: absolute;
  left: 4px; top: 1px; width: 5px; height: 9px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* External link / caveat notes */
.ext-link-note {
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-family: var(--font-sans); font-size: 13px;
  color: var(--color-body); line-height: 1.55;
  letter-spacing: 0.1px;
}
.caveat-box {
  background:
    radial-gradient(140% 100% at 0% 0%, rgba(244,197,168,0.20), rgba(244,197,168,0) 60%),
    var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-family: var(--font-sans); font-size: 13px;
  color: var(--color-body); line-height: 1.6;
  letter-spacing: 0.1px;
}
.caveat-box strong { color: var(--color-ink); font-weight: 600; }
.caveat-box p { margin: 0 0 9px; }
.caveat-box p:last-child { margin-bottom: 0; }

/* In-panel computed result for native calculators */
.calc-result:empty { display: none; }
.calc-result {
  margin-top: 4px;
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-left: 3px solid var(--color-ink);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-sans);
  color: var(--color-ink);
  line-height: 1.5;
  letter-spacing: 0.1px;
}
.calc-result .cr-score { font-size: 22px; font-weight: 600; }
.calc-result .cr-score span { font-size: 14px; color: var(--color-muted); font-weight: 400; }
.calc-result .cr-cat { font-size: 13px; font-weight: 600; margin-top: 2px; }
.calc-result .cr-detail { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.calc-result .cr-pending { font-size: 12.5px; color: var(--color-muted); font-weight: 400; }

/* Charlson comorbidity checkbox grid */
.charlson-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.charlson-grid .chk { font-size: 13px; }
.cci-pts {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--color-muted);
}
@media (max-width: 720px) { .charlson-grid { grid-template-columns: 1fr; } }

/* Per-medication "last dose taken" rows (Med Rec tab) */
#meddose-list { display: flex; flex-direction: column; gap: 8px; }
.meddose-row { display: grid; grid-template-columns: 1fr 200px; gap: 12px; align-items: center; }
.meddose-name {
  font-family: var(--font-sans); font-size: 13px; color: var(--color-ink);
  letter-spacing: 0.1px; word-break: break-word;
}
.meddose-input {
  background: var(--color-canvas); border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md); padding: 0 12px; height: 36px;
  font-family: var(--font-sans); font-size: 13px; color: var(--color-ink); outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.meddose-input:focus { border-color: var(--color-ink); background: #fff; }
@media (max-width: 560px) { .meddose-row { grid-template-columns: 1fr; gap: 4px; } }

/* Real medication-reconciliation table rendered inside the note output */
.assessment-text .note-narrative { white-space: pre-wrap; }
table.note-med-table { border-collapse: collapse; width: 100%; margin: 4px 0 2px; font-family: var(--font-sans); font-size: 12px; }
table.note-med-table th, table.note-med-table td { border: 1px solid var(--color-ink); padding: 6px 9px; text-align: left; vertical-align: top; white-space: normal; }
table.note-med-table th { background: var(--color-surface-strong); font-weight: 600; }
.note-table-title { font-family: var(--font-sans); font-weight: 600; font-size: 12.5px; margin: 4px 0; }
/* Bold, larger section headings inside the assessment note */
.assessment-text .note-section-title { font-family: var(--font-sans); font-weight: 700; font-size: 14px; color: var(--color-ink); margin: 14px 0 3px; letter-spacing: 0.1px; }
.assessment-text .note-narrative:first-child { margin-top: 0; }
/* Action buttons on the two bottom summary tables */
.table-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Per-calculator source / primary-reference links */
.source-link {
  margin-top: 4px; padding-top: 12px;
  border-top: 1px dashed var(--color-hairline);
  font-family: var(--font-sans); font-size: 12px;
  color: var(--color-muted); line-height: 1.6; letter-spacing: 0.1px;
}
.source-link .source-label { font-weight: 600; color: var(--color-ink); margin-right: 4px; }
.source-link a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.source-link a:hover { border-bottom-color: var(--accent); }

/* External-calculator tab (NSQIP) */
.ext-badge {
  display: inline-block; font-family: var(--font-sans);
  font-size: 10px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  color: #fff; background: var(--accent); border-radius: 9999px;
  padding: 2px 9px; margin-left: 10px; vertical-align: middle;
}
.ext-btn {
  display: inline-block; background: var(--color-ink); color: #fff;
  border-radius: 9999px; padding: 9px 18px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  text-decoration: none; letter-spacing: 0.1px;
}
.ext-btn:hover { opacity: 0.9; }

/* Clarifying subtext under a calculator result */
.calc-subnote {
  margin: 8px 0 0;
  font-family: var(--font-sans); font-size: 12px;
  color: var(--color-muted); line-height: 1.55; letter-spacing: 0.1px;
}
.calc-subnote strong { color: var(--color-ink); font-weight: 600; }

/* =====================================================
   Output panel — assessment text + actions
   ===================================================== */
.dash-output h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 24px; line-height: 1.2; letter-spacing: -0.24px;
  color: var(--color-ink); margin: 0;
}
.dash-output h2 .assessment-subcount {
  display: block;
  font-family: var(--font-sans); font-weight: 400;
  font-size: 15px; letter-spacing: 0;
  color: var(--color-muted); margin-top: 4px;
}
.dash-output h2 .helper {
  font-family: var(--font-sans); font-size: 12px;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  margin-left: 10px; vertical-align: middle;
}
.dash-output .helper {
  font-family: var(--font-sans); font-size: 12.5px;
  color: var(--color-muted); margin: 6px 0 14px;
  line-height: 1.5; letter-spacing: 0.1px;
}

.assessment-text {
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.7;
  color: var(--color-ink);
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: 0.05px;
}

.dash-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn-copy {
  background: var(--color-ink); color: #fff;
  border: 0; border-radius: 9999px;
  height: 38px; padding: 0 20px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.btn-copy:hover { background: var(--color-primary-active); }
.btn-copy:active { transform: scale(0.99); }
.btn-copy.copied { background: var(--color-success); }
.small-btn {
  background: var(--color-surface-card);
  color: var(--color-ink);
  border: 1px solid var(--color-hairline-strong);
  border-radius: 9999px;
  height: 38px; padding: 0 18px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
}
.small-btn:hover { border-color: var(--color-ink); }

/* Escalation banner */
.escal {
  border-radius: var(--radius-lg);
  padding: 14px 16px 16px;
  margin-bottom: 16px;
  font-family: var(--font-sans); font-size: 13px;
  line-height: 1.55; letter-spacing: 0.1px;
  border: 1px solid;
}
.escal .etitle {
  font-family: var(--font-sans); font-size: 12px;
  font-weight: 600; letter-spacing: 0.7px; text-transform: uppercase;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.escal .edot { width: 8px; height: 8px; border-radius: 9999px; background: currentColor; }
.escal ul { margin: 6px 0 0 18px; padding: 0; }
.escal li { margin: 2px 0; }
.escal.green  { background: var(--tier-green-bg);  color: var(--tier-green-tx);  border-color: rgba(29,77,43,0.18); }
.escal.yellow { background: var(--tier-yellow-bg); color: var(--tier-yellow-tx); border-color: rgba(122,74,16,0.18); }
.escal.red    { background: var(--tier-red-bg);    color: var(--tier-red-tx);    border-color: rgba(122,20,20,0.18); }

/* =====================================================
   Med table preview (inside output panel)
   ===================================================== */
#med-table-block h2 {
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  letter-spacing: 0.96px; text-transform: uppercase;
  color: var(--color-muted);
  margin: 0 0 6px;
}
.med-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans); font-size: 12.5px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.med-table thead th {
  background: var(--color-canvas-soft);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--color-muted);
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--color-hairline);
}
.med-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--color-hairline-soft);
  vertical-align: top;
}
.med-table tr:last-child td { border-bottom: 0; }
.med-table tr.tier-high td { background: var(--tier-red-bg); }
.med-table tr.tier-high .m-name { color: var(--tier-red-tx); font-weight: 600; }
.med-table tr.tier-moderate .m-name { font-style: italic; }
.med-table .m-cat {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--color-muted);
  text-transform: uppercase;
}
.med-table .med-cat-head td {
  background: var(--color-canvas-soft);
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.96px; text-transform: uppercase;
  color: var(--color-muted);
  padding-top: 12px;
}

/* =====================================================
   Bottom summary tables
   ===================================================== */
.anes-summary {
  margin-top: 32px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  padding: 26px 30px;
}
.as-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.as-head h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 26px; line-height: 1.18; letter-spacing: -0.24px;
  color: var(--color-ink); margin: 0 0 6px;
}
.as-sub {
  font-family: var(--font-sans); font-size: 13px;
  color: var(--color-muted); line-height: 1.55;
  letter-spacing: 0.1px;
  margin: 0;
  max-width: 880px;
}

.summary-flag {
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  letter-spacing: 0.96px; text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 9999px;
  flex-shrink: 0; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.summary-flag::before {
  content: ''; width: 6px; height: 6px; border-radius: 9999px;
  background: currentColor;
}
.summary-flag.gray   { background: var(--color-surface-strong); color: var(--color-muted); }
.summary-flag.green  { background: var(--tier-green-bg);  color: var(--tier-green-tx); }
.summary-flag.yellow { background: var(--tier-yellow-bg); color: var(--tier-yellow-tx); }
.summary-flag.red    { background: var(--tier-red-bg);    color: var(--tier-red-tx); }

.table-wrap { overflow-x: auto; }
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans); font-size: 13px;
  letter-spacing: 0.1px;
}
.summary-table thead th {
  background: var(--color-canvas-soft);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.96px; text-transform: uppercase;
  color: var(--color-muted);
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-hairline);
}
.summary-table thead th:first-child { border-top-left-radius: var(--radius-lg); }
.summary-table thead th:last-child  { border-top-right-radius: var(--radius-lg); }
.summary-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-hairline-soft);
  vertical-align: top;
  color: var(--color-body);
}
.summary-table tr:last-child td { border-bottom: 0; }
.summary-table tr.t-group-row td.t-group-head {
  background: var(--color-surface-strong);
  font-family: var(--font-display); font-weight: 500;
  font-size: 16px; letter-spacing: -0.1px;
  color: var(--color-ink);
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-hairline);
  border-top: 1px solid var(--color-hairline);
}
.summary-table tbody tr.t-group-row:first-child td.t-group-head { border-top: 0; }
.summary-table tr.row-empty td { color: var(--color-muted-soft); }
.summary-table .t-calc { color: var(--color-ink); font-weight: 500; }
.summary-table .t-calc .m-cat {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 500;
  color: var(--color-muted);
  text-transform: none; letter-spacing: 0.1px;
  margin-top: 2px;
}
.summary-table .t-sys { color: var(--color-body); white-space: nowrap; }
.summary-table .t-res { color: var(--color-ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.summary-table .t-rec { color: var(--color-ink); }

.summary-table tr.tier-high td { background: rgba(253,236,236,0.55); }
.summary-table tr.tier-high .t-calc { color: var(--tier-red-tx); font-weight: 600; }
.summary-table tr.tier-moderate .t-calc { font-style: italic; }
.summary-table tr.row-unmatched td { background: var(--color-surface-strong); color: var(--color-muted); }
.summary-table tr.sglt-row.green  td { background: rgba(234,246,238,0.55); }
.summary-table tr.sglt-row.yellow td { background: rgba(255,248,225,0.55); }
.summary-table tr.sglt-row.red    td { background: rgba(253,236,236,0.55); }

/* =====================================================
   Footer disclaimer band + footer
   ===================================================== */
.footer-disclaimer {
  position: sticky; bottom: 0;
  background: rgba(245,245,245,0.92);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--color-hairline);
  padding: 10px 0;
  font-family: var(--font-sans); font-size: 12px;
  color: var(--color-muted); letter-spacing: 0.1px;
  z-index: 40;
}
.footer-disclaimer .container { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer-disclaimer strong { color: var(--color-ink); font-weight: 600; }
.footer-disclaimer a { color: var(--color-ink); margin-left: auto; }

footer.site {
  border-top: 1px solid var(--color-hairline-soft);
  background: var(--color-canvas);
  padding: 24px 0;
  font-family: var(--font-sans); font-size: 12.5px;
  color: var(--color-muted); letter-spacing: 0.1px;
}
footer.site a { color: var(--color-body); margin: 0 4px; }

/* =====================================================
   About / Feedback shared content styling
   ===================================================== */
.page-hero {
  padding: 48px 0 28px;
  position: relative; overflow: hidden;
}
.page-hero::before {
  content: ''; position: absolute;
  top: -100px; right: -120px;
  width: 600px; height: 600px;
  background:
    radial-gradient(closest-side, rgba(20,20,20,0.16), rgba(20,20,20,0) 70%),
    radial-gradient(closest-side, rgba(120,120,120,0.12), rgba(120,120,120,0) 70%);
  pointer-events: none;
}
.page-hero h1 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 56px; line-height: 1.05; letter-spacing: -1.2px;
  color: var(--color-ink); margin: 0 0 12px;
  position: relative;
}
.page-hero .lede {
  font-family: var(--font-sans); font-size: 16px;
  color: var(--color-body); line-height: 1.6;
  letter-spacing: 0.15px;
  max-width: 720px; margin: 0;
  position: relative;
}

article.long {
  max-width: 760px;
  margin: 32px auto 80px;
  padding: 0 32px;
  font-family: var(--font-sans);
  font-size: 15px; line-height: 1.65;
  color: var(--color-body); letter-spacing: 0.15px;
}
article.long h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 30px; line-height: 1.15; letter-spacing: -0.32px;
  color: var(--color-ink);
  margin: 56px 0 14px;
}
article.long h2:first-of-type { margin-top: 0; }
article.long h3 {
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  letter-spacing: 0.96px; text-transform: uppercase;
  color: var(--color-muted);
  margin: 28px 0 8px;
}
article.long ul, article.long ol { margin: 6px 0 14px 22px; padding: 0; }
article.long li { margin: 4px 0; }
article.long p { margin: 0 0 14px; }
article.long .disclaimer-block {
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  padding: 22px 26px;
  margin: 16px 0;
}
article.long .disclaimer-block p:last-child { margin-bottom: 0; }
article.long blockquote {
  margin: 18px 0;
  padding: 18px 22px;
  background: var(--color-canvas-soft);
  border-left: 2px solid var(--color-ink);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  color: var(--color-body);
  font-size: 14.5px; line-height: 1.65;
}
article.long blockquote ul { margin-top: 8px; }

/* Feedback form */
.feedback-form {
  max-width: 720px;
  margin: 24px auto 80px;
  padding: 32px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
}
.feedback-form .setup-note {
  border: 1px dashed var(--color-hairline-strong);
  background: var(--color-surface-strong);
  color: var(--color-body);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px; line-height: 1.6;
  margin-bottom: 26px;
}
.feedback-form .field { gap: 6px; margin-bottom: 18px; }
.feedback-form label { font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--color-ink); letter-spacing: 0.1px; }
.feedback-form select, .feedback-form input[type=text], .feedback-form input[type=email] {
  width: 100%;
  height: 44px; padding: 0 14px;
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 14.5px; color: var(--color-ink);
}
.feedback-form textarea {
  width: 100%; min-height: 160px; padding: 12px 14px;
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 14.5px; color: var(--color-ink);
  line-height: 1.55; resize: vertical;
}
.feedback-form select:focus, .feedback-form input:focus, .feedback-form textarea:focus { border-color: var(--color-ink); background: #fff; outline: none; }
.feedback-form .submit-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.feedback-form .submit-note { font-size: 12px; color: var(--color-muted); flex: 1; }
.feedback-form button[type=submit] {
  background: var(--color-ink); color: #fff;
  border: 0; border-radius: 9999px;
  height: 42px; padding: 0 22px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
}
.feedback-form button[type=submit]:hover { background: var(--color-primary-active); }

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1180px) {
  .dash-layout { grid-template-columns: minmax(0, 1fr); }
  .calc-nav { grid-column: 1; }
  .dash-inputs, .dash-output { grid-column: 1; }
  .dash-output { position: static; max-height: none; }
}
/* Below this width the single line would overflow, so allow it to wrap (dropdowns stay visible). */
@media (max-width: 1080px) {
  .calc-nav { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  .patient-stub { grid-template-columns: 1fr 1fr; }
  .page-hero h1 { font-size: 40px; }
}
@media (max-width: 720px) {
  .container { padding: 0 20px; }
  nav.top { display: none; position: absolute; right: 20px; top: 60px;
    flex-direction: column; background: #fff; border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg); padding: 8px; min-width: 160px; }
  nav.top.open { display: flex; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .patient-stub { grid-template-columns: 1fr; }
  .dashboard-head h1 { font-size: 30px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .dash-inputs, .dash-output, .anes-summary { padding: 22px 18px; }
  .calc-nav { gap: 1px; padding: 8px 10px; justify-content: flex-start; }
  .calc-nav-eye { margin-right: 6px; }
  .cat-btn { padding: 7px 11px; font-size: 12.5px; }
}

/* =====================================================
   Print
   ===================================================== */
@media print {
  header.site, .calc-nav, .dash-inputs, .dash-actions, .footer-disclaimer, footer.site, .menu-toggle, .dashboard-head::before, #med-table-block { display: none !important; }
  body { background: #fff; }
  .dash-layout { display: block; }
  .dash-output { position: static; max-height: none; border: 0; padding: 0; overflow: visible; }
  .assessment-text { background: #fff; border: 0; padding: 0; font-size: 11px; }
  .anes-summary { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
}

/* =====================================================
   Landing hub (index.html) + shared module chrome
   ===================================================== */

/* Hero */
.hero {
  position: relative;
  padding: 72px 0 40px;
  background: var(--color-canvas);
  overflow: hidden;
}
.hero .container { position: relative; z-index: 1; }
.hero .eyebrow {
  font-family: var(--font-sans); font-size: 11.5px;
  font-weight: 600; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--color-muted); margin-bottom: 18px;
  display: inline-flex; align-items: center; gap: 9px;
}
.hero .eyebrow::before {
  content: ''; width: 7px; height: 7px; border-radius: 9999px;
  background: var(--color-error);
  box-shadow: 0 0 0 4px rgba(220,38,38,0.12);
}
.hero h1 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 60px; line-height: 1.02; letter-spacing: -1.2px;
  color: var(--color-ink); margin: 0 0 20px; max-width: 15ch;
}
.hero .lede {
  font-family: var(--font-sans); font-size: 18px; line-height: 1.55;
  color: var(--color-body-strong); letter-spacing: 0.1px;
  max-width: 60ch; margin: 0 0 14px; font-weight: 400;
}
.hero .support {
  font-family: var(--font-sans); font-size: 15px; line-height: 1.6;
  color: var(--color-body); letter-spacing: 0.1px;
  max-width: 62ch; margin: 0 0 26px;
}
.hero .tagline {
  display: inline-flex; flex-wrap: wrap; gap: 8px 10px; align-items: center;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2px;
  color: var(--color-muted);
}
.hero .tagline span {
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-pill);
  padding: 5px 13px;
}

/* Module tiles */
.modules { padding: 8px 0 8px; }
.modules-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.modules-head h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 26px; letter-spacing: -0.3px; color: var(--color-ink); margin: 0;
}
.modules-head p {
  font-family: var(--font-sans); font-size: 13.5px; color: var(--color-muted);
  margin: 0; max-width: 44ch;
}
.tile-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
  align-items: stretch;
}
.tile {
  position: relative; display: flex; flex-direction: column;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  padding: 28px 26px 26px;
  text-decoration: none; color: inherit;
  overflow: hidden;
  transition: transform 200ms cubic-bezier(0.4,0,0.2,1),
              box-shadow 200ms ease, border-color 200ms ease;
}
.tile::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--color-ink), var(--color-error));
  opacity: 0; transition: opacity 200ms ease;
}
.tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 44px rgba(12,10,9,0.12);
  border-color: var(--color-hairline-strong);
}
.tile:hover::before { opacity: 1; }
.tile:focus-visible { outline: 2px solid var(--color-ink); outline-offset: 3px; }
.tile-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.tile-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--color-surface-strong);
  border: 1px solid var(--color-hairline);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-ink); flex-shrink: 0;
}
.tile-icon svg { width: 22px; height: 22px; stroke-width: 1.5; }
.tile-phase {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--color-muted);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
}
.tile-label {
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.9px; text-transform: uppercase;
  color: var(--color-error); margin-bottom: 8px;
}
.tile h3 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 23px; line-height: 1.15; letter-spacing: -0.2px;
  color: var(--color-ink); margin: 0 0 12px;
}
.tile p {
  font-family: var(--font-sans); font-size: 13.5px; line-height: 1.6;
  color: var(--color-body); letter-spacing: 0.1px;
  margin: 0 0 22px; flex-grow: 1;
}
.tile-cta {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  color: var(--color-ink); letter-spacing: 0.1px;
  padding-top: 16px; border-top: 1px solid var(--color-hairline-soft);
}
.tile-cta svg { width: 15px; height: 15px; transition: transform 180ms ease; }
.tile:hover .tile-cta svg { transform: translateX(4px); }

/* Landing sub-strip: how it fits together */
.flightpath {
  margin-top: 44px; padding: 26px 30px;
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--radius-xl);
}
.flightpath h2 {
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  letter-spacing: 0.9px; text-transform: uppercase; color: var(--color-muted);
  margin: 0 0 18px;
}
.flightpath-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  position: relative;
}
.flightpath-step { padding: 0 22px; position: relative; }
.flightpath-step:not(:last-child)::after {
  content: '→'; position: absolute; right: -8px; top: 2px;
  color: var(--color-muted-soft); font-size: 15px;
}
.flightpath-step:first-child { padding-left: 0; }
.flightpath-step h4 {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  color: var(--color-ink); margin: 0 0 6px;
}
.flightpath-step p {
  font-family: var(--font-sans); font-size: 12.5px; line-height: 1.55;
  color: var(--color-body); margin: 0; letter-spacing: 0.1px;
}

/* =====================================================
   Module workflow pages (preop / postop)
   ===================================================== */
.module-layout {
  display: grid; grid-template-columns: minmax(0,1fr) 380px;
  gap: 28px; align-items: start;
}
.module-form {
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  padding: 28px 30px;
}
.module-side { position: sticky; top: 84px; }
.fieldset { margin-bottom: 30px; }
.fieldset:last-child { margin-bottom: 0; }
.fieldset > .fs-title {
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  letter-spacing: 0.8px; text-transform: uppercase; color: var(--color-muted);
  margin: 0 0 4px; padding-bottom: 10px;
  border-bottom: 1px solid var(--color-hairline-soft);
}
.fieldset > .fs-note {
  font-family: var(--font-sans); font-size: 12.5px; color: var(--color-muted);
  margin: 10px 0 0; line-height: 1.5;
}
.fs-body { display: flex; flex-direction: column; gap: 18px; padding-top: 18px; }

/* dense checkbox grid for flag-style inputs */
.flag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
@media (max-width: 720px) { .flag-grid { grid-template-columns: 1fr; } }

/* Recommendation output card */
.reco-card {
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.reco-head {
  padding: 22px 24px;
  border-bottom: 1px solid var(--color-hairline-soft);
  background:
    radial-gradient(140% 120% at 100% 0%, rgba(12,10,9,0.05), rgba(12,10,9,0) 60%),
    var(--color-canvas-soft);
}
.reco-eyebrow {
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  letter-spacing: 0.9px; text-transform: uppercase; color: var(--color-muted);
  margin-bottom: 10px;
}
.reco-level {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 300;
  font-size: 25px; line-height: 1.15; letter-spacing: -0.3px;
  color: var(--color-ink);
}
.reco-dot {
  width: 12px; height: 12px; border-radius: 9999px; flex-shrink: 0;
  background: var(--color-muted-soft);
}
.reco-sub {
  font-family: var(--font-sans); font-size: 13px; color: var(--color-body);
  margin-top: 8px; line-height: 1.5;
}
.reco-score {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--color-muted);
  margin-top: 12px;
}
.reco-score b { color: var(--color-ink); font-weight: 600; font-size: 15px; }
.reco-body { padding: 20px 24px 24px; }
.reco-body h4 {
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  letter-spacing: 0.7px; text-transform: uppercase; color: var(--color-muted);
  margin: 0 0 12px;
}
.reco-rationale { list-style: none; padding: 0; margin: 0; }
.reco-rationale li {
  display: flex; gap: 10px; align-items: flex-start;
  font-family: var(--font-sans); font-size: 13.5px; line-height: 1.5;
  color: var(--color-body-strong); padding: 7px 0;
  border-bottom: 1px solid var(--color-hairline-soft);
}
.reco-rationale li:last-child { border-bottom: 0; }
.reco-rationale li::before {
  content: ''; margin-top: 6px; width: 6px; height: 6px; flex-shrink: 0;
  border-radius: 9999px; background: var(--color-ink);
}
.reco-empty {
  font-family: var(--font-sans); font-size: 13px; color: var(--color-muted);
  line-height: 1.55; padding: 4px 0;
}
.reco-actions { padding: 0 24px 22px; }
.reco-disclaimer {
  font-family: var(--font-sans); font-size: 11.5px; line-height: 1.5;
  color: var(--color-muted); padding: 14px 24px;
  border-top: 1px solid var(--color-hairline-soft);
  background: var(--color-canvas-soft);
}

/* level/flag accent colors */
.lv-green  { background: #16a34a; }
.lv-yellow { background: #d97706; }
.lv-red    { background: #dc2626; }
.reco-head.is-green  { background: radial-gradient(140% 120% at 100% 0%, rgba(22,163,74,0.10), rgba(22,163,74,0) 62%), var(--color-canvas-soft); }
.reco-head.is-yellow { background: radial-gradient(140% 120% at 100% 0%, rgba(217,119,6,0.12), rgba(217,119,6,0) 62%), var(--color-canvas-soft); }
.reco-head.is-red    { background: radial-gradient(140% 120% at 100% 0%, rgba(220,38,38,0.12), rgba(220,38,38,0) 62%), var(--color-canvas-soft); }

/* segmented control full-width variant for module forms */
.seg-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-wrap.seg-3 button { flex: 1 1 30%; }

@media (max-width: 980px) {
  .tile-grid { grid-template-columns: 1fr; }
  .module-layout { grid-template-columns: 1fr; }
  .module-side { position: static; }
  .flightpath-steps { grid-template-columns: 1fr; gap: 18px; }
  .flightpath-step { padding: 0; }
  .flightpath-step:not(:last-child)::after { content: '↓'; right: auto; left: 0; top: auto; bottom: -14px; }
}
@media (max-width: 720px) {
  .hero { padding: 44px 0 28px; }
  .hero h1 { font-size: 40px; letter-spacing: -0.6px; }
  .hero .lede { font-size: 16px; }
  .modules-head { flex-direction: column; gap: 6px; }
}

/* =====================================================
   Compact single-screen landing (body.landing)
   ===================================================== */
body.landing { min-height: 100dvh; display: flex; flex-direction: column; }
body.landing .hero { padding: 30px 0 8px; }
body.landing .hero .eyebrow { margin-bottom: 14px; }
body.landing .hero h1 {
  font-size: clamp(32px, 4.2vw, 50px); margin-bottom: 12px;
  max-width: none; white-space: nowrap;
}
body.landing .hero .lede { font-size: 16.5px; line-height: 1.5; margin: 0; max-width: none; white-space: nowrap; }

/* Workflow / flight plan — numbered, connected, centered over each tile */
.flightstrip { padding: 22px 0 6px; position: relative; z-index: 1; }
.flightplan {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  position: relative;
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(6px) saturate(1.05);
  -webkit-backdrop-filter: blur(6px) saturate(1.05);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  box-shadow: var(--shadow-soft);
}
.fp-stage {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 0 18px;
}
/* connector line sits behind the number badges, spanning stage centers */
.fp-stage::before {
  content: ''; position: absolute; top: 15px; height: 1px;
  background: var(--color-hairline-strong);
  left: -10px; right: 50%;
  z-index: 0;
}
.fp-stage:first-child::before { left: 50%; }
.fp-stage::after {
  content: ''; position: absolute; top: 15px; height: 1px;
  background: var(--color-hairline-strong);
  left: 50%; right: -10px;
  z-index: 0;
}
.fp-stage:last-child::after { right: 50%; }
.fp-num {
  position: relative; z-index: 1;
  width: 30px; height: 30px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-ink); color: #fff;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  box-shadow: 0 0 0 5px rgba(255,255,255,0.75);
  margin-bottom: 12px;
}
.fp-stage h4 {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  color: var(--color-ink); margin: 0 0 4px; letter-spacing: 0.1px;
}
.fp-stage p {
  font-family: var(--font-sans); font-size: 12.5px; line-height: 1.45;
  color: var(--color-muted); margin: 0; letter-spacing: 0.1px;
}

body.landing main { flex: 1 1 auto; display: flex; align-items: center; padding: 16px 0 18px; }
body.landing .tile-grid { width: 100%; gap: 20px; }
body.landing .tile { padding: 22px 22px 20px; }
body.landing .tile-top { margin-bottom: 16px; }
body.landing .tile h3 { font-size: 21px; margin-bottom: 9px; }
body.landing .tile p { font-size: 13px; line-height: 1.5; margin-bottom: 16px; }
body.landing .tile-cta { padding-top: 13px; }
body.landing .footer-disclaimer { margin-top: auto; }

/* Enforce a true single screen on desktop; let smaller screens stack + scroll */
@media (min-width: 981px) and (min-height: 680px) {
  body.landing { height: 100dvh; overflow: hidden; }
}
@media (max-width: 980px) {
  body.landing main { display: block; }
  body.landing .hero h1 { white-space: normal; }
  body.landing .hero .lede { white-space: normal; }
  .flightstrip { padding: 12px 0 2px; }
  /* Even, grid-aligned workflow rows: badge column + stacked title/description */
  .flightplan { display: flex; flex-direction: column; gap: 16px; padding: 18px 18px; }
  .fp-stage {
    display: grid; grid-template-columns: 30px 1fr;
    column-gap: 12px; row-gap: 2px; align-items: start; text-align: left; padding: 0;
  }
  .fp-stage::before, .fp-stage::after { display: none; }
  .fp-num { grid-column: 1; grid-row: 1 / span 2; margin: 0; box-shadow: none; align-self: start; }
  .fp-stage h4 { grid-column: 2; grid-row: 1; margin: 0; }
  .fp-stage p { grid-column: 2; grid-row: 2; margin: 0; }
}

/* =====================================================
   Color application — single terracotta accent, sleek mono
   Controls stay black/ink; accent used only as restrained highlights.
   ===================================================== */

/* Links & focus */
a:hover { text-decoration-color: var(--color-accent); }
.footer-disclaimer a { color: var(--color-accent-ink); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--color-ink);
  box-shadow: 0 0 0 3px var(--color-hairline-soft);
}
.tile:focus-visible,
button.page-icon:focus-visible { outline-color: var(--color-ink); }
.small-btn:hover { border-color: var(--color-ink); color: var(--color-ink); }

/* Brand mark — subtle terracotta pop over ink */
.brand-mark {
  background:
    radial-gradient(closest-side at 30% 30%, rgba(20,20,20,0.92), rgba(20,20,20,0) 72%),
    radial-gradient(closest-side at 75% 72%, rgba(191,90,57,0.85), rgba(191,90,57,0) 72%),
    var(--color-surface-strong);
}

/* Module page header icons stay black on a neutral chip (base .page-icon). */

/* Recommendation card — thin accent signature stripe + accent eyebrow */
.reco-card { border-top: 3px solid var(--color-accent); }
.reco-eyebrow { color: var(--color-accent); }

/* Landing hero eyebrow: quiet muted words + small accent dot */
.hero .eyebrow::before {
  background: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}
.eyebrow .ph-pre, .eyebrow .ph-intra, .eyebrow .ph-post { color: inherit; }

/* Landing tiles: one accent for icon, label, hover bar, CTA */
.tile::before { background: var(--color-accent); }
.tile:hover { border-color: var(--color-accent-border); }
.tile-icon { color: var(--color-ink); background: var(--color-surface-strong); border-color: var(--color-hairline); }
.tile-phase { color: var(--color-muted); background: var(--color-canvas-soft); border-color: var(--color-hairline); }
.tile-label { color: var(--color-accent); }
.tile-cta { color: var(--color-ink); }
.tile:hover .tile-cta { color: var(--color-accent); }

/* Workflow — black number badges, ink titles */

/* =====================================================
   Mobile hardening (phones) — desktop/laptop unchanged.
   Prevents sideways scrolling and contains wide tables.
   ===================================================== */
@media (max-width: 720px) {
  /* No page-level horizontal scroll/drift */
  html, body { overflow-x: hidden; }

  /* Wide summary + note tables scroll inside their own card, not the page */
  .table-wrap, .assessment-text { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .summary-table { min-width: 460px; }          /* keep columns legible; scroll within card */
  .assessment-text table { min-width: 440px; }

  /* Calculator category pipeline wraps instead of overflowing */
  .calc-nav { flex-wrap: wrap; row-gap: 6px; }
  .cat-menu { max-width: 92vw; }

  /* Segmented option groups wrap cleanly */
  .field-opts { width: 100%; }
  .field-opts button { flex: 0 1 auto; }

  /* Keep the fixed ECG canvas from adding a scrollbar-width overflow */
  #bg-motion { width: 100% !important; }

  /* Comfortable side padding + tap-friendly spacing */
  .container { padding-left: 16px; padding-right: 16px; }
  main { padding: 20px 0 48px; }

  /* Table card headers: stack title over actions so Copy/Print aren't cut off */
  .as-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .table-actions { flex-wrap: wrap; }

  /* Hamburger dropdown must paint above page content (header z-index is
     lowered to 1 on motion pages, which otherwise hides the menu). */
  header.site { z-index: 60 !important; }
  nav.top { box-shadow: 0 12px 30px rgba(12,10,9,0.18); z-index: 61; }
  nav.top.open { background: #fff; }
}

@media (max-width: 480px) {
  .summary-table { font-size: 12px; }
  .dashboard-head h1 { font-size: 26px; }
}

/* Touch devices: category dropdowns open/close on tap (not hover/focus),
   so tapping elsewhere reliably closes them. Desktop hover is unchanged. */
@media (hover: none) {
  .cat:hover > .cat-menu,
  .cat:focus-within > .cat-menu { opacity: 0; visibility: hidden; transform: translateY(-4px); }
  .cat.open > .cat-menu { opacity: 1; visibility: visible; transform: translateY(0); }
}
