:root {
  /* Surface & Canvas */
  --canvas: #f1f5f9;
  --paper: #ffffff;
  --paper-subtle: #f8fafc;
  --paper-2: #f1f5f9;
  --paper-muted: #edf2f7;

  /* Typography */
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  /* Lines & Borders */
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --line-strong: #cbd5e1;

  /* Brand Clinical Accent (Teal) */
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-dark: #134e4a;
  --accent-soft: #f0fdfa;
  --accent-border: #99f6e4;
  --accent-ring: rgba(15, 118, 110, 0.18);

  /* Clinical Status Color System */
  --critical: #dc2626;
  --critical-bg: #fef2f2;
  --critical-border: #fecaca;
  --critical-text: #991b1b;

  --high: #ea580c;
  --high-bg: #fff7ed;
  --high-border: #fed7aa;
  --high-text: #9a3412;

  --watch: #d97706;
  --watch-bg: #fffbeb;
  --watch-border: #fde68a;
  --watch-text: #92400e;

  --stable: #16a34a;
  --stable-bg: #f0fdf4;
  --stable-border: #bbf7d0;
  --stable-text: #166534;

  /* Shadows & Depth */
  --shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; border: none; background: transparent; touch-action: manipulation; }
button:active:not(:disabled) { transform: scale(0.97); }

.app-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: max-width var(--transition-normal), border-radius var(--transition-normal);
}

@media (min-width: 768px) and (max-width: 1023px) {
  .app-frame {
    width: min(100% - 32px, 940px);
    height: calc(100vh - 32px);
    margin: 16px auto;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(203, 213, 225, 0.6);
  }
}

@media (min-width: 1024px) {
  .app-frame {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

:fullscreen .app-frame,
body.is-fullscreen .app-frame,
.app-frame.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  z-index: 99999 !important;
}
.app-bar {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  z-index: 30;
  top: 0;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.app-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-back-icon, .icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  transition: all var(--transition-fast);
}

.nav-back-icon:hover, .icon-button:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.nav-back-icon:disabled, .icon-button:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.brand-badge {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #ffffff;
  font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.25);
}

.app-heading { min-width: 0; }
.app-heading h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.025em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-kicker {
  margin: 0;
  color: var(--muted);
  font: 650 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper-subtle);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 650;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}

.header-btn.icon-only {
  width: 32px;
  padding: 0;
  justify-content: center;
  font-size: 16px;
}

.header-btn .btn-icon {
  color: var(--accent);
  font-size: 12px;
}

/* Phase Navigation Bar (Tabs) */
.phase-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.phase-nav::-webkit-scrollbar { display: none; }

.phase-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  touch-action: manipulation;
  scroll-snap-align: start;
  transition: all var(--transition-fast);
}

.phase-tab:hover {
  background: var(--paper-subtle);
  color: var(--ink);
}

.phase-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 750;
}

.phase-icon { font-size: 14px; }

/* Patient Strip & Status */
.patient-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
}

.patient-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.patient-name {
  font-weight: 750;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--muted);
  font: 700 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.badge.demo {
  color: var(--accent-dark);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--watch-bg);
  border: 1px solid var(--watch-border);
  color: var(--watch-text);
  font: 750 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.header-status-wrap { display: flex; align-items: center; flex-shrink: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font: 800 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill-pending { background: var(--paper-muted); color: var(--muted); border-color: var(--line); }
.status-pill.status-critical { background: var(--critical-bg); color: var(--critical); border-color: var(--critical-border); }
.status-pill.status-high-risk { background: var(--high-bg); color: var(--high); border-color: var(--high-border); }
.status-pill.status-watch { background: var(--watch-bg); color: var(--watch); border-color: var(--watch-border); }
.status-pill.status-stable { background: var(--stable-bg); color: var(--stable); border-color: var(--stable-border); }

.progress-track { height: 3px; margin: 0 -16px; overflow: hidden; background: var(--line-soft); }
.progress-track span { display: block; width: 0%; height: 100%; background: var(--accent); transition: width 0.3s ease; }

.not-for-clinical-use {
  margin: 0 -16px;
  padding: 4px 16px;
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #92400e;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}
.not-for-clinical-use strong { font-weight: 750; }

form { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.screen-stack { width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 16px; overflow: hidden; }

@media (min-width: 768px) {
  .screen-stack { padding: 24px 32px; }
}
@media (min-width: 1024px) {
  .screen-stack {
    padding: 16px 28px;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
}

.flow-page-container { display: contents; }
.flow-page {
  display: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.flow-page::-webkit-scrollbar { width: 6px; }
.flow-page::-webkit-scrollbar-thumb { background-color: var(--line-strong); border-radius: var(--radius-full); }

.flow-page.is-active {
  display: flex;
  flex-direction: column;
  animation: page-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes page-fade-in {
  from { opacity: 0.3; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.flow-page.page-disabled { display: none !important; }

.page-intro { flex: 0 0 auto; margin-bottom: 14px; }
.page-intro h2 { margin: 0 0 4px; font-size: 23px; font-weight: 800; line-height: 1.15; letter-spacing: -0.035em; color: var(--ink); }
.page-intro p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font: 750 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; text-transform: uppercase; }

.welcome-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-border);
  background: linear-gradient(135deg, #f0fdfa, #ffffff 75%);
  box-shadow: var(--shadow-sm);
}

.welcome-mark {
  display: grid;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font: 800 13px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.welcome-card h2 { margin: 0 0 4px; font-size: 19px; font-weight: 800; color: var(--ink); }
.welcome-card p:last-child { margin: 0; color: var(--muted); font-size: 13.5px; }

.card {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.page-card { flex: 0 0 auto; margin-bottom: 0; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-heading h2 { margin: 0; font-size: 18px; font-weight: 750; color: var(--ink); }

.form-grid { display: grid; gap: 14px; }
.form-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

@media (max-width: 500px) {
  .form-grid.two-up { grid-template-columns: 1fr; }
}

label { display: flex; flex-direction: column; gap: 5px; color: var(--ink-secondary); font-size: 13.5px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  outline: 0;
  font-size: 16px;
  transition: all var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 38px;
}

small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
output { color: var(--accent); font-weight: 750; }
fieldset { margin: 16px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); }
legend { padding: 0 5px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.check-stack { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; color: var(--ink); font-size: 14.5px; font-weight: 600; cursor: pointer; }
.large-checks .check {
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-subtle);
  transition: all var(--transition-fast);
}
.large-checks .check:hover { background: #ffffff; border-color: var(--line-strong); }
.large-checks .check:has(input:checked) {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.check input, .round-item input, .bundle-check input {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.selection-count {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.choice-groups { display: grid; gap: 10px; }
.choice-group { margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-subtle); overflow: hidden; }
.choice-group summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; color: var(--ink); font-size: 13px; font-weight: 700; list-style: none; cursor: pointer; }
.choice-group summary::-webkit-details-marker { display: none; }
.choice-group summary::after { content: '⌄'; color: var(--accent); font-size: 16px; font-weight: 700; }
.choice-group[open] summary::after { transform: rotate(180deg); }
.choice-group-options, .choice-list { display: grid; gap: 8px; }
.choice-group-options { padding: 0 12px 12px; }

.choice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.35;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.choice-option:hover { border-color: var(--line-strong); }
.choice-option:has(input:checked) {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.choice-option input { flex: 0 0 auto; width: 18px; min-height: 18px; margin: 0; accent-color: var(--accent); }
.choice-option span { min-width: 0; overflow-wrap: anywhere; }
.choice-empty { margin: 0; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); color: var(--muted); font-size: 13px; }
.is-hidden { display: none !important; }
.flow-option-critical { border-left: 3.5px solid var(--critical); }
.flow-restart-row { margin-top: 18px; }

.box-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (min-width: 640px) {
  .box-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.box-card {
  display: grid;
  grid-template-columns: 1fr 24px;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}
.box-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.box-card-label { grid-column: 1; font-size: 15px; font-weight: 700; color: var(--ink); }
.box-card-count { grid-column: 1; font-size: 12.5px; color: var(--muted); }
.box-card .chevron { grid-row: 1 / 3; color: var(--faint); font-size: 20px; text-align: right; }
.box-card:hover .chevron { color: var(--accent); }
.flow-summary-link { margin-top: 16px; }
.box-back-link { display: inline-flex; align-items: center; margin-bottom: 14px; font-size: 13px; font-weight: 650; color: var(--accent); }

/* Three-State Presence Controls */
.choice-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 2px 2px 2px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-subtle);
  transition: all var(--transition-fast);
}
.choice-row:hover { border-color: var(--line-strong); background: #ffffff; }
.choice-row:has(.choice-option input:checked) {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.choice-row .choice-option { margin: 0; border: none; background: transparent; }
.rule-out {
  display: grid;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  place-items: center;
  margin-right: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--faint);
  font-size: 14px;
  font-weight: 800;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}
.rule-out:hover {
  border-color: var(--critical);
  color: var(--critical);
  background: var(--critical-bg);
}
.rule-out.is-on {
  border-color: var(--critical);
  background: var(--critical-bg);
  color: var(--critical);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.15);
}
.choice-option.is-ruled-out span { text-decoration: line-through; color: var(--faint); }
.action-sources.unsourced { color: var(--watch-text); font-weight: 600; font-size: 11px; }

.cleared-note {
  padding: 14px 16px;
  border: 1px solid var(--stable-border);
  border-radius: var(--radius-md);
  background: var(--stable-bg);
}
.cleared-head { margin: 0 0 4px; font-weight: 800; color: var(--stable-text); }
.cleared-caveat { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }

.scope-gate { margin-top: 14px; border: 1px solid #fed7aa; background: #fffdfa; }
.large-check { font-size: 14px; line-height: 1.4; }
.hub-handoff { margin-top: 18px; }
.hub-handoff .button { width: 100%; }

.status-inline {
  margin-bottom: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--paper-subtle);
}
.status-inline.status-critical { border-color: var(--critical-border); background: var(--critical-bg); }
.status-inline.status-high-risk { border-color: var(--high-border); background: var(--high-bg); }
.status-inline.status-watch { border-color: var(--watch-border); background: var(--watch-bg); }
.status-inline.status-stable { border-color: var(--stable-border); background: var(--stable-bg); }

.detail-row {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  overflow: hidden;
  transition: all var(--transition-fast);
}
.detail-row:hover { border-color: var(--line-strong); }
.detail-row > summary { display: grid; gap: 4px; padding: 12px 14px; cursor: pointer; list-style: none; position: relative; }
.detail-row > summary::-webkit-details-marker { display: none; }
.detail-row > summary::after { content: '⌄'; position: absolute; right: 14px; top: 12px; color: var(--accent); font-size: 16px; font-weight: 700; transition: transform var(--transition-fast); }
.detail-row[open] > summary::after { transform: rotate(180deg); }
.detail-row-main { display: flex; align-items: center; gap: 8px; padding-right: 22px; }
.detail-row-title { color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.detail-row-meta { color: var(--muted); font-size: 12px; }
.detail-row-body { padding: 10px 14px 14px; border-top: 1px solid var(--line-soft); background: var(--paper-subtle); }

.box-group { margin-bottom: 18px; }
.box-group h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink-secondary); }
.box-group:last-child { margin-bottom: 0; }

.metric-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.metric-section-heading h3 { margin: 0; font-size: 16px; font-weight: 750; color: var(--ink); }
.metric-section-heading span { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }

.metric-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.metric { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-subtle); transition: all var(--transition-fast); }
.metric:hover { background: #ffffff; border-color: var(--line-strong); }
.metric-name { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--ink); font-size: 13.5px; font-weight: 750; }
.metric-unit { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 500; }
.metric-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric-inputs label { gap: 3px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.metric input { min-height: 44px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--paper); font-size: 16px; }

.callout { display: flex; flex-direction: column; gap: 3px; margin-bottom: 14px; padding: 12px 14px; border-left: 3.5px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink-secondary); font-size: 13px; }
.callout strong { color: var(--ink); font-weight: 700; }
.callout-warning { border-left-color: var(--watch); background: var(--watch-bg); color: var(--watch-text); }
.callout-warning strong { color: var(--watch-text); }
.callout-info { border-left-color: var(--accent); background: var(--accent-soft); }

.bottom-nav {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 88px 1fr 116px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.05);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 750;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}
.button:hover { border-color: var(--line-strong); background: var(--paper-subtle); }
.button-primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.25);
}
.button-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.35);
  transform: translateY(-1px);
}
.button-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button-quiet:hover { background: var(--paper-subtle); color: var(--ink); }
.button:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: none; pointer-events: none; }

.nav-state {
  color: var(--muted);
  font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-card { border-left: 5px solid var(--accent); overflow: hidden; }
.status-card.status-stable { border-left-color: var(--stable); }
.status-card.status-watch { border-left-color: var(--watch); }
.status-card.status-high-risk { border-left-color: var(--high); }
.status-card.status-critical { border-left-color: var(--critical); }

.status-top { display: flex; flex-direction: column; gap: 4px; }
.status-label { font-size: 26px; font-weight: 900; letter-spacing: -0.04em; color: var(--ink); }
.status-card.status-critical .status-label { color: var(--critical); }
.status-card.status-high-risk .status-label { color: var(--high); }
.status-card.status-watch .status-label { color: var(--watch); }
.status-card.status-stable .status-label { color: var(--stable); }

.status-score { color: var(--muted); font: 650 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.status-action { margin: 6px 0 0; color: var(--ink-secondary); font-size: 14.5px; font-weight: 550; line-height: 1.45; }
.warning { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--watch-border); background: var(--watch-bg); color: var(--watch-text); font-size: 12.5px; }

.finding { padding: 12px 0; border-top: 1px solid var(--line-soft); }
.finding:first-of-type { padding-top: 0; border-top: 0; }
.finding-title { display: flex; align-items: baseline; gap: 8px; color: var(--ink); font-size: 14.5px; font-weight: 750; }

.severity { display: inline-flex; align-items: center; padding: 3px 6px; border-radius: var(--radius-xs); font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.severity-critical { color: var(--critical); background: var(--critical-bg); border: 1px solid var(--critical-border); }
.severity-high { color: var(--high); background: var(--high-bg); border: 1px solid var(--high-border); }
.severity-moderate { color: var(--watch); background: var(--watch-bg); border: 1px solid var(--watch-border); }
.severity-info { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border); }

.evidence { margin-top: 6px; color: var(--muted); font: 11.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.asks { margin: 8px 0 0; padding-left: 10px; border-left: 2.5px solid var(--accent); color: var(--accent-dark); font-size: 13px; font-style: italic; }

.protocol-action { margin-bottom: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--shadow-sm); }
.protocol-action + .protocol-action { margin-top: 8px; }
.protocol-text { margin: 8px 0 4px; color: var(--ink); font-size: 15px; font-weight: 700; }
.action-sources, .protocol-sources { margin-top: 8px; color: var(--muted); font-size: 11px; }
.action-sources a, .protocol-sources a { color: var(--accent); text-decoration: underline; }
.source-list { display: grid; gap: 8px; margin-top: 8px; }
.source-list a, .source-list span { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-subtle); color: var(--accent); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }

.protocol-block + .protocol-block { margin-top: 18px; }
.protocol-block h3 { margin: 0 0 8px; font-size: 14px; font-weight: 750; color: var(--ink); }
.awaiting { margin-top: 14px; padding: 10px 0 0; border-top: 1px solid var(--line-soft); }
.awaiting summary { color: var(--watch); font-weight: 750; }

.safety-item, .bundle-item { padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.safety-item:first-of-type, .bundle-item:first-of-type { border-top: 0; padding-top: 0; }
.action { display: inline-flex; align-items: center; margin-right: 8px; padding: 3px 7px; border-radius: var(--radius-xs); font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.action-block { color: #ffffff; background: var(--critical); }
.action-flag { color: var(--high); background: var(--high-bg); border: 1px solid var(--high-border); }
.action-note { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border); }
.bundle-name { display: flex; justify-content: space-between; gap: 8px; font-weight: 750; color: var(--ink); }
.bundle-cadence { color: var(--muted); font-weight: 400; font-size: 12px; }
.bundle-checks { margin-top: 8px; }
.bundle-check { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; color: var(--ink); font-size: 14px; }

.round-template { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.round-meta { margin-bottom: 14px; padding: 12px; border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }
.round-meta p { margin: 0 0 4px; color: var(--accent); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.round-meta strong { color: var(--ink); font-size: 15px; }
.round-progress { height: 6px; margin: 10px 0 14px; overflow: hidden; background: var(--line-soft); border-radius: var(--radius-full); }
.round-progress span { display: block; height: 100%; background: var(--accent); transition: width 0.25s ease; }
.round-system { padding: 12px 0 4px; border-top: 1px solid var(--line-soft); }
.round-system h3 { margin: 0 0 8px; font-size: 15px; font-weight: 750; }
.round-item { display: flex; align-items: flex-start; gap: 12px; min-height: 46px; margin: 6px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-subtle); color: var(--ink); font-size: 14px; font-weight: 550; transition: all var(--transition-fast); }
.round-item:hover { background: #ffffff; border-color: var(--line-strong); }
.round-item input { flex-shrink: 0; margin-top: 2px; }

.table-wrap { overflow-x: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--paper); }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
th { background: var(--paper-subtle); color: var(--muted); font: 750 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
td:first-child { font-weight: 750; color: var(--ink); }
.trend-worsening { color: var(--critical); font-weight: 800; }
.trend-improving { color: var(--stable); font-weight: 800; }
.trend-rising, .trend-falling { color: var(--high); font-weight: 750; }
.trend-stable { color: var(--muted); }

.score-row { display: grid; grid-template-columns: 1fr 48px 1fr; align-items: baseline; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.score-row:first-of-type { border-top: 0; padding-top: 0; }
.score-name { font-size: 14px; font-weight: 750; color: var(--ink); }
.score-number { font: 800 20px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); }
.score-band { color: var(--muted); font-size: 13px; }
.score-caveat { grid-column: 1 / -1; color: var(--watch-text); font-size: 11.5px; }

.plain-list, .missing-list { margin: 6px 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.plain-list li, .missing-list li { margin: 4px 0; }
.review-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.review-list li { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-subtle); color: var(--ink); font-size: 14px; }
.differential-list li { display: grid; gap: 4px; }
.differential-list li > span:last-child { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.footer-note { margin-top: 14px; color: var(--faint); font-size: 11px; text-align: center; }

/* ==========================================================================
   FIGMA-STYLE FLOWCHART CANVAS, DECISION TRAIL & PREVIEW DRAWER
   ========================================================================== */

/* Decision Trail Bar */
.flow-trail-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.flow-trail-track {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.flow-trail-lead {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.flow-trail-empty {
  font-size: 13px;
  color: var(--faint);
  font-style: italic;
}

.flow-trail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--paper-subtle);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.flow-trail-chip:hover {
  border-color: var(--critical);
  background: #fef2f2;
  color: var(--critical);
  transform: translateY(-1px);
}

.flow-trail-chip .trail-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 13px;
  border-radius: 50%;
  color: var(--muted);
  transition: color var(--transition-fast);
}

.flow-trail-chip:hover .trail-remove {
  color: var(--critical);
}

.flow-trail-chip.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: default;
}

.flow-trail-chip.is-current:hover {
  transform: none;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.flow-trail-chip.is-complete {
  border-color: #10b981;
  background: #f0fdf4;
  color: #047857;
  cursor: default;
}

.trail-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--line-strong);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
}

.flow-trail-chip.is-current .trail-step-badge {
  background: var(--accent);
}

.flow-trail-chip.is-complete .trail-step-badge {
  background: #10b981;
}

.trail-arrow {
  color: var(--muted);
  font-weight: 700;
}

.trail-opt-label {
  color: var(--ink);
  font-weight: 750;
}

.flow-trail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-mini-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-subtle);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.flow-mini-btn:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.flow-mini-btn.is-action {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 750;
}

.flow-mini-btn.is-action:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Flow Toolbar & View Switcher */
.flow-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.flow-mode-switch {
  display: inline-flex;
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
}

.flow-mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.flow-mode-tab:hover {
  color: var(--ink);
}

.flow-mode-tab.is-active {
  background: #ffffff;
  color: var(--ink);
  font-weight: 750;
  box-shadow: var(--shadow-sm);
}

.flow-zoom-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px 6px;
}

.flow-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: #ffffff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.flow-zoom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.flow-zoom-btn.flow-fit-btn {
  width: auto;
  padding: 0 8px;
  font-size: 12px;
}

.flow-zoom-label {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

/* Flow View Container & Panes */
.flow-view-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flow-view-container.is-canvas-mode .flow-view-canvas {
  display: block;
}

.flow-view-container.is-canvas-mode .flow-view-step {
  display: block;
}

.flow-view-container.is-step-mode .flow-view-canvas {
  display: none;
}

.flow-view-container.is-step-mode .flow-view-step {
  display: block;
}

/* Figma Canvas Viewport & Surface */
.flow-canvas-viewport {
  position: relative;
  width: 100%;
  height: calc(100vh - 270px);
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #f8fafc;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.flow-canvas-viewport.is-panning {
  cursor: grabbing !important;
}

body.is-fullscreen .flow-canvas-viewport {
  height: calc(100vh - 210px) !important;
}

.flow-canvas-surface {
  position: absolute;
  top: 0;
  left: 0;
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  transform-origin: 0 0;
  will-change: transform;
}

.flow-canvas-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

/* SVG Connectors */
.flow-svg-path {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 2px;
  stroke-linecap: round;
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.flow-svg-path.is-active {
  stroke: #0f766e;
  stroke-width: 3.5px;
  marker-end: url(#arrow-active);
}

.flow-svg-path.is-candidate {
  stroke: #0284c7;
  stroke-width: 2.2px;
  stroke-dasharray: 6 4;
}

.flow-svg-path.is-dimmed {
  stroke: #e2e8f0;
  stroke-width: 1.5px;
  opacity: 0.55;
}

.flow-svg-path.is-highlighted {
  stroke: #2563eb !important;
  stroke-width: 4px !important;
  stroke-dasharray: 8 5;
  opacity: 1 !important;
  animation: flowDash 0.8s linear infinite;
}

@keyframes flowDash {
  to {
    stroke-dashoffset: -26;
  }
}

/* Canvas Node Cards */
.flow-canvas-nodes {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: auto;
}

.flow-canvas-card {
  position: absolute;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1.5px solid var(--line);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  padding: 12px 14px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.flow-canvas-card.is-dragging {
  cursor: grabbing !important;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.2), 0 0 0 2px var(--accent) !important;
  z-index: 100 !important;
  opacity: 0.96;
}

.flow-canvas-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 20px rgba(15, 118, 110, 0.15);
  background: #ffffff;
}

.flow-canvas-card.is-answered {
  border-color: #10b981;
  background: #f0fdf4;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.flow-canvas-card.is-preview {
  border: 1.5px dashed #0284c7;
  background: #f0f9ff;
}

.flow-canvas-card.is-preview-target {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2), 0 10px 24px rgba(37, 99, 235, 0.2) !important;
  transform: translateY(-2px);
}

.flow-canvas-card.is-dimmed {
  opacity: 0.8;
}

.canvas-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  cursor: grab;
}

.canvas-header-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.canvas-drag-grip {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  opacity: 0.65;
  cursor: grab;
  user-select: none;
}

.canvas-card-header:hover .canvas-drag-grip {
  opacity: 1;
  color: var(--accent);
}

.canvas-cat-badge {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--paper-subtle);
  color: var(--muted);
}

.flow-canvas-card.is-active .canvas-cat-badge {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.canvas-status-pill {
  font-size: 10px;
  font-weight: 750;
  color: var(--muted);
}

.flow-canvas-card.is-active .canvas-status-pill {
  color: var(--accent);
}

.flow-canvas-card.is-answered .canvas-status-pill {
  color: #059669;
}

.canvas-card-title {
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 8px;
}

/* Question Card Specifics */
.canvas-question-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-left: 4px solid var(--accent);
}

.canvas-question-card.is-active {
  border-color: var(--accent);
  border-left-width: 5px;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 20px rgba(15, 118, 110, 0.15);
}

.canvas-question-card.is-answered {
  border-color: #10b981;
  border-left-color: #059669;
  background: #f8fafc;
}

.canvas-question-prompt {
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
  color: var(--ink);
  margin: 4px 0 6px;
}

.canvas-question-help {
  font-size: 11px;
  line-height: 1.4;
  color: #64748b;
  margin: 0;
  padding: 4px 6px;
  background: #f8fafc;
  border-radius: var(--radius-xs);
  border-left: 2px solid #cbd5e1;
}

/* Standalone Option Box */
.canvas-opt-box {
  background: #ffffff;
  border: 1.5px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}

.canvas-opt-box:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.12);
  transform: translateY(-1px);
}

.canvas-opt-box.is-candidate {
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 2px var(--accent-soft), 0 6px 14px rgba(15, 118, 110, 0.1);
}

.canvas-opt-box.is-chosen {
  border-color: #10b981;
  border-width: 2px;
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2), 0 6px 14px rgba(16, 185, 129, 0.12);
}

.canvas-opt-box.is-must-not-miss {
  border-left: 4px solid #ef4444 !important;
}

.canvas-opt-box.is-dimmed {
  opacity: 0.82;
}

.canvas-opt-status-pill {
  font-size: 10px;
  font-weight: 750;
  color: var(--muted);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--paper-subtle);
}

.canvas-opt-status-pill.is-chosen {
  background: #dcfce7;
  color: #166534;
}

.canvas-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.opt-edit-btn,
.opt-revert-btn {
  background: none;
  border: 1px solid var(--line);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1.2;
  transition: all var(--transition-fast);
}

.opt-edit-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.opt-revert-btn {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.opt-revert-btn:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

.canvas-opt-body {
  margin: 6px 0 8px;
  min-height: 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink);
  font-weight: 650;
}

.canvas-opt-label-text {
  overflow-wrap: break-word;
  word-break: break-word;
}

.opt-edited-tag {
  font-size: 9.5px;
  font-weight: 750;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 3px;
  align-self: flex-start;
}

.canvas-opt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 6px;
}

.opt-badge-stack {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.canvas-select-btn {
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 750;
  border: 1px solid var(--line);
  background: var(--paper-subtle);
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.canvas-select-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.canvas-select-btn.is-selected {
  background: #10b981;
  border-color: #059669;
  color: #ffffff;
}

/* Anchors */
.canvas-anchor {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  border: 2px solid #ffffff;
  top: 40px;
  pointer-events: none;
}

.canvas-anchor.anchor-in {
  left: -5px;
}

.canvas-anchor.anchor-out {
  right: -5px;
}

.canvas-opt-box.is-candidate .canvas-anchor {
  background: var(--accent);
}

.canvas-opt-box.is-chosen .canvas-anchor {
  background: #10b981;
}

/* Inline Option Editor */
.opt-inline-editor {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.opt-editor-textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.35;
  padding: 6px 8px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-xs);
  background: #ffffff;
  color: var(--ink);
  resize: vertical;
  min-height: 48px;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.opt-editor-textarea:focus {
  outline: none;
  border-color: var(--accent-dark);
}

.opt-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.opt-btn {
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
}

.opt-btn-save {
  background: var(--accent);
  color: #ffffff;
}

.opt-btn-save:hover {
  background: var(--accent-dark);
}

.opt-btn-cancel {
  background: var(--paper-subtle);
  border-color: var(--line);
  color: var(--muted);
}

.opt-btn-cancel:hover {
  color: var(--ink);
}

.option-edit-trigger-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}

.must-not-miss-pill {
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  background: #fee2e2;
  color: #b91c1c;
  letter-spacing: 0.04em;
}

.action-pill {
  font-size: 10px;
  color: #f59e0b;
}

/* Focused Bedside Step Card */
.flow-step-focused-card {
  margin-top: 6px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  border: 2px solid var(--accent-border);
  box-shadow: var(--shadow-md);
}

.step-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.step-card-kicker {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.step-card-node-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}

.step-card-prompt {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 10px;
}

.step-card-guidance {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #fefce8;
  border: 1px solid #fef08a;
  color: #854d0e;
  font-size: 12.5px;
  line-height: 1.4;
}

.step-options-container {
  margin-top: 10px;
}

.step-options-prompt {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Downstream Option Card & Drawer */
.flow-step-option-card {
  margin-bottom: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.flow-step-option-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.flow-step-option-card.is-must-not-miss {
  border-left: 4.5px solid var(--critical);
}

.flow-option-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.flow-option-select-btn:hover {
  background: var(--paper-subtle);
}

.select-indicator {
  font-size: 16px;
  color: var(--muted);
  font-weight: 700;
}

.option-text-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.option-primary-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.select-cta {
  font-size: 12.5px;
  font-weight: 750;
  color: var(--accent);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  transition: all var(--transition-fast);
}

.flow-option-select-btn:hover .select-cta {
  background: var(--accent);
  color: #ffffff;
  transform: translateX(2px);
}

/* Option Preview Drawer */
.option-preview-section {
  border-top: 1px solid var(--line-soft);
  background: var(--paper-subtle);
}

.preview-toggle-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.preview-toggle-bar:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.02);
}

.preview-toggle-bar.is-open {
  color: var(--ink);
  font-weight: 650;
  background: rgba(0, 0, 0, 0.03);
}

.preview-lead-icon {
  color: var(--accent);
  font-weight: 800;
}

.preview-headline {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-headline strong {
  color: var(--ink);
}

.preview-caret {
  font-size: 9px;
  color: var(--muted);
}

.preview-drawer-content {
  padding: 10px 16px 14px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  background: #ffffff;
}

.preview-subcopy {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.preview-next-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-next-prompt {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.preview-child-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chips-title {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.child-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--paper-subtle);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink);
}

.child-chip.is-critical {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 750;
}

.preview-action-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.preview-action-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--paper-subtle);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
}

.action-tag {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.action-tag-emergent {
  background: #fee2e2;
  color: #b91c1c;
}

.action-tag-urgent {
  background: #fef3c7;
  color: #b45309;
}

.action-tag-routine {
  background: #e0f2fe;
  color: #0369a1;
}

/* Terminal Card */
.flow-step-terminal-card {
  margin-top: 14px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: #f0fdf4;
  border: 2px solid #86efac;
  text-align: center;
}

.terminal-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: #15803d;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 800;
  margin-bottom: 10px;
}

.flow-step-terminal-card h3 {
  font-size: 18px;
  font-weight: 800;
  color: #166534;
  margin: 0 0 8px;
}

.terminal-copy {
  color: #15803d;
  font-size: 13.5px;
  line-height: 1.45;
  max-width: 520px;
  margin: 0 auto 16px;
}

.terminal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── qualitative finding entry ─────────────────────────────────────────────
   Replaces the numeric metric grid on the differential path. A parameter is a
   card with two independent axes; nothing picked means UNASSESSED, and the card
   says so rather than looking identical to a normal result. Uses the app's own
   tokens throughout — this app has a single light palette. */
.param-grid {
  display: grid;
  /* 300, not 330: the page card contributes 36px of its own padding, so an
     iPad Pro portrait grid is 630px wide and a second column needs a floor of
     309px or less. 300 also buys a third column on iPad Pro landscape. */
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.param-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px 10px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.param-card.is-set { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-ring); }
.param-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.param-head h4 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
.param-state {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); margin-left: auto; text-align: right;
}
.param-state.is-set {
  color: var(--accent); text-transform: none; letter-spacing: 0;
  font-size: 12px; font-weight: 600;
}
.param-clear {
  border: none; background: none; cursor: pointer; font-size: 11px;
  color: var(--muted); padding: 2px 5px; border-radius: var(--radius-xs);
}
.param-card:not(.is-set) .param-clear { visibility: hidden; }
.param-clear:hover { background: var(--paper-muted); color: var(--ink); }
.param-axis { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 7px; }
.axis-label {
  flex: 0 0 56px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); padding-top: 7px;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.finding-pill {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-xs);
  padding: 5px 9px; background: var(--paper); color: var(--ink-secondary);
  cursor: pointer; font: inherit; font-size: 12.5px; line-height: 1.25; text-align: left;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.finding-pill:hover { border-color: var(--accent); color: var(--ink); }
.finding-pill .pill-label { font-weight: 500; }
.finding-pill .pill-hint { font-size: 10.5px; color: var(--muted); }
.finding-pill.is-picked {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
/* Severity belongs to the finding, not to the accent, so it reads before it is
   picked as well as after. */
.finding-pill.sev-critical { border-color: var(--critical-border); color: var(--critical-text); }
.finding-pill.sev-critical .pill-hint { color: var(--critical-text); opacity: .7; }
.finding-pill.sev-critical.is-picked { background: var(--critical); border-color: var(--critical); color: #fff; }
.finding-pill.sev-high { border-color: var(--high-border); color: var(--high-text); }
.finding-pill.sev-high .pill-hint { color: var(--high-text); opacity: .7; }
.finding-pill.sev-high.is-picked { background: var(--high-text); border-color: var(--high-text); color: #fff; }
.finding-pill.is-normal.is-picked { background: var(--stable); border-color: var(--stable); color: #fff; }

/* Picked-state hint colour is declared AFTER the severity rules and matches
   their specificity, so a picked severity pill does not end up printing its
   dark severity text on its own dark severity fill. */
.finding-pill.is-picked .pill-hint,
.finding-pill.sev-critical.is-picked .pill-hint,
.finding-pill.sev-high.is-picked .pill-hint,
.finding-pill.is-normal.is-picked .pill-hint {
  color: rgba(255, 255, 255, .85);
  opacity: 1;
}
.finding-pill.is-ruled-out { text-decoration: line-through; opacity: .5; }
.finding-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.param-note {
  margin: 6px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--muted);
  border-left: 2px solid var(--line); padding-left: 8px;
}
/* which score each surviving numeric field feeds — nobody should be asked for
   a number without being told what it is for */
.metric-use {
  font-size: 10px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); margin: -2px 0 5px; font-weight: 600;
}
@media (max-width: 760px) {
  .param-grid { grid-template-columns: 1fr; }
  .param-axis { flex-direction: column; gap: 4px; }
  .axis-label { flex: none; padding-top: 0; }
}

/* rule evidence — findings the rule read, and the gaps it could not */
.evidence { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; }
.evidence-item {
  font-size: 11.5px; line-height: 1.4; color: var(--ink-secondary);
  background: var(--paper-muted); border-radius: var(--radius-xs); padding: 2px 7px;
}
.evidence-item b { font-weight: 600; color: var(--ink); }
.evidence-item.is-gap { color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); }
.evidence-item.is-gap b { color: var(--muted); font-weight: 500; }
.evidence-gap { color: var(--watch-text); }
.severity-muted { background: var(--paper-muted); color: var(--muted); border-color: var(--line-strong); }

/* ══ tablet / iPad ════════════════════════════════════════════════════════
   The workflow shows one page at a time, which is right on a phone. On a
   tablet it means ticking a finding and then navigating away to learn what it
   did. The rail keeps the current assessment in view on every page, in both
   orientations, so the consequence of a tap is visible where the tap happens. */

.app-body { display: contents; }              /* phones: layout unchanged */

.assess-rail { display: none; }

@media (min-width: 740px) {
  .app-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
  }
  .app-body > form { flex: 1 1 auto; min-width: 0; }

  .assess-rail {
    display: flex;
    flex-direction: column;
    flex: 0 0 264px;
    width: 264px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-left: 1px solid var(--line);
    background: var(--paper-subtle);
    padding: 14px 14px 20px;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
}
@media (min-width: 1024px) { .assess-rail { flex-basis: 300px; width: 300px; padding: 16px 16px 24px; } }
@media (min-width: 1280px) { .assess-rail { flex-basis: 324px; width: 324px; } }

/* ── rail internals ─────────────────────────────────────────────────────── */
.rail-band {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.rail-band-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.rail-band-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.rail-band.band-critical { background: var(--critical-bg); border-color: var(--critical-border); }
.rail-band.band-critical .rail-band-name { color: var(--critical-text); }
.rail-band.band-high     { background: var(--high-bg); border-color: var(--high-border); }
.rail-band.band-high .rail-band-name { color: var(--high-text); }
.rail-band.band-watch    { background: var(--watch-bg); border-color: var(--watch-border); }
.rail-band.band-watch .rail-band-name { color: var(--watch-text); }
.rail-band.band-stable   { background: var(--stable-bg); border-color: var(--stable-border); }
.rail-band.band-stable .rail-band-name { color: var(--stable-text); }

.rail-caveat {
  font-size: 11.5px; line-height: 1.45; color: var(--watch-text);
  background: var(--watch-bg); border: 1px solid var(--watch-border);
  border-radius: var(--radius-xs); padding: 7px 9px;
}

.rail-section { display: flex; flex-direction: column; gap: 7px; }
.rail-head {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
}
.rail-head .rail-count { margin-left: auto; letter-spacing: 0; text-transform: none; font-weight: 500; }

.rail-item {
  display: block; width: 100%; text-align: left;
  border: none; background: none; padding: 0; font: inherit; cursor: pointer;
  border-left: 2px solid var(--line-strong); padding-left: 8px;
  font-size: 12px; line-height: 1.4; color: var(--ink-secondary);
}
.rail-item:hover { border-left-color: var(--accent); color: var(--ink); }
.rail-item.sev-critical { border-left-color: var(--critical); }
.rail-item.sev-high { border-left-color: var(--high); }
.rail-item.sev-moderate { border-left-color: var(--watch); }
.rail-item b { display: block; font-weight: 600; color: var(--ink); font-size: 12.5px; }

.rail-dx { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
.rail-dx-label { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-dx-strength { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; padding: 1px 5px; border-radius: 3px; }
.strength-HIGH { background: var(--critical-bg); color: var(--critical-text); }
.strength-MODERATE { background: var(--watch-bg); color: var(--watch-text); }
.strength-LOW { background: var(--paper-muted); color: var(--muted); }
.strength-UNASSESSED { background: var(--paper-muted); color: var(--faint); }

.rail-gaps { display: flex; flex-wrap: wrap; gap: 4px; }
.rail-gap {
  font-size: 11px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: 3px; padding: 2px 6px;
}
.rail-more {
  font-size: 11px; color: var(--accent); background: none; border: none;
  padding: 2px 0; cursor: pointer; text-align: left; font: inherit; font-size: 11px;
}
.rail-more:hover { text-decoration: underline; }
.rail-empty { font-size: 11.5px; color: var(--faint); font-style: italic; }

/* ── touch targets ───────────────────────────────────────────────────────
   Several controls sat under Apple's 44pt minimum: direction pills at 28px,
   the parameter clear at 21px, phase tabs at 36px. Sized up wherever the
   pointer is coarse; a mouse keeps the denser layout. */
.finding-pill { min-height: 36px; justify-content: center; }

@media (pointer: coarse) {
  .finding-pill { min-height: 44px; padding: 7px 11px; font-size: 13px; }
  .finding-pill .pill-hint { font-size: 11px; }
  .param-clear { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .param-card { padding: 14px 15px 12px; }
  .axis-label { padding-top: 12px; }
  .box-card { min-height: 64px; }
  .rail-item { padding-top: 4px; padding-bottom: 4px; }
}

/* ── portrait tablet (768–1023px) ────────────────────────────────────────
   Portrait cannot have both the rail and two columns of parameter cards: at
   820px a 224px rail leaves 460px, and two columns would need cards under
   225px, which is too narrow for the pills to sit sensibly. So portrait keeps
   ONE column of full-width cards and a slimmer rail. Cards stay comfortable
   and the trade is paid in scrolling, which a thumb handles better than a
   cramped grid. Landscape has the room for three columns and is left alone. */
@media (min-width: 740px) and (max-width: 1023px) {
  .assess-rail { flex-basis: 224px; width: 224px; padding: 12px 12px 18px; gap: 12px; }
  .rail-band-name { font-size: 15.5px; }
  .rail-gaps { gap: 3px; }
}
