:root {
  color-scheme: light dark;
  --page: #f4f6f2;
  --surface: #fbfcf9;
  --surface-strong: #ffffff;
  --ink: #18211c;
  --muted: #59665e;
  --line: #cbd4cc;
  --accent: #176344;
  --accent-hover: #0f4b33;
  --accent-soft: #dfeee6;
  --danger: #9b2c2c;
  --focus: #b35316;
  --shadow: 0 18px 46px rgba(35, 66, 48, 0.09);
  --radius: 14px;
  --font: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #111713;
    --surface: #172019;
    --surface-strong: #1c2820;
    --ink: #eef4ef;
    --muted: #b2c0b6;
    --line: #405045;
    --accent: #79c99f;
    --accent-hover: #99ddb9;
    --accent-soft: #223c2e;
    --danger: #ffaaaa;
    --focus: #f2a66c;
    --shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.55;
}

a { color: inherit; }

button, input, select { font: inherit; }

button, .file-button { touch-action: manipulation; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--ink);
  color: var(--page);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--page) 94%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 720;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--surface-strong);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: -0.04em;
}

@media (prefers-color-scheme: dark) {
  .brand-mark { color: #102016; }
}

.site-header nav, .site-footer div {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.site-header nav a, .site-footer a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
}

.site-header nav a:hover, .site-footer a:hover { color: var(--accent); text-decoration: underline; }

.shell {
  width: min(1380px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(36px, 6vw, 82px) 0 72px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.7fr);
  gap: clamp(28px, 7vw, 100px);
  align-items: end;
  margin-bottom: 34px;
}

.eyebrow, .section-label {
  margin: 0 0 7px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 820px;
  margin-bottom: 16px;
  font-size: clamp(2.3rem, 5.8vw, 5.1rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 { margin-bottom: 0; font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: -0.025em; }
h3 { font-size: 1rem; }

.lede {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.6vw, 1.22rem);
}

.privacy-note {
  padding: 20px 0 4px 22px;
  border-left: 4px solid var(--accent);
}

.privacy-note p { margin: 5px 0 0; color: var(--muted); }

.message {
  min-height: 0;
  margin-bottom: 18px;
  padding: 0;
  border-radius: 10px;
}

.message:not(:empty) {
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(290px, 0.72fr);
  gap: 22px;
  align-items: start;
}

.builder-column, .tools-column { display: grid; gap: 22px; }

.panel {
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 25px;
}

.save-state, .count {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field-wide { grid-column: 1 / -1; }

.field { display: grid; gap: 7px; }

label { font-weight: 700; }

input, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-strong);
  color: var(--ink);
}

input::placeholder { color: color-mix(in srgb, var(--muted) 88%, transparent); }

input:hover, select:hover { border-color: var(--accent); }

.step-list { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; }

.step-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-strong);
}

.step-number {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 800;
}

.step-copy { min-width: 0; }
.step-copy strong, .step-copy span { display: block; overflow-wrap: anywhere; }
.step-copy span { color: var(--muted); font-size: 0.9rem; }

.step-actions { display: flex; gap: 6px; }

.icon-button {
  min-width: 40px;
  min-height: 40px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.icon-button.delete:hover { border-color: var(--danger); color: var(--danger); }
.icon-button:disabled { opacity: 0.42; cursor: not-allowed; }

.empty-state {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  text-align: center;
}

.empty-state p { max-width: 47ch; margin: 5px auto 0; color: var(--muted); }
.empty-state[hidden] { display: none; }

.add-step-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(220px, 1.5fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:active { transform: translateY(1px); }
.button.primary { background: var(--accent); color: #f8fffb; }
.button.primary:hover { background: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .button.primary { color: #102016; } }
.button.secondary { border-color: var(--line); background: var(--surface-strong); color: var(--ink); }
.button.secondary:hover { border-color: var(--accent); color: var(--accent); }
.text-button { background: transparent; color: var(--danger); }
.text-button:hover { text-decoration: underline; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.full-width { width: 100%; }

.tools-panel > p:not(.section-label), .simulation-panel > p:not(.section-label), .small-copy { color: var(--muted); }
.button-stack { display: grid; gap: 10px; margin-top: 20px; }
.small-copy { margin: 15px 0 0; font-size: 0.82rem; }

.simulation-panel { border-top: 5px solid var(--accent); }
.simulation-output { margin-top: 21px; padding-top: 18px; border-top: 1px solid var(--line); }
.simulation-output h3 { margin-bottom: 10px; }
.log-list { display: grid; gap: 8px; margin: 0; padding-left: 23px; color: var(--muted); font-family: var(--mono); font-size: 0.82rem; }
.log-list .complete { color: var(--accent); }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding: 26px clamp(18px, 4vw, 64px);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.site-footer p { max-width: 68ch; margin-bottom: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.legal-shell { width: min(780px, calc(100% - 36px)); margin: 0 auto; padding: 58px 0 84px; }
.legal-shell h1 { font-size: clamp(2.25rem, 7vw, 4.2rem); }
.legal-shell h2 { margin-top: 38px; margin-bottom: 10px; }
.legal-shell p, .legal-shell li { color: var(--muted); }
.legal-shell a { color: var(--accent); }
.back-link { display: inline-block; margin-bottom: 35px; font-weight: 750; text-decoration: none; }

@media (max-width: 980px) {
  .work-grid { grid-template-columns: 1fr; }
  .tools-column { grid-template-columns: 1fr 1fr; }
  .intro { grid-template-columns: 1fr; align-items: start; }
  .privacy-note { max-width: 680px; }
}

@media (max-width: 720px) {
  .site-header { align-items: flex-start; }
  .site-header nav { justify-content: flex-end; gap: 8px 14px; }
  .site-header nav a { font-size: 0.82rem; }
  .shell { width: min(100% - 24px, 1380px); padding-top: 35px; }
  .field-grid, .tools-column, .add-step-form { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .add-button { width: 100%; }
  .step-item { grid-template-columns: 38px minmax(0, 1fr); align-items: start; }
  .step-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .site-footer { flex-direction: column; }
}

@media (max-width: 460px) {
  .brand > span:last-child { max-width: 118px; line-height: 1.1; }
  .site-header nav a:first-child { display: none; }
  .panel { padding: 18px; }
  .panel-heading { flex-direction: column; gap: 7px; }
  h1 { font-size: clamp(2.15rem, 13vw, 3.2rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
