:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #5f6b64;
  --canvas: #f4f6f3;
  --surface: #ffffff;
  --surface-subtle: #eef2ed;
  --line: #d5ddd7;
  --line-strong: #aab8ae;
  --brand: #155b3b;
  --brand-dark: #0f442c;
  --brand-soft: #dceee3;
  --danger: #a62929;
  --danger-soft: #f9e5e3;
  --focus: #e5a923;
  --radius-sm: 5px;
  --radius-md: 9px;
  --shadow: 0 10px 30px rgba(23, 33, 28, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-bar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(24px, calc((100vw - 1160px) / 2));
  color: white;
  background: var(--ink);
  border-bottom: 3px solid var(--brand);
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--brand); border-radius: var(--radius-sm); font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 1px; color: #bac5bd; font-size: 12px; }
.health { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #d5ddd7; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #d0a036; }
.health.up .health-dot { background: #48b878; }
.health.down .health-dot { background: #e36a62; }

main { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 80px; }
.builder { display: grid; grid-template-columns: minmax(240px, .68fr) minmax(520px, 1.32fr); gap: 56px; align-items: start; }
.intro { padding-top: 6px; }
.step-label { margin: 0 0 8px; color: var(--brand); font-size: 13px; font-weight: 750; }
h1, h2 { letter-spacing: -.025em; }
h1 { max-width: 570px; margin: 0; font-size: clamp(36px, 5vw, 62px); line-height: 1.02; font-weight: 720; }
.intro > p:last-child { max-width: 520px; margin: 22px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.build-form { padding: 24px; background: var(--surface); border: 1px solid var(--line-strong); border-top: 4px solid var(--brand); border-radius: var(--radius-md); box-shadow: var(--shadow); }
.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.context-grid label:last-child { grid-column: 1 / -1; }
label > span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
label em { color: var(--muted); font-style: normal; font-weight: 450; }
input, textarea { width: 100%; color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
input { min-height: 44px; padding: 9px 11px; }
textarea { min-height: 330px; resize: vertical; padding: 13px; line-height: 1.55; }
input:hover, textarea:hover { border-color: #78887d; }
.notes-field { display: block; margin-top: 18px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 14px; }
.form-foot p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.build-button { flex: 0 0 auto; min-height: 46px; padding: 0 20px; color: white; background: var(--brand); border: 1px solid var(--brand); border-radius: var(--radius-sm); font-weight: 750; cursor: pointer; }
.build-button:hover { background: var(--brand-dark); }
.build-button:disabled { cursor: wait; opacity: .65; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }

.run-panel { margin-top: 40px; padding: 28px; background: var(--surface); border: 1px solid var(--line-strong); border-left: 5px solid var(--brand); border-radius: var(--radius-md); }
.run-panel[hidden] { display: none; }
.run-head, .section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.run-head h2, .section-head h2 { margin: 0; font-size: 26px; }
.timer { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin: 28px 0 20px; padding: 0; list-style: none; }
.pipeline li { position: relative; display: flex; align-items: flex-start; gap: 11px; padding: 0 18px 0 0; color: var(--muted); }
.pipeline li:not(:last-child)::after { content: ""; position: absolute; top: 15px; right: 4px; width: 12px; border-top: 1px solid var(--line-strong); }
.pipeline li > span { flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: white; font-size: 12px; font-weight: 750; }
.pipeline strong, .pipeline small { display: block; }
.pipeline strong { margin-top: 4px; color: inherit; font-size: 13px; }
.pipeline small { margin-top: 4px; line-height: 1.4; font-size: 11px; }
.pipeline li.active { color: var(--ink); }
.pipeline li.active > span { color: white; background: var(--brand); border-color: var(--brand); }
.pipeline li.done > span { color: var(--brand-dark); background: var(--brand-soft); border-color: #82aa90; }
.run-status { margin: 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.run-status.error { color: var(--danger); }
.run-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.primary-link, .secondary-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 720; text-decoration: none; cursor: pointer; }
.primary-link { color: white; background: var(--brand); border: 1px solid var(--brand); }
.secondary-button { color: var(--ink); background: white; border: 1px solid var(--line-strong); }

.recent { margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line-strong); }
.text-button { min-height: 40px; padding: 0; color: var(--brand); background: none; border: 0; font-weight: 700; cursor: pointer; }
.recent-list { margin-top: 20px; border-top: 1px solid var(--line-strong); }
.build-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(150px, .6fr) 150px; align-items: center; gap: 20px; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.build-row h3 { margin: 0 0 4px; font-size: 16px; }
.build-row p { margin: 0; color: var(--muted); font-size: 13px; }
.row-status { justify-self: start; padding: 4px 8px; border-radius: 3px; color: #39483f; background: var(--surface-subtle); font-size: 12px; font-weight: 700; }
.row-status.ready { color: var(--brand-dark); background: var(--brand-soft); }
.row-action { color: var(--brand); font-size: 13px; font-weight: 720; text-decoration: none; }
.row-links { justify-self: end; display: flex; gap: 14px; }
.empty { margin: 0; padding: 28px 4px; color: var(--muted); border-bottom: 1px solid var(--line); }

.examples { margin-top: 36px; border-top: 1px solid var(--line); }
.examples summary { padding: 18px 2px; color: var(--muted); cursor: pointer; font-weight: 650; }
.sample-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 4px 0 20px; }
.sample-button { padding: 14px; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.sample-button:hover { border-color: var(--brand); }
.sample-button strong, .sample-button small { display: block; }
.sample-button strong { font-size: 14px; }
.sample-button small { margin-top: 4px; color: var(--muted); }

.header-link { color: #fff; font-size: 14px; font-weight: 700; text-decoration: none; }
.project-page { width: min(1440px, calc(100% - 32px)); padding-top: 34px; }
.project-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.project-heading h1 { max-width: 900px; font-size: clamp(30px, 4vw, 48px); }
.project-heading p:last-child { margin: 9px 0 0; color: var(--muted); }
.project-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.project-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, .65fr); gap: 22px; align-items: start; }
.preview-panel, .change-panel { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-md); }
.preview-panel { overflow: hidden; }
.panel-title { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-title h2, .change-panel h2 { margin: 0; font-size: 21px; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
#project-preview { display: block; width: 100%; height: min(760px, calc(100vh - 190px)); min-height: 580px; border: 0; background: #fff; }
.change-panel { position: sticky; top: 18px; padding: 22px; border-top: 4px solid var(--brand); }
.change-panel > p:not(.step-label) { margin: 10px 0 20px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.change-panel label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 750; }
.change-panel textarea { min-height: 260px; }
.change-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; }
.change-foot > span { color: var(--muted); font-size: 12px; }
.revision-status { margin-top: 18px; padding: 14px; color: var(--ink); background: var(--surface-subtle); border-left: 4px solid var(--brand); border-radius: var(--radius-sm); }
.revision-status[hidden] { display: none; }
.revision-status strong { display: block; font-size: 14px; }
.revision-status p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.publish-again { margin-top: 12px; }
.revision-status.error { background: var(--danger-soft); border-left-color: var(--danger); }
.revision-status.ready { background: var(--brand-soft); }

@media (max-width: 900px) {
  main { padding-top: 36px; }
  .builder { grid-template-columns: 1fr; gap: 28px; }
  .intro > p:last-child { margin-top: 14px; }
  .pipeline { grid-template-columns: 1fr 1fr; gap: 22px 12px; }
  .pipeline li:not(:last-child)::after { display: none; }
  .project-heading { align-items: flex-start; flex-direction: column; }
  .project-links { justify-content: flex-start; }
  .project-layout { grid-template-columns: 1fr; }
  .change-panel { position: static; grid-row: 1; }
  #project-preview { height: 680px; }
}

@media (max-width: 620px) {
  .app-bar { height: auto; min-height: 66px; padding: 12px 16px; }
  .health span:last-child { display: none; }
  main { width: min(100% - 24px, 1160px); padding: 30px 0 56px; }
  h1 { font-size: 40px; }
  .build-form, .run-panel { padding: 18px; }
  .context-grid { grid-template-columns: 1fr; gap: 13px; }
  .context-grid label:last-child { grid-column: auto; }
  textarea { min-height: 300px; font-size: 16px; }
  input { font-size: 16px; }
  .form-foot { align-items: stretch; flex-direction: column; gap: 13px; }
  .build-button { width: 100%; }
  .pipeline { grid-template-columns: 1fr; }
  .build-row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .build-row > div { grid-column: 1 / -1; }
  .row-status { grid-column: 1; }
  .row-action, .row-links { grid-column: 2; justify-self: end; }
  .sample-list { grid-template-columns: 1fr; }
  .project-page { width: min(100% - 20px, 1440px); padding-top: 24px; }
  .project-heading h1 { font-size: 32px; }
  .project-links { width: 100%; }
  .project-links a { flex: 1; }
  .change-panel { padding: 18px; }
  .change-foot { align-items: stretch; flex-direction: column; }
  .change-foot .build-button { width: 100%; }
  #project-preview { min-height: 540px; height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
