:root {
  --bg: #0b0b0d;
  --panel: #111114;
  --panel-2: #17171b;
  --line: #2a2a30;
  --line-soft: #202025;
  --text: #f3f1ea;
  --muted: #96969f;
  --faint: #686871;
  --accent: #ff5a36;
  --accent-2: #ffb35c;
  --green: #79d29b;
  --left-pane: 38%;
  --radius: 18px;
  --fs-micro: clamp(10px, .58vw, 12px);
  --fs-small: clamp(11px, .64vw, 13px);
  --fs-label: clamp(12px, .68vw, 14px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; overflow: hidden; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.hidden { display: none !important; }

/* Login */
.login-screen { min-height: 100dvh; display: grid; grid-template-columns: minmax(340px, 1.15fr) minmax(420px, .85fr); background: #0c0c0f; }
.login-art { position: relative; overflow: hidden; isolation: isolate; background: radial-gradient(circle at 30% 25%, #492117 0, #171013 34%, #0d0d10 72%); }
.login-art::before { content: ""; position: absolute; inset: 8%; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; transform: rotate(-18deg); }
.login-art::after { content: ""; position: absolute; width: 58%; aspect-ratio: 1; left: 22%; top: 18%; border: 1px solid rgba(255,255,255,.1); transform: rotate(22deg); }
.orb { position: absolute; border-radius: 50%; filter: blur(2px); mix-blend-mode: screen; }
.orb-a { width: 46vw; height: 46vw; max-width: 700px; max-height: 700px; left: -8%; top: 15%; background: radial-gradient(circle at 65% 30%, #ffcf83, #ff5a36 24%, #6b1f54 57%, transparent 70%); opacity: .82; animation: drift 12s ease-in-out infinite alternate; }
.orb-b { width: 25vw; height: 25vw; right: -5%; bottom: -5%; background: radial-gradient(circle, #7865ff, #3c1e6b 45%, transparent 70%); opacity: .58; }
.grain { position: absolute; inset: 0; opacity: .18; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E"); pointer-events: none; }
.vertical-word { position: absolute; left: 30px; bottom: 28px; margin: 0; writing-mode: vertical-rl; transform: rotate(180deg); font-size: var(--fs-small); letter-spacing: .24em; color: rgba(255,255,255,.55); }
.login-card { width: min(460px, 78%); margin: auto; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 16px 16px 16px 3px; font: 800 30px/1 Georgia, serif; box-shadow: 0 18px 45px rgba(255,90,54,.24); }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px 10px 10px 2px; font-size: 18px; box-shadow: none; }
.eyebrow { margin: 0 0 9px; color: var(--faint); font-size: var(--fs-small); font-weight: 750; letter-spacing: .18em; }
.login-card .eyebrow { margin-top: 40px; color: var(--accent-2); }
.login-card h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(40px, 5vw, 69px); font-weight: 400; line-height: .98; letter-spacing: -.045em; }
.login-card .muted { max-width: 390px; margin: 24px 0 36px; color: var(--muted); line-height: 1.6; }
.password-field { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 6px 16px; padding: 0 0 10px; border-bottom: 1px solid #3a3a42; }
.password-field span { grid-column: 1/-1; color: var(--faint); font-size: var(--fs-small); text-transform: uppercase; letter-spacing: .12em; }
.password-field input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 21px; letter-spacing: .1em; }
.password-field button { border: 0; padding: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: var(--fs-label); }
.primary-button { border: 0; background: var(--text); color: #111; border-radius: 12px; cursor: pointer; font-weight: 760; }
.login-button { width: 100%; margin-top: 26px; padding: 17px 20px; display: flex; justify-content: space-between; }
.login-button:hover { background: var(--accent); color: white; }
.form-error { min-height: 20px; color: #ff8974; font-size: 13px; }
@keyframes drift { to { transform: translate(5%, -4%) scale(1.06); } }

/* Shell */
.app-shell { height: 100dvh; display: flex; flex-direction: column; }
.topbar { height: 64px; flex: 0 0 64px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(11,11,13,.92); backdrop-filter: blur(16px); z-index: 8; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand > div:last-child { display: grid; line-height: 1; }
.brand strong { font-size: 14px; letter-spacing: .12em; }
.brand span:not(.brand-mark) { margin-top: 5px; color: var(--faint); font-size: var(--fs-micro); letter-spacing: .19em; }
.session-heading { min-width: 0; max-width: 40vw; display: flex; align-items: center; gap: 9px; color: #c5c3bc; font-size: 13px; }
.session-heading > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(121,210,155,.1); }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.quiet-button, .accent-button, .icon-button, .collapse-button, .logout-button { border: 1px solid var(--line); background: transparent; border-radius: 10px; cursor: pointer; }
.quiet-button { padding: 9px 12px; color: #c0c0c7; font-size: var(--fs-label); }
.quiet-button:hover { border-color: #4c4c55; background: #18181c; }
.accent-button { padding: 9px 13px; border-color: var(--accent); background: var(--accent); color: white; font-size: var(--fs-label); font-weight: 720; }
.accent-button:hover { filter: brightness(1.08); }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); font-size: 19px; }
.icon-button:hover { color: white; border-color: #55555e; }
.close-glyph { position: relative; font-size: 0; }
.close-glyph::before, .close-glyph::after { content: ""; position: absolute; width: 14px; height: 2px; left: 50%; top: 50%; border-radius: 999px; background: currentColor; transform-origin: center; }
.close-glyph::before { transform: translate(-50%, -50%) rotate(45deg); }
.close-glyph::after { transform: translate(-50%, -50%) rotate(-45deg); }
.help-button span { width: 18px; height: 18px; display: inline-grid; place-items: center; margin-right: 4px; border: 1px solid #55555f; border-radius: 50%; color: var(--accent-2); font-size: var(--fs-micro); font-weight: 800; }
.logout-button { min-height: 36px; padding: 8px 12px; display: inline-flex; align-items: center; gap: 7px; border-color: rgba(255,137,116,.42); color: #ffae9d; font-size: var(--fs-label); font-weight: 680; }
.logout-button:hover { border-color: #ff8974; background: rgba(255,90,54,.09); color: white; }
.logout-button span { font-size: 16px; }

.studio { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(310px, var(--left-pane)) 9px minmax(0, 1fr); }
.control-pane, .gallery-pane { min-width: 0; min-height: 0; background: var(--panel); }
.control-pane { border-right: 0; overflow: hidden; }
.control-form { height: 100%; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.pane-scroll { min-height: 0; overflow-y: auto; padding: 32px clamp(20px, 3vw, 44px); scrollbar-width: thin; scrollbar-color: #34343b transparent; }
.divider { position: relative; cursor: col-resize; background: #0b0b0d; border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); touch-action: none; z-index: 4; }
.divider i { position: absolute; width: 3px; height: 42px; left: 2px; top: calc(50% - 21px); border-radius: 5px; background: #3c3c44; }
.divider:hover i, .divider.dragging i { background: var(--accent); }
.section-head, .settings-head, .gallery-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.section-head { margin-bottom: 19px; }
h2, h3 { margin: 0; }
.section-head h2, .gallery-head h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.03em; }
.section-head h2 { font-size: 31px; }
.session-mode { padding: 6px 8px; color: var(--green); background: rgba(121,210,155,.08); border: 1px solid rgba(121,210,155,.16); border-radius: 6px; font-size: var(--fs-micro); letter-spacing: .13em; }

/* Composer */
.composer { border: 1px solid #34343c; background: #0e0e11; border-radius: var(--radius); overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.composer:focus-within, .composer.dragover { border-color: #777680; box-shadow: 0 0 0 3px rgba(255,255,255,.035); }
.composer.dragover { border-color: var(--accent); }
.composer textarea { display: block; width: 100%; min-height: 164px; resize: vertical; border: 0; outline: 0; padding: 18px 19px 12px; background: transparent; color: var(--text); font-size: 14px; line-height: 1.62; }
.composer textarea::placeholder { color: #65656d; }
.composer-tools { min-height: 47px; display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-top: 1px solid var(--line-soft); }
.attach-button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 8px; color: #c8c7c2; cursor: pointer; font-size: var(--fs-small); font-weight: 650; }
.attach-button:hover { background: #202025; }
.attach-button span { color: var(--accent); font-size: 16px; }
.composer-hint { min-width: 0; overflow: hidden; color: var(--faint); font-size: var(--fs-small); white-space: nowrap; text-overflow: ellipsis; }
.char-count { margin-left: auto; color: #66666f; font-size: var(--fs-micro); }
.target-strip, .attachment-strip { display: flex; flex-wrap: wrap; gap: 7px; padding: 11px 12px 0; }
.attachment-strip { padding-bottom: 6px; }
.target-chip, .file-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; border-radius: 8px; font-size: var(--fs-small); }
.target-chip { padding: 6px 8px; background: rgba(255,90,54,.12); color: #ff9b84; border: 1px solid rgba(255,90,54,.3); }
.file-chip { padding: 4px 5px 4px 8px; background: #202025; color: #b7b6bb; border: 1px solid transparent; }
.file-chip.source { border-color: rgba(255,90,54,.46); background: rgba(255,90,54,.1); color: #f1c0b5; }
.target-chip button, .file-chip button { border: 0; padding: 0; background: transparent; color: inherit; cursor: pointer; }
.file-chip .file-name { max-width: 155px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-role-button, .file-role-static { flex: 0 0 auto; padding: 4px 6px !important; border: 1px solid #3a3a42 !important; border-radius: 6px; color: #9d9ca4 !important; font-size: var(--fs-micro); line-height: 1; }
.file-role-button:hover { border-color: #64636d !important; color: white !important; }
.file-chip.source .file-role-button { border-color: rgba(255,90,54,.52) !important; background: rgba(255,90,54,.12); color: #ff9b84 !important; }
.file-remove { width: 20px; height: 20px; border-radius: 5px !important; color: #777780 !important; }
.file-remove:hover { background: rgba(255,255,255,.06) !important; color: white !important; }

/* Settings */
.settings-head { margin: 28px 0 13px; }
.settings-head h3 { font-size: 16px; font-weight: 620; }
.collapse-button { padding: 7px 0; border: 0; color: var(--faint); font-size: var(--fs-small); }
.collapse-button:hover { color: #bbb; }
.settings { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #0e0e11; }
.field { min-width: 0; display: grid; gap: 7px; }
.field > span, .field-label { color: #888891; font-size: var(--fs-micro); font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.field input, .field select { width: 100%; height: 41px; min-width: 0; padding: 0 11px; border: 1px solid #2c2c33; outline: 0; border-radius: 9px; background: #17171b; color: #d8d7d2; font-size: var(--fs-small); }
.field input:focus, .field select:focus { border-color: #666670; }
.mode-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.mode-pixels { grid-template-columns: 1fr 1fr; }
.mode-ratio { grid-template-columns: 1.4fr 1fr; }
.output-size { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 10px 12px; border-radius: 10px; background: linear-gradient(110deg, #1b1818, #17171c); border: 1px solid #2e2929; }
.output-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,90,54,.12); color: var(--accent); font-size: 17px; }
.output-size > div { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 2px 10px; }
.output-size small { grid-column: 1/-1; color: #7c7c85; font-size: var(--fs-micro); letter-spacing: .14em; }
.output-size strong { font-size: 14px; }
.output-size strong.invalid { color: #ff8974; }
.output-size div span { color: var(--muted); font-size: var(--fs-micro); }
.quantity-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 2px; transition: background .2s, box-shadow .2s; border-radius: 9px; }
.quantity-row > div:first-child { display: grid; gap: 5px; }
.quantity-row small { color: var(--muted); font-size: var(--fs-micro); }
.quantity-row.reset-flash { animation: resetFlash 1.2s ease; }
@keyframes resetFlash { 0%,100% { box-shadow: none; } 25% { box-shadow: 0 0 0 6px rgba(255,90,54,.13); background: rgba(255,90,54,.08); } }
.stepper { display: grid; grid-template-columns: 34px 43px 34px; border: 1px solid #303037; border-radius: 9px; overflow: hidden; }
.stepper button, .stepper input { height: 35px; border: 0; background: #17171b; text-align: center; }
.stepper button { color: #9d9da6; cursor: pointer; }
.stepper button:hover { color: white; background: #232328; }
.stepper input { width: 43px; color: white; border-left: 1px solid #303037; border-right: 1px solid #303037; appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }
.generation-actions { position: relative; z-index: 5; display: grid; gap: 8px; margin: 0; padding: 12px clamp(20px, 3vw, 44px) 14px; border-top: 1px solid #29292f; background: rgba(17,17,20,.97); box-shadow: 0 -16px 34px rgba(4,4,6,.38); backdrop-filter: blur(16px); }
.generate-button { width: 100%; min-height: 54px; padding: 0 12px 0 19px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 13px; background: var(--accent); color: white; cursor: pointer; font-weight: 730; font-size: 13px; }
.generate-button .arrow { width: 33px; height: 33px; display: grid; place-items: center; background: rgba(0,0,0,.18); border-radius: 9px; font-size: 17px; transition: transform .2s; }
.generate-button:hover .arrow { transform: translate(2px, -2px); }
.edit-button { width: 100%; min-height: 46px; padding: 0 12px 0 18px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #3c3c44; border-radius: 12px; background: #18181c; color: #c4c3c8; cursor: pointer; font-weight: 650; font-size: var(--fs-small); }
.edit-button:hover { border-color: rgba(255,90,54,.6); color: #fff; background: rgba(255,90,54,.06); }
.edit-arrow { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; background: #242429; color: #df8a77; font-size: 17px; }
.generate-button:disabled, .edit-button:disabled { cursor: not-allowed; filter: grayscale(.6); opacity: .55; }
.job-spinner {
  --spinner-size: 25px;
  --spinner-stroke: 2px;
  width: var(--spinner-size);
  height: var(--spinner-size);
  border: 0;
  border-radius: 50%;
  background: conic-gradient(from 20deg, rgba(255,179,92,.13) 0 68%, #a96f35 82%, #ffb35c 92%, #ffd29a 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--spinner-stroke)), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--spinner-stroke)), #000 0);
  animation: spin .82s linear infinite;
  transform: translateZ(0);
  will-change: transform;
}
@keyframes spin { to { transform: translateZ(0) rotate(1turn); } }
.dialogue { margin-top: 30px; border-top: 1px solid var(--line); }
.dialogue summary { padding: 16px 0; display: flex; justify-content: space-between; cursor: pointer; list-style: none; color: #777780; font-size: var(--fs-micro); letter-spacing: .12em; }
.dialogue summary b { color: #777780; font-weight: 500; letter-spacing: 0; }
.message-list { display: grid; gap: 13px; }
.message { position: relative; padding-left: 16px; border-left: 1px solid #35353c; }
.message::before { content: ""; position: absolute; width: 5px; height: 5px; left: -3px; top: 5px; border-radius: 50%; background: #606069; }
.message.user::before { background: var(--accent); }
.message-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; color: #7a7a83; font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .1em; }
.message p { margin: 0; color: #aaa9ae; font-size: var(--fs-small); line-height: 1.62; white-space: pre-wrap; }
.message-targets { margin-top: 5px; color: #d18b7b; font-size: var(--fs-micro); }

/* Gallery */
.gallery-pane { position: relative; padding: 33px clamp(22px, 3vw, 48px) 60px; overflow-y: auto; background: #0d0d10; scrollbar-width: thin; scrollbar-color: #34343b transparent; }
.gallery-head { margin-bottom: 24px; }
.gallery-head h2 { font-size: 32px; }
.gallery-head h2 span { color: #5d5d65; font: 400 13px/1 sans-serif; vertical-align: super; }
.gallery-legend { display: flex; align-items: center; gap: 13px; color: #777780; font-size: var(--fs-micro); }
.gallery-legend > span { display: flex; align-items: center; gap: 7px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); align-items: start; gap: 14px; }
.image-card { position: relative; overflow: hidden; border: 1px solid #27272d; border-radius: 15px; background: #141417; }
.image-card figure { position: relative; margin: 0; overflow: hidden; background: #18181c; cursor: zoom-in; }
.image-card img { width: 100%; height: auto; display: block; object-fit: cover; transition: transform .35s ease; }
.image-card:hover img { transform: scale(1.025); }
.image-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,90,54,.15); }
.generation-card { border-color: rgba(255,179,92,.3); background: #161513; }
.generation-card .generation-placeholder { min-height: 220px; aspect-ratio: 4 / 3; display: grid; place-content: center; justify-items: center; gap: 14px; cursor: default; background: radial-gradient(circle at 50% 46%, rgba(255,179,92,.09), transparent 42%), #181719; }
.generation-card .job-spinner { --spinner-size: 34px; --spinner-stroke: 3px; }
.generation-done-mark, .generation-queue-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid #61594f; border-radius: 50%; color: #afa69d; font-size: 21px; font-weight: 750; }
.generation-done-mark { border-color: rgba(121,210,155,.62); color: var(--green); background: rgba(121,210,155,.07); }
.generation-queue-mark { padding-bottom: 8px; font-size: 25px; letter-spacing: 2px; }
.generation-stage { color: #a79b90; font-size: var(--fs-small); }
.generation-error { border-color: rgba(255,100,78,.38); background: #181313; }
.generation-error .generation-placeholder { background: radial-gradient(circle at 50% 46%, rgba(255,90,54,.1), transparent 42%), #191516; }
.generation-error-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid #934c3e; border-radius: 50%; color: #ff8b74; font-size: 21px; font-weight: 800; }
.card-index { position: absolute; top: 10px; left: 10px; padding: 5px 7px; background: rgba(7,7,9,.68); backdrop-filter: blur(8px); border-radius: 6px; color: #d0cec8; font-size: var(--fs-micro); letter-spacing: .1em; }
.cloud-sync-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(121,210,155,.13), 0 0 9px rgba(121,210,155,.38); }
.card-body { padding: 11px 12px 12px; }
.card-body p { margin: 0 0 10px; min-height: 38px; display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #b1b0b5; font-size: var(--fs-small); line-height: 1.62; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-foot span { color: #73737c; font-size: var(--fs-micro); }
.card-meta { display: inline-flex; align-items: center; gap: 8px; }
.tag-button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid #34343b; border-radius: 7px; background: transparent; color: #b5b4b9; cursor: pointer; font-size: var(--fs-micro); }
.tag-button:hover, .image-card.selected .tag-button { border-color: rgba(255,90,54,.5); color: #ff967e; background: rgba(255,90,54,.08); }
.job-stop-button, .job-dismiss-button { padding: 6px 9px; border: 1px solid #554038; border-radius: 7px; background: rgba(255,90,54,.06); color: #d6a093; cursor: pointer; font-size: var(--fs-micro); }
.job-stop-button:hover, .job-dismiss-button:hover { border-color: #8a5447; color: #ffd0c5; }
.job-stop-button:disabled { cursor: wait; opacity: .62; }
.expired-card { min-height: 160px; display: grid; place-items: center; padding: 20px; color: #74747c; text-align: center; font-size: var(--fs-small); border: 1px dashed #323238; border-radius: 14px; }
.empty-gallery { min-height: calc(100% - 80px); display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-visual { position: relative; width: 138px; height: 112px; margin-bottom: 28px; }
.empty-visual span { position: absolute; width: 84px; height: 96px; left: 27px; top: 4px; border: 1px solid #36363d; border-radius: 8px; transform: rotate(-10deg); background: #121216; }
.empty-visual span:nth-child(2) { transform: rotate(9deg); background: linear-gradient(145deg, #1c1517, #111116); }
.empty-visual b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); font-size: 28px; font-weight: 300; }
.empty-gallery h3 { font: 400 23px/1.2 Georgia, serif; color: #cbc9c2; }
.empty-gallery p { max-width: 420px; line-height: 1.7; color: #797981; font-size: var(--fs-small); }

/* History drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.48); backdrop-filter: blur(3px); }
.history-drawer { position: fixed; z-index: 20; width: min(430px, 92vw); inset: 0 0 0 auto; padding: 27px; display: flex; flex-direction: column; background: #111114; border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(0,0,0,.35); transform: translateX(102%); transition: transform .26s ease; }
.history-drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h2 { font: 400 29px/1 Georgia, serif; }
.new-drawer-button { width: 100%; margin: 26px 0 18px; padding: 13px; border: 1px solid #3a3a42; border-radius: 10px; background: transparent; color: #c7c6c1; cursor: pointer; }
.new-drawer-button:hover { border-color: var(--accent); color: white; }
.session-list { flex: 1; min-height: 0; overflow: auto; display: grid; align-content: start; gap: 8px; }
.session-item { display: grid; grid-template-columns: 1fr auto; gap: 7px; padding: 13px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; background: #17171b; }
.session-item:hover, .session-item.active { border-color: #3a3a42; background: #1b1b20; }
.session-item.active { border-left-color: var(--accent); }
.session-item strong { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-label); font-weight: 570; }
.session-item span { grid-column: 1; color: #7a7a83; font-size: var(--fs-micro); }
.delete-session { grid-row: 1/3; grid-column: 2; align-self: center; width: 29px; height: 29px; border: 0; background: transparent; color: #62626a; cursor: pointer; border-radius: 7px; }
.delete-session:hover { color: #ff8974; background: rgba(255,90,54,.08); }
.drawer-note { color: #74747c; font-size: var(--fs-micro); line-height: 1.62; }

/* Viewer */
.viewer { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(5,5,7,.95); color: white; overflow: hidden; }
.viewer::backdrop { background: rgba(0,0,0,.8); }
.viewer[open] { display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px minmax(300px, 26vw); }
.viewer figure { position: relative; margin: 0; padding: 38px 20px; display: grid; place-items: center; min-width: 0; min-height: 0; }
.viewer figure img { max-width: 100%; max-height: calc(100dvh - 76px); object-fit: contain; box-shadow: 0 20px 80px #000; opacity: 1; transition: opacity .16s ease; }
.viewer figure img.is-loading { opacity: 0; }
.viewer-loading, .viewer-load-error { position: absolute; inset: 38px 20px; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 14px; color: #aaa9b0; font-size: var(--fs-small); text-align: center; }
.viewer-loading .job-spinner { --spinner-size: 38px; --spinner-stroke: 3px; }
.viewer-load-error { color: #d99a8b; }
.viewer figcaption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.viewer-close { position: absolute; z-index: 2; top: 16px; left: 17px; width: 38px; height: 38px; border: 1px solid #39393f; border-radius: 50%; background: #121216; color: #aaa; cursor: pointer; font-size: 22px; }
.viewer-nav { align-self: center; width: 40px; height: 60px; border: 0; background: transparent; color: #777; cursor: pointer; font-size: 23px; }
.viewer-nav:hover { color: white; }
.viewer-nav:disabled { visibility: hidden; }
.viewer-panel { padding: 42px 28px 30px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; border-left: 1px solid #25252b; background: #0e0e11; }
.viewer-index { color: var(--accent); font-size: var(--fs-micro); letter-spacing: .15em; }
.viewer-panel h3 { margin: 14px 0 16px; font: 400 28px/1.1 Georgia, serif; }
.viewer-panel p { max-height: 38vh; overflow: auto; color: #b1b0b5; font-size: var(--fs-label); line-height: 1.7; white-space: pre-wrap; }
.viewer-panel small { color: #797981; font-size: var(--fs-micro); }
.viewer-actions { display: grid; gap: 9px; }
.viewer-actions button, .viewer-actions a { padding: 13px; border-radius: 10px; text-align: center; text-decoration: none; cursor: pointer; font-size: var(--fs-small); }
.tag-action { border: 1px solid var(--accent); background: var(--accent); color: white; }
.download-action { border: 1px solid #35353c; color: #c0bfc4; }

/* Help */
.help-dialog { width: min(940px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #35353d; border-radius: 20px; background: #111114; color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.58); overflow: hidden; }
.help-dialog::backdrop { background: rgba(3,3,5,.76); backdrop-filter: blur(6px); }
.help-head { min-height: 104px; padding: 24px 28px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: linear-gradient(110deg, #171418, #111114); }
.help-head h2 { font: 400 clamp(25px, 3vw, 37px)/1.1 Georgia, serif; letter-spacing: -.03em; }
.help-close { width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid #3c3c44; border-radius: 50%; background: #18181c; color: #aaa9b0; cursor: pointer; font-size: 22px; }
.help-close:hover { color: white; border-color: #686872; }
.help-scroll { max-height: calc(100dvh - 137px); padding: 25px 28px 30px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #42424a transparent; }
.help-intro > p { margin: 0 0 20px; color: #c1c0c5; font-size: clamp(13px, .74vw, 15px); line-height: 1.7; }
.quick-guide { margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); counter-reset: guide; list-style: none; border: 1px solid #2f2f36; border-radius: 14px; overflow: hidden; }
.quick-guide li { min-width: 0; padding: 15px 13px; display: grid; align-content: start; gap: 6px; border-right: 1px solid #2f2f36; counter-increment: guide; background: #151519; }
.quick-guide li:last-child { border-right: 0; }
.quick-guide li::before { content: "0" counter(guide); color: var(--accent); font-size: var(--fs-micro); font-weight: 800; letter-spacing: .12em; }
.quick-guide b { font-size: var(--fs-small); }
.quick-guide span { color: #85858e; font-size: var(--fs-micro); line-height: 1.55; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-card { position: relative; min-width: 0; padding: 19px 19px 17px; border: 1px solid #2d2d34; border-radius: 14px; background: #16161a; }
.help-card.prompt-help { grid-column: 1/-1; padding-right: min(26vw, 240px); background: radial-gradient(circle at 90% 30%, rgba(255,90,54,.12), transparent 34%), #16161a; }
.help-number { position: absolute; right: 16px; top: 14px; color: #484850; font: 400 24px/1 Georgia, serif; }
.help-card h3 { margin: 0 40px 12px 0; color: #dfddd7; font: 400 19px/1.2 Georgia, serif; }
.help-card p { margin: 8px 0 0; color: #aaa9b0; font-size: var(--fs-small); line-height: 1.68; }
.help-card p b { color: #c9c7c1; }
.help-card blockquote { margin: 14px 0 10px; padding: 12px 14px; border-left: 2px solid var(--accent); background: #101013; color: #c4c3c8; font-size: var(--fs-small); line-height: 1.62; }
.help-footer { margin-top: 16px; padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 12px; background: rgba(255,90,54,.07); border: 1px solid rgba(255,90,54,.17); }
.help-footer p { margin: 0; max-width: 580px; color: #b4a29f; font-size: var(--fs-small); line-height: 1.58; }
.help-footer button { flex: 0 0 auto; padding: 11px 14px; border: 0; border-radius: 9px; background: var(--accent); color: white; cursor: pointer; font-size: var(--fs-small); font-weight: 750; }

.toast-region { position: fixed; z-index: 50; right: 18px; bottom: 18px; display: grid; gap: 9px; pointer-events: none; }
.toast { max-width: 390px; padding: 12px 14px; border: 1px solid #3b3b43; border-left: 3px solid var(--accent); border-radius: 10px; background: #18181d; box-shadow: 0 16px 50px rgba(0,0,0,.38); color: #d2d1cc; font-size: var(--fs-small); line-height: 1.58; animation: toastIn .25s ease; }
.toast.success { border-left-color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1000px) {
  .studio { grid-template-columns: minmax(300px, var(--left-pane)) 7px minmax(0, 1fr); }
  .pane-scroll { padding-inline: 22px; }
  .generation-actions { padding-inline: 22px; }
  .gallery-pane { padding-inline: 24px; }
  .top-actions .history-button, .top-actions .help-button { width: 36px; height: 36px; padding: 0; font-size: 0; }
  .top-actions .quiet-button span { font-size: 15px; }
  .top-actions .help-button span { margin: 0; font-size: var(--fs-micro); }
  .quick-guide { grid-template-columns: repeat(3, 1fr); }
  .quick-guide li { border-bottom: 1px solid #2f2f36; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .login-screen { grid-template-columns: 1fr; }
  .login-art { position: absolute; inset: 0; opacity: .43; }
  .login-card { position: relative; z-index: 2; width: min(430px, calc(100% - 44px)); padding: 50px 0; }
  .topbar { position: sticky; top: 0; height: 58px; grid-template-columns: auto 1fr auto; gap: 10px; padding: 0 10px; }
  .brand > div:last-child { display: none; }
  .session-heading { max-width: none; justify-self: start; font-size: var(--fs-small); }
  .top-actions { gap: 5px; }
  .session-heading { display: none; }
  .topbar { grid-template-columns: auto 1fr; }
  .top-actions { justify-self: end; }
  .logout-button { padding-inline: 9px; font-size: var(--fs-small); }
  .accent-button { width: 36px; height: 36px; padding: 0; font-size: 0; }
  .accent-button span { font-size: 18px; }
  .app-shell { height: auto; min-height: 100dvh; }
  .studio { display: block; }
  .divider { display: none; }
  .control-pane, .gallery-pane { height: auto; min-height: 0; overflow: visible; }
  .control-form { height: auto; display: block; }
  .pane-scroll { height: auto; overflow: visible; padding: 27px 17px 20px; }
  .generation-actions { position: sticky; bottom: 0; padding: 10px 17px calc(10px + env(safe-area-inset-bottom)); }
  .gallery-pane { padding: 28px 14px 70px; border-top: 1px solid var(--line); }
  .mode-fields { grid-template-columns: 1fr 1fr; }
  .mode-fields .field:last-child:nth-child(3) { grid-column: 1/-1; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .card-body { padding: 9px; }
  .gallery-head { padding-inline: 3px; }
  .gallery-legend > span { display: none; }
  .empty-gallery { min-height: 430px; }
  .viewer[open] { display: grid; grid-template-columns: 38px 1fr 38px; grid-template-rows: minmax(0, 1fr) auto; }
  .viewer figure { padding: 60px 4px 10px; }
  .viewer figure img { max-height: calc(100dvh - 290px); }
  .viewer-loading, .viewer-load-error { inset: 60px 4px 10px; }
  .viewer-panel { grid-column: 1/-1; padding: 19px; border-left: 0; border-top: 1px solid #29292f; }
  .viewer-panel p { max-height: 80px; }
  .viewer-actions { grid-template-columns: 1fr 1fr; }
  .help-dialog { width: 100vw; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .help-head { min-height: 93px; padding: 20px 17px 17px; }
  .help-head h2 { max-width: 290px; font-size: 25px; }
  .help-scroll { max-height: calc(100dvh - 93px); padding: 18px 15px 24px; }
  .quick-guide { grid-template-columns: 1fr; }
  .quick-guide li { border-right: 0; }
  .help-grid { grid-template-columns: 1fr; }
  .help-card.prompt-help { grid-column: auto; padding-right: 19px; }
  .help-footer { align-items: stretch; flex-direction: column; }
}

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