:root {
  --bg: #10100f;
  --surface: #171716;
  --surface-raised: #1d1d1b;
  --line: #32322f;
  --line-soft: #272725;
  --text: #f1efe8;
  --muted: #9d9a91;
  --quiet: #8b8880;
  --accent: #e85b36;
  --accent-bright: #ff7651;
  --green: #9fc58f;
  --danger: #ef826e;
  --radius: 18px;
  --shadow: 0 24px 80px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }

html { background: var(--bg); color: var(--text); }

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 76% 12%, rgb(232 91 54 / 9%), transparent 25rem),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 76px;
  padding: 0 clamp(22px, 4vw, 68px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
  background: rgb(16 16 15 / 82%);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #4b4a46;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-weight: 700;
  letter-spacing: -1px;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 3px; }

.top-status {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgb(159 197 143 / 10%);
}

.shell {
  width: min(1460px, calc(100% - 44px));
  margin: 0 auto;
}

.intro {
  min-height: 470px;
  padding: 92px 0 70px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  column-gap: 80px;
  align-content: center;
}

.eyebrow, .step {
  margin: 0 0 14px;
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

.intro h1 {
  grid-row: span 2;
  margin: 0;
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(54px, 7.6vw, 108px);
  line-height: .9;
  letter-spacing: -.055em;
  font-weight: 400;
}

.intro h1 em { color: var(--accent); font-weight: 400; }

.intro-copy {
  margin: 76px 0 30px;
  color: #c2bfb6;
  font-size: 17px;
  line-height: 1.65;
  max-width: 460px;
}

.scope-strip {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 18px;
}

.scope-strip span { color: var(--accent-bright); font-size: 12px; font-weight: 700; }
.scope-strip p { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 0; }

.studio {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--surface);
}

.controls, .preview-panel { padding: clamp(25px, 3vw, 42px); }
.controls { border-right: 1px solid var(--line); background: #151514; }
.preview-panel { background: var(--surface-raised); min-width: 0; }

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

.panel-heading h2, .handoff h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 29px;
  font-weight: 400;
  letter-spacing: -.025em;
}

.pill, .approx-badge {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}

.pill.valid { color: var(--green); border-color: rgb(159 197 143 / 35%); }
.pill.invalid { color: var(--danger); border-color: rgb(239 130 110 / 35%); }
.pill.checking { color: var(--muted); }
.approx-badge { color: #ddbd79; }

.field-label, fieldset legend, .slider-heading label {
  display: block;
  color: #bbb8af;
  font-size: 12px;
  font-weight: 600;
}

.text-input {
  width: 100%;
  margin-top: 9px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #111110;
  outline: none;
}

.text-input:focus, .matrix-grid input:focus { border-color: var(--accent); }

.preset-fieldset { border: 0; padding: 0; margin: 28px 0 0; }
.preset-fieldset legend { margin-bottom: 10px; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.preset {
  min-width: 0;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #111110;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}

.preset:hover { transform: translateY(-1px); border-color: #4a4945; }
.preset.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.preset strong, .preset small { display: block; overflow-wrap: anywhere; }
.preset strong { font-size: 12px; line-height: 1.3; margin-top: 9px; }
.preset small { color: var(--quiet); font-size: 11px; line-height: 1.35; margin-top: 4px; }

.swatch { height: 28px; display: block; border-radius: 6px; border: 1px solid rgb(255 255 255 / 8%); }
.swatch.neutral { background: linear-gradient(100deg, #77736b, #b4afa4); }
.swatch.warm { background: linear-gradient(100deg, #54483d, #b17752, #879187); }
.swatch.diagnostic { background: linear-gradient(100deg, #144fd1 0 48%, #dd4c32 52%); }

.slider-block { margin-top: 28px; }
.slider-block.compact { margin-top: 19px; }
.slider-heading { display: flex; align-items: center; justify-content: space-between; }
.slider-heading output { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.approx-label { color: var(--quiet); font-size: 10px; font-weight: 500; }

.basic-divider {
  margin-top: 30px;
  padding-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line-soft);
  color: #bbb8af;
  font-size: 12px;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  margin: 15px 0 6px;
  accent-color: var(--accent);
}

.range-labels { display: flex; justify-content: space-between; color: var(--quiet); font-size: 11px; }

.control-caveat {
  margin: 20px 0 0;
  padding: 11px 12px;
  border-left: 2px solid #514536;
  color: var(--quiet);
  font-size: 11px;
  line-height: 1.55;
}

.tone-divider { margin-top: 30px; }
.dial-options { display: inline-flex; align-items: center; gap: 14px; }
.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.toggle-control input { margin: 0; accent-color: var(--accent); }
.tone-caveat { margin-top: 13px; }
.gamma-controls { transition: opacity 150ms ease; }
.gamma-controls.disabled { opacity: .42; }
.gamma-controls.disabled .range-labels { color: #696761; }

.advanced { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line-soft); }
.advanced summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary span { font-size: 12px; font-weight: 600; }
.advanced summary small { color: var(--quiet); font-size: 11px; line-height: 1.35; text-align: right; }

.matrix-labels, .matrix-grid {
  display: grid;
  grid-template-columns: 36px repeat(3, 1fr);
  gap: 6px;
}

.matrix-labels { margin-top: 20px; color: var(--quiet); font-size: 10px; text-align: center; }
.matrix-labels::before { content: ""; }
.matrix-grid { margin-top: 6px; align-items: center; }
.matrix-grid label { color: var(--muted); font-size: 10px; }
.matrix-grid input {
  min-width: 0;
  width: 100%;
  padding: 8px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #0f0f0e;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.row-sums { margin: 9px 0; color: var(--quiet); font-size: 10px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.row-sums.invalid { color: var(--danger); }
.text-button { border: 0; padding: 0; color: var(--accent-bright); background: transparent; cursor: pointer; font-size: 11px; }
.advanced-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.advanced-actions .hidden { display: none; }

.validation-message {
  margin-top: 22px;
  min-height: 47px;
  padding: 12px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  color: var(--muted);
  background: rgb(0 0 0 / 12%);
  font-size: 11px;
  line-height: 1.5;
}

.validation-message.invalid { color: var(--danger); }
.validation-message.valid { color: var(--green); }

.file-actions { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.file-actions.single-action { grid-template-columns: 1fr; }
.secondary-button, .primary-button {
  border-radius: 9px;
  cursor: pointer;
  font-weight: 650;
  transition: background 150ms ease, opacity 150ms ease, transform 150ms ease;
}
.secondary-button { padding: 12px; border: 1px solid var(--line); background: transparent; font-size: 11px; }
.secondary-button:hover { background: #242421; }

.dropzone {
  min-height: 380px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1px dashed #41413d;
  border-radius: var(--radius);
  background:
    linear-gradient(rgb(20 20 18 / 78%), rgb(20 20 18 / 78%)),
    repeating-linear-gradient(45deg, #20201e 0 1px, transparent 1px 12px);
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color 150ms ease, background 150ms ease;
}

.dropzone:hover, .dropzone.dragging, .dropzone:focus-visible { border-color: var(--accent); background-color: #1b1917; }
.drop-icon { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); font-size: 25px; }
.dropzone h3 { margin: 17px 0 8px; font-family: Georgia, serif; font-size: 22px; font-weight: 400; }
.dropzone p { color: var(--quiet); font-size: 12px; line-height: 1.5; margin: 0; }

.comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.comparison.hidden, .dropzone.hidden { display: none; }
.comparison figure { min-width: 0; margin: 0; }
.comparison figcaption { margin-bottom: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.image-well { min-height: 420px; display: grid; place-items: center; overflow: hidden; border-radius: 12px; background: #090909; position: relative; }
.image-well img { display: block; width: 100%; height: 100%; max-height: 560px; object-fit: contain; }
.preview-well img:not([src]) { display: none; }
.preview-placeholder { position: absolute; color: var(--quiet); font-family: Georgia, serif; font-size: 18px; }
.preview-placeholder.hidden { display: none; }

.render-row { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-soft); }
.render-row strong, .render-row small { display: block; }
.render-row strong { max-width: 480px; overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; }
.render-row small { color: var(--quiet); margin-top: 5px; font-size: 11px; line-height: 1.4; }
.primary-button { min-width: 150px; padding: 13px 18px; border: 0; color: #fff; background: var(--accent); font-size: 12px; }
.primary-button:hover:not(:disabled) { transform: translateY(-1px); background: var(--accent-bright); }
.primary-button:disabled { opacity: .35; cursor: not-allowed; }
.primary-button.loading span::after { content: " ···"; letter-spacing: 2px; }

.truth-note { margin-top: 23px; display: grid; grid-template-columns: 110px 1fr; gap: 20px; }
.truth-note strong { color: #dbb979; font-family: Georgia, serif; font-size: 13px; font-weight: 400; }
.truth-note p { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 0; }

.handoff {
  margin: 40px 0 100px;
  padding: 38px 42px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 70px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.build-intro > p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.build-intro > p strong { color: var(--text); }

.risk-box {
  padding: 25px;
  border: 1px solid rgb(239 130 110 / 32%);
  border-radius: 13px;
  background: rgb(99 28 20 / 12%);
}

.risk-title { display: block; color: var(--danger); font-family: Georgia, serif; font-size: 17px; font-weight: 400; }
.risk-box > p { margin: 8px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.risk-check { display: grid; grid-template-columns: 18px 1fr; gap: 9px; align-items: start; color: #c8c4ba; font-size: 12px; line-height: 1.5; }
.risk-check input { margin: 2px 0 0; accent-color: var(--danger); }
.risk-phrase { display: block; margin-top: 18px; color: #bbb8af; font-size: 12px; }
.risk-phrase code { color: var(--danger); font-size: 12px; }
.risk-phrase .text-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.build-progress { margin-top: 22px; padding-top: 19px; border-top: 1px solid rgb(239 130 110 / 18%); }
.progress-track { height: 2px; margin: 0 7px 17px; overflow: hidden; border-radius: 2px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 350ms ease; }
.progress-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
.progress-steps li { min-width: 0; display: flex; gap: 8px; align-items: flex-start; color: var(--quiet); }
.progress-marker { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 10px; font-weight: 700; }
.progress-steps strong, .progress-steps small { display: block; }
.progress-steps strong { color: inherit; font-size: 11px; line-height: 22px; }
.progress-steps small { margin-top: 4px; color: var(--quiet); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.progress-steps li.complete { color: var(--green); }
.progress-steps li.complete .progress-marker { border-color: rgb(159 197 143 / 45%); background: rgb(159 197 143 / 10%); }
.progress-steps li.current { color: #ddbd79; }
.progress-steps li.current .progress-marker { border-color: rgb(221 189 121 / 50%); }
.progress-steps li.current.working .progress-marker { box-shadow: 0 0 0 4px rgb(221 189 121 / 8%); }
.progress-steps li.failure { color: var(--danger); }
.progress-steps li.failure .progress-marker { border-color: rgb(239 130 110 / 45%); }
.build-detail-steps { margin: 17px 0 0; padding: 14px 15px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgb(0 0 0 / 12%); list-style: none; }
.build-detail-steps.hidden { display: none; }
.build-detail-steps li { display: grid; grid-template-columns: 8px 1fr; gap: 8px; align-items: start; color: var(--quiet); font-size: 10px; line-height: 1.45; }
.build-detail-steps li span { width: 6px; height: 6px; margin-top: 3px; border: 1px solid #4b4a46; border-radius: 50%; }
.build-detail-steps li.complete { color: var(--green); }
.build-detail-steps li.complete span { border-color: var(--green); background: var(--green); }
.build-detail-steps li.current { color: #ddbd79; }
.build-detail-steps li.current span { border-color: #ddbd79; background: #ddbd79; animation: progress-pulse 1.2s ease-in-out infinite; }
.build-detail-steps li.failure { color: var(--danger); }
.build-detail-steps li.failure span { border-color: var(--danger); background: var(--danger); }
@keyframes progress-pulse { 50% { box-shadow: 0 0 0 4px rgb(221 189 121 / 10%); } }
.build-actions { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(150px, 1fr); gap: 9px; margin-top: 18px; }
.build-actions .hidden { display: none; }
.danger-button { min-width: 0; background: #b74631; }
.danger-button:hover:not(:disabled) { background: var(--danger); }
.danger-button small { display: block; margin-top: 4px; font-size: 10px; font-weight: 500; opacity: .82; }
.build-result { margin-top: 15px; min-height: 38px; color: var(--quiet); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.build-result.working { color: #ddbd79; }
.build-result.success { color: var(--green); }
.build-result.failure { color: var(--danger); }

footer {
  min-height: 70px;
  padding: 0 clamp(22px, 4vw, 68px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line-soft);
  color: var(--quiet);
  font-size: 11px;
}

@media (max-width: 980px) {
  .intro { grid-template-columns: 1fr; min-height: 0; padding: 70px 0; }
  .intro h1 { grid-row: auto; }
  .intro-copy { margin: 34px 0 24px; }
  .scope-strip { max-width: 540px; }
  .studio { grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid var(--line); }
  .handoff { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 650px) {
  .shell { width: min(100% - 24px, 1460px); }
  .topbar { padding: 0 16px; }
  .brand small { display: none; }
  .intro { padding: 55px 5px; }
  .intro h1 { font-size: clamp(49px, 16vw, 76px); }
  .scope-strip { grid-template-columns: 1fr; gap: 8px; }
  .controls, .preview-panel { padding: 24px 18px; }
  .preset-grid { grid-template-columns: 1fr; }
  .preset { display: grid; grid-template-columns: 55px 1fr; column-gap: 10px; }
  .preset .swatch { grid-row: span 2; }
  .preset strong { margin-top: 2px; }
  .comparison { grid-template-columns: 1fr; }
  .image-well { min-height: 260px; }
  .render-row { align-items: stretch; flex-direction: column; padding: 18px 0; }
  .primary-button { width: 100%; }
  .truth-note { grid-template-columns: 1fr; gap: 8px; }
  .handoff { padding: 28px 24px; margin-bottom: 55px; }
  .risk-box { padding: 20px 16px; }
  .build-actions { grid-template-columns: 1fr; }
  .progress-steps { grid-template-columns: 1fr 1fr; row-gap: 14px; }
  .build-detail-steps { grid-template-columns: 1fr 1fr; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; }
}

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