:root {
  color-scheme: light dark;
  --background: 48 30% 96%;
  --foreground: 30 8% 10%;
  --card: 45 25% 93%;
  --secondary: 45 22% 90%;
  --muted-foreground: 40 6% 39%;
  --accent: 217 84% 46%;
  --destructive: 4 70% 47%;
  --border: 45 18% 85%;
  --success: 142 58% 32%;
  --font-jb: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-space: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: 30 8% 8%;
    --foreground: 45 25% 90%;
    --card: 30 7% 11%;
    --secondary: 30 6% 15%;
    --muted-foreground: 40 8% 55%;
    --accent: 213 90% 64%;
    --destructive: 4 75% 60%;
    --border: 34 7% 20%;
    --success: 142 50% 52%;
  }
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-jb);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: hsl(var(--border)); text-underline-offset: 3px; }
a:hover { text-decoration-color: hsl(var(--accent)); color: hsl(var(--accent)); }
:focus-visible { outline: 1px solid hsl(var(--accent)); outline-offset: 2px; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: var(--font-jb); background: hsl(var(--secondary)); padding: 0 4px; }
kbd {
  font-family: var(--font-jb); font-size: 11px;
  border: 1px solid hsl(var(--border)); background: hsl(var(--secondary));
  padding: 0 4px; margin-left: 2px; color: hsl(var(--muted-foreground));
}

.top, main, .foot { max-width: 980px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.top { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; padding-bottom: 18px; border-bottom: 1px solid hsl(var(--border)); font-size: 13.5px; }
.brand { text-decoration: none; font-weight: 600; }
.mark { color: hsl(var(--accent)); font-weight: 400; }
#clock { font-variant-numeric: tabular-nums; }

.hero { padding: 48px 0 24px; }
.page-title { font-size: clamp(2rem, 4.6vw, 3.25rem); line-height: 1.04; letter-spacing: -0.045em; font-weight: 600; margin: 0 0 12px; }
.cursor-blink::after { content: "▋"; color: hsl(var(--accent)); animation: sx-blink 1s step-end infinite; margin-left: 4px; font-weight: 400; }
@keyframes sx-blink { 50% { opacity: 0; } }
.lede { margin: 0; color: hsl(var(--muted-foreground)); max-width: 60ch; }

.btn, .chip {
  font-family: var(--font-jb); font-size: 13px; color: hsl(var(--foreground));
  background: hsl(var(--background)); border: 1px solid hsl(var(--border));
  padding: 6px 10px; cursor: pointer; transition: border-color .2s, color .2s;
}
.btn:hover, .chip:hover { border-color: hsl(var(--accent)); color: hsl(var(--accent)); }
.chip { font-size: 12.5px; padding: 3px 8px; }
.chip[aria-pressed="true"] { border-color: hsl(var(--foreground)); }
.chip[aria-pressed="true"]::before { content: "▸ "; color: hsl(var(--accent)); }

.editor { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 18px 20px; border-left: 3px solid hsl(var(--state, var(--accent))); }
.editor[data-state="error"] { --state: var(--destructive); }
.expr-row { display: flex; gap: 8px; align-items: stretch; }
.expr {
  flex: 1; min-width: 0;
  font-family: var(--font-jb); font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: 600; letter-spacing: 0.02em;
  color: hsl(var(--foreground)); background: hsl(var(--background));
  border: 1px solid hsl(var(--border)); padding: 8px 12px;
}
.expr:focus { outline: none; border-color: hsl(var(--accent)); }
.cols { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; }
.col { border: 1px solid hsl(var(--border)); padding: 2px 8px; color: hsl(var(--muted-foreground)); background: hsl(var(--background)); }
.col b { color: hsl(var(--foreground)); font-weight: 600; margin-right: 6px; }
.col.bad { border-color: hsl(var(--destructive)); color: hsl(var(--destructive)); }
.col.bad b { color: hsl(var(--destructive)); }
.explain { font-family: var(--font-space); font-size: clamp(1.15rem, 2.2vw, 1.45rem); font-weight: 700; letter-spacing: -0.01em; margin: 14px 0 0; }
.error { margin: 14px 0 0; color: hsl(var(--destructive)); font-size: 14px; }

.block { margin-top: 40px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-heading { font-family: var(--font-space); font-size: clamp(1.35rem, 2.2vw, 1.7rem); letter-spacing: -0.01em; font-weight: 700; margin: 0; }
.section-heading::before { content: "■ "; color: hsl(var(--accent)); font-weight: 400; }
.toggle { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.toggle input { accent-color: hsl(var(--accent)); }

.builder { border: 1px solid hsl(var(--border)); }
.field { display: grid; grid-template-columns: 130px 170px minmax(0, 1fr); gap: 14px; align-items: center; padding: 10px 16px; border-top: 1px solid hsl(var(--border)); }
.field:first-child { border-top: 0; }
.field-name { font-size: 13.5px; }
.field-name span { display: block; font-size: 11.5px; color: hsl(var(--muted-foreground)); }
.field input {
  font-family: var(--font-jb); font-size: 14px; width: 100%;
  color: hsl(var(--foreground)); background: hsl(var(--background));
  border: 1px solid hsl(var(--border)); padding: 5px 8px;
}
.field input:focus { outline: none; border-color: hsl(var(--accent)); }
.field.bad input { border-color: hsl(var(--destructive)); }
.field .opts { display: flex; gap: 5px; flex-wrap: wrap; }

.zones { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.zone { font-family: var(--font-jb); font-size: 12.5px; width: 190px; padding: 3px 8px; color: hsl(var(--foreground)); background: hsl(var(--background)); border: 1px solid hsl(var(--border)); }
.zone:focus { outline: none; border-color: hsl(var(--accent)); }
.zone.bad { border-color: hsl(var(--destructive)); }
.runs { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid hsl(var(--border)); counter-reset: run; }
.runs li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; padding: 8px 16px; border-top: 1px solid hsl(var(--border)); font-size: 14px; font-variant-numeric: tabular-nums; counter-increment: run; }
.runs li:first-child { border-top: 0; }
.runs li::before { content: counter(run, decimal-leading-zero); color: hsl(var(--muted-foreground)); }
.runs li .rel { color: hsl(var(--muted-foreground)); font-size: 12.5px; }
.runs li.none { display: block; color: hsl(var(--muted-foreground)); }
.runs li.none::before { content: none; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); border-top: 1px solid hsl(var(--border)); border-left: 1px solid hsl(var(--border)); }
.preset {
  text-align: left; font-family: var(--font-jb); font-size: 13px; color: hsl(var(--foreground));
  background: hsl(var(--background)); border: 0; border-right: 1px solid hsl(var(--border)); border-bottom: 1px solid hsl(var(--border));
  padding: 10px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px;
}
.preset:hover { color: hsl(var(--accent)); }

.foot { margin-top: 56px; padding-top: 18px; padding-bottom: 40px; border-top: 1px solid hsl(var(--border)); }
.foot p { margin: 4px 0; }
.preset code { background: none; padding: 0; font-weight: 600; white-space: nowrap; }
.preset span { color: hsl(var(--muted-foreground)); text-align: right; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  margin: 0; padding: 8px 14px; font-size: 12.5px;
  background: hsl(var(--foreground)); color: hsl(var(--background));
  border: 1px solid hsl(var(--foreground));
}

@media (max-width: 720px) {
  .field { grid-template-columns: 1fr 1fr; }
  .field .opts { grid-column: 1 / -1; }
  .expr-row { flex-wrap: wrap; }
  .expr { flex-basis: 100%; }
  .keys { display: none; }
  .runs li { grid-template-columns: 24px minmax(0, 1fr); }
  .runs li .rel { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
