:root {
  --ink: #171913;
  --muted: #74786d;
  --paper: #f3f1e9;
  --panel: rgba(255, 255, 252, 0.78);
  --line: rgba(31, 34, 27, 0.13);
  --acid: #c9f03b;
  --acid-dark: #8bac10;
  --purple: #6d4cff;
  --danger: #c44735;
  --shadow: 0 24px 80px rgba(47, 49, 39, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 0%, rgba(201, 240, 59, 0.13), transparent 27rem),
    linear-gradient(180deg, #f8f6ef 0%, var(--paper) 65%, #ece9df 100%);
  font-family: Manrope, system-ui, sans-serif;
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.ambient { position: fixed; border-radius: 50%; filter: blur(1px); pointer-events: none; z-index: -1; }
.ambient-one { width: 300px; height: 300px; right: -110px; top: 180px; border: 1px solid rgba(109, 76, 255, .2); }
.ambient-two { width: 150px; height: 150px; left: -70px; top: 620px; background: rgba(201, 240, 59, .08); }

.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: -.04em; font-size: 18px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; color: #fff; background: var(--ink); border-radius: 10px; font-size: 14px; letter-spacing: -.08em; }
.brand-mark span { color: var(--acid); }
.engine-health { display: flex; gap: 9px; align-items: center; font: 500 11px/1 DM Mono, monospace; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #b0b2ab; box-shadow: 0 0 0 4px rgba(176, 178, 171, .13); }
.engine-health.ready .pulse { background: var(--acid-dark); box-shadow: 0 0 0 4px rgba(139, 172, 16, .12); }
.engine-health.error .pulse { background: var(--danger); }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.topbar-actions form { margin: 0; }
.logout-button { border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; color: #62665c; background: rgba(255,255,252,.65); cursor: pointer; font-size: 10px; font-weight: 700; transition: .2s ease; }
.logout-button:hover { color: var(--ink); border-color: rgba(23,25,19,.3); background: #fff; }

.login-page { display: grid; place-items: center; }
.login-shell { width: min(100% - 32px, 470px); padding: 40px 0; }
.login-card { position: relative; padding: 38px; overflow: hidden; background: rgba(255,255,252,.82); border: 1px solid rgba(255,255,255,.95); border-radius: 28px; box-shadow: 0 28px 100px rgba(47,49,39,.14); backdrop-filter: blur(20px); }
.login-card::before { content: ""; position: absolute; width: 180px; height: 180px; right: -92px; top: -94px; border: 1px solid rgba(109,76,255,.18); border-radius: 50%; }
.login-brand { width: fit-content; }
.login-copy { margin: 52px 0 30px; }
.login-kicker { color: var(--purple); font: 500 9px/1 DM Mono, monospace; letter-spacing: .16em; }
.login-copy h1 { margin: 12px 0 10px; font-size: 42px; line-height: 1; letter-spacing: -.055em; }
.login-copy p { margin: 0; max-width: 330px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.login-form .field { margin-bottom: 16px; }
.login-form .field input { min-height: 50px; }
.login-button { margin-top: 6px; }
.login-error { margin: 0 0 14px; padding: 11px 12px; color: #963829; background: #fff0ed; border: 1px solid #f1d0ca; border-radius: 10px; font-size: 11px; }
.login-footnote { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 22px 0 0; color: #94978e; font: 9px DM Mono, monospace; }
.login-footnote span { width: 6px; height: 6px; border-radius: 50%; background: var(--acid-dark); box-shadow: 0 0 0 4px rgba(139,172,16,.1); }

.hero { padding: 72px 0 62px; max-width: 870px; }
.eyebrow { display: flex; align-items: center; gap: 12px; font: 500 10px/1 DM Mono, monospace; letter-spacing: .15em; color: var(--muted); margin-bottom: 25px; }
.eyebrow i { width: 24px; height: 1px; background: #c3c5bd; }
.hero h1 { font-size: clamp(48px, 7vw, 86px); line-height: .98; letter-spacing: -.07em; margin: 0; font-weight: 700; }
.hero h1 em { font-style: normal; position: relative; z-index: 0; }
.hero h1 em::after { content: ""; height: 17px; position: absolute; left: -2px; right: -4px; bottom: 5px; background: var(--acid); z-index: -1; transform: rotate(-1deg); border-radius: 2px; }
.hero p { max-width: 660px; margin: 31px 0 0; color: #666a60; font-size: 17px; line-height: 1.75; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr); gap: 22px; align-items: start; padding-bottom: 100px; }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.92); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.builder-panel { padding: 30px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.panel-heading > div, .section-divider { display: flex; gap: 13px; align-items: center; }
.panel h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.step-number { display: grid; place-items: center; flex: 0 0 auto; width: 29px; height: 29px; border-radius: 9px; background: var(--ink); color: var(--acid); font: 500 10px/1 DM Mono, monospace; }
.local-only { padding: 7px 9px; border-radius: 7px; color: #597003; background: rgba(201, 240, 59, .23); font: 500 9px/1 DM Mono, monospace; letter-spacing: .08em; }

.field { display: block; margin-bottom: 23px; }
.field > span { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 700; color: #565a50; }
.field span b { font-size: 9px; font-weight: 500; color: #9a9d94; margin-left: 5px; text-transform: uppercase; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); outline: none; border-radius: 12px; background: rgba(250,250,246,.88); color: var(--ink); padding: 13px 14px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.field textarea { resize: vertical; min-height: 128px; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(109,76,255,.55); box-shadow: 0 0 0 4px rgba(109,76,255,.08); background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #a5a79f; }
.field small { display: block; margin-top: 7px; color: #92958b; font-size: 10px; }
.input-wrap { position: relative; }
.input-wrap svg { position: absolute; width: 17px; left: 14px; top: 50%; transform: translateY(-50%); fill: none; stroke: #8a8d84; stroke-width: 1.7; }
.input-wrap input { padding-left: 42px; }
.section-divider { border-top: 1px solid var(--line); padding-top: 28px; margin: 30px 0 20px; }

.built-in-reference { display: flex; align-items: center; gap: 12px; padding: 13px 14px; margin-bottom: 11px; border: 1px solid rgba(109,76,255,.14); border-radius: 12px; background: rgba(109,76,255,.045); }
.reference-icon { display: grid; place-items: center; width: 35px; height: 35px; flex: 0 0 auto; border-radius: 10px; color: #fff; background: var(--purple); font: 500 9px DM Mono, monospace; }
.built-in-reference p { min-width: 0; flex: 1; margin: 0; color: #7c8076; font-size: 9px; line-height: 1.45; }
.built-in-reference strong { display: block; color: #4d5049; font-size: 11px; }
.locked { color: var(--purple); font: 500 8px DM Mono, monospace; letter-spacing: .08em; }

.drop-zone { border: 1.5px dashed #c6c8be; border-radius: 16px; min-height: 210px; padding: 30px 22px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; background: rgba(248,248,243,.55); outline: none; transition: .2s ease; }
.drop-zone:hover, .drop-zone:focus, .drop-zone.dragging { border-color: var(--purple); background: rgba(109,76,255,.035); transform: translateY(-1px); }
.drop-icon { width: 43px; height: 43px; border-radius: 13px; display: grid; place-items: center; background: var(--ink); margin-bottom: 15px; }
.drop-icon svg { width: 20px; fill: none; stroke: var(--acid); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop-zone strong { font-size: 14px; }
.drop-zone > span { font-size: 10px; color: #8b8f84; margin-top: 7px; }
.upload-actions { display: flex; gap: 8px; margin-top: 20px; }
.mini-button { cursor: pointer; padding: 9px 13px; border-radius: 9px; color: #fff; background: var(--purple); font-size: 10px; font-weight: 700; }
.mini-button.secondary { color: #5f625a; background: #ecece5; }
.mini-button input { display: none; }
.file-list { display: grid; gap: 7px; margin-top: 11px; }
.file-pill { display: flex; align-items: center; gap: 10px; padding: 10px 11px; background: #f4f4ef; border: 1px solid #e5e5de; border-radius: 10px; font-size: 10px; }
.file-pill .type { width: 32px; text-align: center; color: var(--purple); font: 500 9px DM Mono, monospace; text-transform: uppercase; }
.file-pill .name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pill .size { color: #979a92; font: 9px DM Mono, monospace; }
.file-pill button { border: 0; background: transparent; color: #999c93; cursor: pointer; font-size: 16px; line-height: 1; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field.compact { margin-bottom: 14px; }
.model-field { max-width: calc(50% - 7px); }
.privacy-note { display: flex; gap: 12px; padding: 14px; margin: 11px 0 18px; border-radius: 12px; background: rgba(201,240,59,.12); border: 1px solid rgba(139,172,16,.14); }
.privacy-note svg { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: #708d06; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.privacy-note p { margin: 0; color: #727767; font-size: 10px; line-height: 1.55; }
.privacy-note strong { display: block; color: #4f5641; font-size: 11px; }
.generate-button { width: 100%; height: 54px; border: 0; border-radius: 13px; color: #fff; background: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 11px; font-size: 13px; font-weight: 700; transition: transform .2s, box-shadow .2s, opacity .2s; }
.generate-button:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(23,25,19,.18); }
.generate-button:disabled { cursor: wait; opacity: .55; transform: none; }
.generate-button svg { width: 18px; fill: none; stroke: var(--acid); stroke-width: 1.8; stroke-linecap: round; }
.form-error { margin: 10px 0 0; min-height: 16px; color: var(--danger); text-align: center; font-size: 11px; }

.result-column { display: grid; gap: 22px; position: sticky; top: 20px; }
.status-panel { min-height: 490px; padding: 26px; }
.status-empty { min-height: 435px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.status-empty h3 { margin: 24px 0 7px; font-size: 16px; }
.status-empty p { margin: 0; max-width: 220px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.orbit { width: 100px; height: 100px; border: 1px solid #dcddd6; border-radius: 50%; position: relative; animation: rotate 12s linear infinite; }
.orbit::before { content: ""; position: absolute; inset: 17px; border: 1px dashed #d1d3ca; border-radius: 50%; }
.orbit span { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--acid); top: 4px; left: 17px; box-shadow: 0 0 0 5px rgba(201,240,59,.14); }
.orbit i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--purple); bottom: 12px; right: 9px; }
.orbit b { position: absolute; width: 24px; height: 24px; background: var(--ink); border-radius: 8px; top: 37px; left: 37px; }
@keyframes rotate { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.job-view { min-height: 435px; }
.job-topline { display: flex; justify-content: space-between; align-items: center; }
.job-badge { padding: 7px 9px; border-radius: 7px; background: #ecece5; color: #777b70; font: 500 9px/1 DM Mono, monospace; letter-spacing: .08em; }
.job-badge.running { background: rgba(109,76,255,.1); color: var(--purple); }
.job-badge.completed { background: rgba(201,240,59,.22); color: #5e7605; }
.job-badge.failed { background: rgba(196,71,53,.1); color: var(--danger); }
.job-topline code { color: #a1a39a; font: 9px DM Mono, monospace; }
.job-view > h3 { margin: 19px 0 13px; font-size: 18px; letter-spacing: -.03em; }
.progress-track { height: 5px; background: #e8e8e1; border-radius: 99px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 7%; background: linear-gradient(90deg, var(--purple), var(--acid-dark)); transition: width .45s ease; border-radius: inherit; }
.pipeline { list-style: none; padding: 0; margin: 25px 0; display: grid; gap: 2px; }
.pipeline li { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; opacity: .38; transition: .25s; }
.pipeline li > span { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; border: 1px solid #cfd1c8; font: 9px DM Mono, monospace; }
.pipeline li strong, .pipeline li small { display: block; }
.pipeline li strong { font-size: 11px; }
.pipeline li small { margin-top: 2px; font-size: 9px; color: #8c9085; }
.pipeline li.active, .pipeline li.done { opacity: 1; }
.pipeline li.active { background: rgba(109,76,255,.05); }
.pipeline li.active > span { color: #fff; background: var(--purple); border-color: var(--purple); }
.pipeline li.done > span { font-size: 0; background: var(--acid); border-color: var(--acid); }
.pipeline li.done > span::after { content: "✓"; font-size: 11px; font-weight: 800; }
.error-card { padding: 12px; margin-bottom: 14px; color: #963829; background: #fff0ed; border: 1px solid #f1d0ca; border-radius: 10px; font-size: 10px; line-height: 1.5; }
.outputs { padding-top: 4px; }
.outputs-title { display: flex; justify-content: space-between; color: #777b70; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
#outputList { display: grid; gap: 6px; margin: 10px 0; }
.output-file { width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid #e3e4dc; background: #f6f6f1; border-radius: 9px; padding: 10px; cursor: pointer; text-align: left; }
.output-file code { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; color: #42453e; font: 10px DM Mono, monospace; }
.output-file span { color: #999c93; font: 9px DM Mono, monospace; }
.download-button { display: block; padding: 12px; text-align: center; color: #fff; background: var(--purple); border-radius: 10px; text-decoration: none; font-size: 11px; font-weight: 700; }
.agent-log { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 18px; }
.agent-log summary { cursor: pointer; color: #6d7167; font-size: 10px; font-weight: 700; }
.agent-log summary span { color: var(--acid-dark); margin-left: 4px; }
.agent-log pre { max-height: 180px; overflow: auto; padding: 11px; color: #b9d969; background: #1d1f1a; border-radius: 9px; white-space: pre-wrap; word-break: break-word; font: 9px/1.55 DM Mono, monospace; }

.how-it-works { padding: 24px; border: 1px solid var(--line); border-radius: 19px; background: rgba(242,241,234,.5); }
.aside-label { display: block; margin-bottom: 14px; color: #93968d; font: 500 9px DM Mono, monospace; letter-spacing: .12em; }
.how-item { display: flex; gap: 13px; padding: 12px 0; border-top: 1px solid var(--line); }
.how-item > span { color: var(--purple); font: 500 9px DM Mono, monospace; padding-top: 2px; }
.how-item p { margin: 0; color: #85887f; font-size: 10px; line-height: 1.5; }
.how-item strong { display: block; color: #484b44; font-size: 11px; }

.preview-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(24,25,21,.65); backdrop-filter: blur(8px); }
.preview-card { width: min(880px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: #1d1f1a; color: #e6e8df; border: 1px solid rgba(255,255,255,.13); border-radius: 17px; overflow: hidden; box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; background: #272a23; }
.preview-header strong { font: 11px DM Mono, monospace; }
.preview-header button { color: #fff; background: transparent; border: 0; font-size: 22px; cursor: pointer; }
.preview-card > pre { margin: 0; padding: 20px; overflow: auto; font: 11px/1.65 DM Mono, monospace; white-space: pre; }

@media (max-width: 860px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .result-column { position: static; }
  .hero { padding-top: 54px; }
  .status-panel { min-height: 430px; }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1180px); }
  .topbar { height: 68px; }
  .engine-health { max-width: 160px; text-align: right; }
  .topbar-actions { gap: 9px; }
  .engine-health { display: none; }
  .login-card { padding: 28px 22px; border-radius: 22px; }
  .login-copy { margin-top: 42px; }
  .login-copy h1 { font-size: 36px; }
  .hero { padding: 48px 0 42px; }
  .hero h1 { font-size: 47px; }
  .hero h1 em::after { height: 11px; bottom: 3px; }
  .hero p { font-size: 14px; }
  .builder-panel, .status-panel { padding: 20px; border-radius: 18px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .model-field { max-width: none; }
  .upload-actions { flex-direction: column; width: 100%; }
  .mini-button { text-align: center; }
}
