@font-face {
  font-family: "Lyon Display";
  src:
    url("assets/fonts/LyonDisplay-RegularItalic.woff2") format("woff2"),
    url("assets/fonts/LyonDisplay-RegularItalic.woff") format("woff");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  --ochre: #e64626;
  --accessible-ochre: #ce3d20;
  --sandstone: #fcede2;
  --heritage-rose: #daa8a2;
  --jacaranda: #8f9ec9;
  --navy: #1a355e;
  --navy-deep: #0d1b30;
  --eucalypt: #71a499;
  --charcoal: #424242;
  --light-grey: #f1f1f1;

  --ink: #1b1b1b;
  --muted: var(--charcoal);
  --line: #e5e0d8;
  --surface: #ffffff;
  --page: #faf6f1;
  --primary: var(--accessible-ochre);
  --primary-hover: var(--ochre);
  --primary-soft: var(--sandstone);
  --control-border: #c9c2b6;
  --control-focus: var(--navy);
  --analysis-accent: var(--navy);
  --stability-accent: var(--jacaranda);
  --risk-high: var(--ochre);
  --risk-moderate: var(--signal-high-soft);
  --risk-low: var(--jacaranda);
  --signal-high: var(--accessible-ochre);
  --signal-high-soft: var(--heritage-rose);
  --signal-low: var(--navy);
  --signal-low-soft: var(--jacaranda);
  --signal-neutral: var(--light-grey);
  --zscore-zero-line: color-mix(in srgb, var(--muted) 74%, transparent);
  --metric-strong: var(--risk-high);
  --metric-adequate: var(--risk-moderate);
  --metric-limited: var(--risk-low);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.08);

  --sidebar-bg: rgba(252, 237, 226, 0.82);
  --sidebar-bg-top: rgba(252, 237, 226, 0.94);
  --sidebar-text: var(--charcoal);
  --sidebar-muted: rgba(66, 66, 66, 0.68);
  --sidebar-border: rgba(206, 61, 32, 0.16);
  --sidebar-hover: rgba(206, 61, 32, 0.08);
  --sidebar-active: rgba(206, 61, 32, 0.14);
  --sidebar-width: 268px;
  --sidebar-collapsed-width: 80px;
  --calculator-first-row-box-height: 220px;
  --font-sans: "Apercu Pro", "Apercu", "Source Sans Pro", Arial, sans-serif;
  --font-display: "Lyon Display", "Times New Roman", serif;
  --font-mono: "Apercu Pro Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  --ink: #f4ecdf;
  --muted: #d6c8b5;
  --line: #3a3836;
  --surface: #242221;
  --page: #1b1b1b;
  --light-grey: #2e2d2b;
  --charcoal: #d6c8b5;
  --signal-neutral: #e5e0d8;
  --zscore-zero-line: color-mix(in srgb, var(--muted) 78%, transparent);
  --primary-soft: rgba(206, 61, 32, 0.16);
  --control-border: #5a5450;
  --control-focus: var(--ochre);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  --sidebar-bg: rgba(27, 27, 27, 0.94);
  --sidebar-bg-top: rgba(36, 34, 33, 0.98);
  --sidebar-text: #f4ecdf;
  --sidebar-muted: rgba(214, 200, 181, 0.78);
  --sidebar-border: rgba(206, 61, 32, 0.16);
  --sidebar-hover: rgba(230, 70, 38, 0.14);
  --sidebar-active: rgba(230, 70, 38, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font-sans);
  letter-spacing: 0;
}

html {
  scrollbar-color: var(--charcoal) transparent;
  scrollbar-width: thin;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  border: 2px solid var(--page);
  border-radius: 999px;
  background: var(--charcoal);
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--page) 72%, transparent),
      color-mix(in srgb, var(--sandstone) 46%, transparent)
    );
  backdrop-filter: blur(5px) saturate(1.08);
  opacity: 1;
  transition:
    opacity 260ms ease,
    visibility 260ms ease;
}

.app-loader[hidden] {
  display: none;
}

.app-loader-skip .app-loader {
  display: none;
}

.app-loader.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-loader-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  width: min(420px, calc(100vw - 48px));
  min-height: 132px;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid color-mix(in srgb, var(--accessible-ochre) 28%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--sandstone) 78%, transparent);
  box-shadow:
    0 22px 56px rgba(66, 42, 22, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.app-loader-ring {
  --loader-progress: 0%;
  position: relative;
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(
      var(--ochre) var(--loader-progress),
      color-mix(in srgb, var(--accessible-ochre) 13%, transparent) 0
    );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accessible-ochre) 20%, transparent),
    0 10px 24px rgba(206, 61, 32, 0.18);
}

.app-loader-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--sandstone) 88%, white);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.app-loader-ring::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid color-mix(in srgb, var(--ochre) 28%, transparent);
  border-radius: 50%;
  animation: app-loader-halo 1400ms ease-in-out infinite;
}

.app-loader-value {
  position: relative;
  z-index: 1;
  color: var(--accessible-ochre);
  font: 700 18px/1 var(--font-sans);
}

.app-loader-copy {
  min-width: 0;
}

.app-loader-label {
  margin: 0 0 8px;
  color: #2f251e;
  font: 700 13px/1.2 var(--font-sans);
  text-transform: uppercase;
}

.app-loader-step {
  margin: 0;
  color: color-mix(in srgb, #2f251e 82%, transparent);
  font: 600 15px/1.35 var(--font-sans);
}

.app-loader.is-complete .app-loader-ring::after {
  border-color: color-mix(in srgb, var(--eucalypt) 40%, transparent);
  animation: none;
}

.app-loader.is-error .app-loader-card {
  border-color: color-mix(in srgb, var(--accessible-ochre) 48%, transparent);
}

:root[data-theme="dark"] .app-loader {
  background:
    linear-gradient(
      180deg,
      rgba(27, 27, 27, 0.7),
      color-mix(in srgb, var(--sandstone) 16%, rgba(27, 27, 27, 0.78))
    );
}

:root[data-theme="dark"] .app-loader-card {
  background: color-mix(in srgb, var(--sandstone) 70%, rgba(27, 27, 27, 0.12));
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

@media (max-width: 520px) {
  .app-loader-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loader,
  .app-loader-ring::after {
    transition: none;
    animation: none;
  }
}

@keyframes app-loader-halo {
  0%,
  100% {
    opacity: 0.28;
    transform: scale(0.98);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.04);
  }
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.fullscreen-corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  display: grid;
  width: 96px;
  height: 96px;
  justify-items: end;
  align-items: start;
  padding: 10px;
  pointer-events: none;
}

.fullscreen-toggle {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  color: var(--charcoal);
  opacity: 0;
  pointer-events: auto;
  transform: translate(8px, -8px) scale(0.94);
  transition:
    opacity 150ms ease,
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.fullscreen-corner:hover .fullscreen-toggle,
.fullscreen-corner:focus-within .fullscreen-toggle {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.fullscreen-toggle:hover,
.fullscreen-toggle:focus-visible {
  border-color: var(--primary);
  background: var(--surface);
  color: var(--primary);
  outline: 0;
}

.fullscreen-toggle:focus-visible {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--control-focus) 30%, transparent),
    0 10px 24px rgba(0, 0, 0, 0.14);
}

:root.is-fullscreen .fullscreen-corner {
  display: none;
}

.return-position-button {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 39;
  display: inline-flex;
  width: auto;
  min-width: 0;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--charcoal);
  color: #ffffff;
  font: 700 12px/1 var(--font-ui);
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate(-8px, -4px) scale(0.94);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.return-position-button[hidden] {
  display: none;
}

.return-position-button.is-available {
  opacity: 0.78;
  pointer-events: auto;
  transform: translate(0, 0) scale(1);
}

.return-position-button.is-suggested,
.return-position-button:hover,
.return-position-button:focus-visible {
  background: var(--charcoal);
  opacity: 1;
  outline: 0;
}

:root[data-theme="dark"] .return-position-button,
:root[data-theme="dark"] .return-position-button.is-suggested,
:root[data-theme="dark"] .return-position-button:hover,
:root[data-theme="dark"] .return-position-button:focus-visible {
  color: #1a1a1a;
}

.return-position-button.is-suggested {
  animation: calculator-hint-glow 1400ms ease-in-out 2;
}

.return-position-button:focus-visible {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--control-focus) 30%, transparent),
    0 10px 24px rgba(0, 0, 0, 0.13);
}

@media (hover: none) {
  .fullscreen-toggle {
    opacity: 0.72;
    transform: translate(0, 0) scale(1);
  }
}

.vision-filter-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

:root[data-vision="protanopia"] .app-shell,
:root[data-cb="protanopia"] .app-shell {
  filter: url("#vision-protanopia");
}

:root[data-vision="deuteranopia"] .app-shell,
:root[data-cb="deuteranopia"] .app-shell {
  filter: url("#vision-deuteranopia");
}

:root[data-vision="tritanopia"] .app-shell,
:root[data-cb="tritanopia"] .app-shell {
  filter: url("#vision-tritanopia");
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  /* Fill the (fixed-height) embed window so the app bottom aligns with the
     report window boundary; dvh tracks the embedded viewport exactly. */
  min-height: 100vh;
  min-height: 100dvh;
  align-content: stretch;
  transition: grid-template-columns 200ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

/* ----- Embedded (in-report) auto-height mode -----
   In the report iframe the console reports its content height so the parent
   auto-sizes the window. The layout must therefore flow to content instead of
   filling the viewport, and out-of-flow chrome (the sidebar / bottom nav bar)
   must rejoin the flow. */
html.is-embedded,
html.is-embedded body {
  height: auto;
  min-height: 0;
  overflow: visible;
}
html.is-embedded .app-shell {
  min-height: 0;
  grid-template-rows: auto;
  align-content: start;
}
html.is-embedded .sidebar {
  position: static;
  height: auto;
  max-height: none;
  align-self: stretch;
}

.app-shell.sidebar-measuring,
.app-shell.sidebar-measuring *,
.app-shell.sidebar-responsive-sync,
.app-shell.sidebar-responsive-sync * {
  transition: none !important;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-width: 0;
  overflow: visible;
  padding: 20px 14px;
  color: var(--sidebar-text);
  background: linear-gradient(180deg, var(--sidebar-bg-top) 0%, var(--sidebar-bg) 100%);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 4px 0 28px rgba(0, 0, 0, 0.06);
  transition: padding 200ms ease;
}

.sidebar-collapsed .sidebar {
  padding: 16px 10px;
}

.brand-block {
  display: grid;
  grid-template-columns: 1fr 36px;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--ochre), var(--accessible-ochre));
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.brand-mark svg {
  display: block;
}

.brand-eyebrow {
  margin: 0 0 4px;
  color: var(--sidebar-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand-title {
  margin: 0;
  color: var(--sidebar-text);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}

.sidebar-toggle {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--sidebar-border);
  border-radius: 9px;
  background: transparent;
  color: var(--sidebar-text);
  transition: background 150ms ease, border-color 150ms ease;
}

.bottom-bar-toggle {
  display: none;
}

.bottom-bar-toggle-icon {
  display: block;
}

.dock-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  display: inline-block;
  width: max-content;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(20, 20, 20, 0.92);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 80;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.dock-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(20, 20, 20, 0.92);
  border-bottom: 0;
}

.theme-toggle-button[data-theme-choice="light"] .dock-tip,
.bottom-bar-toggle .dock-tip {
  left: 0;
  transform: translateY(4px);
}

.theme-toggle-button[data-theme-choice="light"] .dock-tip::after,
.bottom-bar-toggle .dock-tip::after {
  left: 14px;
  transform: none;
}

.theme-toggle-button[data-theme-choice="system"] .dock-tip {
  right: 0;
  left: auto;
  transform: translateY(4px);
}

.theme-toggle-button[data-theme-choice="system"] .dock-tip::after {
  right: 14px;
  left: auto;
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .sidebar-toggle:hover .dock-tip,
  .sidebar-toggle:focus-visible .dock-tip,
  .bottom-bar-toggle:hover .dock-tip,
  .bottom-bar-toggle:focus-visible .dock-tip,
  .backend-status:hover .dock-tip,
  .backend-status:focus-visible .dock-tip,
  .theme-toggle-button:hover .dock-tip,
  .theme-toggle-button:focus-visible .dock-tip,
  .vision-select-wrap:hover .dock-tip,
  .vision-select-wrap:focus-within .dock-tip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  .theme-toggle-button[data-theme-choice="light"]:hover .dock-tip,
  .theme-toggle-button[data-theme-choice="light"]:focus-visible .dock-tip,
  .theme-toggle-button[data-theme-choice="system"]:hover .dock-tip,
  .theme-toggle-button[data-theme-choice="system"]:focus-visible .dock-tip,
  .bottom-bar-toggle:hover .dock-tip,
  .bottom-bar-toggle:focus-visible .dock-tip {
    transform: translateY(0);
  }
}

.nav-settings .theme-toggle-button .dock-tip,
.nav-settings .vision-select-wrap .dock-tip {
  right: auto;
  left: var(--dock-tip-left, 50%);
  max-width: var(--dock-tip-max-width, calc(100vw - 28px));
  white-space: normal;
  transform: translateX(var(--dock-tip-translate-x, -50%)) translateY(4px);
}

.nav-settings .theme-toggle-button .dock-tip::after,
.nav-settings .vision-select-wrap .dock-tip::after {
  right: auto;
  left: var(--dock-tip-arrow-left, 50%);
  transform: translateX(-50%);
}

@media (hover: hover) and (pointer: fine) {
  .nav-settings .theme-toggle-button:hover .dock-tip,
  .nav-settings .theme-toggle-button:focus-visible .dock-tip,
  .nav-settings .vision-select-wrap:hover .dock-tip,
  .nav-settings .vision-select-wrap:focus-within .dock-tip {
    transform: translateX(var(--dock-tip-translate-x, -50%)) translateY(0);
  }
}

@media (hover: none) {
  .sidebar-toggle:focus-visible .dock-tip,
  .sidebar-toggle:active .dock-tip,
  .bottom-bar-toggle:focus-visible .dock-tip,
  .bottom-bar-toggle:active .dock-tip,
  .backend-status:focus-visible .dock-tip,
  .backend-status:active .dock-tip,
  .theme-toggle-button:focus-visible .dock-tip,
  .theme-toggle-button:active .dock-tip,
  .vision-select-wrap:focus-within .dock-tip {
    animation: dock-tooltip-flash 1800ms ease forwards;
  }

  .theme-toggle-button[data-theme-choice="light"]:focus-visible .dock-tip,
  .theme-toggle-button[data-theme-choice="light"]:active .dock-tip,
  .theme-toggle-button[data-theme-choice="system"]:focus-visible .dock-tip,
  .theme-toggle-button[data-theme-choice="system"]:active .dock-tip,
  .bottom-bar-toggle:focus-visible .dock-tip,
  .bottom-bar-toggle:active .dock-tip {
    animation: dock-tooltip-flash-right 1800ms ease forwards;
  }
}

:root[data-theme="dark"] .dock-tip {
  background: rgba(244, 236, 223, 0.95);
  color: #1a1a1a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
}

:root[data-theme="dark"] .dock-tip::after {
  border-top-color: rgba(244, 236, 223, 0.95);
}

@media (prefers-reduced-motion: reduce) {
  .dock-tip {
    transition: none;
    animation: none;
  }
}

@keyframes dock-tooltip-flash {
  0%   { opacity: 0; transform: translateX(-50%) translateY(4px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  72%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(2px); }
}

@keyframes dock-tooltip-flash-right {
  0%   { opacity: 0; transform: translateY(4px); }
  12%  { opacity: 1; transform: translateY(0); }
  72%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(2px); }
}

.sidebar-toggle:hover {
  background: var(--sidebar-hover);
  border-color: rgba(206, 61, 32, 0.34);
}

.sidebar-toggle-icon {
  display: block;
  transition: transform 200ms ease;
}

.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.sidebar-collapsed .brand-block {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 10px;
  padding-bottom: 16px;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-section-label {
  display: none;
}

.eyebrow,
.micro-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sidebar .eyebrow,
.sidebar .micro-label {
  color: var(--sidebar-muted);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.8rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0 0;
}

.nav-section-label {
  margin: 0 0 10px;
  padding: 0;
  color: var(--sidebar-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav > .nav-section-label {
  margin-left: 4px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-tools {
  display: grid;
  width: auto;
  gap: 7px;
  justify-self: stretch;
  margin: 18px 0 0;
  padding: 14px 4px 0;
  border-top: 1px solid var(--sidebar-border);
  justify-items: stretch;
}

.nav-tools-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 6px;
}

.nav-tools-row > .theme-toggle {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
}

.nav-tools-row > .vision-select,
.nav-tools-row > .vision-select-wrap {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.nav-tools-divider {
  flex: 0 0 1px;
  width: 1px;
  align-self: stretch;
  background: var(--sidebar-border, var(--line));
}

@media (min-width: 1101px) {
  .nav-tools-divider {
    margin-right: 6px;
  }
}

.nav-shortcuts {
  margin: 12px 0 0;
  padding: 12px 4px 0;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-collapsed .nav-shortcuts {
  display: none;
}

.nav-settings {
  position: relative;
  display: grid;
  min-width: 0;
}

/* At vertical/wide layout the gear is hidden — the Mode & Vision controls
   render inline in the sidebar as before. The popup card is only used at
   horizontal/compact widths (see the narrow media query below). */
.nav-settings-toggle {
  display: none;
}

.nav-settings-panel,
.nav-settings-card {
  display: contents;
}

.nav-settings-panel[hidden],
.nav-settings-panel[aria-hidden="true"] {
  display: none !important;
}

.nav-shortcuts-heading {
  display: block;
  position: relative;
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--sidebar-muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-shortcuts-heading::-webkit-details-marker {
  display: none;
}

.nav-shortcuts-heading::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.1em;
  width: 0;
  height: 0;
  border-left: 6px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 160ms ease;
}

.nav-shortcuts[open] > .nav-shortcuts-heading::before {
  transform: rotate(90deg);
}

.nav-shortcuts-heading:hover,
.nav-shortcuts-heading:focus-visible {
  color: var(--sidebar-text, var(--ink));
  outline: none;
}

.nav-shortcuts-heading:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--control-focus) 30%, transparent);
  border-radius: 3px;
}

.nav-shortcuts-list {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  color: var(--sidebar-text, var(--ink));
  font-size: 0.74rem;
  line-height: 1.3;
}

.shortcut-group,
.shortcut-row {
  min-width: 0;
}

.shortcut-row {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  justify-content: flex-start;
  column-gap: 7px;
}

.nav-shortcuts-list dt {
  margin: 0;
  color: var(--sidebar-muted);
  white-space: nowrap;
}

.nav-shortcuts-list dd {
  margin: 0;
  justify-self: start;
  text-align: left;
  white-space: nowrap;
}

.shortcut-row dd {
  justify-self: start;
  text-align: left;
}

.shortcut-platform-list {
  display: grid;
  gap: 4px;
  margin: 5px 0 0;
  padding-left: 16px;
}

.shortcut-platform-list li {
  display: grid;
  grid-template-columns: 28px max-content;
  align-items: center;
  column-gap: 6px;
  padding-left: 0;
  white-space: nowrap;
}

.shortcut-os {
  color: var(--sidebar-muted);
  font-weight: 700;
  text-align: left;
}

.shortcut-keys {
  white-space: nowrap;
}

.nav-shortcuts-list kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--sidebar-border, var(--line));
  border-radius: 4px;
  background: transparent;
  color: var(--sidebar-text, var(--ink));
  font: 600 0.7rem/1 var(--font-ui);
  text-align: center;
  vertical-align: baseline;
}

@media (max-width: 1100px) {
  .nav-shortcuts {
    display: none;
  }
}

.theme-toggle {
  --theme-toggle-button-size: 25px;
  display: inline-flex;
  align-items: center;
  width: max-content;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: transparent;
}

.theme-toggle-button {
  position: relative;
  display: inline-grid;
  flex: 0 0 var(--theme-toggle-button-size);
  place-items: center;
  width: var(--theme-toggle-button-size);
  height: var(--theme-toggle-button-size);
  min-width: var(--theme-toggle-button-size);
  min-height: var(--theme-toggle-button-size);
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.theme-toggle-button:hover,
.theme-toggle-button:focus-visible {
  background: transparent;
  color: var(--ink);
  outline: 0;
}

.theme-toggle-button:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--control-focus) 32%, transparent);
}

.theme-toggle-button.active,
.theme-toggle-button[aria-pressed="true"] {
  border-color: var(--accessible-ochre);
  background: rgba(206, 61, 32, 0.14);
  color: var(--accessible-ochre);
  box-shadow: none;
}

.nav-tools-label {
  width: 100%;
  margin: 4px 0 -1px;
  color: var(--sidebar-muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.vision-select {
  width: 100%;
  max-width: none;
  min-height: 30px;
  border: 1.5px solid var(--control-border);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.vision-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.vision-select:hover,
.vision-select:focus-visible {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
  outline: 0;
}

.vision-select:focus-visible {
  border-color: var(--control-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--control-focus) 32%, transparent);
}

.vision-select {
  padding: 0 20px 0 8px;
  font-size: 0.74rem;
  font-weight: 500;
}

:root[data-theme="dark"] .sidebar-toggle,
:root[data-theme="dark"] .nav-icon,
:root[data-theme="dark"] .backend-status {
  background: var(--surface);
}

:root[data-theme="dark"] .theme-toggle-button.active,
:root[data-theme="dark"] .theme-toggle-button[aria-pressed="true"] {
  border-color: var(--accessible-ochre);
  background: rgba(206, 61, 32, 0.18);
  color: var(--accessible-ochre);
}

:root[data-theme="dark"] .model-output-stat {
  --output-ring-fill: var(--surface);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .csv-dropzone,
:root[data-theme="dark"] .csv-model-card,
:root[data-theme="dark"] .model-output-tile,
:root[data-theme="dark"] .classification-card,
:root[data-theme="dark"] .method-workflow,
:root[data-theme="dark"] .metric-table-card,
:root[data-theme="dark"] .team-panel,
:root[data-theme="dark"] .ack-panel,
:root[data-theme="dark"] .references-panel,
:root[data-theme="dark"] .clinical-action-line,
:root[data-theme="dark"] .note-line,
:root[data-theme="dark"] .file-box-inline,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select {
  background-color: var(--surface);
  color: var(--ink);
}

:root[data-theme="dark"] .csv-dropzone,
:root[data-theme="dark"] .model-output-tile,
:root[data-theme="dark"] .csv-model-card,
:root[data-theme="dark"] .clinical-action-line,
:root[data-theme="dark"] .note-line,
:root[data-theme="dark"] .metric-table-card {
  border-color: var(--line);
}

:root[data-theme="dark"] .model-output-tile.active {
  border-color: var(--accessible-ochre);
  background: color-mix(in srgb, var(--accessible-ochre) 16%, var(--surface));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accessible-ochre) 48%, transparent),
    0 10px 18px rgba(0, 0, 0, 0.16);
}

:root[data-theme="dark"] .model-output-tile.active:hover,
:root[data-theme="dark"] .model-output-tile.active:focus-visible {
  border-color: var(--ochre);
  background: color-mix(in srgb, var(--accessible-ochre) 22%, var(--surface));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--ochre) 56%, transparent),
    0 12px 22px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .csv-model-card.active,
:root[data-theme="dark"] .clinical-action-line.active {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 28%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 40%, transparent);
}

:root[data-theme="dark"] .csv-model-card:not(.active):hover,
:root[data-theme="dark"] .csv-model-card:not(.active):focus-visible {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 30%, transparent);
}

:root[data-theme="dark"] .csv-model-card.active:hover,
:root[data-theme="dark"] .csv-model-card.active:focus-visible,
:root[data-theme="dark"] .clinical-action-line.active:hover,
:root[data-theme="dark"] .clinical-action-line.active:focus-visible {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 34%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 48%, transparent);
}

:root[data-theme="dark"] .classification-cutoff-badge,
:root[data-theme="dark"] .classification-score-marker i {
  border-color: var(--line);
  background: var(--page);
  color: var(--ink);
}

:root[data-theme="dark"] .csv-dropzone-file {
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--muted);
}

:root[data-theme="dark"] .csv-dropzone-file.is-loaded {
  border-color: var(--accessible-ochre);
  background: var(--primary-soft);
  color: var(--accessible-ochre);
}

:root[data-theme="dark"] .gene-item.is-highlighted {
  background: color-mix(in srgb, var(--accessible-ochre) 14%, var(--surface));
  box-shadow: none;
}

:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .subnav-button,
:root[data-theme="dark"] .step-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

:root[data-theme="dark"] .secondary-button:hover,
:root[data-theme="dark"] .icon-button:hover,
:root[data-theme="dark"] .subnav-button:hover,
:root[data-theme="dark"] .step-button:hover {
  border-color: var(--accessible-ochre);
  background: color-mix(in srgb, var(--accessible-ochre) 12%, var(--surface));
  color: var(--ink);
}

:root[data-theme="dark"] .segmented {
  border-color: var(--line);
  background: var(--page);
}

:root[data-theme="dark"] .segment {
  background: transparent;
  color: var(--muted);
}

:root[data-theme="dark"] .segment:hover {
  background: var(--surface);
  color: var(--ink);
}

:root[data-theme="dark"] .subnav-button.active,
:root[data-theme="dark"] .step-button.active,
:root[data-theme="dark"] .segment.active {
  border-color: var(--accessible-ochre);
  background: var(--primary-soft);
  color: var(--accessible-ochre);
}

:root[data-theme="dark"] .nav-icon {
  border-color: var(--sidebar-border);
  background: var(--surface);
  color: var(--sidebar-text);
}

:root[data-theme="dark"] .nav-item:hover .nav-icon,
:root[data-theme="dark"] .nav-item:focus-visible .nav-icon,
:root[data-theme="dark"] .nav-item.active .nav-icon,
:root[data-theme="dark"] .nav-item.active:hover .nav-icon,
:root[data-theme="dark"] .nav-item.active:focus-visible .nav-icon {
  color: var(--accessible-ochre);
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 8px 6px 8px 0;
  border: 0;
  border-radius: 10px;
  color: var(--sidebar-text);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.nav-settings-toggle.nav-item {
  display: none;
}

.sidebar-collapsed .nav-item {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 10px 8px;
}

.sidebar-collapsed .nav-tools {
  display: none;
}

.nav-item:hover,
.nav-item:focus-visible {
  color: var(--accessible-ochre);
  background: transparent;
  box-shadow: none;
  outline: 0;
}

.nav-item.active {
  color: var(--accessible-ochre);
  background: transparent;
  box-shadow: none;
}

.nav-item.active:hover,
.nav-item.active:focus-visible {
  background: transparent;
  box-shadow: none;
}

.nav-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--sidebar-border);
  border-radius: 9px;
  background: transparent;
  color: var(--sidebar-text);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.nav-item:hover .nav-icon,
.nav-item:focus-visible .nav-icon {
  border-color: rgba(206, 61, 32, 0.42);
  background: rgba(206, 61, 32, 0.1);
  color: var(--accessible-ochre);
  box-shadow: none;
  transform: translateY(-1px);
}

.nav-item.active .nav-icon {
  border-color: rgba(206, 61, 32, 0.72);
  background: rgba(206, 61, 32, 0.14);
  color: var(--accessible-ochre);
}

.nav-item.active:hover .nav-icon,
.nav-item.active:focus-visible .nav-icon {
  box-shadow: none;
}

.nav-icon svg {
  display: block;
}

@media (min-width: 921px) {
  .sidebar-collapsed .nav-settings {
    display: grid;
    justify-items: center;
    margin: 4px 0 0;
    overflow: visible;
  }

  .sidebar-collapsed .nav-settings-toggle.nav-item {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 10px 8px;
  }

  .sidebar-collapsed .nav-item {
    overflow: visible;
  }

  .sidebar-collapsed .nav-item .nav-label {
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    display: inline-block;
    width: max-content;
    max-width: calc(100vw - var(--sidebar-collapsed-width) - 32px);
    margin: 0;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(20, 20, 20, 0.92);
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translate(-4px, -50%);
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 80;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  }

  .sidebar-collapsed .nav-item .nav-label::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    width: 0;
    height: 0;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(20, 20, 20, 0.92);
    border-left: 0;
  }

  .sidebar-collapsed .nav-item:hover .nav-label,
  .sidebar-collapsed .nav-item:focus-visible .nav-label {
    opacity: 1;
    transform: translate(0, -50%);
  }

  .sidebar-collapsed .nav-item .nav-label,
  .sidebar-collapsed .nav-item .nav-label::before,
  .sidebar-collapsed .sidebar-toggle .dock-tip,
  .sidebar-collapsed .backend-status .dock-tip {
    display: none;
  }

  .sidebar-collapsed .sidebar-toggle .dock-tip,
  .sidebar-collapsed .backend-status .dock-tip {
    top: 50%;
    right: auto;
    bottom: auto;
    left: calc(100% + 10px);
    max-width: calc(100vw - var(--sidebar-collapsed-width) - 28px);
    text-align: left;
    transform: translateX(-4px) translateY(-50%);
  }

  .sidebar-collapsed .backend-status .dock-tip {
    display: inline-block;
  }

  .sidebar-collapsed .sidebar-toggle .dock-tip::after {
    top: 50%;
    right: 100%;
    left: auto;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(20, 20, 20, 0.92);
    border-left: 0;
  }

  .sidebar-collapsed .backend-status .dock-tip::after {
    top: 50%;
    right: 100%;
    left: auto;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(20, 20, 20, 0.92);
    border-left: 0;
  }

  .sidebar-collapsed .nav-settings-panel {
    position: fixed;
    top: var(--settings-panel-top, 96px);
    left: var(--settings-panel-left, calc(var(--sidebar-collapsed-width) + 12px));
    display: block;
    width: var(--settings-panel-width, min(318px, calc(100vw - 28px)));
    max-width: calc(100vw - 28px);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-4px);
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 95;
  }

  .sidebar-collapsed .nav-settings.is-open .nav-settings-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .sidebar-collapsed .nav-settings-card {
    position: relative;
    display: grid;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    color: var(--ink);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.18);
  }

  .sidebar-collapsed .nav-settings-card::before {
    content: "";
    position: absolute;
    top: var(--settings-arrow-y, 26px);
    right: 100%;
    width: 0;
    height: 0;
    transform: translateY(-50%);
    border: 7px solid transparent;
    border-right-color: color-mix(in srgb, var(--surface) 96%, transparent);
    border-left: 0;
  }

  .sidebar-collapsed .nav-settings-panel .nav-tools {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0 0 12px;
    border-top: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-collapsed .nav-settings-panel .nav-tools-label {
    display: block;
    margin: 0;
  }

  .sidebar-collapsed .nav-settings-panel .nav-shortcuts {
    display: block;
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  .sidebar-collapsed .backend-status {
    overflow: visible;
  }

  .sidebar-collapsed .sidebar-toggle:hover .dock-tip,
  .sidebar-collapsed .sidebar-toggle:focus-visible .dock-tip,
  .sidebar-collapsed .backend-status:hover .dock-tip,
  .sidebar-collapsed .backend-status:focus-visible .dock-tip {
    opacity: 1;
    transform: translateX(0) translateY(-50%);
  }

  :root[data-theme="dark"] .sidebar-collapsed .nav-item .nav-label,
  :root[data-theme="dark"] .sidebar-collapsed .backend-status .dock-tip {
    background: rgba(244, 236, 223, 0.95);
    color: #1a1a1a;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
  }

  :root[data-theme="dark"] .sidebar-collapsed .nav-item .nav-label::before {
    border-right-color: rgba(244, 236, 223, 0.95);
  }

  :root[data-theme="dark"] .sidebar-collapsed .sidebar-toggle .dock-tip::after {
    border-right-color: rgba(244, 236, 223, 0.95);
  }

  :root[data-theme="dark"] .sidebar-collapsed .backend-status .dock-tip::after {
    border-right-color: rgba(244, 236, 223, 0.95);
  }

  :root[data-theme="dark"] .sidebar-collapsed .nav-settings-card::before {
    border-right-color: color-mix(in srgb, var(--surface) 96%, transparent);
  }

  @media (prefers-reduced-motion: reduce) {
    .sidebar-collapsed .nav-item .nav-label,
    .sidebar-collapsed .nav-settings-panel,
    .sidebar-collapsed .backend-status .dock-tip {
      transition: none;
    }
  }
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 10px 6px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-collapsed .sidebar-footer {
  display: grid;
  justify-items: center;
  padding: 14px 0 4px;
}

.backend-status {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--sidebar-text);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
}

.backend-status-label {
  min-width: 0;
}

.backend-status::before {
  content: "";
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--jacaranda);
}

.backend-status[data-state="online"]::before {
  background: var(--jacaranda);
  box-shadow: 0 0 0 3px rgba(143, 158, 201, 0.25);
}

.backend-status[data-state="offline"]::before {
  background: var(--accessible-ochre);
  box-shadow: 0 0 0 3px rgba(206, 61, 32, 0.2);
}

.backend-status[data-state="unknown"]::before {
  background: var(--accessible-ochre);
  box-shadow: 0 0 0 3px rgba(206, 61, 32, 0.2);
}

.sidebar-collapsed .backend-status {
  position: relative;
  display: block;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  color: transparent;
  font-size: 0;
  line-height: 0;
}

.sidebar-collapsed .backend-status::before {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  margin: 0;
}

.sidebar-disclaimer {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.sidebar-collapsed .sidebar-disclaimer {
  display: none;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar:empty {
  display: none;
}

.page-subtitle {
  margin: 4px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.pipeline-flow {
  display: grid;
  gap: 0;
}

.pipeline-step {
  display: block;
  min-width: 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.pipeline-step:first-child {
  padding-top: 0;
  border-top: 0;
}

.pipeline-step:last-child {
  padding-bottom: 0;
}

.pipeline-step h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.25;
}

.pipeline-step p,
.pipeline-list,
.pipeline-data-list {
  margin: 8px 0 0 18px;
  color: var(--charcoal);
  font-size: 0.9rem;
  line-height: 1.45;
}

.pipeline-list,
.pipeline-data-list {
  display: grid;
  gap: 6px;
  padding-left: 18px;
}

.pipeline-data-list li {
  display: list-item;
  padding-left: 2px;
}

.pipeline-data-list span,
.pipeline-list li {
  color: var(--charcoal);
  font-weight: 500;
}

.pipeline-data-list span {
  display: inline;
}

.pipeline-data-list em {
  display: inline;
  margin-top: 0;
  color: var(--muted);
  font-style: normal;
  overflow-wrap: anywhere;
}

.pipeline-data-list em::before {
  content: none;
}

.pipeline-compact {
  color: var(--muted);
}

.classification-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.classification-panel-inline {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.classification-inline-heading {
  margin-bottom: 14px;
}

.classification-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.classification-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.classification-card-top span {
  min-width: 0;
  color: var(--charcoal);
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.25;
}

.classification-card-top strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.classification-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
}

.classification-status span {
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 850;
  line-height: 1.25;
}

.classification-track {
  position: relative;
  height: 22px;
  margin: 34px 0 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      rgba(143, 158, 201, 0.72) 0%,
      rgba(143, 158, 201, 0.72) var(--low-cutoff),
      rgba(218, 168, 162, 0.78) var(--low-cutoff),
      rgba(218, 168, 162, 0.78) var(--high-cutoff),
      rgba(230, 70, 38, 0.92) var(--high-cutoff),
      rgba(230, 70, 38, 0.92) 100%
    );
  overflow: visible;
}

.classification-band-label {
  position: absolute;
  top: 50%;
  z-index: 1;
  color: rgba(35, 42, 58, 0.72);
  font-size: 0.56rem;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
}

.classification-band-low {
  left: 12.5%;
}

.classification-band-mid {
  left: 50%;
}

.classification-band-high {
  left: 87.5%;
  color: rgba(255, 255, 255, 0.94);
}

.classification-cutoff-marker {
  position: absolute;
  top: -13px;
  bottom: -13px;
  left: var(--cutoff);
  width: 0;
  z-index: 1;
}

.classification-cutoff-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-left: 2px solid rgba(0, 0, 0, 0.34);
  transform: translateX(-1px);
}

.classification-cutoff-badge {
  position: absolute;
  left: 0;
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--charcoal);
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.classification-cutoff-low .classification-cutoff-badge,
.classification-cutoff-high .classification-cutoff-badge {
  top: calc(100% + 4px);
}

.classification-cutoff-marker.is-right-edge .classification-cutoff-badge {
  transform: translateX(-100%);
}

.classification-cutoff-marker.is-left-edge .classification-cutoff-badge {
  transform: translateX(0);
}

.classification-score-marker {
  position: absolute;
  top: 50%;
  left: var(--score);
  width: 15px;
  height: 15px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.classification-score-marker::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: currentColor;
  opacity: 0.68;
}

.classification-score-marker i {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.classification-score-marker.is-right-edge i {
  transform: translateX(-100%);
}

.classification-score-marker.is-left-edge i {
  transform: translateX(0);
}

#methods > .panel + .panel,
#methods > .panel + .biomarker-grid,
#methods > .biomarker-grid + .panel {
  margin-top: 18px;
}

#methods > .biomarker-grid:first-child {
  margin-top: 0;
}

.credits-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 0;
}

#references > .panel + .panel,
#references > .panel + .credits-grid,
#references > .credits-grid + .panel {
  margin-top: 18px;
}

.team-list {
  display: grid;
  gap: 0;
  margin-top: 8px;
}

.acknowledgment-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.member-row {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--charcoal);
  font-size: 0.95rem;
  line-height: 1.35;
}

.member-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.member-name {
  font-family: var(--font-sans);
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.04;
  white-space: nowrap;
}

.member-name::after {
  content: none;
}

.member-role {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.32;
}

.member-email,
.member-address,
.acknowledgment-list p {
  margin: 0;
  color: var(--charcoal);
  font-size: 0.9rem;
  line-height: 1.45;
}

.member-email,
.member-address {
  line-height: 1.32;
}

.member-email {
  display: inline-flex;
  width: fit-content;
  color: var(--heritage-rose);
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.member-email:hover {
  color: color-mix(in srgb, var(--heritage-rose) 78%, var(--ink));
  text-decoration-thickness: 2px;
}

.member-email-pending {
  color: var(--muted);
  font-weight: 400;
  text-decoration: none;
}

.member-email-pending:hover {
  color: var(--muted);
  text-decoration: none;
}

.member-address {
  color: var(--muted);
}

.reference-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0 4px;
}

.reference-group {
  margin-top: 18px;
}

.reference-group + .reference-group {
  margin-top: 22px;
}

.reference-group-heading {
  color: var(--charcoal);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
  padding: 0 0 4px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: relative;
  list-style: none;
  user-select: none;
}

.reference-group-heading::-webkit-details-marker {
  display: none;
}

.reference-group-heading::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.3em;
  width: 0;
  height: 0;
  border-left: 6px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 160ms ease;
}

.reference-group[open] > .reference-group-heading::before {
  transform: rotate(90deg);
}

.reference-group-heading:hover {
  color: var(--ochre, var(--charcoal));
}

.reference-group-heading:focus-visible {
  outline: 2px solid var(--ochre, currentColor);
  outline-offset: 2px;
  border-radius: 3px;
}

.reference-group-body {
  display: grid;
  gap: 10px;
  margin: 12px 0 4px;
  color: var(--charcoal);
  font-size: 0.9rem;
  line-height: 1.55;
}

.reference-group-body p {
  margin: 0;
}

.reference-list {
  display: grid;
  gap: 12px;
  list-style: none;
  margin: 10px 0 0;
  padding-left: 0;
}

.reference-list li {
  padding-left: 1.6rem;
  text-indent: -1.6rem;
  color: var(--charcoal);
  font-size: 0.9rem;
  line-height: 1.6;
  scroll-margin-top: 28px;
  transition:
    background 180ms ease,
    box-shadow 180ms ease;
}

.reference-list li.reference-focus {
  border-radius: 7px;
  background: rgba(206, 61, 32, 0.1);
  box-shadow: 0 0 0 5px rgba(206, 61, 32, 0.1);
}

.reference-list a {
  color: var(--ochre);
  font-weight: 400;
  overflow-wrap: anywhere;
}

.reference-list a:hover {
  color: var(--accessible-ochre);
  text-decoration-thickness: 2px;
}

.citation-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.citation-link:hover {
  color: var(--primary-hover);
  text-decoration-thickness: 2px;
}

.section-link {
  color: var(--ochre);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.section-link:hover {
  color: var(--accessible-ochre);
  text-decoration-thickness: 2px;
}

.status-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--stability-accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.lower-grid,
.summary-grid,
.biomarker-grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.summary-integrated {
  margin-top: 18px;
}

.lower-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.lower-grid.lower-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lower-grid.lower-grid-one,
.summary-grid.summary-grid-one {
  grid-template-columns: 1fr;
}

.summary-grid,
.biomarker-grid {
  align-items: stretch;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.biomarker-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  align-items: stretch;
  overflow-x: visible;
  padding-bottom: 0;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calculator-grid > .panel {
  height: var(--calculator-panel-height, auto);
  min-height: 0;
  overflow: hidden;
}

.calculator-section {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.calculator-section .calculator-card-header {
  align-items: center;
  margin-bottom: 10px;
}

.calculator-section .calculator-card-header h3 {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.35;
}

.calculator-section .summary-note {
  margin-top: 0;
}

.handoff-section {
  margin-bottom: 22px;
}

.calculator-header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.wide-panel {
  margin-top: 0;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.compact-heading {
  margin-bottom: 22px;
}

.panel-heading > div {
  min-width: 0;
}

.panel-heading h3,
.panel > h3:first-child {
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
}

.panel-heading h3 {
  margin: 4px 0 8px;
}

.panel > h3:first-child {
  margin: 4px 0 22px;
}

.panel-heading .subnav {
  justify-content: flex-end;
  margin-bottom: 0;
}

.biomarker-grid > .panel > .panel-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  column-gap: 12px;
}

.biomarker-grid > .panel > .panel-heading > div {
  display: flex;
  align-items: center;
  min-height: 30px;
}

.biomarker-grid > .panel > .panel-heading h3 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.biomarker-grid > .panel > .panel-heading .gene-filter-select {
  justify-self: end;
  align-self: center;
  max-width: min(160px, 42vw);
}

select,
.primary-button,
.secondary-button,
.icon-button,
.subnav-button,
.step-button,
.segment {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

select {
  max-width: 220px;
  padding: 0 34px 0 12px;
}

.primary-button,
.secondary-button,
.icon-button,
.subnav-button,
.step-button {
  padding: 0 12px;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  color: var(--charcoal);
}

.secondary-button:hover {
  border-color: var(--charcoal);
  background: var(--light-grey);
}

.icon-button {
  display: grid;
  width: 34px;
  padding: 0;
  place-items: center;
  color: var(--charcoal);
}

.icon-button:hover {
  border-color: var(--charcoal);
  background: var(--light-grey);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--light-grey);
}

.segment {
  border-color: transparent;
  background: transparent;
}

.segment.active {
  color: #ffffff;
  background: var(--primary);
}

.segment.disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.action-row button {
  flex: 1;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.compact-subnav {
  margin-bottom: 0;
}

.subnav-button,
.step-button {
  background: #ffffff;
  color: var(--charcoal);
  font-size: 0.86rem;
}

.subnav-button:hover,
.step-button:hover {
  border-color: var(--charcoal);
}

.subnav-button.active,
.step-button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

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

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.field span {
  color: var(--charcoal);
  font-weight: 700;
}

.field output {
  min-width: 36px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  text-align: center;
  font-weight: 800;
}

.field input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--primary);
}

.field-number {
  min-height: auto;
  grid-template-columns: 1fr;
  align-items: start;
}

.field-number input[type="number"] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}

.field-compact {
  min-height: auto;
  padding: 8px;
}

.field-compact span {
  font-size: 0.78rem;
  font-weight: 600;
  word-break: break-word;
}

.field-grid-dense {
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 2px 8px;
}

.model-input-panels {
  margin-top: 14px;
}

.model-input-panel {
  display: none;
  padding: 12px 0 0;
}

.model-input-panel.active {
  display: block;
}

.model-input-panel[hidden] {
  display: none !important;
}

.select-field-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.select-field-panel select {
  width: 100%;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.panel-actions select {
  min-width: 160px;
}

.model-section-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.file-box-inline {
  display: block;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

/* CSV upload panel */
.csv-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  min-height: 0;
}

.result-panel {
  container-name: result-panel;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.csv-panel-header,
.calculator-card-header {
  margin-bottom: 22px;
}

.csv-panel-header h3,
.calculator-card-header h3 {
  margin: 4px 0 8px;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
}

.calculator-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.result-panel .calculator-card-header,
.result-panel .calculator-section .calculator-card-header {
  align-items: center;
}

.csv-panel > .calculator-card-header,
.result-panel > .calculator-card-header {
  min-height: 34px;
}

.result-panel .calculator-card-header h3,
.result-panel .calculator-section .calculator-card-header h3 {
  min-width: 0;
  margin: 0;
}

.result-panel .handoff-view-select {
  flex: 0 0 auto;
  margin-left: auto;
}

.csv-panel > .calculator-card-header {
  align-items: center;
  justify-content: flex-start;
}

.csv-panel > .calculator-card-header h3 {
  margin: 0;
  text-align: left;
  margin-right: auto;
}

.csv-upload-intro {
  margin: 0;
  max-width: 42ch;
  color: var(--charcoal);
  font-size: 0.92rem;
  line-height: 1.55;
}

.csv-dropzone {
  display: flex;
  margin: 0;
  height: var(--calculator-first-row-box-height);
  min-height: var(--calculator-first-row-box-height);
  padding: 28px 20px;
  border: 2px dashed #c8c8c8;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.csv-dropzone:hover,
.csv-dropzone.is-dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accessible-ochre) 8%, #ffffff);
  box-shadow: 0 0 0 4px rgba(206, 61, 32, 0.1);
}

:root[data-theme="dark"] .csv-dropzone:not(.is-loaded):hover,
:root[data-theme="dark"] .csv-dropzone:not(.is-loaded).is-dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accessible-ochre) 10%, var(--surface));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accessible-ochre) 20%, transparent);
}

.csv-dropzone:focus-within {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accessible-ochre) 8%, #ffffff);
  box-shadow: 0 0 0 4px rgba(206, 61, 32, 0.14);
}

:root[data-theme="dark"] .csv-dropzone:not(.is-loaded):focus-within {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accessible-ochre) 10%, var(--surface));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accessible-ochre) 22%, transparent);
}

.csv-dropzone.is-loaded {
  border-color: var(--ochre);
  border-style: solid;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(230, 70, 38, 0.1);
  animation: none;
}

@keyframes csv-dropzone-prompt {
  0%, 100% {
    border-color: #c8c8c8;
    box-shadow: 0 0 0 0 rgba(206, 61, 32, 0);
  }
  50% {
    border-color: var(--ochre);
    box-shadow: 0 0 0 8px rgba(206, 61, 32, 0.18);
  }
}

.csv-dropzone:not(.is-loaded) {
  animation: csv-dropzone-prompt 2.2s ease-in-out infinite;
}

.csv-dropzone:not(.is-loaded):hover,
.csv-dropzone:not(.is-loaded):focus-within,
.csv-dropzone:not(.is-loaded).is-dragover {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .csv-dropzone:not(.is-loaded) {
    animation: none;
    border-color: var(--ochre);
    box-shadow: 0 0 0 4px rgba(206, 61, 32, 0.12);
  }
}

.csv-dropzone-inner,
.csv-dropzone {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.csv-dropzone-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 999px;
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] .csv-dropzone-icon {
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--accessible-ochre);
  box-shadow: none;
}

.csv-dropzone-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
}

.csv-dropzone-file {
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--navy);
  font-size: 0.86rem;
  font-weight: 700;
  word-break: break-all;
}

.csv-dropzone-file.is-loaded {
  background: var(--primary-soft);
  color: var(--primary);
}

.csv-dropzone-hint {
  color: var(--charcoal);
  font-size: 0.82rem;
}

.csv-dropzone-hint kbd {
  display: inline-block;
  margin: 0 2px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
}

.csv-panel-divider {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.csv-extraction-summary {
  margin-top: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.csv-extraction-summary.csv-extraction-idle {
  background: transparent;
}

.csv-idle-text {
  margin: 0;
  color: var(--charcoal);
  font-size: 0.9rem;
}

.csv-extraction-summary.csv-extraction-idle .csv-idle-text {
  color: var(--accessible-ochre);
  font-weight: 700;
}

.csv-section-head {
  margin-bottom: 12px;
}

.csv-model-cards {
  display: grid;
  gap: 8px;
}

.csv-model-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: var(--stage-card-row-height, 64px);
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--navy) 58%, transparent);
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.csv-model-card.is-complete {
  border-color: color-mix(in srgb, var(--navy) 70%, transparent);
  background: #ffffff;
}

.csv-model-card.is-partial {
  border-color: color-mix(in srgb, var(--navy) 58%, transparent);
  background: #ffffff;
}

.csv-model-card.is-waiting {
  border-color: var(--line);
  border-style: dashed;
  background: var(--surface);
}

.csv-model-card:hover,
.csv-model-card:focus-visible {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 30%, transparent);
  outline: 0;
}

.csv-extraction-summary.csv-extraction-idle .csv-model-card:hover,
.csv-extraction-summary.csv-extraction-idle .csv-model-card:focus-visible,
.csv-model-card.is-waiting:hover,
.csv-model-card.is-waiting:focus-visible {
  border-color: var(--navy);
  background: var(--surface);
  box-shadow: none;
}

:root[data-theme="dark"] .csv-extraction-summary.csv-extraction-idle .csv-model-card:hover,
:root[data-theme="dark"] .csv-extraction-summary.csv-extraction-idle .csv-model-card:focus-visible,
:root[data-theme="dark"] .csv-model-card.is-waiting:hover,
:root[data-theme="dark"] .csv-model-card.is-waiting:focus-visible {
  border-color: var(--navy);
  background: var(--surface);
  box-shadow: none;
}

.csv-model-card.active {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 40%, transparent);
  outline: 0;
}

.csv-model-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.csv-model-card-label {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--ink);
}

.csv-model-card-fraction {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--charcoal);
}

.csv-model-card-bar {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--light-grey);
}

.csv-model-card-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--jacaranda);
  transition: width 320ms ease;
}

.csv-model-card.is-partial .csv-model-card-bar span {
  background: var(--ochre);
}

.csv-model-card.is-waiting .csv-model-card-fraction {
  color: var(--muted);
}

.csv-model-card.is-waiting .csv-model-card-bar span {
  width: 0;
}

.csv-model-card-note {
  display: block;
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--primary);
}

.csv-unknown {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--charcoal);
  font-size: 0.82rem;
  line-height: 1.45;
}

.csv-model-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.risk-tier-footnote {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.csv-result-tile {
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  text-align: center;
}

.csv-result-tile.is-diagnosis {
  border-top: 3px solid var(--navy);
}

.csv-result-tile.is-progression {
  border-top: 3px solid var(--primary);
}

.csv-result-tile.is-response {
  border-top: 3px solid var(--jacaranda);
}

.csv-result-tile-label {
  display: block;
  margin-bottom: 6px;
  color: var(--charcoal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.csv-result-tile-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}

.csv-result-tile-meta {
  display: block;
  margin-top: 4px;
  color: var(--charcoal);
  font-size: 0.75rem;
}

.csv-result-tile-tier,
.model-output-tier {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  font-style: normal;
  white-space: nowrap;
}

.risk-tier-low {
  color: var(--risk-low);
}

.risk-tier-intermediate {
  color: var(--risk-moderate);
}

.risk-tier-high {
  color: var(--risk-high);
}

.risk-tier-unknown {
  color: var(--muted);
  font-weight: 600;
}

.clinical-action-list {
  display: grid;
  gap: 8px;
}

.clinical-review-actions {
  margin-top: 0;
  padding-top: 2px;
}

.clinical-action-line {
  appearance: none;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--stage-card-row-height, 64px);
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--navy) 58%, transparent);
  border-radius: 8px;
  background: #ffffff;
  color: var(--charcoal);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.clinical-action-line:hover,
.clinical-action-line:focus-visible {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 30%, transparent);
  outline: 0;
}

.clinical-action-line.active {
  border-color: var(--navy);
  background: color-mix(in srgb, var(--jacaranda) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--navy) 40%, transparent);
}

.clinical-action-line.is-empty {
  border-color: var(--line);
  border-style: dashed;
  background: #ffffff;
  box-shadow: none;
}

.clinical-action-line.is-empty:hover,
.clinical-action-line.is-empty:focus-visible {
  border-color: var(--navy);
  background: var(--surface);
  box-shadow: none;
}

.clinical-action-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.clinical-action-label {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 400;
}

.clinical-action-meta {
  color: var(--charcoal);
  font-size: 0.82rem;
  font-weight: 400;
  white-space: nowrap;
}

.clinical-action-text {
  display: block;
  color: var(--charcoal);
  font-size: 0.88rem;
  line-height: 1.45;
}

.clinical-action-bar {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--light-grey);
}

.clinical-action-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--jacaranda);
}

.clinical-action-disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.45;
}

.clinical-action-disclaimer a {
  color: var(--accessible-ochre);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.clinical-action-disclaimer a:hover {
  color: var(--ochre);
}

.right-panel-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.right-panel-warning {
  grid-column: 1;
  min-width: 0;
}

.right-panel-warning:empty,
.right-panel-warning[hidden] {
  display: none;
}

.right-panel-footer #copy-summary {
  grid-column: 2;
  align-self: start;
  justify-self: end;
}

.run-models-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.input-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.awaiting-run,
.run-summary {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.run-summary p {
  margin: 0 0 8px;
}

.input-section-label {
  margin-bottom: 6px;
}

.select-field {
  grid-column: 1 / -1;
}

.select-field select {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
}

.upload-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
  margin-top: 16px;
}

.file-box {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px dashed var(--charcoal);
  border-radius: 8px;
  background: #ffffff;
}

.file-box input {
  display: none;
}

#upload-name:not(.is-loaded) {
  color: var(--muted);
  font-weight: 600;
}

.model-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--analysis-accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.risk-visual {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 26px;
  align-items: center;
}

.risk-ring {
  --risk: 48%;
  display: grid;
  width: 230px;
  height: 230px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 58%, transparent 59%),
    conic-gradient(var(--primary) var(--risk), var(--light-grey) 0);
}

.risk-ring span {
  font-size: 2.8rem;
  font-weight: 850;
}

.risk-copy {
  min-width: 0;
}

.risk-copy p {
  margin-bottom: 18px;
  color: var(--charcoal);
  font-size: 1rem;
  line-height: 1.5;
}

.model-output-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}

.model-output-tile {
  display: grid;
  grid-template-rows: 34px 86px minmax(30px, auto) 20px;
  justify-items: center;
  align-content: start;
  gap: 8px 12px;
  height: var(--calculator-first-row-box-height);
  min-height: var(--calculator-first-row-box-height);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
  --output-color: var(--muted);
  --output-risk: 0%;
}

.note-line {
  border-color: var(--line);
  background: var(--surface);
  color: var(--charcoal);
}

.model-output-tile:hover,
.model-output-tile.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.model-output-tile.is-loading {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: color-mix(in srgb, var(--primary-soft) 78%, var(--surface));
}

:root[data-theme="dark"] .model-output-tile.is-loading {
  border-color: color-mix(in srgb, var(--primary) 58%, var(--line));
  background: color-mix(in srgb, var(--primary) 18%, var(--surface));
}

.calculator-grid.is-empty .model-output-tile:hover,
.calculator-grid.is-empty .model-output-tile:focus-visible {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: none;
  outline: 0;
}

.model-output-label {
  justify-self: start;
  min-height: 34px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  text-transform: uppercase;
}

.model-output-stat {
  --output-ring-fill: #ffffff;
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--output-ring-fill) 0 56%, transparent 57%),
    conic-gradient(var(--output-color) var(--output-risk), var(--light-grey) 0);
  color: var(--ink);
  line-height: 1;
}

.model-output-stat span {
  font-size: 1.24rem;
  font-weight: 850;
}

.model-output-stat.is-loading {
  --output-loading-progress: 12%;
  --output-ring-fill: color-mix(in srgb, var(--surface) 92%, var(--primary-soft));
  background:
    radial-gradient(circle at center, var(--output-ring-fill) 0 56%, transparent 57%),
    conic-gradient(
      var(--primary) var(--output-loading-progress),
      color-mix(in srgb, var(--primary) 13%, var(--light-grey)) 0
    );
  color: var(--primary);
  animation: model-output-ring-fill 1500ms ease-in-out infinite;
}

.model-output-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.model-output-loading-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.42;
  animation: model-output-dot 900ms ease-in-out infinite;
}

.model-output-loading-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.model-output-loading-dots i:nth-child(3) {
  animation-delay: 240ms;
}

.model-output-description {
  max-width: 18ch;
  color: var(--charcoal);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.model-output-tile .model-output-tier {
  margin-top: 0;
  line-height: 1.12;
  white-space: normal;
}

.model-output-tier span {
  display: block;
}

@property --output-loading-progress {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 12%;
}

@keyframes model-output-ring-fill {
  0% {
    --output-loading-progress: 10%;
  }
  72%,
  100% {
    --output-loading-progress: 92%;
  }
}

@keyframes model-output-dot {
  0%,
  100% {
    opacity: 0.38;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .model-output-stat.is-loading,
  .model-output-loading-dots i {
    animation: none;
  }

  .model-output-stat.is-loading {
    --output-loading-progress: 72%;
  }
}

.confidence-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.confidence-row span {
  font-size: 1rem;
}

.sparkline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.sparkline-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.sparkline-heading span {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.35;
}

.confidence-row strong,
.sparkline-heading strong {
  color: var(--ink);
}

.ifn-status {
  font-weight: 850;
}

.ifn-status-high {
  color: var(--risk-high);
}

.ifn-status-neutral {
  color: var(--risk-moderate);
}

.ifn-status-low {
  color: var(--risk-low);
}

.ifn-status-empty {
  color: var(--muted);
}

.confidence-row strong {
  font-size: 1.45rem;
  line-height: 1.12;
}

.sparkline-panel {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.fingerprint-chart-box {
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.fingerprint-scroll {
  overflow-x: scroll;
  overflow-y: visible;
  padding: 0 10px 14px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  scrollbar-color: var(--charcoal) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  touch-action: pan-y;
}

.fingerprint-scroll::-webkit-scrollbar {
  height: 8px;
}

.fingerprint-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.fingerprint-scroll::-webkit-scrollbar-thumb {
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--charcoal);
}

.fingerprint-scroll:focus-visible,
.zscore-scroll:focus-visible {
  border-radius: 6px;
  outline: 2px solid color-mix(in srgb, var(--control-focus) 58%, transparent);
  outline-offset: 2px;
}

.fingerprint {
  display: grid;
  grid-template-columns: repeat(var(--fingerprint-count, 18), minmax(16px, 1fr));
  gap: 4px;
  height: 102px;
  min-width: max(100%, var(--fingerprint-min-width, 0px));
  margin-top: 0;
  padding-top: 32px;
  overflow: visible;
}

.fingerprint-cell {
  --bar-color: var(--signal-neutral);
  --bar-tag-text: #000000;
  appearance: none;
  position: relative;
  padding: 0;
  cursor: pointer;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 5px;
  background: var(--bar-color);
  transform-origin: center bottom;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.fingerprint-cell .bar-hover-tag {
  top: -25px;
}

.fingerprint-cell:not(.is-empty):hover,
.fingerprint-cell:not(.is-empty):focus-visible,
.fingerprint-cell:not(.is-empty).is-touch-preview {
  border-color: var(--bar-color);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--bar-color) 36%, transparent),
    0 12px 18px color-mix(in srgb, var(--bar-color) 24%, transparent);
  outline: 0;
  transform: translateY(-3px);
}

.fingerprint-cell:not(.is-empty).fingerprint-scrub-pulse {
  animation: fingerprint-scrub-pulse 280ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes fingerprint-scrub-pulse {
  0% {
    filter: brightness(1);
    transform: translateY(-3px) scale(1);
  }
  42% {
    filter: brightness(1.08) saturate(1.08);
    transform: translateY(-8px) scale(1.13);
  }
  100% {
    filter: brightness(1);
    transform: translateY(-3px) scale(1);
  }
}

.fingerprint-cell.is-empty {
  border-color: var(--line);
  background: transparent;
  cursor: default;
}

.fingerprint-cell.is-empty:hover {
  border-color: var(--accessible-ochre);
  background: transparent;
  box-shadow: none;
  transform: translateY(-2px);
}

:root[data-theme="dark"] .fingerprint-cell.is-empty {
  border-color: var(--line);
  background: transparent;
}

:root[data-theme="dark"] .fingerprint-cell.is-empty:hover {
  border-color: var(--accessible-ochre);
  background: transparent;
  box-shadow: none;
}

.signal-high-strong {
  --bar-color: var(--signal-high);
  --bar-tag-text: #ffffff;
  background: var(--bar-color);
}

.signal-high {
  --bar-color: var(--signal-high-soft);
  --bar-tag-text: #000000;
  background: var(--bar-color);
}

.signal-neutral {
  --bar-color: var(--signal-neutral);
  --bar-tag-text: #000000;
  background: var(--bar-color);
}

.signal-low {
  --bar-color: var(--signal-low-soft);
  --bar-tag-text: #000000;
  background: var(--bar-color);
}

.signal-low-strong {
  --bar-color: var(--signal-low);
  --bar-tag-text: #ffffff;
  background: var(--bar-color);
}

.bar-hover-tag {
  --tag-translate-x: -50%;
  position: absolute;
  top: -21px;
  left: 50%;
  z-index: 5;
  max-width: min(18ch, 160px);
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--bar-color) 72%, #000000);
  border-radius: 999px;
  background: var(--bar-color);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  color: var(--bar-tag-text);
  font-size: 0.64rem;
  font-weight: 850;
  line-height: 1;
  opacity: 0;
  overflow-x: auto;
  overflow-y: hidden;
  pointer-events: none;
  scrollbar-width: thin;
  text-overflow: clip;
  transform: translate(var(--tag-translate-x), 6px);
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

.bar-hover-tag::-webkit-scrollbar {
  height: 4px;
}

.bar-hover-tag::-webkit-scrollbar-track {
  background: transparent;
}

.bar-hover-tag::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--bar-tag-text) 44%, transparent);
}

.fingerprint-cell:not(.is-empty):hover .bar-hover-tag,
.fingerprint-cell:not(.is-empty):focus-visible .bar-hover-tag,
.fingerprint-cell:not(.is-empty).is-touch-preview .bar-hover-tag,
.heatmap-item:hover .bar-hover-tag,
.heatmap-item:focus-visible .bar-hover-tag,
.heatmap-item.is-touch-preview .bar-hover-tag {
  opacity: 1;
  pointer-events: auto;
  transform: translate(var(--tag-translate-x), 0);
}

.fingerprint-legend,
.driver-legend,
.metric-legend,
.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.fingerprint-legend {
  justify-content: flex-end;
  margin-top: 8px;
  text-align: right;
}

.driver-legend {
  justify-content: flex-end;
  margin-top: 10px;
  text-align: right;
}

.fingerprint-legend span,
.driver-legend span,
.metric-legend span,
.heatmap-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fingerprint-legend i,
.driver-legend i,
.metric-legend i,
.heatmap-legend i {
  display: block;
  width: 12px;
  flex: 0 0 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.driver-legend i {
  background: var(--driver-color, var(--primary));
}

.fingerprint-drivers {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  margin-top: 18px;
  min-height: 0;
  padding: 14px 0 12px;
  border-top: 1px solid var(--line);
  background: transparent;
}

.driver-heading {
  margin: 0 0 10px;
}

.sparkline-heading .driver-mode-indicator {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--navy);
  border-radius: 7px;
  background: color-mix(in srgb, var(--jacaranda) 28%, transparent);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sparkline-heading .driver-mode-indicator.is-empty {
  width: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.driver-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.molecular-heading .driver-actions {
  flex: 0 0 auto;
}

.driver-actions .secondary-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 400;
}

.model-output-learn-more,
#copy-summary {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 400;
  white-space: nowrap;
}

.handoff-heading {
  align-items: center;
}

.handoff-subnav {
  align-items: center;
  justify-content: flex-end;
  margin: 0;
}

.handoff-subnav .subnav-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.handoff-view-select {
  min-height: 30px;
  max-width: 170px;
  padding: 0 28px 0 10px;
  color: var(--charcoal);
  font-size: 0.82rem;
  font-weight: 400;
}

.gene-filter-select {
  min-height: 30px;
  max-width: 160px;
  padding: 0 30px 0 10px;
  color: var(--charcoal);
  font-size: 0.82rem;
  font-weight: 400;
}

.driver-list {
  position: relative;
  display: grid;
  align-content: start;
  flex: 1 1 0;
  gap: 8px;
  grid-auto-rows: min-content;
  min-height: 0;
  max-height: 100%;
  overflow-y: scroll;
  padding: 0 28px 0 0;
  border: 0;
  border-radius: 0;
  scrollbar-color: var(--charcoal) transparent;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
}

.calculator-grid.is-empty .driver-list {
  flex: 0 0 auto;
  min-height: 124px;
  max-height: none;
}

.calculator-grid.has-run .driver-list {
  min-height: 124px;
}

.calculator-grid.is-empty .fingerprint-drivers {
  flex: 0 0 auto;
  padding-bottom: 22px;
}

.driver-list::-webkit-scrollbar {
  width: 8px;
}

.driver-list::-webkit-scrollbar-track {
  background: transparent;
}

.driver-list::-webkit-scrollbar-thumb {
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--charcoal);
}

.driver-row {
  appearance: none;
  display: grid;
  grid-template-columns: minmax(86px, 130px) minmax(128px, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 1px 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background 140ms ease;
}

.driver-row:hover,
.driver-row:focus-visible {
  background: transparent;
  outline: 0;
}

.driver-row:hover .bar-track,
.driver-row:focus-visible .bar-track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--driver-color, var(--primary)) 24%, transparent);
}

.driver-row:hover .bar-fill,
.driver-row:focus-visible .bar-fill {
  filter: saturate(1.12);
}

.driver-row-empty {
  grid-template-columns: minmax(0, 1fr);
  color: var(--muted);
  cursor: default;
  opacity: 1;
}

.driver-row-empty:hover .bar-track,
.driver-row-empty:focus-visible .bar-track {
  border-color: var(--accessible-ochre);
  background: transparent;
  box-shadow: none;
}

.driver-row-empty:hover .bar-fill,
.driver-row-empty:focus-visible .bar-fill {
  background: transparent;
  filter: none;
  opacity: 0;
}

.driver-row-empty .bar-track {
  width: 100%;
  min-height: 12px;
  border: 1px solid var(--line);
  background: transparent;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.driver-row-empty .bar-fill {
  background: transparent;
  opacity: 0;
  transition: background 140ms ease, opacity 140ms ease;
}

:root[data-theme="dark"] .driver-row-empty .bar-track,
:root[data-theme="dark"] .driver-row-empty:hover .bar-track,
:root[data-theme="dark"] .driver-row-empty:focus-visible .bar-track {
  border-color: var(--line);
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] .driver-row-empty:hover .bar-track,
:root[data-theme="dark"] .driver-row-empty:focus-visible .bar-track {
  border-color: var(--accessible-ochre);
}

:root[data-theme="dark"] .driver-row-empty .bar-fill,
:root[data-theme="dark"] .driver-row-empty:hover .bar-fill,
:root[data-theme="dark"] .driver-row-empty:focus-visible .bar-fill {
  background: transparent;
  opacity: 0;
}

.driver-name-placeholder {
  display: none;
}

.driver-name {
  min-width: 0;
  font-weight: 400;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
  text-align: right;
  white-space: nowrap;
}

.driver-name::-webkit-scrollbar {
  height: 4px;
}

.driver-name::-webkit-scrollbar-track {
  background: transparent;
}

.driver-name::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line);
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--light-grey);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--driver-color, var(--primary));
}

.driver-impact-high {
  --driver-color: var(--accessible-ochre);
}

.driver-impact-intermediate {
  --driver-color: var(--heritage-rose);
}

.driver-impact-low {
  --driver-color: var(--jacaranda);
}

.metric-supporting {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.metric-definitions {
  display: grid;
  gap: 6px;
  color: var(--charcoal);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.45;
}

.note-section-title {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-style: normal;
  font-weight: 600;
  line-height: 1.25;
}

.metric-definitions p,
.metric-definitions ul {
  margin: 0;
}

.metric-definitions ul {
  display: grid;
  gap: 5px;
  padding-left: 18px;
}

.metric-definitions li {
  padding-left: 2px;
}

.metric-definitions strong {
  color: var(--ink);
  font-weight: 500;
}

.metric-legend {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.validation-panel .metric-legend {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  justify-self: end;
  margin-top: 0;
  padding: 0;
  border-top: 0;
  border-left: 0;
  gap: 8px;
  line-height: 1.25;
}

.validation-panel table {
  width: max-content;
  min-width: 1120px;
  table-layout: auto;
}

.validation-panel th,
.validation-panel td {
  white-space: nowrap;
}

.validation-panel th:nth-child(n + 4),
.validation-panel td.metric-value {
  text-align: right;
}

.validation-panel td em {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(143, 158, 201, 0.2);
  color: var(--jacaranda);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  vertical-align: middle;
}

:root[data-theme="dark"] .validation-panel td em {
  color: var(--jacaranda);
}

.metric-value span {
  display: inline-flex;
  min-width: 4.2ch;
  justify-content: flex-end;
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 600;
  line-height: 1.25;
}

.metric-value.metric-strong span {
  color: var(--metric-strong);
}

.metric-value.metric-adequate span {
  color: var(--metric-adequate);
}

.metric-value.metric-limited span {
  color: var(--metric-limited);
}

.metric-value.metric-unavailable {
  color: var(--muted);
}

.heatmap-legend {
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  min-width: min(230px, 100%);
  margin-top: 0;
  padding-left: 0;
  border-left: 0;
  text-align: right;
  gap: 8px;
  line-height: 1.25;
}

.heatmap-legend > span {
  display: grid;
  grid-template-columns: minmax(102px, max-content) minmax(98px, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
}

.heatmap-legend .legend-signal {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  text-align: left;
}

.heatmap-legend .legend-range {
  color: var(--charcoal);
  justify-self: start;
  text-align: left;
  white-space: nowrap;
}

.heatmap-legend .legend-range .katex {
  display: inline-block;
  font-size: 0.98em;
  text-align: left;
}

.heatmap-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, max-content);
  align-items: start;
  gap: 16px;
  margin-top: 10px;
  margin-right: 0;
}

.heatmap-footer .heatmap-legend {
  order: 2;
  justify-self: end;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.heatmap-footer .zscore-note {
  order: 1;
}

.zscore-note {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: var(--charcoal);
  font-size: 0.82rem;
  line-height: 1.35;
}

.zscore-note-head {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.zscore-note strong {
  color: var(--charcoal);
  font-size: 0.92rem;
  font-weight: 650;
}

.zscore-formula {
  display: block;
  max-width: 100%;
  overflow: visible;
  padding-bottom: 0;
  color: var(--ink);
  font-size: clamp(0.96rem, 2vw, 1.16rem);
  white-space: normal;
}

.zscore-formula .katex {
  max-width: 100%;
  font-size: clamp(0.94rem, 1.45vw, 1.14rem);
  line-height: 1.25;
  white-space: normal;
}

.heatmap-footer:not(.is-zscore-stacked) .zscore-formula .katex {
  white-space: nowrap;
}

.zscore-citation {
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-legend .metric-strong {
  background: var(--metric-strong);
}

.metric-legend .metric-adequate {
  background: var(--metric-adequate);
}

.metric-legend .metric-limited {
  background: var(--metric-limited);
}

.whatif-grid {
  display: grid;
  gap: 10px;
}

.compact-field {
  min-height: 68px;
}

.whatif-result {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.whatif-result div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.whatif-result span {
  color: var(--muted);
  font-weight: 700;
}

.whatif-result strong {
  text-align: right;
}

.summary-note {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.note-line {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--charcoal);
  font-size: 0.88rem;
  line-height: 1.45;
}

.handoff-checklist {
  display: grid;
  gap: 8px;
}

.handoff-check-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--charcoal);
  font-size: 0.88rem;
  line-height: 1.45;
}

.handoff-check-item input {
  appearance: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  border: 1.5px solid color-mix(in srgb, var(--charcoal) 44%, var(--line));
  border-radius: 3px;
  background: var(--surface);
  accent-color: var(--accessible-ochre);
  cursor: pointer;
}

.handoff-check-item input::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg) scale(0);
  transform-origin: center;
}

.handoff-check-item input:checked {
  border-color: var(--accessible-ochre);
  background: var(--accessible-ochre);
}

.handoff-check-item input:checked::after {
  transform: translateY(-1px) rotate(45deg) scale(1);
}

.handoff-check-item input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accessible-ochre) 46%, transparent);
  outline-offset: 2px;
}

.trajectory-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 260px;
  padding: 16px 8px 0;
  border-bottom: 1px solid var(--line);
}

.trajectory-bar {
  display: grid;
  align-items: end;
  width: 52px;
  min-height: 24px;
  border-radius: 8px 8px 0 0;
  background: var(--primary);
  color: #ffffff;
  text-align: center;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--charcoal);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.gene-list {
  flex: 1 1 0;
  margin-top: 16px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: scroll;
  padding-right: 22px;
  scrollbar-color: var(--charcoal) transparent;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
}

.gene-list::-webkit-scrollbar {
  width: 8px;
}

.gene-list::-webkit-scrollbar-track {
  background: transparent;
}

.gene-list::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--charcoal);
}

.gene-table {
  width: max(100%, 520px);
  min-width: 520px;
}

.gene-table-header,
.gene-item {
  display: grid;
  grid-template-columns: minmax(76px, 0.76fr) minmax(78px, 0.5fr) minmax(94px, 0.58fr) minmax(66px, 0.42fr);
  align-items: start;
  gap: 8px;
}

.gene-table-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.gene-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  transition: background 160ms ease;
}

.gene-item.is-highlighted {
  margin: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--accessible-ochre) 14%, var(--surface));
  box-shadow: none;
  scroll-margin-block: 120px;
}

.gene-item span,
.gene-item a {
  color: var(--muted);
  line-height: 1.4;
}

.gene-item .gene-symbol-link {
  color: var(--charcoal);
  font-size: 0.94rem;
  font-weight: 400;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.gene-symbol-link:hover,
.gene-link-group a:hover {
  text-decoration-thickness: 2px;
}

.gene-metrics {
  display: grid;
  gap: 4px;
  color: var(--charcoal);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.35;
}

.gene-stage {
  display: flex;
  min-width: 0;
}

.gene-stage-badge {
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gene-stage-badge.stage-diagnosis {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.gene-stage-badge.stage-progression {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.gene-stage-badge.stage-response {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.gene-link-group {
  display: grid;
  justify-content: flex-start;
  gap: 4px;
}

.gene-item .gene-link-group a {
  font-size: 0.72rem;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.biomarker-grid > .panel {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 600px;
  margin-top: 0;
}

.heatmap {
  display: grid;
  gap: 8px;
  margin-top: 0;
  min-width: 0;
  overflow: visible;
  padding: 0;
}

.heatmap .awaiting-run {
  margin: 0;
}

.zscore-chart-title {
  color: var(--charcoal);
  font-size: 0.92rem;
  font-weight: 650;
}

.zscore-frame {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  min-height: 342px;
  align-items: start;
}

.zscore-axis {
  position: relative;
  height: 270px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.zscore-axis-label {
  position: absolute;
  right: 0;
  top: var(--axis-y);
  display: block;
  width: 100%;
  text-align: right;
  transform: translateY(-50%);
  white-space: nowrap;
}

.zscore-axis-label-math,
.zscore-axis-label-math .katex {
  display: inline-block;
  font-size: 1em;
  text-align: right;
}

.zscore-scroll {
  overflow-x: scroll;
  overflow-y: visible;
  padding: 28px 10px 34px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  scrollbar-color: var(--charcoal) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  touch-action: pan-x pan-y;
}

.zscore-scroll::-webkit-scrollbar {
  height: 8px;
}

.zscore-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.zscore-scroll::-webkit-scrollbar-thumb {
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--charcoal);
}

.heatmap-strip {
  position: relative;
  height: 270px;
  min-width: max(100%, var(--heatmap-min-width, 0px));
  overflow: visible;
}

.zscore-gridline {
  position: absolute;
  right: 0;
  left: 0;
  top: var(--axis-y);
  border-top: 1px solid rgba(66, 66, 66, 0.16);
  pointer-events: none;
}

.zscore-gridline-zero {
  z-index: 0;
  border-top: 2px solid var(--zscore-zero-line);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--zscore-zero-line) 16%, transparent);
}

.zscore-bars {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--heatmap-count, 18), minmax(20px, 1fr));
  gap: 4px;
  height: 100%;
}

.zscore-frame-empty .zscore-scroll {
  pointer-events: none;
}

.zscore-plot-empty {
  opacity: 0.78;
}

.zscore-placeholder-bar {
  position: relative;
  display: block;
  height: 100%;
  min-width: 0;
}

.zscore-placeholder-bar::before {
  content: "";
  position: absolute;
  top: var(--placeholder-top);
  left: 50%;
  width: min(20px, 82%);
  height: max(7px, var(--placeholder-height));
  border: 1px dashed rgba(66, 66, 66, 0.22);
  border-radius: 5px;
  background: rgba(66, 66, 66, 0.05);
  transform: translateX(-50%);
}

.heatmap-item {
  --bar-color: var(--light-grey);
  --bar-tag-text: #000000;
  appearance: none;
  position: relative;
  display: block;
  height: 100%;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  justify-items: center;
  min-width: 0;
}

.heatmap-item::before {
  content: "";
  position: absolute;
  left: 50%;
  z-index: 2;
  border-left: 1px dashed #8a8a8a;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 140ms ease;
}

.heatmap-item.tag-positive::before {
  top: -3px;
  bottom: 50%;
}

.heatmap-item.tag-negative::before {
  top: 50%;
  bottom: -23px;
}

.heatmap-item:hover::before,
.heatmap-item:focus-visible::before,
.heatmap-item.is-touch-preview::before {
  opacity: 1;
}

.heatmap-item.tag-positive .bar-hover-tag {
  top: -22px;
  bottom: auto;
}

.heatmap-item.tag-negative .bar-hover-tag {
  top: auto;
  bottom: -23px;
}

.heatmap-cell {
  position: absolute;
  top: var(--bar-top);
  left: 50%;
  z-index: 1;
  display: block;
  width: min(20px, 82%);
  height: max(4px, var(--bar-height));
  border-radius: 5px;
  background: var(--bar-color);
  transform: translateX(-50%);
  transition: box-shadow 140ms ease, transform 140ms ease;
}

.heatmap-item:hover .heatmap-cell,
.heatmap-item:focus-visible .heatmap-cell,
.heatmap-item.is-touch-preview .heatmap-cell {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--bar-color) 38%, transparent),
    0 12px 18px color-mix(in srgb, var(--bar-color) 26%, transparent);
  transform: translate(-50%, -3px);
}

.heatmap-item:focus-visible {
  outline: 0;
}

@media (prefers-reduced-motion: reduce) {
  .fingerprint-cell:not(.is-empty):hover,
  .fingerprint-cell:not(.is-empty):focus-visible,
  .fingerprint-cell:not(.is-empty).is-touch-preview {
    transform: none;
  }

  .fingerprint-cell:not(.is-empty).fingerprint-scrub-pulse {
    animation: none;
  }

  .heatmap-item:hover .heatmap-cell,
  .heatmap-item:focus-visible .heatmap-cell,
  .heatmap-item.is-touch-preview .heatmap-cell {
    transform: translateX(-50%);
  }

  .bar-hover-tag {
    transition: none;
  }
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(18px);
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--charcoal);
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

:root[data-theme="dark"] .toast {
  color: #1a1a1a;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 920px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 100vh;
    --bottom-bar-height: 74px;
  }

  /* Anchor jumps and scroll-into-view land above the fixed bottom bar. */
  html {
    scroll-padding-bottom: calc(var(--bottom-bar-height, 74px) + 12px);
  }

  /* Keep the swappable-card view from drifting past the pager lane. The
     fixed bottom nav bar stays anchored to the viewport regardless. */
  body {
    overscroll-behavior-y: contain;
  }

  .workspace {
    grid-row: 1;
    grid-column: 1;
    min-width: 0;
    /* Reserve exactly one pager lane above the fixed bottom navigator; the
       page should stop once the dots are neatly between card and nav bar. */
    padding-bottom: calc(var(--bottom-bar-height, 74px) + env(safe-area-inset-bottom, 0px) + 12px);
  }

  /* Calculator panels can extend further than viewport height at narrow
     widths; the .calculator-grid is the horizontal swiper but vertical
     overflow from inside each panel should still scroll the page, not
     the grid itself. */
  .calculator-grid {
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
  }

  /* Embedded auto-height: the bottom nav rejoins the flow at the end of the
     content, so drop the reserved clearance that assumed a fixed bar. */
  html.is-embedded .sidebar {
    position: static;
    inset: auto;
  }
  html.is-embedded .workspace,
  html.is-embedded .app-shell.sidebar-collapsed .workspace {
    padding-bottom: 12px;
  }

  /* Collapsed state: the bottom bar is just a floating hamburger that doesn't
     occupy layout, so workspace can reclaim the bottom clearance. */
  .app-shell.sidebar-collapsed .workspace {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    align-self: auto;
    /* Sidebar's stacking context needs to sit above all workspace/panel
       content so the settings popup card (which lives inside the sidebar)
       always renders on top of the cards. */
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: center;
    gap: 6px;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--sidebar-border);
    border-bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }

  .brand-block,
  .sidebar-disclaimer,
  .sidebar-footer .nav-section-label {
    display: none;
  }

  .sidebar-footer {
    display: contents;
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  .sidebar-footer .backend-status {
    position: relative;
    display: block;
    justify-self: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border-radius: 8px;
    overflow: visible;
    color: transparent;
    font-size: 0;
    line-height: 0;
  }

  .sidebar-footer .backend-status::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    margin: 0;
    transform: translate(-50%, -50%);
  }

  .sidebar-footer .backend-status:hover {
    border-color: rgba(206, 61, 32, 0.34);
    background: var(--sidebar-hover);
  }

  .sidebar-footer .backend-status .dock-tip {
    bottom: calc(100% + 10px);
    right: 0;
    left: auto;
    max-width: calc(100vw - 24px);
    white-space: nowrap;
    transform: translateY(4px);
    z-index: 35;
  }

  .sidebar-footer .backend-status .dock-tip::after {
    right: 14px;
    left: auto;
    transform: none;
  }

  @media (hover: hover) and (pointer: fine) {
    .sidebar-footer .backend-status:hover .dock-tip,
    .sidebar-footer .backend-status:focus-visible .dock-tip {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @media (hover: none) {
    .sidebar-footer .backend-status:focus-visible .dock-tip,
    .sidebar-footer .backend-status:active .dock-tip {
      animation: dock-tooltip-flash-right 1800ms ease forwards;
    }
  }

  @keyframes dock-tooltip-flash-right {
    0%   { opacity: 0; transform: translateY(4px); }
    12%  { opacity: 1; transform: translateY(0); }
    72%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(2px); }
  }

  @media (prefers-reduced-motion: reduce) {
    .sidebar-footer .backend-status .dock-tip {
      transition: none;
      animation: none;
    }
  }

  .bottom-bar-toggle {
    position: relative;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  }

  .bottom-bar-toggle:hover,
  .bottom-bar-toggle:focus-visible {
    background: var(--sidebar-hover);
    border-color: rgba(206, 61, 32, 0.34);
    outline: none;
  }

  /* Bar visible (not collapsed): show the chevron arrow indicator that
     mirrors the vertical-sidebar toggle. */
  .bottom-bar-toggle .bottom-bar-toggle-icon-bar {
    display: block;
  }
  .bottom-bar-toggle .bottom-bar-toggle-icon-corner {
    display: none;
  }

  /* Bar collapsed to a corner: show three horizontal lines. */
  .app-shell.sidebar-collapsed .bottom-bar-toggle .bottom-bar-toggle-icon-bar {
    display: none;
  }
  .app-shell.sidebar-collapsed .bottom-bar-toggle .bottom-bar-toggle-icon-corner {
    display: block;
  }

  .bottom-bar-toggle:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--control-focus) 30%, transparent);
  }

  .bottom-bar-toggle .dock-tip,
  .sidebar-footer .backend-status .dock-tip {
    right: auto;
    left: var(--dock-tip-left, 50%);
    max-width: var(--dock-tip-max-width, calc(100vw - 28px));
    white-space: normal;
    transform: translateX(var(--dock-tip-translate-x, -50%)) translateY(4px);
  }

  .bottom-bar-toggle .dock-tip::after,
  .sidebar-footer .backend-status .dock-tip::after {
    right: auto;
    left: var(--dock-tip-arrow-left, 50%);
    transform: translateX(-50%);
  }

  .bottom-bar-toggle:hover .dock-tip,
  .bottom-bar-toggle:focus-visible .dock-tip,
  .sidebar-footer .backend-status:hover .dock-tip,
  .sidebar-footer .backend-status:focus-visible .dock-tip {
    transform: translateX(var(--dock-tip-translate-x, -50%)) translateY(0);
  }

  :root[data-theme="dark"] .bottom-bar-toggle .dock-tip,
  :root[data-theme="dark"] .sidebar-footer .backend-status .dock-tip {
    color: #1a1a1a;
  }

  .sidebar-nav {
    display: contents;
    gap: 6px;
    overflow: visible;
    min-width: 0;
    padding: 0;
  }

  .nav-section-label {
    display: none;
  }

  .nav-list {
    display: contents;
    gap: 6px;
    max-width: none;
    min-width: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  .nav-tools,
  .sidebar-collapsed .nav-tools {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  .nav-tools-label {
    display: none;
  }

  .theme-toggle {
    width: max-content;
    flex: 0 0 auto;
  }

  .vision-select-wrap {
    --vision-select-width: clamp(76px, 6.8vw, 88px);
    flex: 0 0 var(--vision-select-width);
    width: var(--vision-select-width);
  }

  .vision-select {
    width: 100%;
    flex: 0 0 auto;
    min-height: 34px;
    padding-right: 20px;
    padding-left: 7px;
    font-size: 0.76rem;
  }

  .nav-item,
  .sidebar-collapsed .nav-item {
    position: relative;
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    justify-content: center;
    justify-self: stretch;
    gap: 0;
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 0;
  }

  .nav-list .nav-item.active {
    padding: 0;
  }

  /* macOS dock-style floating label that appears above the icon when the
     button is active, hovered, or keyboard-focused. */
  .nav-list .nav-item .nav-label {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    display: inline-block;
    width: max-content;
    max-width: calc(100vw - 24px);
    margin: 0;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(20, 20, 20, 0.92);
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px);
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 35;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  }

  .nav-list .nav-item .nav-label::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(20, 20, 20, 0.92);
    border-bottom: 0;
  }

  /* PC / desktop with a real pointer: dock tooltips appear only while the
     icon is hovered or keyboard-focused. The active tab alone does NOT keep
     its tooltip visible. */
  @media (hover: hover) and (pointer: fine) {
    .nav-list .nav-item:hover .nav-label,
    .nav-list .nav-item:focus-visible .nav-label {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }
  }

  /* Touch devices (phones / tablets): a tap promotes the tab to active,
     which fires a one-shot fade-in/fade-out flash. */
  @media (hover: none) {
    .nav-list .nav-item:focus-visible .nav-label {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .nav-list .nav-item.active .nav-label {
      animation: dock-tooltip-flash 1800ms ease forwards;
    }
  }

  :root[data-theme="dark"] .nav-list .nav-item .nav-label {
    background: rgba(244, 236, 223, 0.95);
    color: #1a1a1a;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
  }

  :root[data-theme="dark"] .nav-list .nav-item .nav-label::after {
    border-top-color: rgba(244, 236, 223, 0.95);
  }

  @keyframes dock-tooltip-flash {
    0%   { opacity: 0; transform: translateX(-50%) translateY(4px); }
    12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
    72%  { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(2px); }
  }

  @media (prefers-reduced-motion: reduce) {
    .nav-list .nav-item .nav-label {
      transition: none;
      animation: none;
    }
  }

  /* Collapsed state: bar shrinks to just the hamburger floating in bottom-left. */
  .app-shell.sidebar-collapsed > .sidebar {
    background: transparent;
    box-shadow: none;
    border-top: 0;
    padding: 0;
    gap: 0;
    pointer-events: none;
  }

  .app-shell.sidebar-collapsed > .sidebar > * {
    display: none;
  }

  .app-shell.sidebar-collapsed > .sidebar > .bottom-bar-toggle {
    display: inline-flex;
    position: fixed;
    bottom: 14px;
    left: 14px;
    z-index: 31;
    pointer-events: auto;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
    /* Inherit background / border / color from the base .bottom-bar-toggle
       rule so the collapsed hamburger looks identical to its expanded form
       in both light and dark themes. */
  }

  .lower-grid,
  .lower-grid.lower-grid-two,
  .summary-grid,
  .pipeline-flow,
  .credits-grid,
  .metric-supporting {
    grid-template-columns: 1fr;
  }

  .pipeline-step {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .validation-panel .metric-legend {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    min-width: 0;
    padding: 0;
    border-top: 0;
    border-left: 0;
  }

  .biomarker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .csv-panel,
  .result-panel {
    height: auto;
  }

  .fingerprint-drivers {
    flex: 1 1 0;
    min-height: 220px;
  }

  .driver-list {
    min-height: 180px;
    max-height: 100%;
  }
}

@media (max-width: 920px) {
  .nav-settings {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: stretch;
    width: 100%;
    position: relative;
  }

  .nav-settings-toggle.nav-item {
    display: inline-flex;
    width: 100%;
  }

  .nav-settings-toggle .nav-label {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    display: inline-block;
    width: max-content;
    max-width: calc(100vw - 24px);
    margin: 0;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(20, 20, 20, 0.92);
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px);
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 35;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  }

  .nav-settings-toggle .nav-label::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(20, 20, 20, 0.92);
    border-bottom: 0;
  }

  .nav-settings-toggle:hover .nav-label,
  .nav-settings-toggle:focus-visible .nav-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  .nav-list .nav-item .nav-label,
  .nav-settings-toggle .nav-label {
    left: var(--horizontal-nav-label-left, 50%);
    max-width: var(--horizontal-nav-label-max-width, calc(100vw - 28px));
    transform: translateX(var(--horizontal-nav-label-translate-x, -50%)) translateY(4px);
  }

  .nav-list .nav-item .nav-label::after,
  .nav-settings-toggle .nav-label::after {
    left: var(--horizontal-nav-label-arrow-left, 50%);
    transform: translateX(-50%);
  }

  .nav-list .nav-item:hover .nav-label,
  .nav-list .nav-item:focus-visible .nav-label,
  .nav-settings-toggle:hover .nav-label,
  .nav-settings-toggle:focus-visible .nav-label {
    transform: translateX(var(--horizontal-nav-label-translate-x, -50%)) translateY(0);
  }

  .nav-settings-toggle[aria-expanded="true"] {
    color: var(--accessible-ochre);
  }

  .nav-settings-panel {
    position: fixed;
    top: var(--settings-panel-top, 64px);
    right: auto;
    bottom: auto;
    left: var(--settings-panel-left, 14px);
    display: block;
    width: var(--settings-panel-width, min(318px, calc(100vw - 28px)));
    max-width: calc(100vw - 28px);
    max-height: none;
    overflow: visible;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 1000;
  }

  .nav-settings.is-open .nav-settings-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-settings-card {
    position: relative;
    display: grid;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    color: var(--ink);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.18);
  }

  .nav-settings-card::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--settings-arrow-x, 50%);
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-top-color: color-mix(in srgb, var(--surface) 96%, transparent);
    border-bottom: 0;
  }

  .nav-settings-panel .nav-tools {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0 0 12px;
    border-top: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .nav-settings-panel .nav-tools-label {
    display: block;
    margin: 0;
  }

  .nav-settings-panel .nav-tools-row {
    gap: 8px;
  }

  .nav-settings-panel .vision-select-wrap {
    flex: 1 1 auto;
    width: auto;
  }

  .nav-settings-panel .nav-shortcuts {
    display: block;
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  :root[data-theme="dark"] .nav-settings-toggle .nav-label {
    background: rgba(244, 236, 223, 0.95);
    color: #1a1a1a;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
  }

  :root[data-theme="dark"] .nav-settings-toggle .nav-label::after {
    border-top-color: rgba(244, 236, 223, 0.95);
  }

  :root[data-theme="dark"] .nav-settings-card {
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  }

  :root[data-theme="dark"] .nav-settings-card::after {
    border-top-color: color-mix(in srgb, var(--surface) 96%, transparent);
  }

  @media (prefers-reduced-motion: reduce) {
    .nav-settings-toggle .nav-label,
    .nav-settings-panel {
      transition: none;
    }
  }
}

@media (max-width: 1100px) {
  .lower-grid,
  .lower-grid.lower-grid-two,
  .summary-grid,
  .pipeline-flow,
  .credits-grid,
  .metric-supporting {
    grid-template-columns: 1fr;
  }

  .pipeline-step {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .validation-panel .metric-legend {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    min-width: 0;
    padding: 0;
    border-top: 0;
    border-left: 0;
  }

  .biomarker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .csv-panel,
  .result-panel {
    height: auto;
  }

  .fingerprint-drivers {
    flex: 1 1 0;
    min-height: 220px;
  }

  .driver-list {
    min-height: 180px;
    max-height: 100%;
  }

  .gene-list {
    max-height: min(520px, 62vh);
  }

  .heatmap-footer {
    grid-template-columns: minmax(0, 1fr) minmax(168px, max-content);
    align-items: start;
    gap: 12px;
  }

  .heatmap-legend {
    align-items: flex-end;
    min-width: min(188px, 44vw);
    padding-top: 0;
    padding-right: 0;
    padding-bottom: 0;
    padding-left: 12px;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 1px solid var(--line);
    text-align: right;
  }

  .heatmap-footer .heatmap-legend {
    order: 2;
    justify-self: end;
  }

  .heatmap-footer .zscore-note {
    order: 1;
  }

  .heatmap-legend > span {
    grid-template-columns: minmax(82px, max-content) minmax(76px, max-content);
  }

  .heatmap-legend .legend-range {
    text-align: left;
    white-space: nowrap;
  }
}

.heatmap-footer.is-zscore-stacked {
  grid-template-columns: 1fr;
  gap: 10px;
}

.heatmap-footer.is-zscore-stacked .heatmap-legend {
  order: 1;
  justify-self: end;
  width: min(100%, 260px);
  padding-left: 0;
  padding-bottom: 10px;
  border-left: 0;
  border-bottom: 1px solid var(--line);
}

.heatmap-footer.is-zscore-stacked .zscore-note {
  order: 2;
  justify-self: stretch;
}

.heatmap-footer.is-zscore-stacked .zscore-formula .katex {
  font-size: clamp(0.86rem, 2.8vw, 1.05rem);
}

.calculator-pager {
  display: none;
}

.calculator-swap-hint,
.calculator-back-hint {
  position: fixed;
  top: 10px;
  z-index: 60;
  display: inline-flex;
  width: auto;
  min-width: 0;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--charcoal);
  color: #ffffff;
  font: 700 12px/1 var(--font-ui);
  letter-spacing: 0;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(0.94);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.calculator-back-hint {
  left: 10px;
  padding-right: 14px;
  padding-left: 10px;
}

.calculator-swap-hint {
  right: 10px;
  padding-left: 14px;
  padding-right: 10px;
}

.calculator-swap-hint.is-awake,
.calculator-back-hint.is-awake {
  opacity: 0.85;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.calculator-swap-hint:hover,
.calculator-swap-hint:focus-visible,
.calculator-back-hint:hover,
.calculator-back-hint:focus-visible {
  background: var(--charcoal);
  opacity: 1;
  outline: 0;
}

.calculator-swap-hint:focus-visible,
.calculator-back-hint:focus-visible {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--control-focus) 30%, transparent),
    0 10px 24px rgba(0, 0, 0, 0.13);
}

:root[data-theme="dark"] .calculator-swap-hint,
:root[data-theme="dark"] .calculator-back-hint {
  color: #1a1a1a;
}

:root[data-theme="dark"] .calculator-swap-hint:hover,
:root[data-theme="dark"] .calculator-swap-hint:focus-visible,
:root[data-theme="dark"] .calculator-back-hint:hover,
:root[data-theme="dark"] .calculator-back-hint:focus-visible {
  color: #1a1a1a;
}

.calculator-swap-hint-icon {
  display: inline-block;
  flex: 0 0 auto;
}

@keyframes calculator-hint-glow {
  0%, 100% {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.13);
  }
  50% {
    box-shadow:
      0 0 0 6px color-mix(in srgb, var(--primary) 30%, transparent),
      0 0 18px 2px color-mix(in srgb, var(--primary) 40%, transparent),
      0 10px 24px rgba(0, 0, 0, 0.13);
  }
}

.calculator-swap-hint.is-prompting.is-awake,
.calculator-back-hint.is-prompting.is-awake {
  animation: calculator-hint-glow 1400ms ease-in-out 2;
  background: var(--charcoal);
  opacity: 1;
}

:root[data-theme="dark"] .calculator-swap-hint .calculator-swap-hint-label,
:root[data-theme="dark"] .calculator-swap-hint .calculator-swap-hint-icon,
:root[data-theme="dark"] .calculator-back-hint span,
:root[data-theme="dark"] .calculator-back-hint svg {
  color: #1a1a1a;
}

:root[data-theme="dark"] .calculator-swap-hint.is-prompting.is-awake,
:root[data-theme="dark"] .calculator-back-hint.is-prompting.is-awake {
  color: #1a1a1a;
}

:root[data-theme="dark"] .calculator-swap-hint.is-prompting.is-awake .calculator-swap-hint-label,
:root[data-theme="dark"] .calculator-swap-hint.is-prompting.is-awake .calculator-swap-hint-icon,
:root[data-theme="dark"] .calculator-back-hint.is-prompting.is-awake span,
:root[data-theme="dark"] .calculator-back-hint.is-prompting.is-awake svg {
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .return-position-button.is-suggested,
  .calculator-swap-hint.is-prompting.is-awake,
  .calculator-back-hint.is-prompting.is-awake {
    animation: none;
    box-shadow:
      0 0 0 5px color-mix(in srgb, var(--primary) 25%, transparent),
      0 10px 24px rgba(0, 0, 0, 0.13);
  }
}

@media (max-width: 920px) {
  .calculator-grid {
    --calculator-active-panel: 0;
    display: flex;
    grid-template-columns: none;
    gap: 0;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    align-items: stretch;
    margin-inline: calc(var(--workspace-pad, 0px) * -1);
    padding-inline: var(--workspace-pad, 0px);
  }

  .calculator-grid[data-active-panel="1"] {
    --calculator-active-panel: 1;
  }

  .biomarker-grid {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .biomarker-grid > .panel {
    height: auto;
    min-height: 0;
  }

  .biomarker-grid .gene-list {
    flex: 0 0 auto;
    min-height: 320px;
    max-height: min(520px, 62vh);
  }

  .calculator-grid::-webkit-scrollbar {
    display: none;
  }

  .calculator-grid > .panel {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    scroll-snap-align: center;
    scroll-snap-stop: always;
  }

  .calculator-grid > .panel + .panel {
    margin-left: 12px;
  }

  /* The dots stay strictly below the swappable panels in document flow.
     The workspace bottom padding provides the fixed-nav clearance, so the
     scroll naturally stops once the dots sit above the bottom bar. */
  .calculator-pager {
    position: static;
    z-index: 24;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 14px 0 0;
    padding: 6px 0;
  }

  .app-shell.sidebar-collapsed .calculator-pager {
    position: static;
    margin: 14px 0 4px;
    padding: 0;
  }

  .calculator-pager-dot {
    width: 9px;
    height: 9px;
    padding: 0;
    border: 1.5px solid var(--muted);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
  }

  .calculator-pager-dot:hover,
  .calculator-pager-dot:focus-visible {
    border-color: var(--ochre, var(--charcoal));
    outline: none;
  }

  .calculator-pager-dot.is-active {
    background: var(--ochre, var(--charcoal));
    border-color: var(--ochre, var(--charcoal));
    transform: scale(1.1);
  }

  .calculator-pager-dot:focus-visible {
    box-shadow: 0 0 0 3px rgba(206, 61, 32, 0.25);
  }

}

@media (min-width: 921px) {
  .calculator-swap-hint,
  .calculator-back-hint {
    display: none !important;
  }
}

@media (max-width: 700px) {
  .calculator-grid {
    --calculator-first-row-box-height: 158px;
  }

  .sidebar-nav {
    gap: 8px;
  }

  .nav-tools {
    gap: 6px;
  }

  .theme-toggle {
    width: max-content;
    flex: 0 0 auto;
  }

  .theme-toggle-button {
    width: var(--theme-toggle-button-size);
    height: var(--theme-toggle-button-size);
    min-width: var(--theme-toggle-button-size);
    min-height: var(--theme-toggle-button-size);
  }

  .calculator-card-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .calculator-header-actions {
    justify-content: flex-start;
  }

  .result-panel .calculator-card-header,
  .result-panel .calculator-section .calculator-card-header {
    align-items: center;
    flex-direction: row;
  }

  .result-panel .calculator-card-header h3,
  .result-panel .calculator-section .calculator-card-header h3 {
    white-space: normal;
  }

  .result-panel .calculator-header-actions {
    justify-content: flex-end;
    margin-left: auto;
  }

  .result-panel .handoff-view-select {
    margin-left: auto;
  }

  .workspace {
    padding: 16px;
    padding-bottom: calc(var(--bottom-bar-height, 74px) + env(safe-area-inset-bottom, 0px) + 12px);
  }

  .app-shell.sidebar-collapsed .workspace {
    padding-bottom: 16px;
  }

  .topbar,
  .panel-heading,
  .upload-strip,
  .risk-visual,
  .action-row {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .model-output-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .model-output-tile {
    grid-template-rows: 28px 54px minmax(24px, auto) 18px;
    gap: 6px;
    height: var(--calculator-first-row-box-height);
    min-height: var(--calculator-first-row-box-height);
    padding: 8px 5px;
  }

  .csv-dropzone {
    height: var(--calculator-first-row-box-height);
    min-height: var(--calculator-first-row-box-height);
    padding: 10px 8px;
    gap: 6px;
  }

  .csv-dropzone-icon {
    width: 42px;
    height: 42px;
  }

  .csv-dropzone-title {
    font-size: 0.8rem;
    line-height: 1.15;
  }

  .csv-dropzone-file {
    padding: 3px 8px;
    font-size: 0.7rem;
    line-height: 1.15;
  }

  .model-output-label {
    min-height: 28px;
    font-size: 0.58rem;
    line-height: 1.15;
  }

  .model-output-stat {
    width: 54px;
    height: 54px;
  }

  .model-output-stat span {
    font-size: 0.9rem;
  }

  .model-output-tile .model-output-tier {
    font-size: 0.58rem;
  }

  .classification-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .classification-card {
    gap: 8px;
    padding: 9px 7px;
  }

  .classification-card-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .classification-card-top span {
    font-size: 0.64rem;
    line-height: 1.15;
  }

  .classification-card-top strong {
    font-size: 0.96rem;
  }

  .classification-status span {
    font-size: 0.62rem;
    line-height: 1.15;
  }

  .classification-track {
    height: 18px;
    margin: 28px 0 32px;
  }

  .classification-band-label {
    font-size: 0.43rem;
  }

  .classification-cutoff-marker {
    top: -11px;
    bottom: -11px;
  }

  .classification-cutoff-badge {
    min-height: 15px;
    padding: 1px 4px;
    font-size: 0.5rem;
  }

  .classification-score-marker {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
  }

  .classification-score-marker i {
    bottom: calc(100% + 4px);
    padding: 2px 4px;
    font-size: 0.55rem;
  }

  .member-row {
    grid-template-columns: 1fr;
  }

  .risk-ring {
    width: 160px;
    height: 160px;
    margin: 0 auto;
  }

  .driver-row {
    grid-template-columns: 1fr;
  }

  .csv-model-results {
    grid-template-columns: 1fr;
  }

  .csv-dropzone {
    padding: 22px 16px;
  }
}

@media (max-width: 920px) {
  @container result-panel (max-width: 430px) {
    .result-panel > .calculator-card-header {
      gap: 10px;
    }

    .result-panel > .calculator-card-header h3 {
      flex: 1 1 auto;
      font-size: clamp(1.08rem, 5.4cqw, 1.35rem);
      min-width: 0;
    }

    .result-panel > .calculator-card-header .calculator-header-actions {
      flex: 0 1 auto;
      flex-wrap: nowrap;
      gap: clamp(5px, 1.7cqw, 8px);
      min-width: 0;
    }

    .result-panel > .calculator-card-header .model-output-learn-more,
    .result-panel .right-panel-footer #copy-summary {
      min-height: clamp(25px, 7.2cqw, 30px);
      padding-inline: clamp(5px, 2.1cqw, 10px);
      font-size: clamp(0.64rem, 2.3cqw, 0.82rem);
    }
  }

  @container result-panel (max-width: 350px) {
    .result-panel > .calculator-card-header {
      gap: 8px;
    }

    .result-panel > .calculator-card-header .model-output-learn-more,
    .result-panel .right-panel-footer #copy-summary {
      min-height: 25px;
      padding-inline: 5px;
      font-size: 0.64rem;
    }
  }

  @container result-panel (max-width: 300px) {
    .result-panel > .calculator-card-header {
      align-items: flex-start;
      flex-wrap: wrap;
    }

    .result-panel > .calculator-card-header .calculator-header-actions {
      flex-basis: 100%;
      justify-content: flex-start;
      margin-left: 0;
    }
  }
}

/* =============================================================
   Tactile bump feedback
   =============================================================
   Consistent press / hover response across input types: mouse
   (Windows/macOS/Linux), trackpad, finger touch, and pen. Pointer
   devices receive a subtle hover lift and an active press dip;
   touch devices receive a one-shot scale bump applied by app.js
   (and a short haptic vibration where the browser supports it).
   Honours prefers-reduced-motion. */
.primary-button,
.secondary-button,
.icon-button,
.subnav-button,
.step-button,
.csv-model-card,
.calculator-pager-dot,
.theme-toggle-button,
.sidebar-toggle,
.bottom-bar-toggle,
.fullscreen-toggle,
.return-position-button,
.calculator-back-hint,
.calculator-swap-hint,
.nav-item,
.nav-settings-toggle {
  transition: transform 140ms ease,
              box-shadow 160ms ease,
              background 150ms ease,
              border-color 150ms ease,
              color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .primary-button:hover,
  .secondary-button:hover,
  .icon-button:hover,
  .subnav-button:hover,
  .step-button:hover,
  .csv-model-card:hover,
  .theme-toggle-button:hover,
  .sidebar-toggle:hover,
  .bottom-bar-toggle:hover,
  .fullscreen-toggle:hover,
  .return-position-button:hover,
  .calculator-back-hint:hover,
  .calculator-swap-hint:hover,
  .nav-settings-toggle:hover {
    transform: translateY(-1px);
  }
}

.primary-button:active,
.secondary-button:active,
.icon-button:active,
.subnav-button:active,
.step-button:active,
.csv-model-card:active,
.calculator-pager-dot:active,
.theme-toggle-button:active,
.sidebar-toggle:active,
.bottom-bar-toggle:active,
.fullscreen-toggle:active,
.return-position-button:active,
.calculator-back-hint:active,
.calculator-swap-hint:active,
.nav-item:active,
.nav-settings-toggle:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 70ms;
}

.bump-flash {
  animation: bump-flash 260ms cubic-bezier(0.34, 1.56, 0.64, 1) 1;
}

@keyframes bump-flash {
  0%   { transform: scale(1); }
  35%  { transform: scale(0.94); }
  70%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .primary-button,
  .secondary-button,
  .icon-button,
  .subnav-button,
  .step-button,
  .csv-model-card,
  .calculator-pager-dot,
  .theme-toggle-button,
  .sidebar-toggle,
  .bottom-bar-toggle,
  .fullscreen-toggle,
.return-position-button,
.calculator-back-hint,
.calculator-swap-hint,
.nav-item,
.nav-settings-toggle {
    transition: background 150ms ease,
                border-color 150ms ease,
                color 150ms ease;
  }
  .primary-button:hover,
  .secondary-button:hover,
  .icon-button:hover,
  .subnav-button:hover,
  .step-button:hover,
  .csv-model-card:hover,
  .theme-toggle-button:hover,
  .sidebar-toggle:hover,
  .bottom-bar-toggle:hover,
  .fullscreen-toggle:hover,
  .return-position-button:hover,
  .calculator-back-hint:hover,
  .calculator-swap-hint:hover,
  .nav-settings-toggle:hover,
  .primary-button:active,
  .secondary-button:active,
  .icon-button:active,
  .subnav-button:active,
  .step-button:active,
  .csv-model-card:active,
  .calculator-pager-dot:active,
  .theme-toggle-button:active,
  .sidebar-toggle:active,
  .bottom-bar-toggle:active,
  .fullscreen-toggle:active,
  .return-position-button:active,
.calculator-back-hint:active,
.calculator-swap-hint:active,
.nav-item:active,
.nav-settings-toggle:active {
    transform: none;
  }
  .bump-flash {
    animation: none;
  }
}

/* =============================================================
   Skip-to-content link
   =============================================================
   Hidden off-screen until it receives focus (the first Tab from a
   fresh page load). Lets keyboard / screen-reader users bypass the
   sidebar and jump straight into the active workspace panel. */
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--primary, #ce3d20);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  transform: translateY(-200%);
  transition: transform 160ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid color-mix(in srgb, #ffffff 70%, transparent);
  outline-offset: 2px;
}

/* The CSV dropzone label is now focusable (tabindex=0). It already
   has a :focus-within ring, but ensure the same ring fires when the
   label itself is the focused element (older browsers without
   :focus-within reliability on labels). */
.csv-dropzone:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accessible-ochre) 8%, #ffffff);
  box-shadow: 0 0 0 4px rgba(206, 61, 32, 0.18);
}
