/* ===== Design tokens — light mode ===== */
:root {
  --bg: #f7f5f2;
  --bg-elevated: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --ink-muted: #6b6b6b;
  --border: #e8e4de;
  --border-strong: #d4cec4;
  --accent: #2a9d8f;
  --accent-soft: #e6f5f3;
  --animal: #e07a5f;
  --animal-soft: #fdf0ec;
  --plant: #40916c;
  --plant-soft: #e8f5ee;
  --shadow: 0 4px 24px rgba(26, 26, 26, 0.06);
  --shadow-lg: 0 12px 40px rgba(26, 26, 26, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --focus: 0 0 0 3px rgba(42, 157, 143, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(224, 122, 95, 0.07), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(64, 145, 108, 0.08), transparent 45%),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
  opacity: 0.55;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 245, 242, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--animal-soft), var(--plant-soft));
  border: 1px solid var(--border);
  font-size: 1.25rem;
  color: var(--accent);
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink);
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn:active {
  transform: scale(0.98);
}

.hint-pill {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(42, 157, 143, 0.25);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}

/* ===== Main ===== */
main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.intro {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2rem;
}

.intro h2 {
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 0.65rem;
}

.intro p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

/* ===== Cell panels ===== */
.cells-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 860px) {
  .cells-stage {
    grid-template-columns: 1fr;
  }
}

.cell-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding: 1.1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.cell-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  margin-bottom: 0.4rem;
}

.cell-badge.animal {
  background: var(--animal-soft);
  color: #c44536;
}

.cell-badge.plant {
  background: var(--plant-soft);
  color: #1b4332;
}

.panel-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
}

.panel-head p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.svg-wrap {
  padding: 0.75rem 0.5rem 0.25rem;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, #faf9f7 0%, #fff 100%);
}

.cell-svg {
  width: 100%;
  max-width: 400px;
  height: auto;
  display: block;
}

/* Organelle interactivity */
.organelle {
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  outline: none;
}

.organelle:hover,
.organelle:focus-visible {
  filter: brightness(1.08) drop-shadow(0 0 6px rgba(42, 157, 143, 0.45));
}

.organelle.is-active {
  filter: brightness(1.1) drop-shadow(0 0 8px rgba(42, 157, 143, 0.65));
  stroke-width: 3.5;
}

.organelle.is-dimmed {
  opacity: 0.45;
}

/* Lists under diagrams */
.organelle-list {
  list-style: none;
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border-top: 1px solid var(--border);
  background: #faf9f7;
}

.organelle-list button {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.organelle-list button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.organelle-list button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.organelle-list button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* ===== Detail panel ===== */
.detail-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 2.25rem;
  min-height: 200px;
}

.detail-empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--ink-muted);
}

.detail-empty-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.detail-empty h3 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  color: var(--ink);
  font-size: 1.2rem;
}

.detail-empty p {
  margin: 0;
  font-size: 0.95rem;
}

.detail-content.hidden,
.detail-empty.hidden {
  display: none;
}

.detail-top {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}

.detail-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.detail-cell-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.detail-content h3 {
  margin: 0.1rem 0 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.detail-summary {
  margin: 0 0 1.15rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

@media (max-width: 700px) {
  .detail-facts {
    grid-template-columns: 1fr;
  }
}

.fact {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.fact-fun {
  background: var(--accent-soft);
  border-color: rgba(42, 157, 143, 0.2);
}

.fact-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
}

.fact p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
}

.compare-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.compare-row strong {
  color: var(--ink);
}

.compare-row .tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-right: 0.35rem;
}

.compare-row .tag.both {
  background: var(--accent-soft);
  color: var(--accent);
}

.compare-row .tag.animal-only {
  background: var(--animal-soft);
  color: #c44536;
}

.compare-row .tag.plant-only {
  background: var(--plant-soft);
  color: #1b4332;
}

/* ===== Legend ===== */
.legend-section h2 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1rem;
  text-align: center;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 700px) {
  .diff-grid {
    grid-template-columns: 1fr;
  }
}

.diff-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}

.diff-card h4 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.diff-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.diff-card li {
  margin-bottom: 0.4rem;
}

.diff-card li:last-child {
  margin-bottom: 0;
}

/* ===== Footer ===== */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* Active panel glow */
.cell-panel.has-selection {
  border-color: rgba(42, 157, 143, 0.45);
  box-shadow: var(--shadow), 0 0 0 1px rgba(42, 157, 143, 0.15);
}
