/* ==========================================================
   Topology Demo — Canvas Visualization
   Standalone styles for the tectonic-plate topology viewer.
   References design-system tokens from styles.css where possible.
   ========================================================== */

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

:root {
  /* Topology-specific palette (canvas colors used by JS) */
  --paper: #f7f1e7;
  --paper-shadow: #ece3d5;
  --recency: #d46c55;
  --guarded: #23789a;
  --core: #18354a;

  /* Map to design-system tokens */
  --ink: var(--ink, #14181f);
  --muted: var(--ink-3, #6b717a);
  --faint: #9aa2ad;
  --line: rgba(20, 24, 31, 0.1);
  --safe: var(--safe, #2f6f67);
}

html {
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--sans, "Helvetica Neue", Arial, sans-serif);
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.7), transparent 28%),
    linear-gradient(180deg, #faf6ef, #f2eadf);
}

button,
input,
textarea,
select {
  font: inherit;
}

/* ==========================================================
   Artifact Layout
   ========================================================== */

.artifact {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1.25rem;
  padding: 1.4rem;
}

.artifact-head {
  display: grid;
  grid-template-columns: minmax(0, 34rem) minmax(16rem, 22rem);
  gap: 0.7rem 2.6rem;
  align-items: start;
}

.artifact-head.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.artifact-return {
  margin: 0;
  grid-column: 1 / -1;
}

.artifact-return a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
}

.artifact-return a:hover {
  color: var(--ink);
}

.artifact-kicker {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 600;
  grid-column: 1;
}

.artifact-title {
  margin: 0;
  font-family: var(--serif, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif);
  font-size: clamp(2.6rem, 5.5vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
  font-weight: 500;
  color: var(--ink);
  max-width: 8.5ch;
  grid-column: 1;
}

.artifact-note {
  margin: 0;
  max-width: 28rem;
  color: var(--ink-2, #46505b);
  font-size: clamp(1rem, 1.6vw, 1.1rem);
  line-height: 1.62;
  grid-column: 1;
}

.artifact-brief {
  display: grid;
  gap: 0.46rem;
  align-self: start;
  padding-left: 0.95rem;
  border-left: 1px solid var(--rule, rgba(20, 24, 31, 0.12));
  grid-column: 2;
  grid-row: 1 / span 2;
}

.artifact-brief p {
  margin: 0;
  color: var(--ink-2, #5a6570);
  font-size: 0.94rem;
  line-height: 1.5;
}

.artifact-brief strong {
  color: var(--ink);
  font-weight: 600;
  margin-right: 0.42rem;
}

.artifact-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 1rem;
  grid-column: 2;
}

.artifact-axis-note {
  margin: 0;
  color: var(--ink-3, #65707b);
  font-size: 0.84rem;
  line-height: 1.5;
  max-width: 28rem;
}

.artifact-axis-note strong {
  color: var(--ink);
  margin-right: 0.35rem;
}

/* ==========================================================
   Action Buttons
   ========================================================== */

.artifact-action,
.modal-close {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.12));
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.68rem 0.92rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.artifact-action:hover,
.modal-close:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(20, 24, 31, 0.18);
  transform: translateY(-1px);
}

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.65rem;
}

/* ==========================================================
   View Toggle
   ========================================================== */

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.18rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.view-toggle-button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3, #5a6570);
  border-radius: 999px;
  padding: 0.5rem 0.78rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.view-toggle-button:hover {
  color: var(--ink);
}

.view-toggle-button.is-active {
  background: rgba(20, 24, 31, 0.92);
  color: #fffdf9;
  box-shadow: 0 6px 14px rgba(20, 24, 31, 0.14);
}

/* ==========================================================
   Stage (Canvas Container)
   ========================================================== */

.stage {
  position: relative;
  min-height: 60svh;
  border-radius: 2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.34)),
    var(--paper);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 18px 60px rgba(134, 110, 75, 0.12);
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(48% 72% at 24% 56%, rgba(212, 108, 85, 0.08), transparent 70%),
    radial-gradient(48% 72% at 76% 56%, rgba(35, 120, 154, 0.09), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 40%);
  opacity: 0.78;
  pointer-events: none;
}

#mapCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

#mapCanvas.is-dragging {
  cursor: grabbing;
}

#mapCanvas.is-flat {
  cursor: default;
}

/* ==========================================================
   Plate Labels
   ========================================================== */

.plate-label {
  position: absolute;
  z-index: 1;
  top: 1.25rem;
  display: grid;
  gap: 0.12rem;
}

.plate-label--left {
  left: 1.4rem;
}

.plate-label--right {
  right: 1.4rem;
  text-align: right;
}

.plate-name {
  font-family: var(--serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif);
  font-size: 1.35rem;
}

.plate-sub {
  color: var(--ink-2, #47515d);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  font-weight: 600;
  line-height: 1.35;
  max-width: 12rem;
}

/* ==========================================================
   Figure Caption
   ========================================================== */

.caption-step {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 700;
}

.figure-caption {
  display: grid;
  grid-template-columns: minmax(10rem, 12rem) 1fr;
  gap: 0.3rem 1rem;
  align-items: start;
  padding: 0.95rem 1.05rem;
  border-radius: 1.35rem;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.figure-caption-step {
  display: grid;
  gap: 0.18rem;
}

.figure-caption-title {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
}

.figure-caption p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  font-size: 0.98rem;
}

.caption-support {
  grid-column: 2;
  color: var(--ink-2, #5b6671);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ==========================================================
   Axis & Ribbon Legends
   ========================================================== */

.axis-legend {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  color: var(--ink-3, #64707a);
  font-size: 0.78rem;
  line-height: 1.45;
}

.axis-key {
  display: inline-flex;
  align-items: baseline;
  gap: 0.34rem;
}

.axis-key strong {
  color: var(--ink);
  font-weight: 600;
}

.ribbon-legend {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.2rem;
  margin-top: 0.1rem;
  color: var(--ink-3, #66717b);
  font-size: 0.78rem;
}

.ribbon-key {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.marker-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.12));
  background: rgba(250, 246, 239, 0.96);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.marker-swatch--pivot {
  border-radius: 50%;
}

.marker-swatch--selected {
  transform: rotate(45deg);
  background: rgba(212, 108, 85, 0.2);
  border-color: rgba(181, 62, 43, 0.36);
}

.ribbon-swatch {
  display: inline-block;
  width: 1.5rem;
  height: 0.32rem;
  border-radius: 999px;
}

.ribbon-swatch--support {
  background: linear-gradient(90deg, rgba(89, 118, 140, 0.28), rgba(89, 118, 140, 0.82));
}

.ribbon-swatch--faux {
  background: repeating-linear-gradient(90deg, rgba(181, 62, 43, 0.94) 0 0.42rem, rgba(181, 62, 43, 0.18) 0.42rem 0.72rem);
}

/* ==========================================================
   Scrubber / Slider Controls
   ========================================================== */

.scrubber {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 16rem);
  gap: 0.45rem 1rem;
  padding: 0.82rem 0.95rem 0.88rem;
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.scrubber-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  grid-column: 1 / 2;
  color: var(--muted);
  font-size: 0.82rem;
}

.scrubber-head span:last-child {
  color: var(--ink);
  font-weight: 600;
}

.scrubber-note {
  margin: -0.2rem 0 0.1rem;
  color: var(--ink-2, #616b76);
  font-size: 0.88rem;
  line-height: 1.45;
}

.checkpoint-slider {
  grid-column: 1 / 2;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(212, 108, 85, 0.68), rgba(35, 120, 154, 0.68));
  outline: none;
  box-shadow: inset 0 1px 2px rgba(20, 24, 31, 0.08);
}

.checkpoint-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--rule, rgba(20, 24, 31, 0.14));
  background: #fffdf9;
  box-shadow: 0 6px 18px rgba(20, 24, 31, 0.16);
}

.checkpoint-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--rule, rgba(20, 24, 31, 0.14));
  background: #fffdf9;
  box-shadow: 0 6px 18px rgba(20, 24, 31, 0.16);
}

.slider-labels {
  grid-column: 1 / 2;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.slider-label {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0;
  cursor: pointer;
  transition: color 160ms ease, transform 160ms ease;
}

.slider-label:hover {
  color: var(--ink-2, #5f6872);
}

.slider-label.is-active {
  color: var(--ink);
  transform: translateY(-1px);
}

/* ==========================================================
   Impact Controls
   ========================================================== */

.impact-controls {
  display: grid;
  grid-column: 2 / 3;
  grid-row: 1 / span 3;
  grid-template-columns: 1fr;
  gap: 0.52rem;
  align-content: center;
  padding-left: 0.9rem;
  border-left: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
}

.impact-control {
  display: grid;
  gap: 0.18rem;
}

.impact-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mini-slider {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 999px;
  background: rgba(20, 24, 31, 0.14);
  outline: none;
}

#reliefSlider {
  background: linear-gradient(90deg, rgba(31, 98, 120, 0.16), rgba(31, 98, 120, 0.44));
}

#contrastSlider {
  background: linear-gradient(90deg, rgba(20, 24, 31, 0.12), rgba(181, 62, 43, 0.4));
}

.mini-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.12));
  background: #fffdf9;
  box-shadow: 0 3px 12px rgba(20, 24, 31, 0.12);
}

.mini-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.12));
  background: #fffdf9;
  box-shadow: 0 3px 12px rgba(20, 24, 31, 0.12);
}

.impact-hint {
  margin: 0;
  grid-column: auto;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

/* ==========================================================
   Modal
   ========================================================== */

.modal-shell[hidden] {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 31, 0.34);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 0.88rem;
  width: min(60rem, calc(100% - 2rem));
  max-height: min(90vh, 48rem);
  margin: 4vh auto;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-radius: 1.8rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.68)),
    var(--paper);
  box-shadow: 0 24px 90px rgba(19, 24, 31, 0.22);
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
  padding: 1.4rem;
}

.modal-card::-webkit-scrollbar {
  display: none;
}

.modal-copy {
  max-width: 44rem;
  padding-right: 4.4rem;
}

.modal-kicker {
  margin: 0 0 0.35rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  font-weight: 700;
}

.modal-copy h2 {
  margin: 0;
  font-family: var(--serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 500;
}

.modal-intro {
  margin: 0.72rem 0 0;
  color: var(--ink-2, #56606b);
  line-height: 1.58;
}

/* ── Modal Highlight Grid ─────────────────────── */

.modal-highlight {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) repeat(3, minmax(0, 0.92fr));
  gap: 0.68rem;
  margin-top: -0.02rem;
}

.modal-highlight-callout,
.modal-highlight-stat {
  border-radius: 1.1rem;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
  background: rgba(255, 255, 255, 0.7);
  padding: 0.82rem 0.92rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.modal-highlight-callout {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.62)),
    rgba(255, 255, 255, 0.74);
}

.modal-highlight-stat {
  display: grid;
  align-content: center;
}

.modal-highlight-label,
.modal-highlight-stat span {
  display: block;
  margin: 0 0 0.2rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.66rem;
  font-weight: 700;
}

.modal-highlight-callout strong,
.modal-highlight-stat strong {
  display: block;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.16;
}

.modal-highlight-callout p {
  margin: 0.4rem 0 0;
  color: var(--ink-2, #55606b);
  line-height: 1.45;
  font-size: 0.92rem;
}

/* ── Modal Bridge ─────────────────────────────── */

.modal-bridge {
  margin: -0.08rem 0 0;
  padding: 0.7rem 0.82rem 0.76rem;
  border-radius: 1rem;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.07));
  background: rgba(255, 255, 255, 0.46);
  color: var(--ink-2, #4e5964);
  line-height: 1.54;
}

/* ── Modal Table ──────────────────────────────── */

.modal-table-section {
  display: grid;
  gap: 0.6rem;
}

.modal-table-head {
  display: grid;
  gap: 0.28rem;
}

.modal-table-head h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-table-head p {
  margin: 0;
  color: var(--ink-2, #58636e);
  line-height: 1.5;
}

.modal-table-wrap {
  overflow: hidden;
  border-radius: 1.15rem;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.modal-table th,
.modal-table td {
  padding: 0.82rem 0.9rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
}

.modal-table thead th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.5);
}

.modal-table tbody th {
  color: var(--ink);
  font-weight: 700;
  width: 5rem;
}

.modal-table tbody td {
  color: var(--ink-2, #55606b);
  line-height: 1.45;
}

.modal-table tbody tr:last-child th,
.modal-table tbody tr:last-child td {
  border-bottom: 0;
}

.modal-footnote {
  margin: -0.06rem 0 0;
  color: var(--ink-2, #55606b);
  font-size: 0.9rem;
  line-height: 1.48;
}

/* ── Modal Grid & Panels ─────────────────────── */

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.modal-panel {
  border-radius: 1.35rem;
  border: 1px solid var(--rule, rgba(20, 24, 31, 0.08));
  background: rgba(255, 255, 255, 0.62);
  padding: 0.88rem 0.92rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.modal-panel--guarded {
  background: rgba(245, 251, 253, 0.9);
}

.modal-panel-kicker {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  font-weight: 700;
}

.modal-panel h3 {
  margin: 0.28rem 0 0.56rem;
  font-size: 1.1rem;
}

.metric-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.48rem;
}

.metric-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink-2, #56606b);
  font-size: 0.92rem;
}

.metric-list strong {
  color: var(--ink);
  font-weight: 700;
}

.modal-panel-note {
  margin: 0.68rem 0 0;
  color: var(--ink-2, #5a6570);
  line-height: 1.55;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  padding: 0.48rem 0.78rem;
  font-size: 0.76rem;
}

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 820px) {
  .artifact {
    padding: 1rem;
    gap: 1rem;
  }

  .artifact-tools {
    display: grid;
  }

  .artifact-head {
    grid-template-columns: 1fr;
  }

  .artifact-kicker,
  .artifact-title,
  .artifact-note,
  .artifact-brief,
  .artifact-tools {
    grid-column: auto;
    grid-row: auto;
  }

  .stage {
    min-height: 56svh;
    border-radius: 1.5rem;
  }

  .stage.is-stacked {
    min-height: 86svh;
  }

  .artifact-brief {
    padding-left: 0.8rem;
  }

  .plate-label {
    top: 0.9rem;
  }

  .plate-label--left {
    left: 1rem;
  }

  .plate-label--right {
    right: 1rem;
  }

  .stage.is-stacked .plate-label--left {
    left: 1rem;
    right: auto;
    top: 0.9rem;
    text-align: left;
  }

  .stage.is-stacked .plate-label--right {
    left: 1rem;
    right: auto;
    top: calc(50% + 0.8rem);
    text-align: left;
  }

  .scrubber-head {
    flex-direction: column;
    align-items: start;
  }

  .figure-caption {
    grid-template-columns: 1fr;
  }

  .caption-support,
  .axis-legend,
  .ribbon-legend {
    grid-column: auto;
  }

  .scrubber {
    grid-template-columns: 1fr;
  }

  .impact-controls {
    grid-column: auto;
    grid-row: auto;
    grid-template-columns: 1fr;
    padding-left: 0;
    border-left: 0;
  }

  .impact-hint {
    text-align: left;
  }

  .artifact-actions {
    justify-content: flex-start;
  }

  .modal-card {
    width: calc(100% - 1rem);
    margin: 2vh auto;
    padding: 1rem;
    border-radius: 1.25rem;
  }

  .modal-copy {
    padding-right: 3.8rem;
  }

  .modal-highlight {
    grid-template-columns: 1fr;
  }

  .modal-bridge {
    margin-top: -0.02rem;
  }

  .modal-table {
    font-size: 0.86rem;
  }

  .modal-table th,
  .modal-table td {
    padding: 0.72rem 0.78rem;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .plate-name {
    font-size: 1.18rem;
  }

  .plate-sub {
    max-width: 14rem;
  }
}

/* ==========================================================
   Dark Mode
   ========================================================== */

[data-theme="dark"] {
  --paper: #1a1e26;
  --paper-shadow: #12151b;
  --line: rgba(255, 255, 255, 0.08);
  --faint: #5a6370;
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.03), transparent 28%),
    linear-gradient(180deg, var(--bg, #0a0a0f), #0d1017);
}

/* Stage */
[data-theme="dark"] .stage {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--surface, #13161d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 60px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .stage::before {
  background:
    radial-gradient(48% 72% at 24% 56%, rgba(212, 108, 85, 0.06), transparent 70%),
    radial-gradient(48% 72% at 76% 56%, rgba(35, 120, 154, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%);
}

/* Plate labels */
[data-theme="dark"] .plate-label-bg {
  background: rgba(15, 18, 24, 0.88);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Buttons & toggles */
[data-theme="dark"] .artifact-action,
[data-theme="dark"] .modal-close {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .artifact-action:hover,
[data-theme="dark"] .modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

[data-theme="dark"] .view-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

[data-theme="dark"] .view-toggle-button.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: #14181f;
}

/* Figure caption */
[data-theme="dark"] .figure-caption {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

/* Legend swatches */
[data-theme="dark"] .marker-swatch {
  background: rgba(30, 35, 44, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

/* Scrubber */
[data-theme="dark"] .scrubber {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

[data-theme="dark"] .checkpoint-slider {
  box-shadow: none;
}

[data-theme="dark"] .checkpoint-slider::-webkit-slider-thumb {
  background: var(--surface, #1a1e26);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .checkpoint-slider::-moz-range-thumb {
  background: var(--surface, #1a1e26);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .slider-label.is-active {
  color: var(--accent, #e8927c);
}

/* Experiment table modal */
[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-panel {
  background: var(--surface, #13161d);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .modal-panel th {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .modal-panel td {
  border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .modal-panel tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}
