:root {
  color-scheme: light;
  --paper: #f7f3e7;
  --surface: #fffdf7;
  --ink: #071720;
  --muted: #40535c;
  --line: rgba(7, 23, 32, 0.34);
  --teal: #2e7487;
  --gold: #b68327;
  --rust: #a34f32;
  --shadow: rgba(7, 23, 32, 0.18);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  background:
    linear-gradient(rgba(7, 23, 32, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 23, 32, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 64px 64px;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  margin: 0;
  min-height: 100vh;
}

.site-header {
  align-items: center;
  background: rgba(247, 243, 231, 0.96);
  border-bottom: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  padding: 14px clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 900;
  text-decoration: none;
}

.topbar {
  display: flex;
  gap: 16px;
}

.topbar a {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.page-hero,
.section {
  padding: clamp(46px, 7vw, 88px) clamp(18px, 6vw, 86px) 32px;
}

.page-hero h1,
.section-heading h2 {
  font-size: clamp(2.2rem, 6vw, 5.4rem);
  letter-spacing: 0;
  line-height: 1;
  margin: 10px 0 18px;
  max-width: 1100px;
}

.page-hero > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 820px;
}

.eyebrow {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.demo-page {
  padding: 20px clamp(18px, 6vw, 86px) clamp(56px, 8vw, 100px);
}

.demo-shell,
.quantum-layout,
.comparison-layout {
  align-items: start;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(220px, 0.28fr) minmax(0, 1fr);
}

.control-stack,
.comparison-list,
.terminal {
  background: var(--surface);
  border: 2px solid var(--ink);
  display: grid;
  gap: 14px;
  padding: 18px;
}

.control-stack label {
  color: var(--muted);
  display: grid;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 800;
  gap: 8px;
}

input,
select {
  accent-color: var(--teal);
  width: 100%;
}

select {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px;
}

button {
  background: var(--ink);
  border: 2px solid var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 900;
  min-height: 42px;
  padding: 10px 12px;
}

button:hover,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.demo-surface,
.chart-wrap,
.lattice-panel {
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: 0 16px 38px var(--shadow);
  min-width: 0;
  overflow: hidden;
  position: relative;
}

canvas {
  display: block;
  height: auto;
  max-height: 72vh;
  width: 100%;
}

.readout,
.equation,
.comparison-note {
  background: rgba(46, 116, 135, 0.1);
  border-left: 4px solid var(--teal);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  min-height: 48px;
  padding: 12px;
}

.chart-wrap .readout {
  border-left: 0;
  border-top: 1px solid var(--line);
}

.sim-buttons {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
}

.terminal {
  align-content: start;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  min-height: 320px;
  white-space: pre-wrap;
}

.comparison-list button {
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.comparison-list button.active {
  background: var(--teal);
  color: white;
}

.comparison-detail,
.comparison-columns {
  display: grid;
  gap: 18px;
}

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

.comparison-columns article {
  background: var(--surface);
  border: 2px solid var(--ink);
  padding: 18px;
}

.matrix-table {
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) repeat(2, minmax(220px, 1fr));
  overflow-x: auto;
}

.matrix-cell {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 0;
  padding: 14px;
}

.matrix-cell.header,
.matrix-cell.label {
  font-family: var(--mono);
  font-weight: 900;
}

.matrix-cell button {
  height: 100%;
  width: 100%;
}

.matrix-explain {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  margin-top: 16px;
  min-height: 70px;
  padding: 18px;
}

.law-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.law-grid article {
  background: var(--surface);
  border: 2px solid var(--ink);
  padding: 22px;
}

.law-index {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 900;
}

.demo-status {
  align-items: center;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  font-family: var(--mono);
  font-size: 0.78rem;
  justify-content: space-between;
  padding: 10px 14px;
}

.demo-status a {
  color: var(--paper);
  font-weight: 900;
}

@media (max-width: 820px) {
  .site-header,
  .demo-shell,
  .quantum-layout,
  .comparison-layout,
  .comparison-columns,
  .law-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-hero h1,
  .section-heading h2 {
    font-size: clamp(2rem, 11vw, 3.5rem);
  }

  .matrix-table {
    grid-template-columns: 140px repeat(2, 240px);
  }
}
