:root {
  color-scheme: light;
  --bg: #f6f0e6;
  --panel: #fffaf4;
  --ink: #221a16;
  --muted: #6f6257;
  --line: #d8cbbb;
  --accent: #b14d30;
  --accent-soft: #f4d9ce;
  --odd: #ffe3c7;
  --even: #ddebff;
  --blue: #326fc5;
  --orange: #d17a17;
  --red: #b13838;
  --green: #3e8a46;
  --shadow: 0 18px 40px rgba(82, 55, 24, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #fff8ec 0, #fff8ec 18%, transparent 42%),
    linear-gradient(180deg, #f1e8dc 0%, var(--bg) 100%);
}

.page {
  max-width: 1340px;
  margin: 0 auto;
  padding: 36px 24px 48px;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
h3,
p,
ol {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.06;
  margin-bottom: 14px;
}

.lead,
.hint {
  color: var(--muted);
}

.lead {
  max-width: 88ch;
  font-size: 1.06rem;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(125, 93, 57, 0.12);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.controls {
  margin-bottom: 20px;
}

.control-grid {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: end;
}

.picker {
  display: grid;
  gap: 8px;
  min-width: 320px;
  color: var(--muted);
  font-size: 0.95rem;
}

select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  color: var(--muted);
}

.summary-grid,
.proof-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 18px;
}

.summary-grid {
  margin-top: 18px;
}

.proof-grid {
  margin-bottom: 22px;
}

.proof-card {
  border-radius: 16px;
  border: 1px dashed #ddbea0;
  background: linear-gradient(180deg, #fffdf8 0%, #fff6ea 100%);
  padding: 14px 16px;
}

.label {
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.82rem;
}

.big {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 1.02rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 20px;
  align-items: start;
}

.network-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.network-panel,
.state-panel {
  min-width: 0;
}

.row-labels {
  display: grid;
  gap: 18px;
  padding-top: 42px;
}

.row-label {
  height: 28px;
  display: grid;
  align-items: center;
  font-family: "SF Mono", "Menlo", monospace;
  color: var(--muted);
  white-space: nowrap;
}

.network {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(68px, 1fr));
  gap: 14px;
  min-width: max-content;
}

.layer {
  position: relative;
  min-height: var(--network-height);
  border-radius: 18px;
  border: 1px solid #e1d5c7;
  background: #fffdfa;
  padding: 12px 8px;
}

.layer.active {
  background: linear-gradient(180deg, #fff8ef 0%, #fff 100%);
  border-color: #d7a37f;
  box-shadow: inset 0 0 0 2px rgba(177, 77, 48, 0.16);
}

.layer-title {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 12px;
}

.wire-stack {
  position: relative;
  height: calc(var(--rows) * 46px);
}

.wire {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  background: #dbcab8;
}

.node {
  position: absolute;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -5px;
  border-radius: 999px;
  background: #a28e7d;
  border: 2px solid white;
}

.comp-line {
  position: absolute;
  left: 50%;
  width: 4px;
  margin-left: -2px;
  border-radius: 999px;
  background: #b58d73;
}

.comp-cap {
  position: absolute;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 999px;
  border: 3px solid #b58d73;
  background: white;
}

.layer.active .comp-line,
.layer.active .comp-cap {
  background: var(--accent);
  border-color: var(--accent);
}

.schedule-list {
  margin: 18px 0 0;
  padding-left: 20px;
}

.schedule-list li + li {
  margin-top: 8px;
}

.row-block + .row-block {
  margin-top: 24px;
}

.row-head {
  margin-bottom: 12px;
}

.row-head h3 {
  margin-bottom: 6px;
}

.cell-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
}

.cell {
  width: 84px;
  min-height: 92px;
  border-radius: 18px;
  border: 2px solid #d4c4b4;
  background: white;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  align-items: start;
  gap: 8px;
  padding: 10px 8px 12px;
  position: relative;
}

.cell.active-odd {
  background: linear-gradient(180deg, #fff7f0 0%, #fff 100%);
  border-color: #d49a72;
}

.cell.active-even {
  background: linear-gradient(180deg, #f3f7ff 0%, #fff 100%);
  border-color: #7f99d4;
}

.cell.active-swap {
  box-shadow: inset 0 0 0 3px rgba(177, 77, 48, 0.16);
  border-color: #b9774f;
}

.cell.swap-animating .cell-value {
  opacity: 0.15;
}

.cell.target {
  background: #fffdfa;
}

.cell.bad-k {
  box-shadow: inset 0 0 0 4px rgba(177, 56, 56, 0.15);
  border-color: #be5757;
}

.cell.bad-r {
  box-shadow: inset 0 0 0 4px rgba(62, 138, 70, 0.14);
  border-color: #5aa15f;
}

.cell.witness-k {
  box-shadow: inset 0 0 0 4px rgba(209, 122, 23, 0.16);
  border-color: #d2842f;
}

.cell.witness-r {
  box-shadow: inset 0 0 0 4px rgba(50, 111, 197, 0.16);
  border-color: #4b86da;
}

.cell-index {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-value {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.1rem;
}

.cell-value.zero {
  background: #fbf6ef;
  color: #5f5146;
  border: 1px solid #ddcfc0;
}

.cell-value.one {
  background: #202020;
  color: white;
  border: 1px solid #202020;
}

.cell-value.num {
  background: linear-gradient(180deg, #fff8ef 0%, #fff0e1 100%);
  color: #6d4a2e;
  border: 1px solid #e4c7aa;
}

.swap-overlay-chip {
  position: absolute;
  margin: 0;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 10px 22px rgba(86, 57, 26, 0.18);
}

.marker-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: white;
}

.marker-tag.k {
  background: var(--red);
}

.marker-tag.r {
  background: var(--blue);
}

.proof-box {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf7 0%, #fff6ea 100%);
  border: 1px dashed #ddbea0;
}

code {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.95em;
}

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

@media (max-width: 760px) {
  .summary-grid,
  .proof-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .page {
    padding-inline: 16px;
  }

  .summary-grid,
  .proof-grid {
    grid-template-columns: 1fr;
  }

  .cell {
    width: 62px;
    min-height: 78px;
    padding: 8px 6px 10px;
    gap: 6px;
  }

  .cell-row {
    gap: 8px;
  }

  .cell-value {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1rem;
  }

  .marker-tag {
    top: 6px;
    right: 6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 0.68rem;
  }
}
