/* ==========================================================================
   Agescape Webapp: Design System & Stylesheet (Spec v2.0)
   Mobile-First, Graph-First. Light editorial theme matching rezaalipour.com
   (Newsreader serif headlines, Plus Jakarta Sans body, ink/slate palette).
   ========================================================================== */

[hidden] {
  display: none !important;
}

:root {
  /* Surface colors (light editorial, from rezaalipour.com) */
  --bg-page: #fafaf9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-overlay: rgba(250, 250, 249, 0.92);
  --bg-mini: #f1f5f9;

  /* Borders & accents */
  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-card: #e2e8f0;
  --border-highlight: rgba(3, 105, 161, 0.45);

  /* Typography */
  --text-main: #292524;
  --text-sub: #475569;
  --text-muted: #64748b;
  --text-highlight: #0f172a;

  /* Pinned Spec v2 Color System */
  --color-mouse: #2563eb;       /* Strong Blue */
  --color-human: #7c3aed;       /* Muted Purple */
  --color-nmr: #ea580c;         /* Warm Orange */
  
  --color-dir-up: #dc2626;      /* Vermillion */
  --color-dir-down: #475569;    /* Blue-Grey */
  
  --color-tissue-lung: #0284c7;   /* Distinct Cyan-Blue */
  --color-tissue-kidney: #0d9488; /* Distinct Teal */
  --color-tissue-neutral: #94a3b8;/* Ineligible Tissues (recede on light bg) */

  --color-verdict-agree: #059669;
  --color-verdict-partial: #d97706;
  --color-verdict-lowpower: #d97706;

  --tost-band-fill: rgba(234, 88, 12, 0.15);
  --tost-band-stroke: rgba(234, 88, 12, 0.55);

  /* Sizing & Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Editorial serif headlines (matches rezaalipour.com display type) */
.chapter-headline, .graph-title, .panel-title, #methods-title {
  font-family: var(--font-serif);
  letter-spacing: -0.02em;
  color: var(--text-highlight);
}

/* Tabular numbers for all stats, axes, and tables */
.font-mono, td, .readout-val, .sha-short, .stat-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Navigation Bar & Progress Rail
   ========================================================================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  height: 58px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text-highlight);
}

.brand-pill {
  font-size: 0.72rem;
  font-weight: 500;
  color: #0369a1;
  background: rgba(3, 105, 161, 0.08);
  border: 1px solid rgba(3, 105, 161, 0.28);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.progress-rail {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rail-step {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.rail-step .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-card);
  transition: all 0.2s ease;
}

.rail-step:hover, .rail-step.active {
  color: var(--text-main);
}

.rail-step.active .dot {
  background: #0369a1;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-text:hover {
  color: var(--text-highlight);
  background: rgba(15, 23, 42, 0.04);
}

/* ==========================================================================
   Page Layout & Chapters
   ========================================================================== */
.page-container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 64px;
}

.chapter {
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-margin-top: 76px;
}

.chapter-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.chapter-num {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  color: #0369a1;
  letter-spacing: 0.06em;
}

.chapter-headline {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-highlight);
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin-top: 4px;
}

/* ==========================================================================
   Intro Hero (product landing block)
   ========================================================================== */
.hero-intro {
  scroll-margin-top: 76px;
  padding: 72px 24px 56px;
  background:
    radial-gradient(1100px 380px at 12% -10%, rgba(3, 105, 161, 0.09), transparent 60%),
    var(--bg-page);
  border-bottom: 1px solid var(--border-subtle);
}

.hero-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0369a1;
  background: rgba(3, 105, 161, 0.08);
  border: 1px solid rgba(3, 105, 161, 0.25);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
}

.hero-headline {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 5.5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text-highlight);
  margin: 0;
}

.hero-sub {
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  line-height: 1.6;
  color: var(--text-sub);
  max-width: 640px;
  margin: 0;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--text-sub);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chip strong {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: #0369a1;
}

.hero-cta {
  display: inline-block;
  margin-top: 10px;
  padding: 13px 28px;
  background: #0369a1;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: background 0.15s ease;
}

.hero-cta:hover {
  background: #075985;
}

@media (max-width: 480px) {
  .hero-intro {
    padding: 48px 18px 40px;
  }
  .hero-cta {
    width: 100%;
    text-align: center;
  }
}

/* ==========================================================================
   Graph Blocks (Cards)
   ========================================================================== */
.graph-block {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  position: relative;
}

.graph-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  row-gap: 6px;
}

.graph-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.graph-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.drawer-toggle, .btn-compare {
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 32px;
}

.drawer-toggle:hover, .btn-compare:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-highlight);
}

.chart-canvas-wrap {
  width: 100%;
  position: relative;
  overflow: hidden;
}

.echart-container {
  width: 100%;
}

.graph-support {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
}

/* Compare container for swapping published PNG */
.compare-container {
  background: #ffffff;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}

.compare-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #0369a1;
  margin-bottom: 10px;
}

.compare-close {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.2rem;
  cursor: pointer;
}

.compare-img {
  width: 100%;
  border-radius: 4px;
  display: block;
}

/* ==========================================================================
   Story Expanders
   ========================================================================== */
.story-expander {
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 6px;
}

.expander-summary {
  font-size: 0.84rem;
  font-weight: 600;
  color: #0369a1;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.expander-content {
  padding-top: 12px;
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expander-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   Provenance Drawers
   ========================================================================== */
.drawer {
  background: #ffffff;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.drawer-header h4 {
  font-size: 0.85rem;
  color: #0369a1;
}

.drawer-close {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.2rem;
  cursor: pointer;
}

.provenance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-bottom: 12px;
}

.provenance-grid code {
  color: #475569;
  background: rgba(15, 23, 42, 0.05);
  padding: 2px 5px;
  border-radius: 3px;
}

.btn-download {
  background: rgba(3, 105, 161, 0.08);
  border: 1px solid rgba(3, 105, 161, 0.32);
  color: #0369a1;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: 8px;
  transition: all 0.2s ease;
}

.btn-download:hover {
  background: rgba(3, 105, 161, 0.15);
}

/* ==========================================================================
   Chapter 5: Power Map & Readout Bar
   ========================================================================== */
.power-grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.power-panel {
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.panel-subtitle {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 8px;
  text-align: center;
}

.power-readout-bar {
  background: #ffffff;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.readout-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}

.readout-label {
  color: var(--text-muted);
}

.readout-val {
  color: var(--text-highlight);
  font-weight: 600;
}

.badge-verdict {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-lowpower {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-floor {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

/* Constructive Turn closing strip */
.closing-strip {
  margin-top: 16px;
}

.constructive-box {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
  border: 1px solid rgba(3, 105, 161, 0.32);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.constructive-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.constructive-text h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 6px;
}

.constructive-text p {
  font-size: 0.86rem;
  color: var(--text-sub);
  line-height: 1.5;
}

/* ==========================================================================
   Slide-Over Unit Panel (Section 8)
   ========================================================================== */
.slideover-panel {
  position: fixed;
  top: 0;
  right: -460px;
  width: 440px;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid var(--border-card);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.18);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.slideover-panel.open {
  right: 0;
}

.panel-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: rgba(15, 23, 42, 0.03);
}

.panel-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #0369a1;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-highlight);
  margin-top: 2px;
}

.panel-close {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.panel-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 10px;
}

.panel-stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: 6px;
}

.panel-meta-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(15, 23, 42, 0.04);
  padding-bottom: 4px;
}

.meta-label {
  color: var(--text-muted);
}

.text-warning {
  color: #f59e0b;
  font-weight: 600;
}

.inline-link {
  color: #0369a1;
  text-decoration: underline;
}

.panel-table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-search input {
  width: 100%;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 0.8rem;
  outline: none;
  margin-bottom: 10px;
}

.panel-table-wrap {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.unit-gene-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  text-align: left;
}

.unit-gene-table th {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-muted);
  padding: 8px 10px;
  position: sticky;
  top: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.unit-gene-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.03);
  color: var(--text-sub);
}

.unit-gene-table tr:hover td {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-main);
}

/* ==========================================================================
   Methods Overlay Modal
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  background: #ffffff;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.15rem;
  color: #0369a1;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body-content {
  padding: 24px;
  overflow-y: auto;
  overflow-x: auto;
  font-size: 0.86rem;
  color: var(--text-sub);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body-content h3 {
  font-size: 0.95rem;
  color: var(--text-highlight);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
  margin-top: 8px;
}

.methods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 6px 0;
}

.methods-table th, .methods-table td {
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.methods-table th {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-main);
}

.methods-list {
  padding-left: 20px;
}

.methods-list li {
  margin-bottom: 4px;
}

.citation-block {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #475569;
  overflow-x: auto;
}

.license-line {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Author & Conversion Footer
   ========================================================================= */
.author-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 36px;
}

.author-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.author-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-highlight);
}

.author-role {
  font-size: 0.88rem;
  color: #0369a1;
  font-weight: 500;
}

.author-links {
  display: flex;
  gap: 16px;
  margin: 10px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.author-links a {
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  transition: all 0.2s ease;
}

.author-links a:hover {
  background: rgba(3, 105, 161, 0.12);
  border-color: #0369a1;
  color: #0369a1;
}

.footer-note {
  font-size: 0.85rem;
  color: var(--text-sub);
  max-width: 600px;
}

.footer-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Story strip & chapter sub-lines (zero-jargon narrative layer)
   ========================================================================== */
.story-strip {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 8px;
}

.story-strip-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-highlight);
  letter-spacing: -0.015em;
  margin-bottom: 16px;
}

.story-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: step;
}

.story-step-link {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.55;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.story-step-link:hover {
  border-color: var(--border-highlight);
  box-shadow: 0 4px 16px rgba(3, 105, 161, 0.12);
}

.story-step-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 105, 161, 0.1);
  color: #0369a1;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 50%;
  margin-top: 2px;
}

.story-step-body strong {
  color: var(--text-highlight);
}

.chapter-sub {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-sub);
  margin-top: 8px;
  max-width: 720px;
}

/* Species browser (G14) */
.species-browser {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.species-search {
  width: 100%;
  max-width: 420px;
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  outline: none;
  min-height: 44px;
}

.species-search:focus {
  border-color: var(--border-highlight);
}

.species-table-wrap {
  max-height: 420px;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.species-latin {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.badge-sc {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(3, 105, 161, 0.1);
  color: #0369a1;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

.species-none {
  color: var(--text-muted);
  font-size: 0.82rem;
}

@media (max-width: 480px) {
  .story-strip {
    padding: 28px 16px 4px;
  }
  .story-step-link {
    padding: 12px 14px;
    font-size: 0.9rem;
  }
}

/* Tap-target floor (44px minimum) & mobile navigation */
.rail-step {
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.drawer-toggle, .btn-compare, .btn-download {
  min-height: 44px;
}

.drawer-close, .compare-close, .panel-close, .modal-close-btn {
  min-width: 44px;
  min-height: 44px;
}

.expander-summary {
  min-height: 44px;
  display: flex;
  align-items: center;
}

@media (max-width: 900px) {
  .top-nav {
    flex-wrap: wrap;
    row-gap: 0;
    padding: 8px 12px;
    height: auto;
    min-height: 58px;
  }
  .progress-rail {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }
  .chapter, .hero-intro {
    scroll-margin-top: 112px;
  }
}

/* ==========================================================================
   Mobile Responsiveness (360px design surface)
   ========================================================================= */
@media (max-width: 900px) {
  .power-grid-container {
    grid-template-columns: 1fr;
  }
  .rail-step .rail-label {
    display: none;
  }
  .slideover-panel {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 640px) {
  .chapter-headline {
    font-size: 1.25rem;
  }
  .graph-block {
    padding: 16px;
  }
  .top-nav {
    padding: 10px 14px;
  }
  .power-readout-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.species-table-wrap::after { content: ""; display: block; height: 2px; background: linear-gradient(90deg, rgba(15,23,42,0.18), transparent); }

.badge-lowpower { color: #92400e; background: #fffbeb; border-color: #d97706; }
.badge-floor { color: #065f46; background: #ecfdf5; border-color: #059669; }
.text-warning { color: #92400e; }
.slideover-panel { visibility: hidden; }
.slideover-panel.open { visibility: visible; }
.accessible-chart-select {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--border-card); border-radius: var(--radius-md);
  background: var(--bg-card); color: var(--text-main); font: inherit;
}
.load-error { padding: 16px; color: #991b1b; background: #fef2f2; border: 1px solid #dc2626; }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 500; padding: 12px; background: #fff; color: #075985; }
.skip-link:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #075985; outline-offset: 3px;
}
@media (max-width: 640px) {
  .graph-title-row { gap: 10px; }
  .graph-controls { width: 100%; }
  .graph-support { font-size: 0.88rem; line-height: 1.55; }
}

/* Explicit chart container dimensions (migrated from inline styles for strict CSP) */
#chart-g0 { height: 380px; }
#chart-g4-mini { height: 180px; }
#chart-g1 { height: 480px; }
#chart-g3-scatter { height: 420px; }
#chart-g3-lollipop { height: 220px; }
.sub-chart-wrap { margin-top: 24px; }
#chart-g2 { height: 160px; }
.guard-img { max-width: 100%; border-radius: 6px; margin-top: 8px; }
#chart-g4-full { height: 240px; }
#chart-g6 { height: 480px; }
#chart-g7 { height: 600px; }
#chart-g9 { height: 520px; }
#chart-g10 { height: 240px; }
#chart-g15 { height: 340px; }
#chart-g11 { height: 180px; }
#chart-g14 { height: 360px; }
#chart-g12 { height: 280px; }
#chart-g13-low, #chart-g13-mid, #chart-g13-high { height: 280px; }
#chart-g16 { height: 640px; }
#chart-panel-bar { height: 90px; width: 100%; }
.hero-subtitle-note { margin-top: 6px; font-size: 0.95rem; color: var(--text-sub); }
.ai-disclosure { font-size: 0.88rem; line-height: 1.6; color: var(--text-sub); background: var(--bg-mini); padding: 12px; border-radius: var(--radius-sm); border-left: 3px solid var(--border-highlight); margin-top: 8px; }
.text-dir-up { color: var(--color-dir-up); font-weight: 600; }
.text-dir-down { color: var(--color-dir-down); font-weight: 600; }

