:root {
  --purple: #5b21b6;
  --purple-dark: #40148a;
  --purple-soft: #f1eaff;
  --fuchsia: #d946ef;
  --turquoise: #0faaa5;
  --ink: #211c2d;
  --muted: #6b6475;
  --line: #ded9e7;
  --surface: #ffffff;
  --canvas: #f7f6fa;
  --danger: #b42318;
  --success: #19744c;
  --shadow: 0 18px 55px rgba(40, 22, 66, .10);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; }
body.auth-required { overflow: hidden; }
.auth-gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(30,22,42,.72); backdrop-filter: blur(8px); }
.auth-card { width: min(440px, 100%); display: grid; gap: 14px; padding: 30px; border-radius: 24px; background: white; box-shadow: var(--shadow); }
.auth-card h1 { font-size: clamp(2rem, 8vw, 3.2rem); }
.auth-card label { display: grid; gap: 7px; font-weight: 750; }
.auth-card input { min-height: 48px; padding: 11px 13px; border: 1px solid #cbc5d6; border-radius: 12px; }
.auth-card .brand-mark { margin-bottom: 4px; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(15,170,165,.45); outline-offset: 3px; }
.topbar { height: 72px; padding: 0 max(20px, calc((100vw - 1180px)/2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 850; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--purple); color: white; font-size: .78rem; box-shadow: inset -8px -8px 18px rgba(217,70,239,.28); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.demo-badge { display: inline-flex; align-items: center; width: fit-content; padding: 7px 10px; border-radius: 999px; color: var(--purple-dark); background: var(--purple-soft); font-size: .78rem; font-weight: 750; }
.quiet-button, .icon-button { border: 0; background: transparent; color: var(--purple); font-weight: 750; cursor: pointer; }
.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 72px; }
.steps { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; color: #8d8794; font-size: .88rem; font-weight: 650; }
.step { display: flex; align-items: center; gap: 8px; }
.step:not(:last-child)::after { content: ""; width: 42px; height: 1px; margin-left: 6px; background: var(--line); }
.step b { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: white; }
.step.active { color: var(--purple); }
.step.active b { color: white; background: var(--purple); border-color: var(--purple); }
.screen-heading { margin-bottom: 30px; }
.kicker { margin: 0 0 7px; color: var(--purple); font-size: .78rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2.25rem, 5vw, 4.3rem); line-height: 1; letter-spacing: -.055em; }
h2 { margin: 0; letter-spacing: -.03em; }
.create-layout { display: grid; grid-template-columns: 1.08fr .92fr; gap: 26px; }
.form-column, .upload-column, .review-panel, .result-panel { padding: 30px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.field-group { display: grid; gap: 10px; margin: 0 0 24px; padding: 0; border: 0; font-weight: 750; }
.field-group legend, .field-group > span { margin-bottom: 9px; }
textarea { width: 100%; min-height: 132px; resize: vertical; padding: 15px 16px; border: 1px solid #cbc5d6; border-radius: 14px; color: var(--ink); background: white; line-height: 1.5; }
textarea::placeholder { color: #9991a4; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: #eeeaf3; }
.segmented label, .choice-row label { cursor: pointer; }
.segmented input, .choice-row input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 44px; border-radius: 10px; color: var(--muted); font-weight: 750; }
.segmented input:checked + span { color: var(--purple); background: white; box-shadow: 0 3px 12px rgba(49,31,74,.10); }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.choice-row { display: grid; gap: 9px; }
.choice-row label > span { display: grid; gap: 2px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; }
.choice-row small { color: var(--muted); font-size: .78rem; font-weight: 500; }
.choice-row input:checked + span { border-color: var(--purple); background: var(--purple-soft); box-shadow: 0 0 0 1px var(--purple); }
.upload-column { display: flex; flex-direction: column; }
.upload-card { position: relative; min-height: 390px; display: grid; place-items: center; overflow: hidden; border: 2px dashed #cfc8da; border-radius: 19px; background: #fbfaff; }
.upload-card.dragging { border-color: var(--turquoise); background: #effcfb; }
.upload-card > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-empty { display: grid; justify-items: center; gap: 10px; padding: 30px; text-align: center; color: var(--muted); }
.upload-empty strong { color: var(--ink); font-size: 1.12rem; }
.upload-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 17px; color: white; background: var(--purple); font-size: 2rem; }
.upload-preview { width: 100%; height: 100%; padding: 15px; }
.upload-preview img { width: 100%; height: 320px; object-fit: contain; border-radius: 13px; background: #eeeaf3; }
.preview-actions { display: flex; justify-content: center; gap: 16px; margin-top: 12px; }
.privacy-note { margin: 12px 0 18px; color: var(--muted); font-size: .84rem; }
.primary-button, .secondary-button { min-height: 50px; border-radius: 13px; padding: 13px 18px; font-weight: 850; cursor: pointer; text-align: center; text-decoration: none; }
.primary-button { border: 1px solid var(--purple); color: white; background: var(--purple); box-shadow: 0 8px 22px rgba(91,33,182,.20); }
.primary-button:hover { background: var(--purple-dark); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid #c9c2d4; color: var(--purple); background: white; }
.secondary-button.full { width: 100%; margin-top: 10px; }
.text-button { padding: 8px; border: 0; color: var(--purple); background: transparent; font-weight: 750; cursor: pointer; }
.text-button.danger { color: var(--danger); }
.inline-message { min-height: 1.3em; color: var(--muted); font-size: .88rem; }
.inline-message.error { color: var(--danger); }
.review-grid, .result-grid { display: grid; grid-template-columns: minmax(390px, 1.15fr) minmax(330px, .85fr); gap: 26px; align-items: start; }
.preview-stage, .result-stage { min-height: 650px; display: grid; align-content: start; padding: 18px; border-radius: 24px; background: #18151e; box-shadow: var(--shadow); }
.stage-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 14px; color: white; font-weight: 750; }
.preview-stage > img { width: 100%; max-height: 590px; object-fit: contain; border-radius: 15px; }
.review-panel h1, .result-panel h1 { margin-bottom: 16px; font-size: clamp(2rem, 4vw, 3.4rem); }
.supporting { color: var(--muted); line-height: 1.55; }
.agent-status { margin: 24px 0; padding: 16px; border: 1px solid #b9dfcb; border-radius: 14px; color: var(--success); background: #f0faf4; line-height: 1.4; }
.agent-status.blocked { color: var(--danger); border-color: #f2b8b5; background: #fff2f1; }
.agent-status strong { display: block; margin-bottom: 4px; }
.change-form { margin-top: 18px; padding: 18px; border-radius: 16px; background: var(--purple-soft); }
.change-form label { display: block; margin-bottom: 10px; font-weight: 800; }
.change-form textarea { min-height: 100px; }
.button-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.versions-block { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.section-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-weight: 800; }
.section-label small { color: var(--muted); font-weight: 500; }
.version-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.version-button { padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.version-button img { width: 100%; aspect-ratio: 9/12; object-fit: cover; border-radius: 7px; }
.version-button span { display: block; padding: 5px 2px 2px; color: var(--muted); font-size: .76rem; }
.version-button.active { border-color: var(--purple); box-shadow: 0 0 0 2px var(--purple-soft); }
.version-button.blocked { opacity: .58; }
.result-stage { place-items: center; }
.result-stage img, .result-stage video { width: min(100%, 430px); max-height: 650px; border-radius: 16px; background: black; }
.result-facts { display: grid; gap: 9px; margin: 24px 0; }
.fact { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); }
.fact span { color: var(--muted); }
.download { display: block; width: 100%; }
.previous-results { margin-top: 22px; color: var(--muted); font-size: .86rem; }
.busy-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(25,18,34,.54); backdrop-filter: blur(4px); }
.busy-card { width: min(390px, 100%); padding: 30px; border-radius: 22px; background: white; text-align: center; box-shadow: var(--shadow); }
.busy-card strong { display: block; margin: 16px 0 7px; font-size: 1.18rem; }
.busy-card p { margin: 0; color: var(--muted); }
.spinner { display: inline-block; width: 42px; height: 42px; border: 4px solid var(--purple-soft); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.projects-drawer { position: fixed; z-index: 100; top: 0; right: 0; width: min(420px, 92vw); height: 100vh; padding: 24px; background: white; box-shadow: -20px 0 60px rgba(31,19,46,.18); overflow: auto; }
.review-drawer { position: fixed; z-index: 110; top: 0; right: 0; width: min(620px, 96vw); height: 100vh; padding: 24px; background: white; box-shadow: -20px 0 60px rgba(31,19,46,.18); overflow: auto; }
.artifact-review-list, .infrastructure-review { display: grid; gap: 12px; margin-top: 20px; }
.artifact-review-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fbfaff; }
.artifact-review-card header { display: flex; justify-content: space-between; gap: 12px; }
.artifact-review-card pre { max-height: 180px; overflow: auto; padding: 10px; border-radius: 9px; background: #211c2d; color: #f5f1fa; font-size: .72rem; white-space: pre-wrap; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.icon-button { font-size: 2rem; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(24,18,31,.3); }
.projects-list { display: grid; gap: 10px; }
.project-item { width: 100%; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: left; cursor: pointer; }
.project-item strong { display: block; margin-bottom: 5px; }
.project-item span { color: var(--muted); font-size: .82rem; }

@media (max-width: 840px) {
  .create-layout, .review-grid, .result-grid { grid-template-columns: 1fr; }
  .upload-card { min-height: 330px; }
  .preview-stage, .result-stage { min-height: 500px; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; padding: 0 14px; }
  .brand > span:last-child { font-size: .93rem; }
  .top-actions .demo-badge { display: none; }
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .steps { gap: 5px; font-size: .72rem; }
  .step { gap: 4px; }
  .step:not(:last-child)::after { width: 14px; margin-left: 2px; }
  .step b { width: 23px; height: 23px; }
  .form-column, .upload-column, .review-panel, .result-panel { padding: 19px; border-radius: 18px; }
  .options-grid { grid-template-columns: 1fr; gap: 0; }
  .upload-card { min-height: 280px; }
  .upload-preview img { height: 230px; }
  .preview-stage, .result-stage { min-height: 0; border-radius: 18px; }
  .version-list { grid-template-columns: repeat(3, 1fr); }
}

[hidden] { display: none !important; }
