:root {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #233e50;
  background: #f2f5f7;
  font-synthesis: none;
  --ink: #233e50;
  --muted: #687b87;
  --line: #dae3e8;
  --accent: #216d94;
  --on: #69cbe2;
  --off: #173744;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 16px; }
button, input, select { font: inherit; }
button, label.button, input[type=range], select { cursor: pointer; }
button, a, input, select { outline-offset: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #319dbb; }
button:disabled { cursor: not-allowed; opacity: .5; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 88px; padding: 18px 36px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; color: var(--ink); font-size: 20px; font-weight: 650; white-space: nowrap; }
.brand small { display: block; margin-top: 4px; font-size: 9px; letter-spacing: 1.9px; font-weight: 650; color: var(--muted); }
.brand-mark { display: grid; grid-template-columns: repeat(3, 6px); grid-template-rows: repeat(3, 6px); gap: 3px; place-content: center; width: 43px; height: 43px; background: #183b50; border-radius: 11px; }
.brand-mark i { background: #2d5669; border-radius: 1px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4), .brand-mark i:nth-child(6), .brand-mark i:nth-child(7), .brand-mark i:nth-child(8), .brand-mark i:nth-child(9) { background: var(--on); }
.app-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 40px; border: 1px solid #cfdce3; border-radius: 7px; background: #fff; color: var(--ink); padding: 9px 14px; font-size: 14px; font-weight: 600; text-decoration: none; transition: background .15s; }
.button:hover { background: #edf5f9; border-color: #98bccd; }
.button.quiet { background: transparent; border-color: transparent; }
.button.quiet:hover { background: #edf3f6; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: #185675; }
.full { width: 100%; }
.layout { display: grid; grid-template-columns: 285px minmax(0, 1fr); max-width: 1800px; margin: auto; }
.sidebar { padding: 32px 26px; background: #fbfcfd; border-right: 1px solid var(--line); min-height: calc(100vh - 88px); }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 1.6px; color: #5f889a; }
h1, h2, h3, p { margin-top: 0; }
.sidebar h1 { margin: 15px 0 12px; font-size: 28px; line-height: 1.26; font-weight: 600; letter-spacing: -.9px; }
.intro { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 29px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.field-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.field-heading label { margin: 0; }
.field-heading>span { font-size: 12px; color: var(--muted); }
input[type=number], select { width: 100%; background: #fff; border: 1px solid #cddae1; border-radius: 6px; padding: 9px 11px; min-height: 41px; color: var(--ink); font-variant-numeric: tabular-nums; }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23687b87' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field-note { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 7px 0 20px; }
#pattern { margin-bottom: 20px; }
.seed-row { display: flex; align-items: center; gap: 7px; }
.icon-button { font-size: 23px; font-weight: 400; min-width: 42px; padding: 4px; }
.presets { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.presets h2 { font-size: 14px; margin-bottom: 8px; font-weight: 650; }
.presets button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 0; background: transparent; border: 0; border-bottom: 1px solid #e7edf0; color: var(--ink); text-align: left; }
.presets button:hover strong { color: var(--accent); }
.presets strong { display: block; font-size: 13px; font-weight: 600; }
.presets small { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.rule-mini { font-family: Consolas, monospace; font-size: 12px; color: #558198; border: 1px solid #d8e4e9; border-radius: 5px; min-width: 37px; text-align: center; padding: 8px 4px; }
.sidebar-note { font-size: 12px; line-height: 1.7; color: #83949e; margin: 29px 0 0; }
.workspace { padding: 33px 34px 20px; min-width: 0; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.workspace-heading h2 { font-size: 28px; font-weight: 600; letter-spacing: -.9px; margin: 9px 0 0; }
.badge { border: 1px solid #cedee5; color: var(--muted); border-radius: 5px; padding: 7px 9px; font-size: 10px; font-weight: 600; letter-spacing: 1px; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 21px 0; margin-bottom: 25px; }
.stats>div { border-right: 1px solid var(--line); padding: 0 22px; }
.stats>div:first-child { padding-left: 0; }
.stats>div:last-child { border: 0; padding-right: 0; }
.stats span { display: block; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: 1.2px; margin-bottom: 9px; }
.stats strong { display: block; font-size: 26px; font-weight: 550; letter-spacing: -.7px; font-variant-numeric: tabular-nums; }
.stats small { display: block; color: var(--muted); font-size: 11px; margin-top: 7px; line-height: 1.5; }
#stat-bits { letter-spacing: 2px; font-family: Consolas, monospace; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 23px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 25px 18px; }
.panel-heading .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
.panel-heading h3 { font-size: 17px; font-weight: 650; margin: 7px 0; letter-spacing: -.2px; }
.panel-heading p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
.legend { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend>span { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.off-swatch { background: var(--off); }
.on-swatch { background: var(--on); }
.plot-layout { display: flex; gap: 6px; padding: 0 25px 0 10px; }
.y-axis { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; width: 20px; color: var(--muted); font-size: 9px; letter-spacing: 2px; }
.plot-scroll { background: var(--off); width: 100%; max-height: 500px; overflow: auto; border-radius: 5px; }
#evolution { display: block; width: 100%; height: 500px; image-rendering: pixelated; cursor: crosshair; }
.plot-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 11px 25px 16px 36px; font-size: 11px; color: var(--muted); }
.timeline { display: flex; align-items: center; gap: 15px; padding: 0 25px 20px; }
.timeline label { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.timeline output { color: var(--ink); font-weight: 650; min-width: 22px; }
.timeline input { width: 100%; min-width: 30px; accent-color: var(--accent); }
.timeline>span { font-size: 11px; color: var(--muted); }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid #e7eef2; padding: 15px 25px; }
.chart-toolbar>div { display: flex; gap: 6px; flex-wrap: wrap; }
.cell-inspector { display: flex; align-items: center; gap: 11px; padding: 14px 25px; background: #f9fbfc; border-top: 1px solid #e7eef2; }
.cell-inspector label { font-size: 13px; margin: 0; }
.cell-inspector input { width: 80px; min-height: 34px; padding: 6px 9px; font-size: 13px; }
.cell-inspector strong { font-size: 13px; font-weight: 600; }
.cell-inspector>span { font-size: 11px; color: var(--muted); margin-left: auto; }
.mono-badge { color: #54839a; background: #eff5f8; border: 1px solid #deeaee; border-radius: 5px; padding: 7px 9px; letter-spacing: 3px; font-family: Consolas, monospace; font-size: 13px; }
.rule-table { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 9px; padding: 0 25px 22px; }
.rule-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 13px 5px; border: 1px solid #dce5eb; border-radius: 7px; background: #fbfcfd; color: var(--ink); }
.rule-card:hover { border-color: #80b8d0; background: #f0f8fc; }
.neighborhood { display: flex; gap: 3px; }
.mini-cell { display: block; width: 14px; height: 14px; border-radius: 2px; background: #dfe8ed; border: 1px solid #d1dfe5; }
.mini-cell.on { background: #277da4; border-color: #277da4; }
.rule-pattern { color: var(--muted); font-family: Consolas, monospace; font-size: 12px; letter-spacing: 2px; }
.output-cell { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 5px; background: #e4ecf0; color: #617b89; font-size: 14px; font-weight: 650; }
.output-cell.on { background: #22779e; color: #fff; }
.panel-footnote { border-top: 1px solid #e7eef2; color: var(--muted); font-size: 12px; padding: 15px 25px; line-height: 1.6; margin: 0; }
.initial-preview { margin: 0 25px 20px; background: var(--off); border-radius: 4px; overflow: hidden; }
#initial-row { display: block; width: 100%; height: 32px; image-rendering: pixelated; cursor: crosshair; }
.initial-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 0 25px 22px; }
.initial-controls label { margin: 0; font-size: 13px; }
.initial-controls input { width: 82px; font-size: 14px; }
.initial-controls>span { color: var(--muted); font-size: 11px; margin-left: auto; }
footer { display: flex; justify-content: space-between; gap: 20px; color: #83949e; font-size: 10px; line-height: 1.7; }
.notice { padding: 12px 16px; font-size: 14px; line-height: 1.5; color: #285f7b; border: 1px solid #bfdbe7; background: #e8f4f9; border-radius: 7px; margin-bottom: 20px; }
.notice.error { background: #fff1eb; border-color: #e9beab; color: #984224; }
.visually-hidden { position: absolute; height: 1px; width: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -70px; left: 20px; z-index: 10; background: var(--ink); color: #fff; padding: 12px; }
.skip-link:focus { top: 10px; }
dialog { max-width: 650px; width: calc(100% - 32px); max-height: 85vh; border: 1px solid var(--line); border-radius: 12px; padding: 26px 32px; color: var(--ink); box-shadow: 0 25px 100px #17374433; }
dialog::backdrop { background: #15314377; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
dialog h2 { font-size: 28px; line-height: 1.3; letter-spacing: -.5px; margin: 22px 0; }
dialog h3 { font-size: 16px; margin: 24px 0 10px; }
dialog p, dialog li { font-size: 15px; line-height: 1.75; color: #607581; }
dialog li { margin-bottom: 9px; }
dialog .field-note { font-size: 13px; }
@media (min-width: 1600px) {
  .layout { grid-template-columns: 310px minmax(0, 1fr); }
  .workspace { padding: 38px 48px 20px; }
  .sidebar { padding: 38px 33px; }
}
@media (max-width: 1200px) {
  .app-header { padding: 18px 24px; }
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar { padding: 28px 20px; }
  .workspace { padding: 28px 22px 18px; }
  .stats>div { padding: 0 13px; }
  .rule-table { gap: 5px; padding-left: 18px; padding-right: 18px; }
  .mini-cell { width: 11px; height: 11px; }
  .initial-controls>span { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 800px) {
  .app-header { padding: 18px 20px; flex-wrap: wrap; gap: 18px; }
  .app-header nav { gap: 5px; }
  .app-header .button { font-size: 12px; padding: 8px 10px; }
  .layout { display: block; }
  .sidebar { padding: 24px 20px; border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; }
  .sidebar h1 { font-size: 27px; }
  .sidebar h1 br { display: none; }
  .intro { margin-bottom: 24px; }
  .sidebar .presets, .sidebar-note { display: none; }
  #controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
  #controls>.field-heading, #controls>.field-note { grid-column: 1; }
  #controls>input { grid-column: 2; grid-row: span 2; }
  #controls>label { grid-column: 1; padding-top: 12px; }
  #controls>select { grid-column: 2; }
  #controls>#seed-field { grid-column: 1/-1; }
  #controls>#boundary-note { grid-column: 1/-1; margin-top: 8px; }
  #controls>.button { grid-column: 1/-1; }
  .workspace { padding: 25px 20px 18px; }
  .workspace-heading { gap: 10px; }
  .workspace-heading h2 { font-size: 25px; }
  .workspace-heading .eyebrow { font-size: 9px; }
  .workspace-heading>.badge { font-size: 9px; padding: 6px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 0; }
  .stats>div:nth-child(odd) { padding-left: 0; }
  .stats>div:nth-child(even) { border: 0; padding-left: 18px; }
  .panel-heading { padding: 20px 18px 15px; flex-wrap: wrap; gap: 12px; }
  .panel-heading h3 { font-size: 16px; }
  .panel-heading p { font-size: 12px; }
  .legend { margin-left: auto; font-size: 11px; }
  .plot-layout { padding-right: 16px; }
  .plot-caption { font-size: 10px; margin-right: 16px; }
  .plot-caption>span:first-child { display: none; }
  .plot-caption>span:last-child { margin-left: auto; }
  .timeline { padding: 0 16px 18px; gap: 8px; }
  .timeline label { font-size: 11px; gap: 7px; }
  .chart-toolbar { padding: 13px 16px; flex-wrap: wrap; }
  .chart-toolbar .button { font-size: 12px; padding: 8px 12px; }
  .cell-inspector { padding: 13px 16px; flex-wrap: wrap; }
  .cell-inspector>span { flex-basis: 100%; }
  .rule-table { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .mini-cell { width: 14px; height: 14px; }
  .rule-card { gap: 8px; padding: 12px 6px; }
  .panel-footnote { padding: 14px 18px; font-size: 11px; }
  .initial-preview { margin: 0 18px 18px; }
  .initial-controls { padding: 0 18px 20px; gap: 8px; }
  .initial-controls .button { font-size: 12px; }
  footer { display: block; }
  footer span { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
