:root[data-theme="dark"] {
  --bg: #000000;
  --bg-ambient: radial-gradient(at 50% -10%, rgba(76, 175, 80, 0.16), transparent 60%);
  --nav-glass: rgba(28, 28, 30, 0.82);
  --card: #1c1c1e;
  --card-secondary: #2c2c2e;
  --card-hover: #3a3a3c;
  --text: #f5f5f7;
  --muted: #98989d;
  --hairline: #38383a;
  --system-blue: #0a84ff;
  --system-green: #30d158;
  --system-red: #ff453a;
  --system-orange: #ff9f0a;
  --seg-bg: rgba(118, 118, 128, 0.28);
  --seg-pill: #636366;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
  --graphic-stage: #121214;
  --code-bg: #2c2c2e;
  --code-text: #64d2ff;
  --success-bg: rgba(48, 209, 88, 0.16);
  --success-text: #86efac;
  --danger-bg: rgba(255, 69, 58, 0.16);
  --danger-text: #fca5a5;
  --info-bg: rgba(255, 159, 10, 0.16);
  --info-text: #fde68a;
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-ambient: radial-gradient(at 50% -10%, rgba(76, 175, 80, 0.1), transparent 60%);
  --nav-glass: rgba(255, 255, 255, 0.85);
  --card: #ffffff;
  --card-secondary: #f2f2f7;
  --card-hover: #e5e5ea;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --hairline: #d2d2d7;
  --system-blue: #007aff;
  --system-green: #34c759;
  --system-red: #ff3b30;
  --system-orange: #ff9500;
  --seg-bg: rgba(118, 118, 128, 0.12);
  --seg-pill: #ffffff;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
  --graphic-stage: #f5f5f7;
  --code-bg: #f2f2f7;
  --code-text: #007aff;
  --success-bg: rgba(52, 199, 89, 0.12);
  --success-text: #1d6f31;
  --danger-bg: rgba(255, 59, 48, 0.1);
  --danger-text: #b91c1c;
  --info-bg: rgba(255, 149, 0, 0.12);
  --info-text: #9a5700;
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  padding: 0 0 36px 0;
  background-color: var(--bg);
  background-image: var(--bg-ambient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 0.5px solid var(--hairline);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.header-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand-group { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.iemr-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(46, 125, 50, 0.35));
}
header h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.header-sub { font-size: 0.76rem; color: var(--muted); font-weight: 500; }

.segmented-control {
  display: inline-flex;
  background: var(--seg-bg);
  padding: 3px;
  border-radius: 9px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--seg-pill);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.container { max-width: 820px; margin: 0 auto; padding: 0 14px; }
.card {
  background: var(--card);
  border: 0.5px solid var(--hairline);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.ios-top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--hairline);
}
.ios-nav-link {
  background: none;
  border: none;
  color: var(--system-blue);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.step-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 6px 0; color: var(--text); }
.step-desc { color: var(--muted); margin-bottom: 16px; font-size: 0.95rem; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.device-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 16px;
  border-radius: 16px;
  background: var(--card-secondary);
  border: 0.5px solid var(--hairline);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
  gap: 10px;
}
.device-card:hover { background: var(--card-hover); transform: scale(1.015); }
.device-card:active { transform: scale(0.98); }
.device-card-top { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; }
.device-card svg { width: 72px; height: 60px; overflow: visible; }
.card-chevron { color: var(--muted); font-size: 1.25rem; font-weight: 600; opacity: 0.65; }
.device-card-title { font-weight: 600; font-size: 1rem; color: var(--text); line-height: 1.25; }
.device-card-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.btn-list {
  display: flex;
  flex-direction: column;
  background: var(--card-secondary);
  border-radius: 14px;
  overflow: hidden;
  border: 0.5px solid var(--hairline);
  margin-top: 18px;
}
button.opt-btn {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--hairline);
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
button.opt-btn:last-child { border-bottom: none; }
button.opt-btn:hover { background: var(--card-hover); }
.opt-left { display: flex; align-items: center; gap: 12px; }
.opt-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(10, 132, 255, 0.16);
  color: var(--system-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
}
.arrow-icon { color: var(--muted); font-weight: 600; font-size: 1.2rem; }

.alert { padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; font-size: 0.92rem; border: 0.5px solid var(--hairline); }
.alert-success { background: var(--success-bg); border-color: var(--system-green); color: var(--success-text); }
.alert-escalate { background: var(--danger-bg); border-color: var(--system-red); color: var(--danger-text); }
.alert-info { background: var(--info-bg); border-color: var(--system-orange); color: var(--info-text); }

ul { margin: 10px 0 16px 0; padding-left: 20px; }
li { margin-bottom: 9px; font-size: 0.94rem; color: var(--text); }
code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  vertical-align: middle;
  margin: 0 2px;
  border: 1px solid rgba(0,0,0,0.25);
  white-space: nowrap;
}
.chip-vsm-tab { background: #c5e8ff; color: #000; }
.chip-vsm-save { background: #00a2ff; color: #000; }
.chip-snake { background: #2b2b2b; color: #fff; border-color: #ff2d55; }
.chip-green { background: #34c759; color: #fff; }
.chip-yellow { background: #ffcc00; color: #000; }
.chip-blue { background: #007aff; color: #fff; }
.chip-orange { background: #ff9500; color: #fff; }
.chip-purple { background: #af52de; color: #fff; }
.chip-grey { background: #e5e5ea; color: #1d1d1f; }
.chip-menu { background: #f1f5f9; color: #0f172a; border-color: #94a3b8; font-weight: 600; }
.chip-red { background: #fee2e2; color: #991b1b; border-color: #dc2626; }
.chip-cardio { background: #fff1f2; color: #9f1239; border-color: #be123c; }

/* Little inline icons in step text (built by ico() in devices/apps.js) */
.ui-ico {
  display: inline-flex;
  width: 1.45em;
  height: 1.45em;
  vertical-align: -0.38em;
  margin: 0 1px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}
.ui-ico svg { width: 100%; height: 100%; display: block; }
/* Numbered markers that match the 1 / 2 badges in a diagram */
.ui-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  border-radius: 50%;
  background: #c800c8;
  color: #fff;
  font-size: 0.78em;
  font-weight: 800;
  vertical-align: 0.05em;
  margin-right: 2px;
}

.graphic-container {
  margin: 14px 0;
  text-align: center;
  background: var(--graphic-stage);
  border: 0.5px solid var(--hairline);
  border-radius: 16px;
  padding: 12px;
}
.graphic-container svg { max-width: 580px; width: 100%; height: auto; border-radius: 8px; display: block; margin: 0 auto; }

footer.app-footer {
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 18px;
  padding: 4px 10px;
  letter-spacing: -0.01em;
  line-height: 1.5;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
footer.app-footer a {
  color: var(--system-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

@keyframes magenta-ring-flash {
  0%, 100% { stroke-width: 5.5px; stroke-opacity: 1; filter: drop-shadow(0 0 8px #ff00ff); }
  50% { stroke-width: 2px; stroke-opacity: 0.35; filter: none; }
}
@keyframes magenta-arrow-nudge {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-6px, -6px); }
}
@keyframes cce-button-cycle {
  0%, 40% { fill: #ea580c; stroke: #fdba74; }
  55%, 100% { fill: #0284c7; stroke: #7dd3fc; }
}
.anim-ring { fill: none; stroke: #ff00ff; stroke-dasharray: 7 5; animation: magenta-ring-flash 1.1s infinite ease-in-out; }
.anim-arrow { animation: magenta-arrow-nudge 1.1s infinite ease-in-out; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5)); }
.anim-cce-power { animation: cce-button-cycle 2.6s infinite ease-in-out; }

/* =====================================================================
   Usability layer: navigation, search, zoom, progress, keyboard,
   phone and wide-screen layouts. Content styling above is unchanged.
   ===================================================================== */

/* ---- Header link + keyboard focus ---- */
a.brand-group { color: inherit; text-decoration: none; border-radius: 12px; }
:focus-visible { outline: 3px solid var(--system-blue); outline-offset: 2px; }
.step-title:focus { outline: none; }
button { font-family: inherit; }

/* ---- Device tiles are real buttons now (keyboard + screen reader friendly) ---- */
button.device-card {
  width: 100%;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.device-card-icon { display: block; line-height: 0; }
.device-card-title, .device-card-sub { display: block; }

/* ---- Answer buttons: optional second line (used by search results) ---- */
.opt-text { display: flex; flex-direction: column; gap: 2px; }
.opt-sub { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
button.opt-btn { min-height: 52px; }

/* ---- Device label + step progress ---- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.device-chip {
  background: var(--seg-bg);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.device-chip:hover:not(:disabled) { background: var(--card-hover); }
.device-chip:disabled { cursor: default; opacity: 1; }
.step-progress { display: inline-flex; align-items: center; gap: 10px; }
.step-progress-label { font-size: 0.78rem; font-weight: 700; color: var(--system-blue); letter-spacing: 0.02em; text-transform: uppercase; }
.step-progress-bar { display: inline-flex; gap: 4px; }
.step-progress-bar span { width: 22px; height: 6px; border-radius: 3px; background: var(--seg-bg); }
.step-progress-bar span.done { background: var(--system-blue); }

/* ---- Search ---- */
.search-wrap { position: relative; margin: 4px 0 12px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-icon svg { width: 18px; height: 18px; display: block; }
.search-input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 1rem;              /* 16px stops iPhone zooming in on focus */
  color: var(--text);
  background: var(--card-secondary);
  border: 0.5px solid var(--hairline);
  border-radius: 12px;
  padding: 13px 14px 13px 42px;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus-visible { outline-offset: 0; }
.search-list { margin-top: 0; margin-bottom: 8px; }
.search-empty { color: var(--muted); font-size: 0.92rem; padding: 6px 2px 4px; }
.grid-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 0 -6px; }

/* ---- Diagram: tap to enlarge ---- */
button.graphic-container {
  display: block;
  width: 100%;
  box-sizing: border-box;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
  position: relative;
}
.zoom-hint {
  margin: 8px auto 0;
  width: max-content;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--seg-bg);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  pointer-events: none;
}
.zoom-hint svg { width: 14px; height: 14px; }
.zoom-hint-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .zoom-hint-touch { display: none; }
  .zoom-hint-mouse { display: inline; }
  .zoom-hint { opacity: 0.75; transition: opacity 0.15s ease; }
  button.graphic-container:hover .zoom-hint { opacity: 1; color: var(--text); }
}

/* ---- Zoom viewer ---- */
html.zoom-open, html.zoom-open body { overflow: hidden; }
.zoom-dialog {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: var(--graphic-stage);
  color: var(--text);
}
.zoom-dialog[open] { display: flex; flex-direction: column; }
.zoom-dialog::backdrop { background: rgba(0, 0, 0, 0.85); }
.zoom-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--nav-glass);
  border-bottom: 0.5px solid var(--hairline);
}
.zoom-title { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.zoom-controls { display: flex; gap: 6px; flex-shrink: 0; }
.zoom-btn {
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 0.5px solid var(--hairline);
  background: var(--card-secondary);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.zoom-close { background: var(--system-blue); border-color: transparent; color: #fff; font-size: 0.9rem; }
.zoom-stage {
  flex: 1;
  overflow: auto;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
}
.zoom-canvas { display: flex; min-width: min-content; min-height: 100%; }
.zoom-canvas svg { display: block; height: auto; max-width: none; border-radius: 8px; flex-shrink: 0; margin: auto; }
.zoom-tip {
  margin: 0;
  padding: 8px 14px max(8px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 0.5px solid var(--hairline);
  background: var(--nav-glass);
}
@media (hover: hover) and (pointer: fine) { .zoom-tip { display: none; } }

/* ---- Phone bottom bar (hidden on larger screens) ---- */
.bottom-bar { display: none; }

/* ---- Picture + steps layout ---- */
.step-layout { display: block; }

/* =========================== Phones =========================== */
@media (max-width: 700px) {
  body.on-step .ios-top-nav { display: none; }
  body.on-step { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.on-step .bottom-bar {
    display: flex;
    gap: 10px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: var(--nav-glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 0.5px solid var(--hairline);
  }
  .bottom-btn {
    flex: 1;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: var(--system-blue);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
  }
  .bottom-btn-secondary { background: var(--card-secondary); color: var(--system-blue); border: 0.5px solid var(--hairline); }
}

@media (max-width: 600px) {
  header {
    padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    padding-top: max(8px, env(safe-area-inset-top));
    margin-bottom: 12px;
  }
  .header-inner { flex-wrap: nowrap; gap: 8px; }
  .brand-group { gap: 9px; min-width: 0; }
  .iemr-logo { width: 34px; height: 34px; }
  header h1 { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .h1-long, .header-sub { display: none; }
  .segmented-control { flex-shrink: 0; }
  .seg-btn { padding: 5px 9px; font-size: 0.74rem; }
  .container { padding: 0 10px; }
  .card { padding: 16px; border-radius: 18px; }
  .step-title { font-size: 1.22rem; }
  .home-grid { grid-template-columns: 1fr; gap: 8px; }
  button.device-card {
    display: grid;
    grid-template-columns: 58px 1fr 14px;
    grid-template-areas: "icon title chev" "icon sub chev";
    align-items: center;
    column-gap: 12px;
    row-gap: 1px;
    padding: 10px 12px;
  }
  .device-card-top { display: contents; }
  .device-card-icon { grid-area: icon; }
  .card-chevron { grid-area: chev; }
  .device-card-title { grid-area: title; align-self: end; font-size: 0.95rem; }
  .device-card-sub { grid-area: sub; align-self: start; font-size: 0.76rem; margin-top: 0; }
  .device-card svg { width: 58px; height: 48px; }
  .graphic-container { padding: 8px; }
}


/* ======================== Wide screens (PC) ======================== */
@media (min-width: 1000px) {
  .container, .header-inner { max-width: 1120px; }
  .home-grid { grid-template-columns: repeat(3, 1fr); }
  .step-inner:not(.has-media) { max-width: 820px; margin: 0 auto; }
  .has-media .step-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 26px;
    align-items: start;
  }
  .has-media .step-media { position: sticky; top: 88px; }
  .has-media .step-media .graphic-container { margin-top: 0; }
  .has-media .graphic-container svg { max-width: 100%; }
  .has-media .step-body ul { margin-top: 0; }
  .has-media .step-body .btn-list { margin-top: 12px; }
}

/* ---- Respect "reduce motion" (diagram arrows still pulse, as they carry meaning) ---- */
@media (prefers-reduced-motion: reduce) {
  .device-card, body { transition: none; }
  .device-card:hover, .device-card:active { transform: none; }
}

/* =====================================================================
   Data path ("how it works"), scan cards and "why this matters" notes
   ===================================================================== */
.flow {
  margin: 18px 0 4px;
  padding: 14px 16px 16px;
  border-radius: 14px;
  background: var(--card-secondary);
  border: 0.5px solid var(--hairline);
}
.flow-compact { margin: 0 0 14px; padding: 10px 12px 12px; }
.flow-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.flow-compact .flow-head { margin-bottom: 8px; }
.flow-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.flow-status { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--system-blue); }
.flow-status.is-fault { color: var(--system-red); }
.flow-status.is-ok { color: var(--system-green); }

.flow-track { display: flex; align-items: flex-start; }
.hop { flex: 0 0 auto; width: 86px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.hop-text { display: flex; flex-direction: column; gap: 2px; }
.hop-name { font-size: 0.8rem; font-weight: 600; line-height: 1.2; color: var(--text); }
.hop-sub { font-size: 0.7rem; line-height: 1.2; color: var(--muted); }
.hop-dot {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--system-green);
  background: var(--success-bg);
  border: 1.5px solid var(--system-green);
  box-sizing: border-box;
}
.hop-dot svg { width: 22px; height: 22px; }
.hop.is-current .hop-dot { color: var(--system-blue); background: rgba(10, 132, 255, 0.16); border-color: var(--system-blue); }
.hop.is-current .hop-name { color: var(--system-blue); }
.hop.is-current .hop-dot::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--system-blue);
  opacity: 0.6;
}
.hop.is-fault .hop-dot { color: var(--system-red); background: var(--danger-bg); border-color: var(--system-red); border-width: 2px; }
.hop.is-fault .hop-name { color: var(--system-red); }
.hop.is-dim .hop-dot { color: var(--muted); background: var(--seg-bg); border-color: var(--hairline); }
.hop.is-dim .hop-name, .hop.is-dim .hop-sub { color: var(--muted); }

.link { flex: 1 1 auto; min-width: 16px; margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.lane { position: relative; display: block; height: 4px; border-radius: 2px; background: var(--seg-bg); }
.link .lane:only-child { margin-top: 4px; }
.lane.is-on { background: rgba(48, 209, 88, 0.25); }
.lane.back.is-on { background: rgba(10, 132, 255, 0.22); }
.lane.is-stopped { background: repeating-linear-gradient(90deg, var(--system-red) 0 5px, transparent 5px 9px); }
.lane i {
  position: absolute;
  top: -3px;
  left: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--system-green);
  opacity: 0;
}
.lane.back i { background: var(--system-blue); }
.lane.is-on i:nth-child(1) { left: 15%; opacity: 1; }
.lane.is-on i:nth-child(2) { left: 50%; opacity: 1; }
.lane.is-on i:nth-child(3) { left: 80%; opacity: 1; }

@keyframes pkt     { 0% { left: -5px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: calc(100% - 5px); opacity: 0; } }
@keyframes pkt-rev { 0% { left: calc(100% - 5px); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: -5px; opacity: 0; } }
@keyframes pkt-dn  { 0% { top: -5px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: calc(100% - 5px); opacity: 0; } }
@keyframes pkt-up  { 0% { top: calc(100% - 5px); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: -5px; opacity: 0; } }
@keyframes hop-pulse { 0% { transform: scale(0.85); opacity: 0.8; } 100% { transform: scale(1.35); opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .lane.is-on i { animation: pkt 1.5s linear infinite; }
  .lane.back.is-on i { animation-name: pkt-rev; animation-duration: 1.8s; }
  .lane.is-on i:nth-child(2) { animation-delay: -0.5s; }
  .lane.is-on i:nth-child(3) { animation-delay: -1s; }
  .lane.back.is-on i:nth-child(2) { animation-delay: -0.9s; }
  .hop.is-current .hop-dot::after { animation: hop-pulse 1.6s ease-out infinite; }
}

.flow-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 0.76rem; color: var(--muted); }
.flow-legend span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 0;
  background: var(--system-green);
}
.flow-legend .back::before { background: var(--system-blue); }

/* Compact strip (step and escalation screens) */
.flow-compact .hop { width: 64px; gap: 4px; }
.flow-compact .hop-dot { width: 30px; height: 30px; border-width: 1.5px; }
.flow-compact .hop-dot svg { width: 16px; height: 16px; }
.flow-compact .hop-name { font-size: 0.68rem; font-weight: 600; }
.flow-compact .hop-sub { display: none; }
.flow-compact .link { margin-top: 10px; gap: 4px; min-width: 10px; }
.flow-compact .lane { height: 3px; }
.flow-compact .lane i { width: 8px; height: 8px; top: -2.5px; }
.flow-compact .hop.is-current .hop-dot::after { inset: -5px; }

/* Phones: the full path runs top to bottom so the lines have room */
@media (max-width: 600px) {
  .flow-full .flow-track { flex-direction: column; align-items: stretch; }
  .flow-full .hop { width: auto; flex-direction: row; align-items: center; gap: 12px; text-align: left; }
  .flow-full .link { flex: 0 0 28px; min-width: 0; margin: 3px 0 3px 20px; flex-direction: row; gap: 6px; }
  .flow-full .link .lane:only-child { margin-top: 0; }
  .flow-full .lane { width: 4px; height: 100%; }
  .flow-full .lane i { top: 0; left: -3px; }
  .flow-full .lane.is-on i:nth-child(1) { top: 15%; left: -3px; }
  .flow-full .lane.is-on i:nth-child(2) { top: 50%; left: -3px; }
  .flow-full .lane.is-on i:nth-child(3) { top: 80%; left: -3px; }
  .flow-full .lane.is-stopped { background: repeating-linear-gradient(180deg, var(--system-red) 0 5px, transparent 5px 9px); }
  .flow-compact .hop { width: 54px; }
  .flow-compact .hop-name { font-size: 0.64rem; }
}
@media (max-width: 600px) and (prefers-reduced-motion: no-preference) {
  .flow-full .lane.is-on i { animation-name: pkt-dn; }
  .flow-full .lane.back.is-on i { animation-name: pkt-up; }
}

/* "Why this matters" notes and scan cards */
details.explain {
  margin: 14px 0 4px;
  border-radius: 14px;
  border: 0.5px solid var(--hairline);
  background: var(--card-secondary);
  overflow: hidden;
}
details.explain > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
details.explain > summary::-webkit-details-marker { display: none; }
details.explain > summary::before {
  content: "\203A";
  display: inline-block;
  width: 12px;
  color: var(--system-blue);
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.15s ease;
}
details.explain[open] > summary::before { transform: rotate(90deg); }
.explain-body { padding: 0 16px 14px 38px; font-size: 0.92rem; color: var(--text); }
.explain-body p { margin: 0 0 8px; }
.explain-body p:last-child { margin-bottom: 0; }
.scan-list { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
.scan-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--card); border: 0.5px solid var(--hairline); }
.scan-glyph { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 10px; background: #fff; border: 0.5px solid var(--hairline); display: flex; align-items: center; justify-content: center; }
.scan-glyph svg { width: 34px; height: 34px; }
.scan-what { font-weight: 700; font-size: 0.92rem; line-height: 1.3; }
.scan-where { font-size: 0.78rem; color: var(--system-blue); font-weight: 600; margin: 2px 0 4px; }
.scan-why { font-size: 0.88rem; color: var(--muted); line-height: 1.45; }

/* Data path spacing fixes: fewer, smaller dots where lines are short */
.flow-compact .lane i:nth-child(3) { display: none; }
@media (max-width: 600px) {
  .flow-full .link { flex-basis: 40px; }
  .flow-full .lane i { width: 8px; height: 8px; left: -2px; }
  .flow-full .lane.is-on i:nth-child(1), .flow-full .lane.is-on i:nth-child(2) { left: -2px; }
  .flow-full .lane i:nth-child(3) { display: none; }
  .flow-compact .lane i { width: 7px; height: 7px; top: -2px; }
  .flow-compact .lane.is-on i:nth-child(1) { left: 20%; }
  .flow-compact .lane.is-on i:nth-child(2) { left: 65%; }
}
@media (prefers-reduced-motion: no-preference) {
  .flow-compact .lane.is-on i:nth-child(2) { animation-delay: -0.75s; }
}
@media (min-width: 1000px) {
  .has-media + .flow, .step-inner > .flow-full { margin-top: 22px; }
  .scans .scan-list { display: grid; grid-template-columns: 1fr 1fr; }
}

/* Data path inside its collapsible section (menu screens) */
.flow-details .flow { margin: 0 12px 12px; background: var(--card); }
.flow-details .flow-head { display: none; }
@media (min-width: 1000px) { .step-inner > .flow-details { margin-top: 22px; } }

/* Workflow screens (Clinical Apps & Workflows) */
.wf-section { margin: 4px 0 18px; }
.wf-heading { font-size: 1rem; font-weight: 700; margin: 18px 0 8px; color: var(--text); }
.wf-section:first-child .wf-heading { margin-top: 4px; }
.wf-intro { margin: 0 0 8px; font-size: 0.92rem; color: var(--muted); }
.wf-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: wf; }
.wf-steps li { counter-increment: wf; position: relative; padding: 0 0 0 36px; margin-bottom: 10px; font-size: 0.94rem; line-height: 1.5; }
.wf-steps li::before {
  content: counter(wf);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: rgba(10, 132, 255, 0.16);
  color: var(--system-blue);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wf-note {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  background: var(--info-bg);
  border: 0.5px solid var(--system-orange);
  color: var(--info-text);
}
.wf-source { margin: 18px 0 0; font-size: 0.75rem; color: var(--muted); }
.step-body > .home-grid { margin-top: 8px; }

/* Beta preview label (index.html adds it only on the beta address) */
.beta-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ff9500;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  vertical-align: middle;
}
/* Standard workflow: numbered stage strip (node.stages) */
.wf-stages {
  list-style: none;
  margin: 4px 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 6px;
  align-items: center;
}
.wf-stages li { display: flex; align-items: center; }
.wf-stages li + li::before {
  content: "›";
  color: var(--muted);
  font-weight: 700;
  margin-right: 6px;
}
.wf-stage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  background: var(--card-secondary);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  cursor: pointer;
}
.wf-stage:hover { background: var(--card-hover); }
.wf-stage-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  background: var(--system-green);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}
.wf-section[id] { scroll-margin-top: 80px; }

/* ================= Readability: answer buttons, headings and fold-out panels ================= */
/* Each answer is its own card with breathing room, a coloured accent and an icon for its kind:
   green = how it should work / fixed, amber = a problem to pick, blue = guide or link,
   red = escalate, magenta = camera (beta). */
.btn-list {
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
  gap: 10px;
  margin-top: 10px;
}
button.opt-btn {
  --accent: var(--system-blue);
  --accent-bg: rgba(10, 132, 255, 0.14);
  background: var(--card-secondary);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 14px 14px 14px 12px;
  min-height: 60px;
  font-size: 0.97rem;
  line-height: 1.35;
  transition: background 0.15s ease, transform 0.1s ease;
}
button.opt-btn:last-child { border-bottom: 1px solid var(--hairline); }
button.opt-btn:hover { background: var(--card-hover); }
button.opt-btn:active { transform: scale(0.99); }
button.opt-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt-left { gap: 14px; }
.opt-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
}
.opt-badge svg { width: 21px; height: 21px; }
.opt-label { font-weight: 600; }
.opt-sub { font-size: 0.8rem; margin-top: 1px; }
.arrow-icon { color: var(--accent); opacity: 0.8; font-size: 1.4rem; }

button.opt-issue    { --accent: var(--system-orange); --accent-bg: rgba(255, 159, 10, 0.16); }
button.opt-workflow, button.opt-ok { --accent: var(--system-green); --accent-bg: rgba(48, 209, 88, 0.16); }
button.opt-escalate { --accent: var(--system-red); --accent-bg: rgba(255, 69, 58, 0.14); }
button.opt-camera   { --accent: #c800c8; --accent-bg: rgba(200, 0, 200, 0.14); }
button.opt-plain    { border-left-width: 1px; }

/* Featured: "How it should work" stands out from the problem list */
.btn-featured { margin-top: 18px; }
.btn-featured button.opt-btn { background: var(--success-bg); border-color: rgba(48, 209, 88, 0.45); border-left-color: var(--accent); }
.btn-featured button.opt-camera { background: rgba(200, 0, 200, 0.08); border-color: rgba(200, 0, 200, 0.35); }
.btn-featured .opt-label { font-weight: 700; }

/* Small section headings above each group */
.opt-heading {
  margin: 22px 0 2px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Fold-out panels: icon, title, hint, chevron on the right */
.learn-more { margin-top: 22px; display: grid; gap: 10px; }
.learn-more .opt-heading { margin-top: 0; }
.learn-more details.explain { margin: 0; }
details.explain > summary { padding: 13px 14px; gap: 12px; }
details.explain > summary::before { display: none; }
details.explain > summary::after {
  content: "\203A";
  margin-left: auto;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  transition: transform 0.15s ease;
}
details.explain[open] > summary::after { transform: rotate(90deg); }
details.explain[open] > summary { border-bottom: 1px solid var(--hairline); margin-bottom: 10px; }
.panel-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(10, 132, 255, 0.14);
  color: var(--system-blue);
}
.panel-ico svg { width: 20px; height: 20px; }
.panel-scan { background: rgba(175, 82, 222, 0.16); color: #af52de; }
.panel-why { background: rgba(255, 159, 10, 0.16); color: var(--system-orange); }
.panel-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.panel-title { font-weight: 700; font-size: 0.95rem; }
.panel-hint { font-weight: 500; font-size: 0.78rem; color: var(--muted); }
.explain-why .explain-body { padding-left: 16px; }

/* Footer: separated from the content, clear of the phone's Back / Start Over bar */
footer.app-footer {
  border-top: 1px solid var(--hairline);
  padding: 16px 12px 8px;
  margin-top: 24px;
}
@media (max-width: 700px) {
  body.on-step { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
}
