:root {
  color-scheme: light;
  --bg: #f4efe6;
  --ink: #1b1a18;
  --muted: #675f54;
  --panel: rgba(255, 251, 245, 0.88);
  --panel-strong: #fffaf2;
  --line: rgba(72, 55, 30, 0.14);
  --accent: #9e3d22;
  --accent-soft: #e7c2a4;
  --teal: #0f6b66;
  --teal-soft: #bee5df;
  --gold: #bc8a21;
  --shadow: 0 24px 80px rgba(71, 43, 10, 0.12);
  --radius: 24px;
  --radius-small: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(188, 138, 33, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 107, 102, 0.14), transparent 30%),
    linear-gradient(180deg, #f7f2ea 0%, #efe4d2 100%);
  font: 16px/1.6 "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

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

.page-shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 52px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 36px;
  border: 1px solid rgba(158, 61, 34, 0.12);
  border-radius: calc(var(--radius) + 8px);
  background:
    linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(251, 243, 230, 0.92)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23b79258' stroke-opacity='.18'%3E%3Cpath d='M14 90h152M90 14v152'/%3E%3Ccircle cx='90' cy='90' r='52'/%3E%3Cpath d='M38 38l104 104M142 38L38 142'/%3E%3C/g%3E%3C/svg%3E");
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -60px -80px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 107, 102, 0.18) 0%, rgba(15, 107, 102, 0) 68%);
}

.eyebrow,
.section-label,
.metric-label,
.formula-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--muted);
}

.hero h1,
.panel h2,
.result-heading h3,
.note-card h2,
.explain-grid h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  line-height: 1.08;
}

.hero h1 {
  max-width: 14ch;
  margin-top: 8px;
  font-size: clamp(2.8rem, 6vw, 5.2rem);
}

.lede {
  max-width: 72ch;
  margin-top: 18px;
  color: #3c372f;
  font-size: 1.08rem;
}

.hero-notes,
.results-grid,
.explain-grid,
.metric-grid,
.chart-grid,
.controls-grid,
.content-grid {
  display: grid;
  gap: 18px;
}

.hero-notes {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 28px;
}

.note-card,
.metric-card,
.chart-card,
.result-card,
.panel,
.formula-band,
.explain-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.note-card {
  padding: 22px;
}

.note-card p {
  margin-top: 10px;
  color: #4b443a;
}

.content-grid {
  margin-top: 22px;
}

.panel {
  padding: 28px;
  box-shadow: var(--shadow);
}

.panel-heading,
.result-heading,
.button-row,
.formula-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.status-pill {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(15, 107, 102, 0.12);
  color: var(--teal);
  font-weight: 700;
}

.status-pill.alt {
  background: rgba(188, 138, 33, 0.12);
  color: #875f08;
}

.panel-copy,
.result-note,
.explain-grid p {
  color: #4d463e;
}

.panel-copy {
  max-width: 84ch;
  margin-top: 10px;
}

.controls-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 22px;
}

.controls-grid label {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: rgba(255, 251, 245, 0.95);
}

.controls-grid output {
  font-weight: 700;
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.button-row {
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: white;
  background: linear-gradient(135deg, #9e3d22, #6d2610);
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(123, 46, 16, 0.18);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(123, 46, 16, 0.24);
}

button:active {
  transform: translateY(1px);
}

.metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 20px;
}

.metric-card {
  padding: 18px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card strong {
  font-size: 1.42rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.chart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
}

.chart-card,
.large-chart {
  padding: 18px;
}

.chart-card figcaption {
  margin-bottom: 12px;
  font-weight: 700;
}

canvas {
  width: 100%;
  display: block;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 249, 242, 0.96), rgba(248, 238, 222, 0.94));
  border: 1px solid rgba(72, 55, 30, 0.1);
}

.formula-band {
  margin-top: 20px;
  padding: 16px 18px;
  gap: 20px;
}

.formula-band strong {
  display: block;
  margin-top: 4px;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 1.08rem;
}

.results-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
}

.result-card {
  padding: 20px;
}

.accent-local {
  box-shadow: inset 0 0 0 1px rgba(158, 61, 34, 0.1);
}

.accent-quantum {
  box-shadow: inset 0 0 0 1px rgba(15, 107, 102, 0.14);
}

table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 0;
  border-bottom: 1px solid rgba(72, 55, 30, 0.1);
  text-align: left;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.result-note {
  margin-top: 12px;
}

.large-chart {
  margin-top: 20px;
}

.explain-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
}

.explain-grid article {
  padding: 20px;
}

@media (max-width: 1080px) {
  .controls-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid,
  .results-grid,
  .explain-grid,
  .hero-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 16px, 1320px);
    padding-top: 16px;
  }

  .hero,
  .panel {
    padding: 20px;
  }

  .controls-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: 10ch;
    font-size: clamp(2.4rem, 12vw, 4rem);
  }
}