/* ============================================================
   Design Tokens – Material Design 3 (Light scheme)
   --g-* and legacy --shadow-*, --radius-*, --border,
   --text-* variables are kept for header/footer compatibility.
   Content styles use --md-* tokens directly.
   ============================================================ */
:root {
  /* ── HostCell brand palette (header/footer – do not remove) */
  --g-blue:   #4285f4;
  --g-red:    #ea4335;
  --g-yellow: #fbbc05;
  --g-green:  #34a853;

  /* ── MD3 Primary (harmonised with HostCell blue) */
  --md-primary:              #1a6fe8;
  --md-on-primary:           #ffffff;
  --md-primary-container:    #d6e4ff;
  --md-on-primary-container: #001946;

  /* ── MD3 Secondary */
  --md-secondary:              #555f71;
  --md-on-secondary:           #ffffff;
  --md-secondary-container:    #d9e3f8;
  --md-on-secondary-container: #111c2b;

  /* ── MD3 Tertiary (green) */
  --md-tertiary:              #006e1c;
  --md-on-tertiary:           #ffffff;
  --md-tertiary-container:    #b7f0bb;
  --md-on-tertiary-container: #002105;

  /* ── MD3 Error */
  --md-error:           #ba1a1a;
  --md-error-container: #ffdad6;

  /* ── MD3 Surface hierarchy */
  --md-surface:                   #f8f9fa;
  --md-on-surface:                #191c20;
  --md-on-surface-variant:        #43474e;
  --md-surface-container-lowest:  #ffffff;
  --md-surface-container-low:     #f1f4f9;
  --md-surface-container:         #eaecf0;
  --md-surface-container-high:    #e4e7eb;
  --md-surface-container-highest: #dee1e5;

  /* ── MD3 Outline */
  --md-outline:         #73777f;
  --md-outline-variant: #c3c6cf;

  /* ── MD3 Shape scale */
  --md-shape-extra-small: 4px;
  --md-shape-small:       8px;
  --md-shape-medium:      12px;
  --md-shape-large:       16px;
  --md-shape-extra-large: 28px;
  --md-shape-full:        9999px;

  /* ── MD3 Elevation */
  --md-elev1: 0 1px 2px rgba(0,0,0,.09), 0 1px 3px 1px rgba(0,0,0,.06);
  --md-elev2: 0 1px 2px rgba(0,0,0,.09), 0 2px 6px 2px rgba(0,0,0,.06);
  --md-elev3: 0 1px 3px rgba(0,0,0,.09), 0 4px 8px 3px rgba(0,0,0,.06);

  /* ── Legacy aliases (referenced by header / footer – keep unchanged) */
  --bg:           #f8f9fa;
  --surface:      #ffffff;
  --surface-alt:  #f5f9ff;
  --border:       #e0e0e0;
  --border-focus: #4285f4;
  --text-primary:   #202124;
  --text-secondary: #5f6368;
  --shadow-sm: 0 1px 3px rgba(60,64,67,.12), 0 1px 2px rgba(60,64,67,.08);
  --shadow-md: 0 4px 12px rgba(60,64,67,.15), 0 2px 4px rgba(60,64,67,.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --hc-header-height: 84px;
  --hc-footer-height: 56px;
}

/* ── Reset ──────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Roboto", sans-serif;
  background: var(--md-surface);
  color: var(--md-on-surface);
}

body {
  background:
    radial-gradient(circle at 0% 0%,   rgba(26,111,232,.06) 0%, transparent 38%),
    radial-gradient(circle at 100% 0%, rgba(0,110,28,.05)   0%, transparent 32%),
    var(--md-surface);
}

a { color: inherit; }

/* ── Layout shell ───────────────────────────────────────── */
.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding-top:    calc(var(--hc-header-height) + 22px);
  padding-bottom: calc(var(--hc-footer-height) + 28px);
}

/* ── Shared surface baseline ────────────────────────────── */
.control-panel,
.plot-card,
.explain-card,
.hero-card,
.hero-copy {
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  box-shadow: var(--md-elev1);
}

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.hero-copy {
  border-radius: var(--md-shape-extra-large);
  padding: 30px 32px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px 12px;
  border-radius: var(--md-shape-full);
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 14px;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--md-on-surface);
}

.lede {
  margin: 0;
  max-width: 60ch;
  color: var(--md-on-surface-variant);
  font-size: 1rem;
  line-height: 1.6;
}

.hero-card {
  border-radius: var(--md-shape-extra-large);
  padding: 20px;
  display: grid;
  gap: 12px;
  background: var(--md-surface-container-low);
  border-color: var(--md-outline-variant);
}

.hero-metric {
  padding: 16px 18px;
  border-radius: var(--md-shape-large);
  background: var(--md-primary-container);
  border: none;
}

.hero-metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--md-on-primary-container);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: .72;
}

.hero-metric strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--md-on-primary-container);
}

/* ── Reactor diagram (hero-card) ────────────────────────── */
.hero-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reactor-figure {
  margin: 0;
  padding: 0;
  flex: 1;
}

.reactor-svg {
  width: 100%;
  height: auto;
  display: block;
}

.r-port-label {
  fill: #4285f4;
  font-size: 9px;
  font-weight: 600;
  font-family: "IBM Plex Sans", sans-serif;
}

.r-port-label-out {
  fill: #ee8b42;
}

/* Mode-conditional elements */
.r-inlet,
.r-outlet,
.r-vmax,
.r-v0m  { display: none; }

.mode-fedbatch .r-inlet,
.mode-continuous .r-inlet  { display: block; }
.mode-continuous .r-outlet { display: block; }
.mode-fedbatch .r-vmax,
.mode-fedbatch .r-v0m      { display: block; }

/* Liquid level per mode (translateY = 124 × (1 − fill_fraction)) */
.mode-batch      #r-liq-inner { transform: translateY(43px); }   /* 65% */
.mode-continuous #r-liq-inner { transform: translateY(31px); }   /* 75% */
.mode-fedbatch   #r-liq-inner { animation: r-fb-rise 7s ease-in-out infinite alternate; }

@keyframes r-fb-rise {
  from { transform: translateY(81px); }  /* 35% */
  to   { transform: translateY(19px); }  /* 85% */
}

/* Agitator */
#r-impeller {
  transform-origin: 130px 118px;
  animation: r-spin 2.7s linear infinite;
}
@keyframes r-spin { to { transform: rotate(360deg); } }

/* Cells */
.r-cell { animation: r-cell-pulse 3s ease-in-out infinite; }
.r-cell:nth-child(2)  { animation-delay: -0.30s; }
.r-cell:nth-child(3)  { animation-delay: -0.60s; }
.r-cell:nth-child(4)  { animation-delay: -0.90s; }
.r-cell:nth-child(5)  { animation-delay: -1.20s; }
.r-cell:nth-child(6)  { animation-delay: -1.50s; }
.r-cell:nth-child(7)  { animation-delay: -1.80s; }
.r-cell:nth-child(8)  { animation-delay: -2.10s; }
.r-cell:nth-child(9)  { animation-delay: -2.40s; }
.r-cell:nth-child(10) { animation-delay: -2.70s; }
@keyframes r-cell-pulse {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 0.95; }
}

/* Flow particles */
.r-flow-in  { animation: r-flow-right 1.35s ease-in-out infinite; }
.r-flow-out { animation: r-flow-right 1.5s ease-in-out infinite; }
.r-feed-drop { animation: r-feed-drop 1.6s ease-in infinite; }
@keyframes r-flow-right {
  0%   { transform: translateX(-8px); opacity: 0; }
  25%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { transform: translateX(14px); opacity: 0; }
}
@keyframes r-feed-drop {
  0%   { transform: translateY(-2px) scale(0.9); opacity: 0; }
  18%  { opacity: 0.95; }
  100% { transform: translateY(22px) scale(1.05); opacity: 0; }
}

/* Model / mode meta row */
.reactor-meta {
  display: flex;
  gap: 8px;
}

.reactor-meta-item {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--md-shape-medium);
  background: var(--md-primary-container);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reactor-meta-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--md-on-primary-container);
  opacity: 0.72;
}

.reactor-meta-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--md-on-primary-container);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main layout ────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

/* ── Control panel ──────────────────────────────────────── */
.control-panel {
  border-radius: var(--md-shape-extra-large);
  padding: 22px;
  position: sticky;
  top: calc(var(--hc-header-height) + 20px);
  align-self: start;
  background: var(--md-surface-container-low);
  border: 1px solid var(--md-outline-variant);
  box-shadow: none;
}

.panel-section + .panel-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--md-outline-variant);
}

/* ── Section / card headings ────────────────────────────── */
.section-title h2,
.card-header h2,
.teaching-card h3,
.note-panel h2 {
  margin: 0 0 6px;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--md-on-surface);
}

.section-title p,
.card-header p,
.note-panel p,
.teaching-card p {
  margin: 0;
  color: var(--md-on-surface-variant);
  line-height: 1.55;
}

/* ── Control list ───────────────────────────────────────── */
.control-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.control {
  display: grid;
  gap: 6px;
}

.control span {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-on-surface);
}

/* ── MD3 Slider ─────────────────────────────────────────── */
.control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;       /* click-target height */
  background: transparent;
  cursor: pointer;
  outline: none;
}

/* WebKit – track */
.control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-highest);
}

/* WebKit – thumb */
.control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--md-primary);
  border: none;
  margin-top: -8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2), 0 0 0 4px rgba(26,111,232,.10);
  transition: box-shadow 150ms ease, transform 100ms ease;
}
.control input[type="range"]:hover::-webkit-slider-thumb {
  box-shadow: 0 1px 3px rgba(0,0,0,.2), 0 0 0 8px rgba(26,111,232,.12);
}
.control input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 1px 3px rgba(0,0,0,.2), 0 0 0 10px rgba(26,111,232,.18);
  transform: scale(1.05);
}

/* Firefox – track */
.control input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-highest);
}

/* Firefox – thumb */
.control input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--md-primary);
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  cursor: pointer;
}
.control input[type="range"]:hover::-moz-range-thumb {
  box-shadow: 0 1px 3px rgba(0,0,0,.2), 0 0 0 5px rgba(26,111,232,.12);
}

/* ── MD3 Outlined Select ────────────────────────────────── */
.select-control {
  width: 100%;
  min-height: 44px;
  padding: 0 36px 0 14px;
  border-radius: var(--md-shape-extra-small);
  border: 1px solid var(--md-outline);
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%2373777f'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  -webkit-appearance: none;
  appearance: none;
  color: var(--md-on-surface);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 150ms ease;
}
.select-control:hover {
  border-color: var(--md-on-surface);
}
.select-control:focus {
  outline: none;
  border: 2px solid var(--md-primary);
  padding-left: 13px;
}

/* ── Output badge ───────────────────────────────────────── */
.control output {
  justify-self: end;
  padding: 2px 9px;
  border-radius: var(--md-shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.parameter-hidden { display: none; }

/* ── Note / Lectura rápida panel ────────────────────────── */
.note-panel {
  padding: 16px 18px;
  border-radius: var(--md-shape-large);
  background: var(--md-secondary-container);
  border: 1px solid rgba(85,95,113,.20);
}
.note-panel h2 { color: var(--md-on-secondary-container); }
.note-panel p  { color: var(--md-on-secondary-container); opacity: .82; }

/* ── Content column ─────────────────────────────────────── */
.content { display: grid; gap: 20px; }

/* ── Metrics grid ───────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* MD3 Filled Card with left tonal accent */
.metric-card {
  border-radius: var(--md-shape-large);
  padding: 16px 18px 16px 22px;
  background: var(--md-surface-container-low);
  border: 1px solid var(--md-outline-variant);
  box-shadow: none;
  position: relative;
  overflow: hidden;
  transition: box-shadow 150ms ease;
}
.metric-card:hover { box-shadow: var(--md-elev1); }

/* Left accent bar replaces the top border */
.metric-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--md-primary);
}
.metric-card:nth-child(2)::before { background: var(--g-red);    }
.metric-card:nth-child(3)::before { background: var(--g-yellow); }
.metric-card:nth-child(4)::before { background: var(--g-green);  }
.metric-card:nth-child(5)::before { background: #7e57c2;         }

.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: .01em;
}

.metric-card strong {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--md-on-surface);
  display: block;
}

/* ── Plot cards (MD3 Elevated Card) ─────────────────────── */
.plot-card {
  border-radius: var(--md-shape-extra-large);
  padding: 22px 22px 8px;
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  box-shadow: var(--md-elev1);
  transition: box-shadow 150ms ease;
}
.plot-card:hover { box-shadow: var(--md-elev2); }

.plot { min-height: 400px; }

@media (max-width: 680px) {
  .plot { min-height: 260px; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 12px;
}

/* ── Guide section: banner + collapsible panel ───────────── */
.guide-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Banner — always visible, acts as toggle */
.guide-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 26px 28px;
  border-radius: var(--md-shape-extra-large);
  background: var(--md-primary-container);
  border: 1px solid rgba(26,111,232,.15);
  box-shadow: var(--md-elev1);
  cursor: pointer;
  user-select: none;
  transition: box-shadow 200ms ease, border-radius 300ms ease;
}
.guide-banner:hover {
  box-shadow: var(--md-elev2);
}
.guide-banner[aria-expanded="true"] {
  border-radius: var(--md-shape-extra-large) var(--md-shape-extra-large) 0 0;
  border-bottom-color: transparent;
  box-shadow: none;
}
.guide-banner:focus-visible {
  outline: 3px solid var(--md-primary);
  outline-offset: 2px;
}

.guide-banner-main { flex: 1 1 auto; }

.guide-kicker {
  display: inline-block;
  margin-bottom: 0.4rem;
  color: var(--md-on-primary-container);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: .70;
}

.guide-title {
  margin: 0 0 0.36rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--md-on-primary-container);
}

.guide-copy {
  margin: 0;
  color: var(--md-on-primary-container);
  line-height: 1.55;
  opacity: .82;
}

/* Topic preview chips inside banner */
.guide-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.guide-topic {
  padding: 3px 11px;
  border-radius: var(--md-shape-full);
  background: rgba(26,111,232,.12);
  color: var(--md-on-primary-container);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Right-side CTA column */
.guide-banner-action {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 4px 0;
  color: var(--md-on-primary-container);
}

.guide-action-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  opacity: .85;
}

.guide-chevron {
  transition: transform 380ms cubic-bezier(0.4, 0, 0.2, 1);
}
.guide-banner[aria-expanded="true"] .guide-chevron {
  transform: rotate(180deg);
}

/* Collapsible panel */
.guide-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 450ms cubic-bezier(0.4, 0, 0.2, 1);
}
.guide-panel.open {
  grid-template-rows: 1fr;
}

.guide-panel-inner {
  overflow: hidden;
  min-height: 0;
  /* top border connects panel to open banner */
  border-radius: 0 0 var(--md-shape-extra-large) var(--md-shape-extra-large);
  border: 1px solid rgba(26,111,232,.15);
  border-top: none;
  background: var(--md-surface-container-lowest);
}

.guide-panel-inner > .teaching-panel {
  padding: 24px;
}

/* ── Teaching divider (group separator inside panel) ─────── */
.teaching-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin: 6px 0 2px;
  padding: 14px 0;
  color: var(--md-on-surface-variant);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.teaching-divider::before,
.teaching-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--md-outline-variant);
}
.teaching-divider span { white-space: nowrap; }

/* ── Teaching panel grid ────────────────────────────────── */
.teaching-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-width: 980px;
  margin: 0 auto;
}

.teaching-card.span-2 { grid-column: span 1; }

@media (max-width: 1024px) {
  .teaching-panel {
    grid-template-columns: 1fr;
  }
  .teaching-card.span-2 { grid-column: span 1; }
}

/* MD3 Outlined Card */
.teaching-card {
  border-radius: var(--md-shape-extra-large);
  padding: 22px;
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  box-shadow: var(--md-elev1);
  transition: box-shadow 150ms ease;
}
.teaching-card:hover { box-shadow: var(--md-elev2); }

.teaching-card h3 { margin: 0 0 0.85rem; }
.teaching-card p  { margin: 0 0 0.85rem; }

.equation-card { background: var(--md-surface-container-lowest); }

.inline-math {
  display: inline-block;
  margin: 0 0.08em;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--md-on-surface);
  white-space: nowrap;
}

.inline-equation {
  display: inline-flex;
  align-items: center;
  margin: 0 0.08em;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--md-on-surface);
  white-space: nowrap;
  vertical-align: -0.18em;
}

.inline-math sub,
.inline-math sup,
.inline-equation sub,
.inline-equation sup,
.balance-eq sub,
.balance-eq sup,
.textbook-equation sub,
.textbook-equation sup,
.rk-block sub,
.rk-block sup {
  font-size: 0.7em;
  line-height: 0;
}

/* ── Math typography ────────────────────────────────────── */
.textbook-equation {
  margin: 0.8rem 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.65rem;
  line-height: 1.35;
  color: var(--md-on-surface);
  letter-spacing: -0.02em;
}

.textbook-equation-compact {
  margin: 0.5rem 0 0.8rem;
  font-size: 1.3rem;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  vertical-align: middle;
  margin: 0 0.12em;
}
.frac .top {
  border-bottom: 2px solid var(--md-on-surface);
  padding: 0 0.22em 0.06em;
  text-align: center;
}
.frac .bottom {
  padding: 0.06em 0.22em 0;
  text-align: center;
}

.frac-inline {
  margin: 0;
  line-height: 1;
}

.frac-inline .top {
  border-bottom-width: 1.5px;
  padding: 0 0.18em 0.04em;
}

.frac-inline .bottom {
  padding: 0.04em 0.18em 0;
}

.derivative { font-weight: 700; }

.equation-system {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--md-outline-variant);
}

.system-title {
  margin-bottom: 0.55rem;
  color: var(--md-primary);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* MD3 Secondary Tonal Container for RK block */
.rk-block {
  margin: 0.9rem 0;
  padding: 0.95rem 1rem;
  border-radius: var(--md-shape-medium);
  border: 1px solid rgba(26,111,232,.18);
  background: var(--md-surface-container-low);
  color: var(--md-on-surface);
  font-family: "IBM Plex Mono", "Roboto Mono", ui-monospace, monospace;
  font-size: 0.87rem;
  line-height: 1.72;
}

.rk-result {
  margin-top: 0.35rem;
  font-weight: 700;
  color: var(--md-primary);
}

/* ── Concept highlight box ──────────────────────────────── */
.concept-box {
  margin: 0.75rem 0 0.2rem;
  padding: 0.75rem 1rem;
  border-radius: var(--md-shape-medium);
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-size: 0.92rem;
  line-height: 1.5;
}

.concept-box-equation {
  padding: 1rem;
  text-align: center;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Balance table (mass balance equation rows) ─────────── */
.balance-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0.75rem 0 0.2rem;
}

.balance-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 0 12px;
  padding: 8px 12px;
  border-radius: var(--md-shape-small);
  background: var(--md-surface-container-low);
  border-left: 3px solid var(--md-primary);
}

.balance-mode {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-primary);
  white-space: nowrap;
}

.balance-eq {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--md-on-surface);
  letter-spacing: -0.02em;
}

.balance-note {
  grid-column: 2;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--md-on-surface-variant);
  line-height: 1.45;
}

/* ================================================================
   HEADER & FOOTER  –  HostCell brand identity, do not modify
   ================================================================ */

.hc-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hc-header-height);
  z-index: 1001;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(60, 64, 67, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  overflow: hidden;
}

.hc-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.g-logo {
  width: 48px;
  height: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.g-dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.hc-header-text {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hc-title-line {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-width: 0;
}

.hc-header-title {
  margin: 0;
  font-family: "Google Sans", "Roboto", sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hc-tagline {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.83rem;
  line-height: 1.2;
}

.hc-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.hc-suite-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #f5f9ff 0%, #e8f0fe 100%);
  border: 1px solid #c5d9fb;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 110ms ease, box-shadow 130ms ease, background 130ms ease;
}

.hc-suite-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, #eef5ff 0%, #dcebff 100%);
}

.hc-suite-label {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--g-blue);
  text-transform: uppercase;
}

.hc-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--hc-footer-height);
  background: rgba(248, 249, 250, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -1px 8px rgba(60, 64, 67, 0.07);
  z-index: 999;
}

.hc-footer-inner {
  height: 100%;
  padding: 0 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  font-family: "Roboto", "Google Sans", sans-serif;
}

.hc-footer-suite {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.hc-footer-name {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--g-blue);
  white-space: nowrap;
}

.hc-footer-slogan {
  font-size: 0.67rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-style: italic;
}

.hc-footer-author {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: auto;
}

.hc-footer-github {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0.44rem 1.05rem;
  border-radius: 999px;
  background: #1e2330;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 130ms ease, transform 110ms ease, box-shadow 130ms ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.hc-footer-github:hover {
  background: #2d3348;
  transform: translateY(-1px);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.25);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .hero,
  .layout,
  .metrics-grid,
  .teaching-panel {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  :root { --hc-header-height: 80px; }

  .hc-header { padding: 0 1rem; }

  .g-logo {
    width: 40px;
    height: 40px;
    padding: 6px;
    gap: 4px;
  }

  .hc-header-title { font-size: 0.98rem; }
  .hc-tagline     { font-size: 0.76rem; }
  .hc-suite-label { font-size: 0.72rem; }
}

@media (max-width: 720px) {
  .page-shell { width: min(100vw - 18px, 1440px); }

  .hero-copy,
  .hero-card,
  .control-panel,
  .plot-card,
  .metric-card,
  .teaching-card,
  .guide-banner {
    border-radius: var(--md-shape-large);
  }
  .guide-banner[aria-expanded="true"] {
    border-radius: var(--md-shape-large) var(--md-shape-large) 0 0;
  }
  .guide-panel-inner {
    border-radius: 0 0 var(--md-shape-large) var(--md-shape-large);
  }

  .card-header {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  :root {
    --hc-header-height: 94px;
    --hc-footer-height: 76px;
  }

  .hc-header { padding: 0 0.8rem; }

  .g-logo {
    width: 36px;
    height: 36px;
    padding: 5px;
  }

  .hc-title-line {
    align-items: flex-start;
    gap: 0.2rem;
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .hc-header-title { font-size: 0.9rem; }
  .hc-tagline   { font-size: 0.72rem; }

  .hc-footer-inner {
    padding: 0.45rem 0.9rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35rem 1rem;
  }

  .hc-footer-author { margin-left: 0; }
  .hc-footer-github { margin-left: auto; }
}
