@font-face {
  font-family: "Golos Text";
  src: url("/studio/golos-text-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #edf3f7;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --line: #d6e0e7;
  --line-strong: #9db3c4;
  --text: #152434;
  --muted: #6d7c89;
  --navy: #12365f;
  --navy-deep: #0a2747;
  --blue: #205a8b;
  --mint: #157565;
  --amber: #986d19;
  --danger: #a2443f;
  --shadow: 0 14px 38px rgba(10, 39, 71, .08);
  --radius: 2px;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 400 16px/1.55 "Golos Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid #79a5c9;
  outline-offset: 3px;
}
.is-hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.app-layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; z-index: 40; height: 100vh; padding: 24px 18px;
  color: #fff; background: var(--navy-deep);
}
.brand { display: block; color: #fff; text-decoration: none; }
.brand-plate { display: grid; height: 78px; padding: 8px 12px; place-items: center; background: #fff; }
.brand-plate img { display: block; width: 154px; max-width: 100%; height: auto; }
.brand-copy { display: flex; margin-top: 14px; padding: 0 4px; flex-direction: column; gap: 3px; }
.brand-copy strong { font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.brand-copy small { color: #94abc0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.side-nav { display: grid; gap: 6px; margin-top: 30px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.13); }
.side-nav a {
  display: grid; grid-template-columns: 26px 1fr; min-height: 48px; padding: 0 14px; align-items: center; gap: 10px;
  color: #b9cada; border: 1px solid transparent; text-decoration: none;
}
.side-nav a span { color: #7792aa; font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.side-nav a strong { font-size: 14px; font-weight: 600; }
.side-nav a:hover { color: #fff; background: rgba(255,255,255,.045); }
.side-nav a.is-active { color: #fff; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); }
.sidebar-note { position: absolute; right: 18px; bottom: 24px; left: 18px; padding: 18px 4px 0; border-top: 1px solid rgba(255,255,255,.13); }
.sidebar-note strong { display: block; margin-bottom: 5px; font-size: 12px; }
.sidebar-note span { display: block; color: #aebfd0; font-size: 12px; line-height: 1.55; }

.app-main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; min-height: 72px; padding: 12px clamp(18px, 3vw, 36px); align-items: center; justify-content: space-between; gap: 20px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(14px);
}
.page-id { display: flex; align-items: center; gap: 12px; }
.page-id strong { color: var(--navy); font-size: 18px; }
.page-id span { color: var(--muted); font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.route-pill, .balance-pill {
  display: flex; min-height: 44px; padding: 0 14px; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 0; color: var(--muted); background: #fff; font-size: 13px;
}
.route-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.balance-pill { color: #fff; border-color: var(--navy); background: var(--navy); }
.balance-pill strong { font-weight: 700; }

.shell { width: min(1420px, calc(100% - 48px)); margin: 0 auto; padding: 40px 0 72px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 48px; align-items: end; margin: 0 0 28px; }
.eyebrow { margin: 0 0 12px; color: var(--blue); font: 700 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.hero h1 { margin: 0; color: var(--navy-deep); font-size: clamp(36px, 4.5vw, 58px); line-height: 1.12; letter-spacing: -.045em; text-wrap: balance; }
.hero h1 span { color: var(--navy); }
.hero-copy { max-width: 520px; margin: 0 0 5px; color: #5c6c79; font-size: 16px; line-height: 1.65; }

.studio-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr); gap: 16px; align-items: start; scroll-margin-top: 92px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.composer { padding: clamp(22px, 2.5vw, 32px); }
.preview { position: sticky; top: 88px; padding: 0; }

.workflow-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 28px; border: 1px solid var(--line); }
.workflow-step { min-height: 68px; padding: 13px 14px; border-right: 1px solid var(--line); background: #f8fafb; }
.workflow-step:last-child { border-right: 0; }
.workflow-step span { display: block; color: var(--muted); font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.workflow-step strong { display: block; margin-top: 7px; color: #53616e; font-size: 13px; }
.workflow-step.is-current { background: var(--navy); }
.workflow-step.is-current span, .workflow-step.is-current strong { color: #fff; }

.panel-head, .preview-head, .section-title, .section-title > div, .preview-head > div {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head > div, .section-title > div, .preview-head > div { justify-content: flex-start; }
.panel h2 { margin: 0; color: var(--navy); font-size: 16px; letter-spacing: -.01em; }
.step-number { color: var(--blue); font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }
.autosave, .hint { color: var(--muted); font-size: 12px; }
.autosave::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--mint); }

.kind-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 20px 0 0; }
.kind-button {
  display: flex; min-height: 62px; padding: 10px 14px; align-items: center; justify-content: center;
  color: #566674; border: 1px solid var(--line); border-radius: 0; background: #f8fafb; text-align: center;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.kind-button:hover { color: var(--navy); border-color: var(--line-strong); }
.kind-button.is-active { color: #fff; border-color: var(--blue); background: var(--blue); }
.kind-button > span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.kind-button strong { font-size: 15px; }
.kind-button small { overflow: hidden; color: inherit; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; opacity: .8; }

.form-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.section-title { margin-bottom: 14px; justify-content: flex-start; }
.section-title.compact { justify-content: space-between; }
.mode-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-button {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 0;
  color: #536371; background: #f8fafb; font-size: 13px; font-weight: 600;
}
.mode-button:hover { color: var(--navy); border-color: var(--line-strong); }
.mode-button.is-active { color: #fff; border-color: var(--blue); background: var(--blue); }

.prompt-studio { margin-bottom: 14px; padding: 16px; border: 1px solid #b9cfdd; background: #f2f7fa; }
.prompt-style-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.prompt-style-head > div { display: grid; gap: 4px; }
.prompt-style-head strong { color: var(--navy); font-size: 14px; }
.prompt-style-head span:not(.ai-badge) { color: var(--muted); font-size: 12px; line-height: 1.45; }
.ai-badge { flex: 0 0 auto; padding: 5px 7px; color: #fff; background: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.prompt-styles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.prompt-style {
  min-width: 0; min-height: 62px; padding: 10px 11px; text-align: left; border: 1px solid #c6d5df; color: #4e6170; background: #fff;
}
.prompt-style:hover { border-color: #6c9abd; background: #f8fbfd; }
.prompt-style:focus-visible { outline: 3px solid #79a5c9; outline-offset: 2px; }
.prompt-style strong, .prompt-style span { display: block; }
.prompt-style strong { color: var(--navy); font-size: 12px; line-height: 1.3; }
.prompt-style span { margin-top: 4px; font-size: 10px; line-height: 1.35; }
.prompt-style.is-active { color: #fff; border-color: var(--navy); background: var(--navy); }
.prompt-style.is-active strong { color: #fff; }
.prompt-product-row { display: flex; min-height: 70px; margin-top: 12px; padding-top: 12px; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid #cbd9e2; }
.prompt-product-row > div:first-child { display: grid; gap: 3px; min-width: 0; }
.prompt-product-row > div:first-child strong { color: var(--navy); font-size: 12px; }
.prompt-product-row > div:first-child span { color: var(--muted); font-size: 10px; line-height: 1.4; }
.prompt-product-selected { display: grid; min-width: 0; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 10px; }
.prompt-product-selected img { width: 52px; height: 52px; object-fit: contain; border: 1px solid var(--line); background: #fff; }
.prompt-product-selected span { display: grid; gap: 3px; min-width: 0; }
.prompt-product-selected small { color: var(--muted); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.prompt-product-selected strong { overflow: hidden; color: var(--navy); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; }
.prompt-product-dimensions { color: #527083; font-size: 10px; font-style: normal; line-height: 1.35; }
.prompt-product-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.secondary-button, .text-button { min-height: 44px; padding: 0 12px; font-size: 11px; font-weight: 700; }
.secondary-button { color: var(--navy); border: 1px solid var(--line-strong); background: #fff; }
.secondary-button:hover { background: #e8f1f6; }
.text-button { color: var(--muted); border: 0; background: transparent; }
.prompt-wrap { position: relative; }
textarea, select, input[type="url"], input[type="password"], input[type="number"] {
  width: 100%; color: var(--text); border: 1px solid var(--line); border-radius: 0; background: #fbfcfd;
}
textarea { min-height: 190px; padding: 16px; resize: vertical; line-height: 1.6; }
textarea::placeholder, input::placeholder { color: #82909b; }
textarea:hover, textarea:focus, select:hover, select:focus, input:hover, input:focus { border-color: #79a5c9; }
.prompt-helper {
  min-height: 46px; padding: 0 14px; color: var(--navy); border: 1px solid var(--line-strong); border-radius: 0; background: #fff; font-size: 12px; font-weight: 700;
}
.prompt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; align-items: center; }
.prompt-ai-button { display: inline-flex; min-height: 46px; padding: 0 16px; align-items: center; gap: 9px; border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.prompt-ai-button:hover { border-color: var(--navy); background: var(--navy); }
.prompt-ai-button:disabled { cursor: wait; opacity: .64; }
.prompt-ai-button span { font-size: 16px; }
.prompt-ai-button b { font-size: 12px; }
.prompt-chat-button { display: inline-flex; min-height: 46px; padding: 0 15px; align-items: center; gap: 8px; border: 1px solid var(--navy); color: var(--navy); background: #edf5f8; }
.prompt-chat-button:hover { color: #fff; background: var(--navy); }
.prompt-chat-button span { font-size: 18px; }
.prompt-chat-button b { font-size: 12px; }
.prompt-undo { min-height: 44px; padding: 0 8px; border: 0; color: var(--blue); background: transparent; font-size: 11px; font-weight: 700; }
.prompt-ai-status { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.prompt-ai-status.is-success { color: #166044; }
.prompt-ai-status.is-error { color: var(--danger); }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.field-wide { grid-column: 1 / -1; }
.field > span { color: #576674; font-size: 13px; font-weight: 600; }
.field em { margin-left: 6px; padding: 3px 6px; color: #fff; background: var(--blue); font-size: 9px; font-style: normal; letter-spacing: .05em; text-transform: uppercase; }
select, input[type="url"], input[type="password"], input[type="number"] { height: 48px; padding: 0 12px; }
select {
  appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, #728493 50%), linear-gradient(135deg, #728493 50%, transparent 50%);
  background-position: calc(100% - 16px) 21px, calc(100% - 11px) 21px; background-size: 5px 5px; background-repeat: no-repeat;
}
.control-note { margin: 14px 0 0; padding: 12px 14px; border: 1px solid #bdd0dc; color: #4f6474; background: #edf5f8; font-size: 12px; line-height: 1.55; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 16px 28px; margin-top: 18px; }
.toggle { display: flex; min-height: 44px; align-items: center; gap: 10px; color: #526574; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle > span { position: relative; width: 40px; height: 22px; border: 1px solid var(--line-strong); border-radius: 99px; background: #e5edf2; transition: .16s; }
.toggle > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #7f909c; transition: .16s; }
.toggle input:checked + span { border-color: var(--blue); background: #d5e7f3; }
.toggle input:checked + span::after { left: 21px; background: var(--blue); }
.toggle input:focus-visible + span { outline: 3px solid #79a5c9; outline-offset: 3px; }
.toggle input:disabled + span, .toggle input:disabled ~ b { opacity: .42; cursor: not-allowed; }
.toggle b { font-size: 13px; font-weight: 600; }

.source-grid { display: grid; gap: 12px; }
.source-slot { padding: 14px; border: 1px solid var(--line); background: #f9fbfc; }
.source-slot-head { display: flex; margin: 0 2px 10px; justify-content: space-between; gap: 12px; }
.source-slot-head strong { color: var(--navy); font-size: 13px; }
.source-slot-head span { color: var(--muted); font-size: 12px; }
.drop-zone {
  display: flex; min-height: 112px; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px dashed #8da6b9; color: var(--muted); background: #f4f8fa; cursor: pointer; transition: border-color .16s, background .16s;
}
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--blue); background: #eaf3f8; }
.upload-icon { display: grid; width: 36px; height: 36px; margin-bottom: 5px; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-size: 20px; font-weight: 700; }
.drop-zone b { color: var(--navy); font-size: 13px; }
.drop-zone small { font-size: 12px; }
.source-status { min-height: 18px; margin: 8px 2px 0; color: var(--mint); font-size: 12px; }
.source-status.is-error { color: var(--danger); }
.url-field { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 8px; align-items: center; }
.url-field span { color: var(--muted); font-size: 12px; }
.url-field input { height: 44px; font-size: 13px; }
.product-picker-button {
  display: flex; width: 100%; min-height: 56px; margin-top: 10px; padding: 10px 14px; align-items: flex-start; justify-content: center;
  flex-direction: column; border: 1px solid #8eafc6; color: var(--navy); background: #edf5f8; text-align: left;
}
.product-picker-button:hover { border-color: var(--blue); background: #e2eff5; }
.product-picker-button strong { font-size: 13px; }
.product-picker-button span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.selected-product {
  display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; min-height: 72px; margin-top: 10px; align-items: center;
  border: 1px solid var(--line-strong); background: #fff;
}
.selected-product img { display: block; width: 62px; height: 70px; object-fit: contain; background: #f4f6f7; }
.selected-product > span { display: flex; min-width: 0; padding: 8px 12px; flex-direction: column; }
.selected-product small { color: var(--muted); font-size: 11px; }
.selected-product strong { overflow: hidden; margin-top: 2px; color: var(--navy); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.selected-product-dimensions { margin-top: 3px; color: #527083; font-size: 10px; font-style: normal; line-height: 1.35; }
.selected-product button { min-height: 44px; margin-right: 8px; padding: 0 10px; border: 0; color: var(--danger); background: transparent; font-size: 12px; }

.form-message { display: none; margin-top: 18px; padding: 12px 14px; border: 1px solid #d6a4a0; color: #7d332e; background: #fff1ef; font-size: 13px; line-height: 1.5; }
.form-message:not(:empty) { display: block; }
.submit-row { display: grid; grid-template-columns: 1fr auto; gap: 18px; margin-top: 28px; padding: 18px; align-items: center; background: var(--bg); }
.quote { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.quote span, .quote small { color: var(--muted); font-size: 12px; }
.quote strong { overflow: hidden; color: var(--navy); font-size: 20px; white-space: nowrap; text-overflow: ellipsis; }
.generate-button {
  display: flex; min-width: 210px; min-height: 54px; padding: 0 18px 0 22px; align-items: center; justify-content: space-between; gap: 22px;
  color: #fff; border: 0; border-radius: 0; background: var(--navy); font-size: 14px; font-weight: 700; transition: background .16s;
}
.generate-button:hover:not(:disabled) { background: var(--blue); }
.generate-button:disabled { color: #8795a0; background: #d8e1e7; cursor: not-allowed; }
.generate-button i { font-size: 18px; font-style: normal; }

.preview-head { min-height: 64px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.status-badge { padding: 7px 9px; color: var(--muted); background: #f2f6f8; font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; text-transform: uppercase; }
.status-running { color: var(--amber); background: #fff5db; }
.status-done { color: var(--mint); background: #e6f3ef; }
.status-error { color: var(--danger); background: #fff0ee; }
.preview-stage { position: relative; display: grid; min-height: 430px; padding: 28px; place-items: center; overflow: hidden; background: #dfeaf1; }
.empty-preview, .loading-preview, .error-preview { width: min(340px, 88%); text-align: center; }
.empty-preview h3, .loading-preview h3, .error-preview h3 { margin: 18px 0 8px; color: var(--navy); font-size: 18px; }
.empty-preview p, .loading-preview p, .error-preview p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.orb { display: grid; width: 76px; height: 76px; margin: 0 auto; place-items: center; border: 1px solid var(--navy); border-radius: 50%; color: var(--navy); background: #fff; }
.orb span { font: 700 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.render-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; width: 72px; height: 72px; margin: 0 auto; transform: rotate(45deg); }
.render-grid i { background: #c4d8e5; animation: pulse 1.5s infinite ease-in-out; }
.render-grid i:nth-child(2) { animation-delay: .15s; background: #6fa1c3; }
.render-grid i:nth-child(3) { animation-delay: .3s; background: #9abbd1; }
.render-grid i:nth-child(4) { animation-delay: .45s; background: var(--blue); }
@keyframes pulse { 0%,100% { transform: scale(.86); opacity: .45; } 50% { transform: scale(1); opacity: 1; } }
.progress-track { height: 5px; margin-top: 22px; overflow: hidden; background: #c6d5de; }
.progress-track span { display: block; width: 10%; height: 100%; background: var(--blue); transition: width 1s ease; }
.result-preview { width: 100%; height: 100%; min-height: 430px; }
.result-preview video, .result-preview img { display: block; width: 100%; height: 430px; object-fit: contain; background: #091f37; }
.result-actions { position: absolute; right: 14px; bottom: 14px; left: 14px; display: flex; justify-content: flex-end; gap: 8px; pointer-events: none; }
.result-actions a { pointer-events: auto; min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; color: #fff; background: var(--navy); font-size: 12px; font-weight: 700; text-decoration: none; box-shadow: var(--shadow); }
.error-preview > span { display: grid; width: 54px; height: 54px; margin: 0 auto; place-items: center; border: 1px solid #d6a4a0; border-radius: 50%; color: var(--danger); background: #fff; font-size: 20px; font-weight: 800; }
.error-preview button { min-height: 44px; margin-top: 18px; padding: 0 14px; border: 1px solid var(--line-strong); color: var(--navy); background: #fff; font-size: 13px; font-weight: 600; }

.quality-checks { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quality-checks > div { min-height: 76px; padding: 14px; border-right: 1px solid var(--line); }
.quality-checks > div:last-child { border-right: 0; }
.quality-checks small { display: block; color: var(--muted); font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.quality-checks strong { display: block; margin-top: 8px; color: var(--navy); font-size: 12px; }
.job-card { margin: 14px; padding: 16px; border: 1px solid var(--line); background: #f8fafb; }
.job-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.job-card-head span { color: var(--navy); font-size: 13px; font-weight: 700; }
.job-card-head code { overflow: hidden; max-width: 58%; color: var(--muted); font-size: 11px; text-overflow: ellipsis; }
.job-steps { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0 0; padding: 0; list-style: none; }
.job-steps li { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.job-steps li::before { content: ""; position: absolute; top: 5px; right: -8px; left: 8px; height: 1px; background: var(--line); }
.job-steps li:last-child::before { display: none; }
.job-steps i { position: relative; z-index: 1; width: 10px; height: 10px; border: 2px solid #f8fafb; border-radius: 50%; background: #93a3ae; }
.job-steps span { display: flex; min-width: 0; padding-right: 5px; flex-direction: column; gap: 3px; }
.job-steps b { color: #768591; font-size: 10px; }
.job-steps small { display: none; color: var(--muted); font-size: 10px; line-height: 1.35; }
.job-steps .is-current i, .job-steps .is-done i { background: var(--blue); box-shadow: 0 0 0 3px #d9e9f3; }
.job-steps .is-current b, .job-steps .is-done b { color: var(--navy); }
.job-steps .is-current small { display: block; }
.privacy-note { display: flex; gap: 10px; margin: 0 14px 14px; padding: 13px 14px; color: var(--muted); background: #edf5f8; }
.privacy-note > span { display: grid; width: 22px; height: 22px; place-items: center; flex: 0 0 auto; border: 1px solid #89a8bc; border-radius: 50%; color: var(--blue); font-weight: 700; }
.privacy-note p { margin: 0; font-size: 12px; line-height: 1.55; }
.privacy-note strong { color: var(--navy); }

.history { margin-top: 16px; padding: clamp(22px, 2.5vw, 32px); scroll-margin-top: 92px; }
.history-head { display: flex; margin-bottom: 18px; align-items: center; justify-content: space-between; gap: 16px; }
.history-head > div { display: flex; align-items: center; gap: 12px; }
.history-empty { padding: 34px 20px; border: 1px dashed var(--line-strong); color: var(--muted); background: #f8fafb; text-align: center; font-size: 14px; }
.history-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.history-card { display: grid; grid-template-columns: 160px minmax(0, 1fr); min-width: 0; overflow: hidden; border: 1px solid var(--line); background: #f8fafb; }
.history-media { display: grid; min-height: 150px; place-items: center; overflow: hidden; color: #aebdca; background: var(--navy-deep); font-size: 11px; text-align: center; }
.history-media img, .history-media video { display: block; width: 100%; height: 100%; min-height: 150px; max-height: 220px; object-fit: cover; }
.history-media span { max-width: 130px; padding: 16px; line-height: 1.45; }
.history-body { display: flex; min-width: 0; padding: 16px; flex-direction: column; align-items: flex-start; }
.history-card-head { display: flex; width: 100%; align-items: flex-start; justify-content: space-between; gap: 10px; }
.history-card-head strong { overflow: hidden; color: var(--navy); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.history-status { flex: 0 0 auto; padding: 4px 6px; color: var(--muted); background: #eaf0f4; font: 700 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.history-completed { color: var(--mint); background: #e6f3ef; }
.history-failed { color: var(--danger); background: #fff0ee; }
.history-running, .history-queued { color: var(--amber); background: #fff5db; }
.history-body > small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.history-body p { display: -webkit-box; overflow: hidden; margin: 13px 0; color: #526371; font-size: 12px; line-height: 1.55; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.history-error { margin: auto 0 10px; color: var(--danger); font-size: 11px; line-height: 1.4; }
.history-open { min-height: 44px; margin-top: auto; padding: 0 12px; display: inline-flex; align-items: center; border: 1px solid var(--line-strong); color: var(--navy); background: #fff; font-size: 11px; font-weight: 700; text-decoration: none; }
.history-open:hover { background: #eaf3f8; }

.product-dialog, .auth-dialog, .prompt-chat-dialog { padding: 0; color: var(--text); border: 1px solid var(--line-strong); border-radius: 0; background: #fff; box-shadow: 0 36px 90px rgba(10,39,71,.28); }
.product-dialog::backdrop, .auth-dialog::backdrop, .prompt-chat-dialog::backdrop { background: rgba(10,39,71,.62); backdrop-filter: blur(7px); }
.product-dialog { width: min(980px, calc(100% - 32px)); max-height: min(88vh, 900px); overflow: auto; }
.product-dialog-shell { padding: 28px; }
.product-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.product-dialog-head h2 { margin: 4px 0 8px; color: var(--navy); font-size: 28px; line-height: 1.25; }
.product-dialog-head p:not(.eyebrow) { max-width: 64ch; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.dialog-close { width: 48px; height: 48px; flex: 0 0 auto; border: 1px solid var(--line); color: var(--navy); background: #fff; font-size: 28px; line-height: 1; }
.dialog-close:hover { background: #edf5f8; }
.product-search { display: grid; gap: 8px; margin-top: 24px; }
.product-search span { color: var(--navy); font-size: 14px; font-weight: 600; }
.product-search input { min-height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); color: var(--text); background: #fff; font-size: 16px; }
.product-catalog-status { min-height: 24px; margin: 16px 0 8px; color: var(--muted); font-size: 14px; }
.product-catalog-status.is-error { color: var(--danger); }
.product-catalog-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding-bottom: 4px; }
.product-card { min-width: 0; padding: 16px; border: 1px solid var(--line); background: #f8fafb; }
.product-card-head { margin-bottom: 12px; }
.product-card-head strong { display: block; color: var(--navy); font-size: 16px; line-height: 1.4; }
.product-card-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.product-card-head .product-card-dimensions {
  margin-top: 9px; padding: 7px 9px; color: #244f70; border-left: 3px solid #79a5c9; background: #eaf3f8;
  font-size: 11px; font-weight: 600; line-height: 1.45;
}
.product-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.product-photo {
  position: relative; min-width: 0; min-height: 150px; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); background: #fff;
}
.product-photo:hover { border-color: var(--blue); box-shadow: 0 0 0 2px #d6e8f2; }
.product-photo:focus-visible { outline: 3px solid #79a5c9; outline-offset: 2px; }
.product-photo img { display: block; width: 100%; height: 150px; object-fit: contain; background: #f2f4f5; }
.product-photo span {
  position: absolute; right: 0; bottom: 0; left: 0; overflow: hidden; padding: 7px 8px; color: #fff;
  background: rgba(10,39,71,.88); font-size: 11px; white-space: nowrap; text-overflow: ellipsis;
}
.product-catalog-empty { grid-column: 1 / -1; padding: 32px; border: 1px dashed var(--line-strong); color: var(--muted); text-align: center; }
.prompt-chat-dialog { width: min(760px, calc(100% - 28px)); max-height: min(90vh, 920px); overflow: hidden; }
.prompt-chat-shell { display: grid; max-height: min(90vh, 920px); grid-template-rows: auto auto minmax(230px, 1fr) auto auto; }
.prompt-chat-head { display: flex; padding: 24px 24px 18px; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.prompt-chat-head h2 { margin: 4px 0 6px; color: var(--navy); font-size: 27px; line-height: 1.2; }
.prompt-chat-head p:not(.eyebrow) { max-width: 62ch; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.prompt-chat-context { display: flex; gap: 7px; padding: 12px 24px; overflow-x: auto; border-bottom: 1px solid var(--line); background: #f7fafc; }
.prompt-chat-context span { flex: 0 0 auto; padding: 6px 9px; color: #4d6474; border: 1px solid #c5d5df; background: #fff; font-size: 10px; font-weight: 700; }
.prompt-chat-messages { display: flex; min-height: 230px; padding: 20px 24px; overflow-y: auto; flex-direction: column; gap: 12px; background: #eef4f7; }
.chat-message { display: grid; max-width: 84%; grid-template-columns: 30px minmax(0, 1fr); align-items: start; gap: 9px; }
.chat-message > span { display: grid; width: 30px; height: 30px; place-items: center; color: #fff; background: var(--blue); font-size: 9px; font-weight: 800; }
.chat-message p { margin: 0; padding: 11px 13px; border: 1px solid #cad8e1; color: var(--text); background: #fff; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.chat-message.is-user { align-self: flex-end; grid-template-columns: minmax(0, 1fr) 30px; }
.chat-message.is-user > span { grid-column: 2; background: var(--navy); }
.chat-message.is-user p { grid-row: 1; color: #fff; border-color: var(--navy); background: var(--navy); }
.chat-message.is-loading p { color: var(--muted); font-style: italic; }
.prompt-chat-candidate { display: flex; padding: 13px 24px; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid #b7d2c4; background: #edf8f2; }
.prompt-chat-candidate > div { display: grid; gap: 3px; }
.prompt-chat-candidate strong { color: #185b43; font-size: 12px; }
.prompt-chat-candidate span { color: #4d7163; font-size: 10px; }
.prompt-chat-candidate button { min-height: 42px; padding: 0 13px; border: 0; color: #fff; background: #186246; font-size: 11px; font-weight: 700; }
.prompt-chat-form { padding: 16px 24px 20px; border-top: 1px solid var(--line); background: #fff; }
.prompt-chat-form > label { display: block; margin-bottom: 7px; color: var(--navy); font-size: 11px; font-weight: 700; }
.prompt-chat-form textarea { min-height: 84px; max-height: 180px; padding: 11px 12px; background: #fbfcfd; }
.prompt-chat-form-foot { display: flex; min-height: 46px; margin-top: 8px; align-items: center; justify-content: space-between; gap: 12px; }
.prompt-chat-form-foot > span { color: var(--muted); font-size: 10px; }
.prompt-chat-form-foot > div { display: flex; align-items: center; gap: 7px; }
#promptChatSend { min-height: 44px; padding: 0 18px; border: 0; color: #fff; background: var(--blue); font-size: 12px; font-weight: 700; }
#promptChatSend:disabled { cursor: wait; opacity: .55; }
.auth-dialog { width: min(460px, calc(100% - 28px)); }
.auth-dialog form { padding: 32px; }
.auth-brand { display: grid; width: 170px; min-height: 62px; margin-bottom: 24px; place-items: center; background: #fff; }
.auth-brand img { display: block; width: 160px; }
.auth-dialog h2 { margin: 0 0 10px; color: var(--navy); font-size: 26px; letter-spacing: -.03em; }
.auth-dialog p:not(.eyebrow) { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.auth-field { margin-top: 18px; }
.auth-message { min-height: 20px; margin: 8px 0; color: var(--danger); font-size: 12px; }
.connect-button { width: 100%; min-height: 50px; border: 0; border-radius: 0; color: #fff; background: var(--navy); font-weight: 700; }
.connect-button:hover { background: var(--blue); }
.disconnect-button { width: 100%; min-height: 44px; margin-top: 8px; padding: 0 10px; border: 0; color: var(--muted); background: transparent; font-size: 12px; }

.storyboard-builder { margin-top: 22px; padding: 20px; border: 1px solid #afc6d5; background: #f2f7fa; }
.storyboard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.storyboard-head h3 { margin: 0 0 6px; color: var(--navy); font-size: 20px; line-height: 1.25; }
.storyboard-head p:not(.eyebrow) { max-width: 66ch; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.storyboard-progress { flex: 0 0 auto; padding: 7px 9px; color: #456477; border: 1px solid #bfd0db; background: #fff; font-size: 10px; font-weight: 700; }
.storyboard-count { margin: 18px 0 0; padding: 0; border: 0; }
.storyboard-count legend { margin-bottom: 8px; color: var(--navy); font-size: 11px; font-weight: 700; }
.storyboard-count-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; max-width: 680px; }
.storyboard-count label { position: relative; min-width: 0; cursor: pointer; }
.storyboard-count input { position: absolute; opacity: 0; pointer-events: none; }
.storyboard-count label > span { display: flex; min-height: 58px; padding: 8px 10px; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line-strong); background: #fff; text-align: center; }
.storyboard-count b { color: var(--navy); font-size: 16px; }
.storyboard-count small { color: var(--muted); font-size: 10px; }
.storyboard-count input:checked + span { color: #fff; border-color: var(--blue); background: var(--blue); box-shadow: inset 4px 0 0 #9ac1dc; }
.storyboard-count input:checked + span b, .storyboard-count input:checked + span small { color: inherit; }
.storyboard-count input:focus-visible + span { outline: 3px solid #79a5c9; outline-offset: 3px; }
.storyboard-count-note { display: block; max-width: 680px; margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.storyboard-video-route { display: grid; max-width: 620px; margin-top: 14px; gap: 5px; }
.storyboard-video-route > span { color: var(--navy); font-size: 11px; font-weight: 700; }
.storyboard-video-route select { width: 100%; min-height: 46px; padding: 0 38px 0 12px; border: 1px solid var(--line-strong); color: var(--navy); background-color: #fff; font-size: 12px; font-weight: 650; }
.storyboard-video-route small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.storyboard-toolbar { display: flex; margin-top: 14px; align-items: center; flex-wrap: wrap; gap: 9px; }
.storyboard-toolbar > span { flex: 1 1 220px; color: var(--muted); font-size: 11px; }
.storyboard-create { min-height: 46px; padding: 0 16px; border: 1px solid var(--navy); color: #fff; background: var(--navy); font-size: 12px; font-weight: 750; }
.storyboard-create:hover { border-color: var(--blue); background: var(--blue); }
.storyboard-create:disabled { cursor: not-allowed; opacity: .5; }
.storyboard-frames { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.storyboard-frame { min-width: 0; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.storyboard-frame.is-failed { border-color: #d5aaa7; }
.storyboard-frame.is-ready { border-color: #9ec6b6; }
.storyboard-frame-media { position: relative; display: grid; min-height: 230px; overflow: hidden; place-items: center; border-bottom: 1px solid var(--line); background: #e5edf2; }
.storyboard-frame-media img { display: block; width: 100%; height: 230px; object-fit: cover; }
.storyboard-frame-number { position: absolute; top: 10px; left: 10px; z-index: 2; display: grid; width: 34px; height: 34px; place-items: center; color: #fff; background: rgba(10,39,71,.92); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.storyboard-frame-placeholder { display: grid; max-width: 220px; padding: 20px; text-align: center; }
.storyboard-frame-placeholder b { color: #557082; font-size: 12px; }
.storyboard-frame-placeholder small { margin-top: 5px; color: #7c8d99; font-size: 10px; }
.storyboard-frame-loader { display: grid; place-items: center; gap: 9px; color: var(--navy); font-size: 11px; }
.storyboard-frame-loader span { width: 30px; height: 30px; border: 3px solid #b8cad6; border-top-color: var(--blue); border-radius: 50%; animation: storyboard-spin .8s linear infinite; }
@keyframes storyboard-spin { to { transform: rotate(360deg); } }
.storyboard-frame-body { padding: 14px; }
.storyboard-frame-title { display: grid; min-height: 46px; gap: 2px; }
.storyboard-frame-title strong { color: var(--navy); font-size: 13px; line-height: 1.35; }
.storyboard-frame-title span { color: var(--muted); font-size: 10px; line-height: 1.45; }
.storyboard-frame-body > label { display: block; margin-top: 10px; }
.storyboard-frame-body > label > span { display: block; margin-bottom: 5px; color: #4c6576; font-size: 10px; font-weight: 700; }
.storyboard-frame textarea { width: 100%; min-height: 136px; resize: vertical; padding: 10px; border: 1px solid var(--line); color: var(--text); background: #f9fbfc; font-size: 11px; line-height: 1.5; }
.storyboard-frame textarea[readonly] { cursor: default; color: #3d4e5b; }
.storyboard-frame-status { min-height: 32px; padding-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.storyboard-frame.is-failed .storyboard-frame-status { color: var(--danger); }
.storyboard-frame.is-ready .storyboard-frame-status { color: var(--mint); }
.storyboard-frame-actions { display: flex; min-height: 44px; margin-top: 7px; align-items: center; flex-wrap: wrap; gap: 6px; }
.storyboard-frame-actions button { min-height: 42px; padding: 0 10px; border: 1px solid var(--line-strong); color: var(--navy); background: #fff; font-size: 10px; font-weight: 700; }
.storyboard-frame-actions button:hover { border-color: var(--blue); }
.storyboard-frame-actions button:disabled { cursor: not-allowed; opacity: .45; }
.storyboard-frame-use { display: flex; min-height: 42px; margin-right: auto; align-items: center; gap: 7px; color: #4c6576; font-size: 10px; }
.storyboard-frame-use input { width: 17px; height: 17px; accent-color: var(--blue); }
.storyboard-confirm-dialog { width: min(520px, calc(100% - 28px)); }
.storyboard-confirm-shell { padding: 28px; }
.storyboard-confirm-shell h2 { margin: 0 0 9px; color: var(--navy); font-size: 26px; }
.storyboard-confirm-shell > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.storyboard-confirm-cost { display: grid; margin: 20px 0; padding: 16px; gap: 3px; border-left: 4px solid var(--blue); background: #edf4f8; }
.storyboard-confirm-cost span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.storyboard-confirm-cost strong { color: var(--navy); font-size: 22px; }
.storyboard-confirm-cost small { color: #526b7b; font-size: 10px; }
.storyboard-confirm-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; }
.storyboard-confirm-actions > button { width: 100%; }

@media (max-width: 1120px) {
  .app-layout { grid-template-columns: 88px minmax(0, 1fr); }
  .sidebar { padding: 18px 12px; }
  .brand-plate { height: 58px; padding: 6px; }
  .brand-copy, .side-nav a strong, .sidebar-note { display: none; }
  .side-nav a { grid-template-columns: 1fr; padding: 0; place-items: center; }
  .side-nav a span { font-size: 12px; }
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .hero-copy { max-width: 720px; }
  .studio-grid { grid-template-columns: 1fr; }
  .preview { position: static; }
  .history-list { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-layout { display: block; }
  .sidebar { position: static; display: flex; width: 100%; height: auto; min-height: 66px; padding: 9px 14px; align-items: center; justify-content: space-between; }
  .brand { display: flex; align-items: center; gap: 10px; }
  .brand-plate { width: 126px; height: 48px; }
  .side-nav { display: flex; gap: 6px; margin: 0; padding: 0; border: 0; }
  .side-nav a { width: 46px; min-height: 46px; }
  .side-nav a:nth-child(n+3) { display: none; }
  .topbar { position: sticky; top: 0; min-height: 62px; padding: 9px 12px; }
  .page-id span, .route-pill, .balance-pill span { display: none; }
  .page-id strong { font-size: 15px; }
  .balance-pill { min-height: 44px; padding: 0 12px; font-size: 12px; }
  .shell { width: calc(100% - 24px); padding: 28px 0 56px; }
  .hero { margin-bottom: 22px; }
  .hero h1 { font-size: clamp(34px, 10vw, 44px); }
  .prompt-style-head { display: grid; }
  .ai-badge { justify-self: start; }
  .prompt-styles { display: flex; margin-right: -16px; overflow-x: auto; padding: 0 16px 8px 0; scroll-snap-type: x proximity; }
  .prompt-style { min-width: 164px; scroll-snap-align: start; }
  .prompt-product-row { align-items: flex-start; flex-direction: column; }
  .prompt-product-actions { width: 100%; }
  .prompt-product-actions .secondary-button { flex: 1; }
  .prompt-actions { align-items: stretch; flex-direction: column; }
  .prompt-actions > button { width: 100%; justify-content: center; }
  .prompt-chat-dialog { width: 100%; max-width: none; max-height: 100dvh; height: 100dvh; border: 0; }
  .prompt-chat-shell { height: 100dvh; max-height: none; grid-template-rows: auto auto minmax(180px, 1fr) auto auto; }
  .prompt-chat-head { padding: 16px 14px 12px; }
  .prompt-chat-head h2 { font-size: 22px; }
  .prompt-chat-head p:not(.eyebrow) { font-size: 11px; }
  .prompt-chat-context { padding: 9px 14px; }
  .prompt-chat-messages { padding: 14px; }
  .chat-message { max-width: 94%; }
  .prompt-chat-candidate { align-items: stretch; flex-direction: column; padding: 11px 14px; }
  .prompt-chat-form { padding: 12px 14px 14px; }
  .prompt-chat-form-foot { align-items: stretch; flex-direction: column; }
  .prompt-chat-form-foot > div { justify-content: flex-end; }
  .hero-copy { font-size: 15px; }
  .composer { padding: 18px; }
  .workflow-steps { grid-template-columns: repeat(2, 1fr); }
  .workflow-step:nth-child(2) { border-right: 0; }
  .workflow-step:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .kind-switch, .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .kind-button { min-height: 52px; }
  .section-title.compact { align-items: flex-start; }
  .section-title.compact > .hint { max-width: 45%; text-align: right; }
  .submit-row { grid-template-columns: 1fr; }
  .generate-button { width: 100%; }
  .preview-stage, .result-preview { min-height: 380px; }
  .result-preview video, .result-preview img { height: 380px; }
  .quality-checks { grid-template-columns: 1fr; }
  .quality-checks > div { min-height: 58px; border-right: 0; border-bottom: 1px solid var(--line); }
  .quality-checks > div:last-child { border-bottom: 0; }
  .job-steps small { display: none !important; }
  .history { padding: 18px; }
  .history-card { grid-template-columns: 1fr; }
  .history-media img, .history-media video { height: 220px; }
  .product-dialog { width: calc(100% - 20px); max-height: 92vh; }
  .product-dialog-shell { padding: 20px 16px; }
  .product-dialog-head h2 { font-size: 23px; }
  .product-dialog-head p:not(.eyebrow) { font-size: 14px; }
  .product-catalog-list { grid-template-columns: 1fr; }
  .product-card { padding: 12px; }
  .product-photo, .product-photo img { min-height: 132px; height: 132px; }
  .selected-product { grid-template-columns: 54px minmax(0, 1fr) auto; }
  .selected-product img { width: 54px; }
  .storyboard-head { display: grid; }
  .storyboard-progress { justify-self: start; }
  .storyboard-count-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .storyboard-toolbar { align-items: stretch; flex-direction: column; }
  .storyboard-toolbar > button { width: 100%; }
  .storyboard-toolbar > span { flex-basis: auto; }
  .storyboard-frames { grid-template-columns: 1fr; }
  .storyboard-frame-media, .storyboard-frame-media img { min-height: 300px; height: 300px; }
  .storyboard-confirm-shell { padding: 24px 18px; }
  .storyboard-confirm-actions { grid-template-columns: 1fr; }
  .auth-dialog form { padding: 26px 20px; }
}

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