:root {
  --ink: #171815;
  --muted: #6e7068;
  --paper: #f3f1ea;
  --panel: #fbfaf6;
  --line: #d9d6cc;
  --acid: #d9ff43;
  --accent: #5965f2;
  --danger: #b23b2c;
  --field: #fff;
  --placeholder-a: #ece9e0;
  --placeholder-b: #f5f3ed;
  --button-bg: #171815;
  --button-text: #fff;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf0e8;
  --muted: #a9ada2;
  --paper: #11130f;
  --panel: #181b16;
  --line: #34382f;
  --acid: #c8ef3f;
  --accent: #8e98ff;
  --danger: #ff8878;
  --field: #22261f;
  --placeholder-a: #20241e;
  --placeholder-b: #272b24;
  --button-bg: #edf0e8;
  --button-text: #171815;
}
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font-family: "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }

.topbar {
  height: 72px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(22px, 4vw, 64px); border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.wordmark { font: 700 20px/1 "Segoe UI"; letter-spacing: -.06em; text-decoration: none; }
.wordmark span { color: var(--accent); }
.top-actions, .submit-row, .section-heading { display: flex; align-items: center; }
.top-actions { gap: 20px; }
.status { font: 500 11px Consolas, monospace; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.status i { width: 7px; height: 7px; background: #63a648; border-radius: 50%; box-shadow: 0 0 0 4px #63a64818; }
.user-email { font-size: 12px; color: var(--muted); }
.quiet-button { border: 0; border-bottom: 1px solid var(--ink); padding: 5px 0; background: none; font-size: 12px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--field); color: var(--ink); border-radius: 50%; }

.workspace { max-width: 1500px; margin: auto; display: grid; grid-template-columns: minmax(420px, .82fr) 1.5fr; min-height: calc(100vh - 72px); }
.composer { padding: clamp(46px, 6vw, 96px) clamp(28px, 5vw, 82px); background: var(--panel); border-right: 1px solid var(--line); }
.intro { margin-bottom: 45px; max-width: 560px; }
.eyebrow { margin: 0 0 14px; font: 500 10px Consolas, monospace; letter-spacing: .16em; color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(38px, 4vw, 62px); line-height: .98; letter-spacing: -.06em; margin-bottom: 22px; }
.intro > p:last-child, .lede { color: var(--muted); line-height: 1.7; max-width: 520px; }
.prompt-label, label { font: 500 11px Consolas, monospace; text-transform: uppercase; letter-spacing: .08em; }
.prompt-wrap { position: relative; margin-top: 10px; }
textarea, input, select {
  width: 100%; border: 1px solid var(--line); background: var(--field); color: var(--ink);
  border-radius: 0; outline: none;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #5965f21a; }
textarea { resize: vertical; padding: 18px; line-height: 1.55; text-transform: none; letter-spacing: 0; font-family: "Segoe UI", sans-serif; }
.key-hint { position: absolute; right: 12px; bottom: 10px; color: #999b94; font: 10px Consolas, monospace; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; margin-top: 20px; }
.settings-grid .wide-field { grid-column: 1 / -1; }
.settings-grid label { color: var(--muted); }
input, select { height: 45px; padding: 0 12px; margin-top: 7px; font: 12px Consolas, monospace; text-transform: none; }
details { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
summary { cursor: pointer; color: var(--muted); font: 500 11px Consolas, monospace; text-transform: uppercase; letter-spacing: .08em; }
.full-label { display: block; margin-top: 16px; color: var(--muted); }
.full-label textarea { margin-top: 7px; }
.enhancement-panel { margin-top: 24px; padding: 18px; border: 1px solid var(--line); background: color-mix(in srgb, var(--field) 65%, transparent); }
.enhancement-heading, .step-copy { display: flex; align-items: center; gap: 12px; }
.enhancement-heading { justify-content: space-between; }
.enhancement-heading > div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 3px 10px; }
.enhancement-heading small { grid-column: 2; color: var(--muted); font: 11px/1.4 "Segoe UI", sans-serif; }
.step-number { width: 25px; height: 25px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font: 600 11px Consolas, monospace; }
.secondary-button { min-height: 40px; padding: 0 15px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font-size: 12px; white-space: nowrap; }
.secondary-button:hover { border-color: var(--accent); }
.secondary-button:disabled { opacity: .5; cursor: wait; }
#enhanced-prompt-wrap { padding-top: 16px; border-top: 1px solid var(--line); }
#enhanced-prompt-wrap[hidden] { display: none; }
.submit-row { justify-content: space-between; gap: 20px; margin-top: 25px; }
.generation-step { padding-top: 4px; }
.step-copy > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.step-copy small { color: var(--muted); font: 11px "Segoe UI", sans-serif; }
.switch { display: flex; align-items: center; gap: 9px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 32px; height: 18px; border: 1px solid var(--line); background: var(--field); border-radius: 20px; position: relative; }
.switch span::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); top: 2px; left: 3px; transition: .2s; }
.switch input:checked + span { background: var(--acid); border-color: var(--ink); }
.switch input:checked + span::after { transform: translateX(13px); background: var(--ink); }
.primary-button { min-height: 48px; padding: 0 22px; border: 1px solid var(--button-bg); background: var(--button-bg); color: var(--button-text); font-weight: 600; }
.generate-button { min-width: 160px; display: flex; justify-content: space-between; align-items: center; }
.primary-button:hover { background: var(--accent); border-color: var(--accent); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.form-message { min-height: 20px; color: var(--danger); font-size: 12px; margin: 10px 0 0; }

.gallery-section { padding: clamp(46px, 5vw, 80px); }
.section-heading { justify-content: space-between; margin-bottom: 32px; }
.gallery-actions, .card-actions, .dialog-actions { display: flex; align-items: center; gap: 14px; }
.gallery-actions { justify-content: flex-end; flex-wrap: wrap; }
.folder-label { color: var(--muted); font: 10px Consolas, monospace; }
.section-heading h2 { font-size: 29px; letter-spacing: -.04em; margin-bottom: 0; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.gallery-card { position: relative; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.image-button { border: 0; padding: 0; width: 100%; display: block; background: #e8e5dd; aspect-ratio: 1; overflow: hidden; }
.image-button img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.image-button:hover img { transform: scale(1.025); }
.job-placeholder { aspect-ratio: 1; display: grid; place-items: center; background: repeating-linear-gradient(135deg, var(--placeholder-a) 0, var(--placeholder-a) 10px, var(--placeholder-b) 10px, var(--placeholder-b) 20px); }
.job-placeholder.failed { color: var(--danger); padding: 25px; text-align: center; }
.spinner { width: 34px; height: 34px; border: 2px solid #cbc8be; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-meta { padding: 14px 16px 16px; }
.card-meta p { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin: 0 0 8px; font-size: 13px; }
.card-meta small { color: var(--muted); font: 10px Consolas, monospace; text-transform: uppercase; }
.card-actions { justify-content: space-between; padding: 0 16px 16px; }
.danger-button { border: 0; border-bottom: 1px solid var(--danger); padding: 5px 0; color: var(--danger); background: none; font-size: 12px; cursor: pointer; }
.empty-state { min-height: 420px; border: 1px dashed #c8c5bb; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state[hidden] { display: none; }
.empty-mark { color: var(--accent); font-size: 36px; margin-bottom: 14px; }
.empty-state h3 { color: var(--ink); margin-bottom: 7px; }

.auth-page { min-height: 100vh; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.25fr .75fr; }
.brand-panel { background: var(--ink); color: white; padding: clamp(35px, 6vw, 90px); display: flex; flex-direction: column; justify-content: space-between; }
.brand-panel .wordmark span { color: var(--acid); }
.brand-panel h1 { max-width: 850px; font-size: clamp(52px, 7vw, 100px); }
.brand-panel .lede { font-size: 17px; }
.privacy-note { color: #a4a69f; font: 11px Consolas, monospace; }
.auth-card { display: grid; place-items: center; padding: 40px; background: var(--panel); }
.auth-inner { width: min(100%, 390px); }
.auth-inner h2 { font-size: 30px; letter-spacing: -.04em; margin-bottom: 30px; }
.auth-inner label { display: block; margin: 16px 0; color: var(--muted); }
.auth-inner input { margin-top: 8px; height: 50px; }
.auth-inner .primary-button { width: 100%; margin-top: 12px; }
.auth-switch { margin-top: 22px; color: var(--muted); font-size: 13px; text-align: center; }
.auth-switch a { color: var(--ink); }
.error-banner { border-left: 3px solid var(--danger); background: #b23b2c12; color: var(--danger); padding: 12px 14px; font-size: 13px; }

dialog { width: min(94vw, 1100px); border: 0; padding: 0; background: var(--panel); box-shadow: 0 20px 80px #0005; }
dialog::backdrop { background: #111b; }
dialog img { width: 100%; max-height: 80vh; object-fit: contain; display: block; background: #111; }
.dialog-close { position: absolute; right: 10px; top: 10px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #fff; font-size: 24px; }
.dialog-meta { padding: 16px 20px; font-size: 13px; }
.dialog-actions { justify-content: flex-end; padding: 0 20px 18px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: 48vh; }
  .privacy-note { margin-top: 50px; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 18px; }
  .status, .user-email { display: none; }
  .section-heading { align-items: flex-start; gap: 20px; }
  .gallery-actions { justify-content: flex-start; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .enhancement-heading { align-items: stretch; flex-direction: column; }
  .gallery { grid-template-columns: 1fr; }
  .gallery-section, .composer { padding: 38px 20px; }
  .auth-card { padding: 42px 20px; }
  .brand-panel { padding: 30px 22px; }
}
