:root {
  --bg: #11110f;
  --surface: #1b1a17;
  --fg: #ece8df;
  --muted: #9a9488;
  --subtle: #6e6a62;
  --primary: #5f8a86;
  --primary-fg: #0e1413;
  --border: #2c2a26;
  --danger: #c45c4a;
  --sans: "Figtree", "Segoe UI", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.5;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--border) 0.6px, transparent 0.6px);
  background-size: 7px 7px;
  opacity: 0.35;
}

.wrap {
  position: relative;
  max-width: 72rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.kicker {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
h1 em {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-style: italic;
}

.lede {
  max-width: 40rem;
  margin: 1.25rem 0 1.5rem;
  color: var(--muted);
}

.engines {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chip {
  height: 2.25rem;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: 500 0.75rem/1 var(--sans);
  cursor: pointer;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}

.desk {
  display: grid;
  gap: 1.1rem;
}
@media (min-width: 960px) {
  .desk { grid-template-columns: 1fr 1fr; }
}

.panel {
  min-height: 26rem;
  display: flex;
  flex-direction: column;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.panel-head label,
.panel-head h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.count { font-family: var(--mono); font-size: 0.7rem; color: var(--subtle); }
.count.over { color: var(--danger); }

textarea,
.result {
  flex: 1;
  min-height: 16rem;
  width: 100%;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  resize: none;
}
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: 0;
}
.result {
  overflow: auto;
  white-space: pre-wrap;
}
.result.empty { color: var(--subtle); text-align: center; padding-top: 4rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  height: 2.75rem;
  padding: 0 1.15rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font: 600 0.875rem/1 var(--sans);
  cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-fg); }
.btn.secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border);
}
.btn.ghost {
  height: 2.25rem;
  background: transparent;
  color: var(--muted);
}

.status {
  min-height: 1.25rem;
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}
.status.error { color: var(--danger); }
