:root {
  --bg: #f6f1e8;
  --bg-soft: #efe6d5;
  --paper: rgba(255, 250, 241, 0.86);
  --ink: #1f2933;
  --muted: #5d6b78;
  --line: rgba(31, 41, 51, 0.12);
  --accent: #9b3d2f;
  --accent-soft: rgba(155, 61, 47, 0.1);
  --shadow: 0 24px 60px rgba(52, 38, 24, 0.12);
}

* {
  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(155, 61, 47, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(48, 96, 112, 0.16), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, #fbf7ef 100%);
  font-family: "IBM Plex Sans", "Helvetica Neue", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 75%);
}

.page-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 72px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.site-sidebar {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 18px;
}

.sidebar-card,
.sidebar-nav {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 249, 239, 0.88), rgba(247, 238, 220, 0.8));
  box-shadow: var(--shadow);
}

.sidebar-card {
  padding: 28px 24px;
  display: grid;
  place-items: center;
}

.sidebar-card h1 {
  margin-top: 12px;
  font-size: clamp(3.1rem, 8vw, 4.6rem);
}

.brand-mark {
  aspect-ratio: 1 / 1;
  width: 100%;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid rgba(155, 61, 47, 0.18);
  background:
    radial-gradient(circle at top left, rgba(155, 61, 47, 0.18), transparent 36%),
    linear-gradient(160deg, rgba(255, 252, 246, 0.95), rgba(243, 232, 214, 0.9));
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.brand-mark-title {
  display: block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(3rem, 8vw, 4.4rem);
  line-height: 0.9;
  text-align: center;
  color: var(--ink);
}

.sidebar-nav {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.sidebar-nav a {
  display: block;
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.4;
  transition: background 140ms ease, transform 140ms ease;
}

.sidebar-nav a span {
  color: var(--muted);
  font-size: 0.9rem;
}

.sidebar-nav a:hover {
  background: rgba(155, 61, 47, 0.1);
  transform: translateX(2px);
}

.site-main {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.hero {
  width: 100%;
  padding: 40px clamp(24px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 249, 239, 0.9), rgba(247, 238, 220, 0.82));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -35% auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(155, 61, 47, 0.18), transparent 68%);
}

.eyebrow,
.section-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  line-height: 0.95;
}

h1 {
  margin-top: 14px;
  font-size: clamp(4rem, 12vw, 7rem);
}

.hero-title {
  margin-top: 10px;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 0.98;
}

.hero-copy {
  margin: 18px 0 0;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--muted);
}

.content-grid {
  display: grid;
  gap: 24px;
}

.panel {
  padding: clamp(24px, 4vw, 36px);
  border-radius: 26px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel-head {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

h2 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
}

h3 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  margin-bottom: 14px;
}

.lead {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.8;
}

.formula-card,
.subpanel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
}

.formula-card {
  padding: 22px;
  margin-bottom: 18px;
}

.formula-label {
  margin: 0 0 12px;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.formula-block {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
  border-radius: 16px;
  background: #1e252c;
  color: #f8f1e8;
  font-size: clamp(0.88rem, 1.25vw, 1.05rem);
  line-height: 1.45;
  font-family: "Times New Roman", Georgia, serif;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.subpanel {
  padding: 22px;
}

.table-panel {
  padding: 24px;
}

.evolution-panel {
  margin-top: 18px;
}

.benchmark-panel {
  margin-bottom: 18px;
}

.evolution-copy {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.75;
}

.timeline-list {
  display: grid;
  gap: 16px;
}

.timeline-item {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid rgba(155, 61, 47, 0.24);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.timeline-item h4 {
  margin: 6px 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.45rem;
  line-height: 1.05;
}

.timeline-item p {
  margin: 0;
  line-height: 1.75;
}

.timeline-item p + p {
  margin-top: 10px;
}

.timeline-formula code {
  display: inline-block;
  padding: 0.45rem 0.6rem;
  line-height: 1.7;
}

.timeline-date {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.timeline-metric {
  color: var(--ink);
  font-weight: 500;
}

.flowchart {
  display: grid;
  gap: 16px;
}

.flow-node {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  position: relative;
}

.module-step {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.flow-node h3 {
  margin-bottom: 12px;
}

.flow-node p {
  margin: 0;
  line-height: 1.75;
}

.flow-node p + p {
  margin-top: 10px;
}

.flow-start,
.flow-mid,
.flow-decision,
.flow-end {
  width: min(760px, 100%);
  justify-self: center;
}

.flow-arrow {
  justify-self: center;
  font-size: 1.15rem;
  color: var(--accent);
  line-height: 1;
}

.flow-branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.flow-branch {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.42);
}

.branch-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--accent);
  text-align: center;
}

.branch-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  text-align: center;
}

.flow-layer {
  position: relative;
}

.layer-tag {
  margin: 0 0 8px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.flow-fallback {
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(239, 230, 213, 0.78));
}

.flow-output {
  background: rgba(247, 238, 220, 0.82);
}

.flow-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.governance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.notation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.notation-card,
.notation-detail {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.notation-card h4,
.notation-detail h4 {
  margin: 6px 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.4rem;
  line-height: 1.05;
}

.notation-card p,
.notation-detail p {
  margin: 0;
  line-height: 1.75;
}

.notation-detail-list {
  display: grid;
  gap: 12px;
}

.governance-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.governance-card h4 {
  margin: 6px 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.4rem;
  line-height: 1.05;
}

.governance-card p {
  margin: 0;
  line-height: 1.75;
}

.resource-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.resource-link:hover {
  text-decoration: underline;
}

.governance-panel,
.trigger-panel {
  margin-top: 18px;
}

.governance-example {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.workbench-textarea,
.workbench-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
}

.workbench-textarea {
  min-height: 240px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.6;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
}

.workbench-textarea-short {
  min-height: 180px;
}

.workbench-input {
  padding: 12px 14px;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.workbench-actions {
  margin-top: 14px;
}

.workbench-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.action-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff8f1;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(155, 61, 47, 0.2);
}

.action-button-secondary {
  background: rgba(155, 61, 47, 0.12);
  color: var(--accent);
  box-shadow: none;
}

.action-button:hover {
  filter: brightness(1.04);
}

.action-button:disabled {
  background: rgba(31, 41, 51, 0.16);
  color: rgba(31, 41, 51, 0.48);
  box-shadow: none;
  cursor: not-allowed;
  filter: none;
}

.input-table {
  min-width: 880px;
}

.workbench-table-wrap {
  margin-top: 14px;
}

.table-field,
.table-select {
  width: 100%;
  min-width: 110px;
  height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font: inherit;
}

.table-field[type="number"] {
  min-width: 140px;
}

.table-field[data-field="value"] {
  min-width: 160px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.benchmark-table .table-field {
  min-width: 160px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-action {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(31, 41, 51, 0.08);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.row-action:hover {
  background: rgba(31, 41, 51, 0.14);
}

.inline-feedback {
  min-height: 1.4rem;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.result-panel {
  margin-top: 18px;
}

.workbench-benchmark-panel {
  margin-top: 18px;
}

.benchmark-table {
  min-width: 560px;
}

.result-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-chip {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
}

.empty-state {
  color: var(--muted);
}

.empty-state-cell {
  color: var(--muted);
  text-align: center;
}

.module-output,
.flow-output p:last-child {
  font-weight: 500;
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  font-size: 0.92rem;
}

thead th {
  position: sticky;
  top: 0;
  background: #efe3cf;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.benchmark-table td {
  vertical-align: middle;
}

tbody tr:nth-child(even) {
  background: rgba(155, 61, 47, 0.035);
}

tbody tr:hover {
  background: rgba(48, 96, 112, 0.08);
}

td:first-child,
th:first-child {
  white-space: nowrap;
}

.math-token {
  font-style: italic;
}

.math-operator {
  display: inline-block;
  padding: 0 0.45rem;
  font-style: normal;
}

.math-group {
  display: inline-block;
}

ul,
ol {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.85;
}

li + li {
  margin-top: 0.45rem;
}

code {
  padding: 0.12rem 0.36rem;
  border-radius: 0.4rem;
  background: var(--accent-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.95em;
}

.formula-block code {
  padding: 0;
  background: transparent;
  color: inherit;
}

@media (max-width: 800px) {
  .page-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 20px;
    grid-template-columns: 1fr;
  }

  .hero,
  .panel {
    border-radius: 22px;
  }

  .site-sidebar {
    position: static;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 840px;
  }

  .flow-branches,
  .flow-split,
  .governance-grid,
  .notation-grid {
    grid-template-columns: 1fr;
  }
}
