@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/ibm-plex-sans-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/ibm-plex-sans-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/ibm-plex-sans-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "DejaVu Cmd";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/dejavu-cmd.woff2") format("woff2");
  unicode-range: U+2318;
}

:root {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #1b2336;
  --inset: #0b1220;
  --muted-surface: #272f42;
  --fg: #f8fafc;
  --secondary: #cbd5e1;
  --muted: #94a3b8;
  --line: #64748b;
  --line-soft: #3c4c63;
  --accent: #22c55e;
  --accent-hover: #4ade80;
  --on-accent: #0f172a;
  --safe: #4ade80;
  --risk: #fbbf24;
  --risk-text: #fde68a;
  --hold: #93c5fd;
  --danger: #fca5a5;
  --danger-text: #fecaca;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  --sans: "IBM Plex Sans", "DejaVu Cmd", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --enter: 420ms cubic-bezier(0.22, 1, 0.36, 1);
  --press: 120ms cubic-bezier(0.2, 0, 0, 1);
  --hover: 180ms cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100dvh;
  border-top: 3px solid var(--accent);
  background:
    radial-gradient(640px 240px at 8% -10%, rgba(34, 197, 94, 0.16), transparent 62%),
    var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.5;
  overflow-x: clip;
}

.skip {
  position: absolute;
  left: 16px;
  top: -80px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: 10px;
  z-index: 10;
  text-decoration: none;
  font-weight: 600;
}

.skip:focus { top: 12px; }

.top, .workspace, footer {
  width: auto;
  margin-inline: 0;
  padding-inline: max(20px, calc((100% - 1120px) / 2));
}

.top { padding-top: 28px; padding-bottom: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--secondary);
}

.brand p { margin: 0; }

.top h1 {
  margin: 14px 0 12px;
  max-width: 22ch;
  font-size: clamp(1.875rem, 1rem + 2.4vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.12;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 62ch;
  color: var(--secondary);
  font-size: 1.0625rem;
  line-height: 1.6;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  font-variant-ligatures: none;
}

.lede code, footer code, .force code, .banner code {
  background: var(--muted-surface);
  color: var(--safe);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  padding-top: 20px;
  padding-bottom: 8px;
}

.source, .plan, .miss {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

h2 {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

label, .hint, .note, button, input, textarea, summary, h3, .field-error {
  font-family: var(--sans);
}

label {
  display: grid;
  gap: 6px;
  color: var(--secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.stack-label { margin-top: 4px; }

input[type="text"], textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--inset);
  color: var(--fg);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 400;
  font-variant-ligatures: none;
  line-height: 1.45;
}

textarea {
  min-height: 160px;
  resize: vertical;
}

input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }

::placeholder { color: var(--muted); opacity: 1; }

.field-error {
  margin: 8px 0 0;
  color: var(--danger-text);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--hover), border-color var(--hover), transform var(--press);
}

button.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
  font-weight: 500;
}

button:active { transform: scale(0.98); }

.hint {
  margin: 0 0 12px;
  color: var(--secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
}

details { margin: 0 0 8px; }

summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
  color: var(--fg);
  font-size: 1rem;
  font-weight: 500;
  list-style: none;
  touch-action: manipulation;
}

summary::-webkit-details-marker { display: none; }

summary::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--hover);
}

details[open] summary::before { transform: rotate(45deg); }

pre {
  margin: 8px 0 0;
  padding: 12px;
  max-height: 12rem;
  overflow: auto;
  border-radius: 10px;
  background: var(--inset);
  border: 1px solid var(--line-soft);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  font-variant-ligatures: none;
  line-height: 1.5;
  white-space: pre;
}

#status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  min-height: 24px;
  color: var(--secondary);
  font-size: 0.9375rem;
  line-height: 1.45;
}

#status::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.85);
}

#status.bad { color: var(--danger-text); }

#status.bad::before {
  background: var(--danger);
  box-shadow: none;
}

#status.quiet {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#status.quiet::before { content: none; }

.source, .plan { position: relative; }

.plan {
  display: flex;
  flex-direction: column;
}

.empty {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin: 0;
  color: var(--secondary);
}

.empty p:first-child {
  margin: 4px 0 8px;
  color: var(--fg);
  font-size: clamp(1.5rem, 2vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.empty ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.empty li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 0;
  padding: 14px 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
  color: var(--secondary);
  line-height: 1.5;
}

.empty li::before {
  content: counter(step);
  font-family: var(--mono);
  font-weight: 600;
  color: var(--safe);
  font-size: 1rem;
  line-height: 1.5;
}

.empty p:last-child {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--muted-surface);
  color: var(--fg);
  line-height: 1.5;
}

.banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #3a2f1a;
  color: var(--risk-text);
  border: 1px solid #a16207;
  line-height: 1.5;
}

#error {
  background: #3f1d24;
  color: var(--danger-text);
  border-color: var(--danger);
  scroll-margin: 24px;
}

#summary {
  margin: 0 0 16px;
  max-width: 70ch;
  font-size: 1.0625rem;
  line-height: 1.5;
}

.cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.col {
  min-width: 0;
  padding: 14px 14px 8px;
  border-radius: 12px;
  background: var(--inset);
  border: 1px solid var(--line-soft);
  border-top: 3px solid var(--muted);
}

.col.safe { border-top-color: var(--safe); }
.col.risk { border-top-color: var(--risk); }
.col.hold { border-top-color: var(--hold); }

h3 {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
}

h3 span {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.safe h3 span { color: var(--safe); }
.risk h3 span { color: var(--risk); }
.hold h3 span { color: var(--hold); }

.col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow: auto;
}

.col li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.name {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-variant-ligatures: none;
  line-height: 1.45;
}

.note {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.none { color: var(--muted); display: block; }

.scriptbox {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--inset);
  border: 1px solid var(--line-soft);
}

.scripthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.scripthead h3 { margin: 0; }

.scriptbox pre {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  max-height: 14rem;
}

.force {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--secondary);
  font-size: 0.9375rem;
  font-weight: 400;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

#copy-script { margin-top: 12px; }

footer {
  padding-top: 16px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  color: var(--secondary);
  font-size: 0.9375rem;
}

footer p {
  margin: 0;
  max-width: 68ch;
  line-height: 1.5;
}

.miss {
  width: min(640px, calc(100% - 40px));
  margin: 64px auto;
  padding: 28px 24px;
}

.miss h1 {
  max-width: none;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  text-wrap: balance;
}

.brandline {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
}

.miss a {
  color: var(--safe);
  font-weight: 600;
}

.miss a:hover { color: var(--fg); }

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

@media (hover: hover) {
  button:hover { background: var(--accent-hover); }
  button.ghost:hover {
    background: var(--muted-surface);
    border-color: var(--secondary);
  }
}

@media (max-width: 1023px) {
  .actions button { flex: 1 1 0; }
  #copy-script { width: 100%; }
}

@media (max-width: 719px) {
  .top { padding-top: 16px; }
  .top h1 { margin: 8px 0; font-size: 1.75rem; }
  .lede { font-size: 1rem; line-height: 1.5; }
  .workspace { gap: 16px; padding-top: 16px; }
  .source, .plan, .miss { padding: 16px; }
  h2 { margin-bottom: 12px; }
  textarea { min-height: 96px; }
  .actions { margin: 8px 0; }
  .hint { margin-bottom: 8px; }
  .empty li { padding: 10px 0; }
}

@media (max-width: 719px) and (max-height: 820px) {
  .top { padding-top: 12px; }
  .top h1 { margin: 6px 0; }
  .workspace { padding-top: 12px; }
  textarea { min-height: 72px; }
}

@media (min-width: 720px) {
  .cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  body {
    display: flex;
    flex-direction: column;
  }

  .workspace {
    flex: 1;
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    padding-top: 24px;
    padding-bottom: 20px;
  }

  .source, .plan { height: 100%; }

  .source {
    display: flex;
    flex-direction: column;
  }

  .fields { grid-template-columns: 0.8fr 1.2fr; }

  textarea { flex: 1; min-height: 180px; }

  .actions button, #copy-script { flex: 0 0 auto; width: auto; }

  .empty p:last-child { margin-top: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  #status:not(.bad)::before { animation: pulse 1.8s ease-in-out infinite; }

  .empty li, #ready .col {
    animation: rise var(--enter) both;
  }

  .empty li:nth-child(2), #ready .col:nth-child(2) { animation-delay: 60ms; }
  .empty li:nth-child(3), #ready .col:nth-child(3) { animation-delay: 120ms; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

  button:active { transform: none; }
}

@media (forced-colors: active) {
  :focus-visible { outline: 2px solid Highlight; }
  button, input, textarea, pre, .source, .plan, .col { border: 1px solid ButtonText; }
}
