:root {
  --bg: #f3efe5;
  --ink: #1f2933;
  --ink-soft: #51606f;
  --panel: rgba(255, 255, 255, 0.9);
  --line: #c9d3dc;
  --accent: #124e66;
  --accent-strong: #0b3a4c;
  --ok: #1f6d45;
  --error: #9f1239;
  --running: #8a5300;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(18, 78, 102, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(173, 107, 77, 0.10) 0%, transparent 32%),
    var(--bg);
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1rem 2.4rem;
}

.hero {
  margin-bottom: 1.2rem;
}

.kicker {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

h1 {
  margin: 0.3rem 0 0.4rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  line-height: 1.1;
}

.lede {
  margin: 0;
  color: var(--ink-soft);
}

/* ── Notice ─────────────────────────────────────────────────────────── */

.notice {
  background: rgba(18, 78, 102, 0.07);
  border: 1px solid rgba(18, 78, 102, 0.22);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.865rem;
  color: var(--ink);
}

.notice strong:first-child {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.notice ul {
  margin: 0.2rem 0 0;
  padding-left: 1.3rem;
}

.notice li + li {
  margin-top: 0.3rem;
}

.notice a {
  color: var(--accent);
}

.notice a:hover {
  color: var(--accent-strong);
}

/* ── Panels ─────────────────────────────────────────────────────────── */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  backdrop-filter: blur(2px);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.panel-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0;
  flex: 1 0 auto;
}

textarea {
  width: 100%;
  height: min(68vh, 620px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.84rem;
  resize: vertical;
  font: 500 0.875rem/1.5 "Cascadia Code", "Consolas", monospace;
  background: #f9fafb;
  color: #111827;
}

textarea:focus-visible {
  outline: 2px solid rgba(18, 78, 102, 0.33);
  outline-offset: 1px;
}

textarea[readonly] {
  background: #f4f6f9;
  color: #1e2936;
}

/* ── Controls ───────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: 0.9rem;
}

select {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  background: #fff;
  color: var(--ink);
  font: 500 1rem/1.2 "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  cursor: pointer;
  min-width: 140px;
}

select:focus-visible {
  outline: 2px solid rgba(18, 78, 102, 0.33);
  outline-offset: 1px;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.48rem 0.88rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover,
button.primary:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* ── Status / Metrics ───────────────────────────────────────────────── */

.bottom-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.8rem;
}

.metrics {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.metrics p { margin: 0; }

#status {
  margin: 0;
  font-size: 0.9rem;
}

#status[data-state="idle"]    { color: var(--ink-soft); }
#status[data-state="running"] { color: var(--running); }
#status[data-state="ok"]      { color: var(--ok); }
#status[data-state="error"]   { color: var(--error); }

#download-link {
  margin-left: auto;
  text-decoration: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.48rem 0.88rem;
  white-space: nowrap;
  font-size: 0.9rem;
}

#download-link[aria-disabled="true"] {
  opacity: 0.42;
  pointer-events: none;
}

#download-link:hover,
#download-link:focus-visible {
  color: #fff;
  background: var(--accent);
}

code {
  font-family: "Cascadia Code", "Consolas", monospace;
}

/* ── Responsive ─────────────────────────────────────────────────────── */

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

  textarea {
    height: 46vh;
  }

  #download-link {
    margin-left: 0;
  }
}
