/* Alchemist page layouts: header, pages, periodic table, molecule profile, labs and print. */

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
  flex: none;
  min-height: 44px;
}
.brand img {
  width: 36px;
  height: 36px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text strong {
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}
.brand-text small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}
.nav-primary {
  display: none;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.5rem;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.93rem;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.nav-link:hover {
  background: var(--surface-2);
}
.nav-link[aria-current='page'],
.nav-link.is-active {
  color: var(--brand-strong);
  background: var(--brand-soft);
}
.nav-link .count {
  background: var(--brand);
  color: var(--on-brand);
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0 0.45rem;
}
.nav-more {
  position: relative;
}
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 230px;
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.menu[hidden] {
  display: none;
}
.header-tools {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  min-width: 0;
}
.header-search {
  display: none;
  align-items: center;
  position: relative;
}
.header-search input {
  width: 220px;
  border-radius: 999px;
  padding-right: 2.8rem;
}
.header-search .icon-btn {
  position: absolute;
  right: 0;
}
.mode-select {
  width: auto;
  min-width: 0;
  max-width: 9.5rem;
  border-radius: 999px;
  font-weight: 600;
  padding-inline: 0.7rem 0.4rem;
}
.lang-btn span {
  font-weight: 800;
  font-size: 0.85rem;
}
.offline-bar {
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.35rem var(--gutter);
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.offline-bar[hidden] {
  display: none;
}
.drawer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 0.5rem var(--gutter) 1rem;
}
.drawer[hidden] {
  display: none;
}
.drawer nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 0.2rem;
}
.drawer-mode {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.6rem 0 0;
}
@media (min-width: 720px) {
  .header-search {
    display: flex;
  }
}
@media (min-width: 1180px) {
  .nav-primary {
    display: flex;
  }
  .menu-btn {
    display: none;
  }
  .drawer {
    display: none !important;
  }
  .header-search input {
    width: 180px;
  }
}
@media (min-width: 1320px) {
  .header-search input {
    width: 230px;
  }
}
@media (max-width: 420px) {
  .brand-text small {
    display: none;
  }
  .mode-select {
    max-width: 6.5rem;
    font-size: 0.85rem;
  }
}
@media (max-width: 380px) {
  .brand-text {
    display: none;
  }
  .header-bar {
    gap: 0.25rem;
  }
  .mode-select {
    max-width: 5.6rem;
    padding-inline: 0.5rem 0.2rem;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 0 1rem;
  font-size: 0.93rem;
}
.footer-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}
.footer-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-links a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
}
.footer-bottom {
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding-top: 1rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}
.footer-bottom p {
  margin: 0;
}

/* ---------- Page heads & breadcrumbs ---------- */
.page-head {
  padding: 1.2rem 0 0.5rem;
}
.page-head .lead,
.lead {
  font-size: clamp(1.02rem, 0.5vw + 0.95rem, 1.15rem);
  color: var(--muted);
  max-width: 70ch;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-strong);
  margin: 0;
}
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.crumbs li + li::before {
  content: '›';
  margin-right: 0.3rem;
}
.crumbs a {
  color: var(--muted);
}
.source-line {
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 0.6rem;
}
.hero-try {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  color: var(--muted);
}
.h-small + ul,
.card ul,
.card ol {
  padding-left: 1.2rem;
}

/* ---------- Home ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--brand-soft), var(--bg) 70%);
  border-bottom: 1px solid var(--border);
}
.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  padding-block: 2.5rem 2rem;
}
.hero h1 {
  max-width: 22ch;
}
.hero-search {
  display: flex;
  gap: 0.5rem;
  max-width: 640px;
  margin: 1.2rem 0 0.6rem;
}
.hero-search input {
  border-radius: 999px;
  min-height: 52px;
  padding-inline: 1.1rem;
  box-shadow: var(--shadow);
}
.hero-search .btn {
  min-height: 52px;
  flex: none;
}
@media (max-width: 480px) {
  .hero-search .btn span {
    display: none;
  }
}
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 1.4rem 0 0;
  max-width: 720px;
}
@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.stats div {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}
.stats dt {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-strong);
}
.stats dd {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.home-sections > section {
  margin-top: 2rem;
}
.mode-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.2rem;
}
.mode-choose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.mode-choose h2 {
  margin-top: 0;
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  gap: 0.6rem;
}
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: left;
  min-height: 84px;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.mode-card strong {
  font-size: 1.1rem;
}
.mode-card span {
  font-size: 0.86rem;
  color: var(--muted);
}
.mode-card.is-active,
.mode-card:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.split {
  display: grid;
  gap: 1rem;
}
@media (min-width: 860px) {
  .split {
    grid-template-columns: 1fr 2fr;
  }
}
.split h2 {
  margin-top: 0;
  font-size: 1.2rem;
}
.element-day {
  border-top: 5px solid var(--accent);
}
.element-big {
  display: inline-grid;
  grid-template-rows: auto 1fr auto auto;
  width: 140px;
  aspect-ratio: 1;
  padding: 0.6rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  border: 2px solid var(--accent);
  color: var(--text);
  text-decoration: none;
  margin-bottom: 0.6rem;
}
.element-big .z {
  font-weight: 700;
}
.element-big .sym {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  align-self: center;
}
.element-big .nm {
  font-weight: 600;
  font-size: 0.9rem;
}
.element-big .m {
  font-size: 0.8rem;
  color: var(--muted);
}
.place-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.teacher-cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  background: linear-gradient(120deg, var(--brand-soft), var(--surface));
}
.teacher-cta h2 {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.teacher-cta p {
  margin: 0;
  max-width: 60ch;
}

/* ---------- Explore ---------- */
.suggest-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 0.4rem;
}
.suggest {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.suggest small {
  margin-left: auto;
  color: var(--muted);
}
.suggest:hover {
  border-color: var(--brand);
}
.center > .btn {
  margin-top: 1rem;
}

/* ---------- Molecule page ---------- */
.mol-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}
.mol-titles {
  min-width: 0;
  flex: 1 1 320px;
}
.mol-titles h1 {
  margin: 0.2rem 0;
}
.mol-other {
  color: var(--muted);
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}
.mol-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.mol-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-content: flex-start;
}
@media (max-width: 560px) {
  .mol-actions .btn span {
    display: none;
  }
  .mol-actions .btn {
    padding-inline: 0.8rem;
  }
}
.mol-stage {
  display: grid;
  gap: 1rem;
}
@media (min-width: 920px) {
  .mol-stage {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }
}
.viewer-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.tool-group {
  display: flex;
  flex-wrap: wrap;
}
.viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  background: var(--stage);
  overflow: hidden;
  touch-action: none;
}
.viewer-sm {
  aspect-ratio: 1;
}
.viewer-canvas {
  display: block;
  cursor: grab;
}
.viewer-canvas:active {
  cursor: grabbing;
}
.viewer-empty {
  display: grid;
  place-items: center;
  align-content: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}
.viewer-hint,
.atom-info {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
.atom-info {
  color: var(--text);
  font-weight: 600;
}
.lattice-note {
  margin-top: 0.6rem;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.92rem;
}
.lattice-note p {
  margin: 0.3rem 0 0;
}
.mol-side {
  display: grid;
  gap: 1rem;
  min-width: 0;
}
.mol-photo,
.structure-2d {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.mol-photo img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
}
.structure-2d img {
  display: block;
  margin: 0 auto;
  background: #fff;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  object-fit: contain;
}
.mol-photo figcaption,
.structure-2d figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.5rem 0.8rem;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 1.2rem 0 0;
  position: sticky;
  top: 64px;
  z-index: 5;
  padding: 0.5rem 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}
.mol-section {
  margin-top: 1.5rem;
  scroll-margin-top: 8rem;
}
.mol-section > h2 {
  margin-top: 0.5rem;
}
.explain h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--brand-strong);
}
.explain,
.composition {
  margin: 1rem 0;
}
.fun {
  background: linear-gradient(135deg, var(--brand-soft), var(--surface));
}
.comp-bar {
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 0.5rem 0;
}
.comp-bar span {
  height: 100%;
}
.comp-list {
  list-style: none;
  padding: 0 !important;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.9rem;
}
.wiki p {
  max-width: 75ch;
}
.ghs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0.6rem 0;
}
.ghs-pic {
  margin: 0;
  text-align: center;
  width: 92px;
}
.ghs-pic figcaption {
  font-size: 0.78rem;
  line-height: 1.25;
}
.signal {
  display: inline-block;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.7rem;
  border-radius: 6px;
}
.signal-danger {
  color: #fff;
  background: #b42318;
}
.signal-warning {
  color: #3d2800;
  background: #fbbf24;
}
.hazards {
  padding-left: 1.2rem;
}
.hazards li {
  margin-bottom: 0.3rem;
}
.uses li {
  margin-bottom: 0.4rem;
}
.synonyms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
blockquote {
  margin: 0.6rem 0;
  padding: 0.6rem 0.9rem;
  border-left: 4px solid var(--brand);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
blockquote footer {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Classes ---------- */
.class-head {
  border-left: 6px solid var(--accent);
  padding-left: 1rem;
  margin-top: 1rem;
}
.class-facts .card {
  border-top: 4px solid var(--brand);
}
.tree {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}
.tree ul {
  list-style: none;
  padding-left: 1.2rem;
  margin: 0.3rem 0 0;
  border-left: 2px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
}
.tree-node {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  font-weight: 600;
}
.tree > li > .tree-node {
  font-size: 1.1rem;
  color: var(--text);
  border-left: 4px solid var(--accent);
  padding-left: 0.5rem;
}
.tree-node small {
  color: var(--muted);
  font-weight: 500;
}

/* ---------- Periodic table ---------- */
.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.table-tools .field {
  flex: 1 1 200px;
  max-width: 320px;
}
.pt-scroll {
  overflow-x: auto;
  padding-bottom: 0.5rem;
  border-radius: var(--radius);
}
.ptable {
  display: grid;
  grid-template-columns: repeat(18, minmax(52px, 1fr));
  grid-template-rows: repeat(7, auto) 14px repeat(2, auto);
  gap: 3px;
  min-width: 980px;
}
.el-tile {
  --tile: #8a94a6;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  aspect-ratio: 1 / 1.1;
  padding: 3px 4px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--tile) 30%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--tile) 75%, var(--surface));
  color: var(--text);
  text-decoration: none;
  line-height: 1.1;
  overflow: hidden;
  transition: transform 0.1s;
}
.el-tile:hover,
.el-tile:focus-visible {
  transform: scale(1.12);
  z-index: 2;
  box-shadow: var(--shadow-lg);
}
.el-tile .z {
  font-size: 0.66rem;
  font-weight: 700;
}
.el-tile .sym {
  font-size: 1.15rem;
  font-weight: 800;
  align-self: center;
  text-align: center;
}
.el-tile .nm {
  font-size: 0.56rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.el-tile .val {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.55rem;
  font-weight: 700;
}
.el-tile.is-dim {
  opacity: 0.22;
}
.el-tile.no-data {
  opacity: 0.55;
}
.pt-gap {
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 7px;
}
.pt-rowlabel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.pt-legend {
  margin: 0.8rem 0;
}
.heat-legend {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
}
.heat-bar {
  flex: 1 1 160px;
  max-width: 360px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(49 99 181), rgb(45 170 160), rgb(233 196 70), rgb(214 79 60));
}
.pt-list summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ---------- Element page ---------- */
.element-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: center;
  margin-top: 1rem;
}
.element-head h1 {
  margin: 0.2rem 0;
}
.el-nav {
  display: flex;
  gap: 0.4rem;
}
.element-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
@media (min-width: 900px) {
  .element-grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }
}
.element-visuals {
  display: grid;
  gap: 1rem;
}
.bohr-card {
  margin: 0;
  text-align: center;
}
.bohr {
  display: block;
  margin: 0 auto;
}
.bohr-ring {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}
.bohr-e {
  fill: var(--brand);
}
.bohr-nucleus {
  fill: #e8663d;
}
.bohr-sym {
  fill: #fff;
  font-weight: 800;
  font-size: 15px;
}
.orbitals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}
.orb-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.orb-boxes {
  display: flex;
}
.orb-box {
  width: 28px;
  height: 32px;
  border: 1.5px solid var(--text);
  margin-left: -1.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--brand-strong);
}
.orb-label {
  font-family: var(--mono);
  font-size: 0.85rem;
}
.particles {
  list-style: none;
  padding: 0 !important;
}
.particles li {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.dot-p {
  background: #e8663d;
}
.dot-n {
  background: #8a94a6;
}
.dot-e {
  background: #4a9fe0;
}

/* ---------- Lessons & prose ---------- */
.prose {
  max-width: 78ch;
}
.lesson-body {
  font-size: 1.05rem;
  margin: 1rem 0 1.5rem;
}
.lesson-body h3 {
  color: var(--brand-strong);
}
.lesson-body ul,
.lesson-body ol,
.prose ul,
.prose ol {
  padding-left: 1.3rem;
}
.lesson-body li {
  margin-bottom: 0.35rem;
}
.term {
  text-decoration-style: dotted;
}
.lesson-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.6rem 0;
}
.lesson section,
.lesson .card {
  margin-top: 1rem;
}
.teacher-notes dt {
  font-weight: 700;
  margin-top: 0.7rem;
}
.teacher-notes dd {
  margin: 0.2rem 0 0;
}
.pager {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
}

/* ---------- Quiz ---------- */
.quiz-card {
  margin-top: 1rem;
}
.quiz-card h2 {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.quiz-progress {
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.quiz-bar {
  width: 100%;
  height: 8px;
  margin: 0.4rem 0 1rem;
  accent-color: var(--brand);
}
.quiz-q {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}
.quiz-img {
  display: block;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 0 0 0.8rem;
}
.quiz-options {
  display: grid;
  gap: 0.5rem;
}
.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 48px;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.quiz-option:hover {
  border-color: var(--brand);
}
.quiz-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.quiz-option.is-right {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.quiz-option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.quiz-actions {
  margin-top: 1rem;
}
.feedback {
  display: flex;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
}
.feedback p {
  margin: 0.2rem 0 0;
}
.feedback.ok {
  background: var(--ok-soft);
  color: var(--text);
}
.feedback.ok > svg {
  color: var(--ok);
}
.feedback.no {
  background: var(--danger-soft);
  color: var(--text);
}
.feedback.no > svg {
  color: var(--danger);
}
.quiz-result {
  text-align: center;
  outline: none;
}
.quiz-score {
  font-size: 1.5rem;
  font-weight: 800;
}
.stars {
  font-size: 2rem;
  color: #f5b301;
  letter-spacing: 0.1em;
  margin: 0;
}
.quiz-review {
  text-align: left;
  margin-top: 1rem;
}
.quiz-review summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quiz-review li {
  margin-bottom: 0.8rem;
}
.quiz-review li.no > p:nth-child(2) {
  color: var(--ok);
}
.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 0.6rem;
}
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.2rem;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.badge-card strong {
  color: var(--text);
}
.badge-card.is-earned {
  border-style: solid;
  border-color: #f5b301;
  background: color-mix(in srgb, #f5b301 12%, var(--surface));
  color: var(--text);
}
.badge-card.is-earned svg {
  color: #c98a00;
}

/* ---------- Glossary ---------- */
.term-card h2 {
  margin-top: 0;
}
.term-card.is-open {
  border-color: var(--brand);
}

/* ---------- Labs ---------- */
.lab-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 900px) {
  .lab-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    align-items: start;
  }
  .lab-wide {
    grid-column: 1 / -1;
  }
}
.lab-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.slider label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.state-now,
.ph-value {
  font-size: 1.15rem;
  font-weight: 700;
}
.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart .grid-line {
  stroke: var(--border);
}
.chart .axis {
  stroke: var(--muted);
}
.chart .tick,
.chart .axis-label,
.chart .mark-label {
  fill: var(--muted);
  font-size: 12px;
}
.chart .series {
  stroke: var(--brand);
  stroke-width: 3;
}
.chart .h-line {
  stroke: var(--accent);
  stroke-dasharray: 5 4;
}
.chart .mark {
  fill: var(--accent);
}
.chart .point {
  fill: #e8663d;
  stroke: var(--surface);
  stroke-width: 2;
}
.shapes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
}
.shape {
  margin: 0;
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
.shape .axis {
  stroke: var(--border);
}
.shape figcaption {
  font-size: 0.88rem;
}
.burner {
  display: grid;
  place-items: center;
  min-height: 260px;
  background: radial-gradient(circle at 50% 80%, #1f2533, #0b1220);
  border-radius: var(--radius);
}
.flame {
  --flame: #ffb300;
  position: relative;
  width: 110px;
  height: 200px;
}
.flame span {
  position: absolute;
  left: 50%;
  bottom: 0;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  transform: translateX(-50%);
  filter: blur(2px);
  animation: flicker 1.4s ease-in-out infinite alternate;
}
.flame span:nth-child(1) {
  width: 100px;
  height: 190px;
  background: radial-gradient(
    ellipse at 50% 80%,
    color-mix(in srgb, var(--flame) 90%, #fff),
    var(--flame) 45%,
    transparent 72%
  );
}
.flame span:nth-child(2) {
  width: 60px;
  height: 120px;
  background: radial-gradient(ellipse at 50% 85%, #fff, var(--flame) 60%, transparent 80%);
  animation-delay: 0.3s;
}
.flame span:nth-child(3) {
  width: 30px;
  height: 60px;
  background: radial-gradient(ellipse at 50% 80%, #8fd3ff, transparent 75%);
}
@keyframes flicker {
  from {
    transform: translateX(-50%) scaleY(1);
  }
  to {
    transform: translateX(-50%) scaleY(1.08) skewX(2deg);
  }
}
.game-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  background: radial-gradient(circle at 20% 80%, #1f2533, #0b1220 60%, transparent 61%);
  border-radius: var(--radius);
}
.spectrum {
  position: relative;
  height: 34px;
}
.spectrum-bar {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    #7a00d4,
    #2c3fff 15%,
    #00b3ff 30%,
    #00d45a 45%,
    #e8f000 60%,
    #ff9a00 75%,
    #ff2a00 90%,
    #a00000
  );
  opacity: 0.35;
}
.spectrum-line {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 5px;
  border-radius: 3px;
  background: var(--text);
  transform: translateX(-50%);
}
.spectrum-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}
.atom-counters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 0.4rem;
}
.counter {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.3rem;
}
.counter-el {
  font-weight: 800;
  width: 2rem;
}
.counter output {
  min-width: 2rem;
  text-align: center;
  font-weight: 700;
}
.equation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
}
.equation.result {
  color: var(--brand-strong);
}
.eq-term {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.coef-input {
  width: 4.2rem;
  text-align: center;
  font-weight: 800;
}
.op {
  color: var(--muted);
}
.eq-name {
  font-weight: 700;
}
.tally {
  max-width: 360px;
  margin: 0.8rem 0;
}
.tally tr.ok td {
  color: var(--ok);
  font-weight: 700;
}
.tally tr.no td {
  color: var(--danger);
  font-weight: 700;
}
.beaker,
.flask {
  position: relative;
  width: 160px;
  height: 190px;
  margin: 0.6rem auto;
  border: 4px solid var(--muted);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  overflow: hidden;
}
.flask {
  border-radius: 0 0 60px 60px;
}
.liquid {
  position: absolute;
  inset: 35% 0 0;
  background: #4caf50;
  transition: background 0.4s;
}
.ph-scale {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d7263d, #f46036, #f7b32b, #4caf50, #2e86ab, #3d348b, #5b1a7a);
  margin: 0.8rem 0;
}
.ph-marker {
  position: absolute;
  top: -6px;
  width: 6px;
  height: 28px;
  border-radius: 3px;
  background: var(--text);
  transform: translateX(-50%);
  transition: left 0.3s;
}
.indicators {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 0.6rem;
}
.indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex: none;
}
.cell {
  width: 100%;
  height: auto;
}
.cell .wire {
  stroke: var(--text);
  stroke-width: 3;
  fill: none;
}
.cell .meter {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 3;
}
.cell .meter-text,
.cell .label,
.cell .sign {
  fill: var(--text);
  font-weight: 700;
  font-size: 14px;
}
.cell .flow-text,
.cell .small-text {
  fill: var(--muted);
  font-size: 12px;
}
.cell .arrow {
  fill: var(--brand);
}
.cell .beaker-a {
  fill: color-mix(in srgb, #9aa6bb 35%, transparent);
  stroke: var(--muted);
}
.cell .beaker-c {
  fill: color-mix(in srgb, #4a9fe0 35%, transparent);
  stroke: var(--muted);
}
.cell .electrode {
  fill: #8a6f4d;
}
.cell .bridge {
  fill: none;
  stroke: #d6c7a1;
  stroke-width: 12;
  stroke-linecap: round;
}
.compare-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  margin-bottom: 1rem;
}
.check-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  margin-top: 0.4rem;
}
.tab-panel {
  margin-top: 0.5rem;
}
.tips li {
  margin-bottom: 0.5rem;
}
.note-text {
  white-space: pre-wrap;
}
.sources li {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.as-questions li {
  margin-bottom: 1rem;
}
.center .field {
  align-items: center;
}

/* ---------- Printable sheets & print ---------- */
#print-sheet {
  display: none;
}
.flashcards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.flashcard {
  border: 1px dashed #999;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  break-inside: avoid;
  min-height: 250px;
}
.ws-lines {
  height: 5rem;
  background: repeating-linear-gradient(
    transparent,
    transparent 1.6rem,
    #bbb 1.6rem,
    #bbb calc(1.6rem + 1px)
  );
}
.print-brand {
  font-size: 0.8rem;
  color: #555;
}
@media print {
  .site-header,
  .site-footer,
  .toast-region,
  .viewer-toolbar,
  .mol-actions,
  .jump,
  .hero-canvas,
  .lesson-tools,
  .quiz-card,
  .pager,
  .filters,
  .btn,
  .skip-link {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card {
    box-shadow: none;
    break-inside: avoid;
  }
  a {
    color: #000;
  }
  body.printing-sheet > *:not(#print-sheet) {
    display: none !important;
  }
  body.printing-sheet #print-sheet {
    display: block;
    color: #000;
    font-size: 11pt;
  }
}

/* ---------- 2D structure drawings ---------- */
.depict {
  color: var(--text);
  max-width: 100%;
  height: auto;
}
.depict-box {
  display: grid;
  place-items: center;
  padding: 1rem;
  min-height: 200px;
}
.card-media .depict {
  max-height: 88%;
  max-width: 88%;
}
@media (min-width: 1180px) and (max-width: 1439px) {
  .header-search input {
    display: none;
  }
  .header-search .icon-btn {
    position: static;
  }
}
@media (min-width: 1180px) and (max-width: 1379px) {
  .nav-primary .nav-link > svg:first-child {
    display: none;
  }
}
