.chem-page {
  --chem-bg: #f3f6f2;
  --chem-card: #fffefa;
  --chem-ink: #16302b;
  --chem-muted: #4b635d;
  --chem-line: #c9dad1;
  --chem-green: #1b604e;
  margin: 0;
  background: var(--chem-bg);
  color: var(--chem-ink);
  font: 16px/1.6 Inter, "Segoe UI", Arial, sans-serif;
}
.chem-main, .chem-main * { box-sizing: border-box; }
.chem-main { --chem-nav-clearance: 226px; width: min(1120px, 100% - 2 * clamp(18px, 5vw, 60px)); margin: 0 auto; padding-bottom: 64px; }
.chem-main h1, .chem-main h2, .chem-main h3, .chem-main p { margin: 0; }
.chem-main h1 { font-size: clamp(45px, 6.8vw, 82px); line-height: 1; letter-spacing: -.067em; font-weight: 630; }
.chem-main h2 { font-size: clamp(27px, 4.1vw, 46px); line-height: 1.15; letter-spacing: -.037em; font-weight: 650; }
.chem-main h3 { font-size: 20px; line-height: 1.25; letter-spacing: -.02em; font-weight: 650; }
.chem-main a { color: var(--chem-green); text-underline-offset: .24em; }
.chem-main :focus-visible, .chem-skip:focus-visible { outline: 2px solid var(--chem-green); outline-offset: 4px; }
.chem-main [id] { scroll-margin-top: var(--chem-nav-clearance); }
.chem-skip, .chem-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chem-skip:focus { top: 10px; left: 10px; z-index: 90; width: auto; height: auto; clip-path: none; padding: 10px; background: var(--chem-card); color: var(--chem-ink); }
.chem-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(22px, 4vw, 52px);
  padding: clamp(32px, 5vw, 66px) 0 34px;
}
.chem-intro-copy > p { max-width: 650px; margin-top: 20px; font-size: clamp(16px, 2.15vw, 22px); color: var(--chem-muted); }
.chem-cover { display: block; width: 100%; height: auto; border: 1px solid var(--chem-line); border-radius: 14px; }
.chem-index { display: flex; gap: 9px 24px; flex-wrap: wrap; margin-top: 23px; font-size: 14px; font-weight: 650; }
.chem-index a { padding-block: 4px; }
.chem-section { padding: clamp(26px, 4vw, 47px) 0; border-top: 1px solid var(--chem-line); }
.chem-section-lead { max-width: 750px; margin-bottom: 22px; }
.chem-section-lead p { margin-top: 11px; color: var(--chem-muted); }

.chem-cell {
  margin: 0;
  padding: clamp(15px, 3.5vw, 37px);
  border: 1px solid #354d48;
  border-radius: 14px;
  color: #ecf8f3;
  background: radial-gradient(ellipse at 75% 0, #1c3c38 0, #0e2221 70%);
}
.chem-cell figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; margin-bottom: 22px; }
.chem-cell figcaption strong { font-size: clamp(18px, 2.6vw, 25px); }
.chem-formula, .chem-equation { font-family: "IBM Plex Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.chem-formula { font-size: clamp(16px, 2.35vw, 22px); color: #c7f5d9; }
.chem-circuit { padding: 10px 12px; border: 1px dashed #76978f; border-radius: 7px; text-align: center; color: #d1e8e0; font-size: 13px; }
.chem-circuit span { display: block; color: #f1cf88; font-weight: 650; }
.chem-circuit strong { font-weight: 500; }
.chem-cell-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(135px, .52fr) minmax(0, 1fr); gap: 12px; margin-top: 14px; }
.chem-electrode, .chem-membrane { min-width: 0; padding: clamp(12px, 2.4vw, 25px); border: 1px solid #49645d; border-radius: 8px; background: #172f2e; }
.chem-anode { border-top: 3px solid #8dc9e6; }
.chem-cathode { border-top: 3px solid #a6e8ba; }
.chem-electrode h3, .chem-membrane h3 { margin-top: 9px; }
.chem-electrode p, .chem-membrane p { margin-top: 8px; font-size: 14px; color: #d1e8e0; }
.chem-electrode p.chem-equation { margin: 12px 0; color: #eefaf4; overflow-wrap: anywhere; }
.chem-stream { display: inline-block; color: #b9e8fb; font-size: 13px; font-weight: 650; }
.chem-cathode .chem-stream { color: #c7f5d9; }
.chem-membrane { display: grid; place-content: center; justify-items: center; text-align: center; }
.chem-ion { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: #f1cf88; font: 650 16px/1 Consolas, monospace; }
.chem-ion::after { content: '→'; color: inherit; font-size: 20px; }

.chem-columns, .chem-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chem-columns { margin-top: 14px; }
.chem-columns > div, .chem-card, .chem-example, .chem-related { border: 1px solid var(--chem-line); border-radius: 8px; background: var(--chem-card); padding: clamp(16px, 2.55vw, 28px); }
.chem-columns p, .chem-card p, .chem-example p, .chem-related p { margin: 9px 0 0; }
.chem-columns a { display: inline-block; margin-top: 9px; font-size: 14px; }
.chem-example { margin-top: 14px; background: #e6f0e9; }
.chem-measures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 13px 0; }
.chem-measures > div { display: flex; flex-direction: column-reverse; padding: 12px 14px; border: 1px solid var(--chem-line); border-radius: 6px; background: var(--chem-card); }
.chem-measures dt { color: var(--chem-muted); font-size: 13px; line-height: 1.35; }
.chem-measures dd { margin: 0 0 5px; font-size: clamp(21px, 3vw, 31px); font-weight: 650; line-height: 1.15; }
.chem-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chem-habitat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chem-process-reference { margin-top: 14px; background: #f1f7f2; }
.chem-half-reactions {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  margin: 12px 0 0;
  border-left: 3px solid #80a99a;
  background: #edf4ee;
}
.chem-half-reactions dt { color: var(--chem-muted); font-size: .8rem; }
.chem-half-reactions dd { margin: 0; font: 600 .91rem/1.45 "IBM Plex Mono", Consolas, monospace; overflow-wrap: anywhere; }
.chem-card p.chem-equation { color: var(--chem-green); font-weight: 650; overflow-wrap: anywhere; }
.chem-card p.chem-path { font-size: 14px; color: var(--chem-green); font-weight: 650; }
.chem-links { display: flex; flex-wrap: wrap; gap: 4px 15px; align-items: baseline; font-size: 13px; }
.chem-related { background: transparent; }
.chem-related h2 { font-size: clamp(20px, 3vw, 29px); }

@media (min-width: 1200px) {
  .chem-main { --chem-nav-clearance: 190px; }
}
@media (max-width: 800px) {
  .chem-main { --chem-nav-clearance: 94px; }
  .chem-intro { grid-template-columns: minmax(0, 1fr); }
  .chem-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 590px) {
  .chem-cell-grid, .chem-columns, .chem-cards { grid-template-columns: minmax(0, 1fr); }
  .chem-membrane { display: block; text-align: left; }
  .chem-membrane h3 { margin-top: 0; }
  .chem-ion { display: inline-flex; }
  .chem-ion::after { content: '↓'; }
}
@media (max-width: 420px) {
  .chem-measures { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .chem-measures > div { flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 8px; }
  .chem-measures dd { margin: 0; white-space: nowrap; }
}
