:root {
  --bg: #f8f8fc;
  --bg-2: #f1f4fb;
  --text: #17171c;
  --text-2: #61616c;
  --text-3: #8c8c98;
  --line: rgba(24, 24, 30, .09);
  --card: rgba(255, 255, 255, .70);
  --card-strong: rgba(255, 255, 255, .86);
  --shadow: 0 20px 55px rgba(65, 63, 86, .10);
  --shadow-soft: 0 8px 26px rgba(65, 63, 86, .07);
  --accent: #5f67f5;
  --accent-2: #8c6cf3;
  --accent-soft: rgba(95, 103, 245, .10);
  --success: #2da66e;
  --danger: #de5d69;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --sidebar-w: 92px;
  --blur: blur(24px) saturate(130%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #101116;
    --bg-2: #151720;
    --text: #f2f3f7;
    --text-2: #b2b4c1;
    --text-3: #777a88;
    --line: rgba(255,255,255,.08);
    --card: rgba(29, 31, 41, .66);
    --card-strong: rgba(27, 29, 38, .88);
    --shadow: 0 22px 60px rgba(0,0,0,.27);
    --shadow-soft: 0 8px 28px rgba(0,0,0,.20);
    --accent-soft: rgba(126, 132, 255, .14);
  }
  html[data-theme="system"] .ambient { opacity: .30; }
  html[data-theme="system"] .brand-mark { background: linear-gradient(135deg, #fafafe, #cdd0dd); color: #121319; }
  html[data-theme="system"] .generate-btn { background: linear-gradient(135deg, #f3f4f8, #d5d7df); color: #17181d; }
  html[data-theme="system"] .generate-btn .gen-icon, html[data-theme="system"] .generate-btn kbd { background: rgba(0,0,0,.08); color: #2e3037; }
}
html[data-theme="dark"] {
  --bg: #101116;
  --bg-2: #151720;
  --text: #f2f3f7;
  --text-2: #b2b4c1;
  --text-3: #777a88;
  --line: rgba(255,255,255,.08);
  --card: rgba(29, 31, 41, .66);
  --card-strong: rgba(27, 29, 38, .88);
  --shadow: 0 22px 60px rgba(0,0,0,.27);
  --shadow-soft: 0 8px 28px rgba(0,0,0,.20);
  --accent-soft: rgba(126, 132, 255, .14);
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); min-height: 100%; }
body { margin: 0; min-height: 100vh; background: linear-gradient(145deg, var(--bg), var(--bg-2)); overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.ambient { position: fixed; pointer-events: none; filter: blur(75px); opacity: .58; z-index: 0; border-radius: 50%; }
.ambient-a { width: 45vw; height: 42vw; left: -12vw; top: -10vw; background: radial-gradient(circle at 55% 55%, rgba(255, 179, 220, .86), rgba(236, 198, 255, .42) 44%, transparent 72%); }
.ambient-b { width: 46vw; height: 46vw; right: -12vw; top: -10vw; background: radial-gradient(circle at 45% 55%, rgba(151, 201, 255, .78), rgba(177, 205, 255, .20) 53%, transparent 74%); }
.ambient-c { width: 48vw; height: 34vw; right: 7vw; bottom: -13vw; background: radial-gradient(circle at 50% 40%, rgba(255, 228, 152, .72), rgba(255, 192, 191, .32) 49%, transparent 72%); }
html[data-theme="dark"] .ambient { opacity: .30; }
.noise { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .025; 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='.95' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E"); }

.app-shell { position: relative; z-index: 2; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); width: min(1500px, calc(100vw - 34px)); min-height: calc(100vh - 34px); margin: 17px auto; gap: 22px; }
.glass, .glass-strong { border: 1px solid var(--line); box-shadow: var(--shadow-soft); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.glass { background: var(--card); }
.glass-strong { background: var(--card-strong); box-shadow: var(--shadow); }

.sidebar { position: sticky; top: 17px; align-self: start; height: calc(100vh - 34px); border-radius: 28px; padding: 16px 11px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; z-index: 5; }
.brand-mark { width: 52px; height: 52px; border: 0; border-radius: 18px; background: linear-gradient(135deg, #17181e, #3a3d4b); color: #fff; font-weight: 800; font-size: 22px; cursor: pointer; box-shadow: 0 10px 26px rgba(20,22,30,.18); }
html[data-theme="dark"] .brand-mark { background: linear-gradient(135deg, #fafafe, #cdd0dd); color: #121319; }
.side-nav, .side-bottom { display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center; }
.nav-btn { width: 68px; height: 64px; border: 0; border-radius: 19px; background: transparent; color: var(--text-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; transition: .25s ease; }
.nav-btn span { font-size: 11px; font-weight: 650; letter-spacing: .04em; }
.nav-btn:hover { color: var(--text); background: rgba(127,127,140,.08); }
.nav-btn.active { color: var(--text); background: var(--card-strong); box-shadow: 0 8px 20px rgba(45,45,60,.07); }
.side-icon { width: 44px !important; height: 44px !important; }

.main { min-width: 0; padding: 8px 4px 60px; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 17px; }
.eyebrow { display: flex; gap: 8px; align-items: center; color: var(--text-3); text-transform: uppercase; letter-spacing: .12em; font-size: 10px; font-weight: 750; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #50c790; box-shadow: 0 0 0 5px rgba(80,199,144,.10); }
.sep { opacity: .45; }
.topbar h1 { margin: 7px 0 0; font-size: clamp(28px, 3vw, 43px); letter-spacing: -.05em; font-weight: 760; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.pill-btn, .ghost-btn, .text-btn, .icon-btn, .avatar-btn, .primary-small { border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.pill-btn:hover, .ghost-btn:hover, .icon-btn:hover, .avatar-btn:hover { transform: translateY(-1px); background: var(--card-strong); box-shadow: var(--shadow-soft); }
.pill-btn { min-height: 42px; padding: 0 14px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-size: 13px; font-weight: 650; }
.pill-btn svg { width: 17px; height: 17px; }
.icon-btn { width: 38px; height: 38px; padding: 0; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.avatar-btn { width: 43px; height: 43px; border-radius: 14px; padding: 2px; background: linear-gradient(145deg, rgba(255,255,255,.92), rgba(214,219,255,.82)); }
.avatar-btn span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 11px; background: linear-gradient(135deg, #7e84ff, #b47df2 58%, #ff9da8); color: white; font-size: 11px; font-weight: 800; letter-spacing: .06em; }

.view { display: none; animation: viewIn .35s ease both; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr); gap: 18px; }
.composer-card, .preview-card { border-radius: var(--radius-xl); min-height: 560px; }
.composer-card { padding: clamp(22px, 3vw, 34px); display: flex; flex-direction: column; }
.composer-head, .preview-head, .section-head, .dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.micro-label { display: inline-block; color: var(--text-3); font-size: 10px; letter-spacing: .18em; font-weight: 800; }
.composer-head h2, .section-head h2, .settings-card h2 { font-size: 21px; margin: 7px 0 0; letter-spacing: -.035em; }
.reference-entry { height: 40px; padding: 0 10px 0 12px; border-radius: 13px; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; }
.reference-entry svg { width: 17px; }
.soon { padding: 3px 6px; border-radius: 7px; font-size: 9px; background: var(--accent-soft); color: var(--accent); }
.reference-note { display: grid; grid-template-columns: 34px 1fr; gap: 12px; margin-top: 20px; padding: 12px 13px; border-radius: 15px; background: var(--accent-soft); color: var(--text-2); animation: noteIn .25s ease both; }
@keyframes noteIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.note-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.45); color: var(--accent); }
.reference-note strong { color: var(--text); font-size: 12px; }
.reference-note p { margin: 3px 0 0; font-size: 11px; line-height: 1.55; }
#promptInput { width: 100%; flex: 1; min-height: 255px; margin-top: 24px; resize: none; border: 0; outline: none; background: transparent; color: var(--text); font-size: clamp(19px, 2vw, 27px); font-weight: 520; line-height: 1.55; letter-spacing: -.025em; }
#promptInput::placeholder { color: var(--text-3); opacity: .64; }
.prompt-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 32px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.char-count { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: 11px; }
.text-btn { border: 0; background: transparent; color: var(--text-2); padding: 5px 8px; font-size: 12px; border-radius: 8px; }
.text-btn:hover { color: var(--text); background: rgba(127,127,140,.08); }
.control-row { display: flex; align-items: stretch; gap: 10px; margin-top: 17px; }
.control-box { min-width: 150px; height: 55px; border: 1px solid var(--line); border-radius: 15px; padding: 7px 11px 6px; background: rgba(127,127,140,.045); display: flex; flex-direction: column; justify-content: center; }
.control-box.compact { min-width: 84px; }
.control-box > span { color: var(--text-3); font-size: 9px; font-weight: 750; letter-spacing: .07em; }
.control-box select { border: 0; outline: none; color: var(--text); background: transparent; font-size: 12px; font-weight: 650; margin-top: 3px; width: 100%; }
.ratio-control { padding-right: 8px; }
.ratio-trigger { width: 100%; min-height: 27px; margin-top: 1px; padding: 0; border: 0; outline: none; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; text-align: left; }
.ratio-trigger strong { font-size: 13px; font-weight: 720; letter-spacing: -.01em; }
.ratio-trigger svg { width: 16px; height: 16px; color: var(--text-3); transition: transform .18s ease; }
.ratio-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.generate-btn { margin-left: auto; min-width: 174px; border: 0; border-radius: 16px; background: linear-gradient(135deg, #25262d, #121319); color: white; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; cursor: pointer; box-shadow: 0 12px 28px rgba(24,25,32,.18); font-size: 13px; font-weight: 700; transition: .22s ease; }
.generate-btn:hover { transform: translateY(-1px) scale(1.005); box-shadow: 0 16px 34px rgba(24,25,32,.23); }
.generate-btn:disabled { opacity: .58; cursor: wait; transform: none; }
.generate-btn .gen-icon { width: 25px; height: 25px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.10); }
.generate-btn svg { width: 15px; }
.generate-btn kbd { padding: 3px 5px; border-radius: 6px; background: rgba(255,255,255,.10); font-size: 9px; font-weight: 600; color: rgba(255,255,255,.72); }
html[data-theme="dark"] .generate-btn { background: linear-gradient(135deg, #f3f4f8, #d5d7df); color: #17181d; }
html[data-theme="dark"] .generate-btn .gen-icon, html[data-theme="dark"] .generate-btn kbd { background: rgba(0,0,0,.08); color: #2e3037; }

.preview-card { padding: 22px; display: flex; flex-direction: column; overflow: hidden; }
.preview-head { align-items: center; padding: 3px 2px 16px; }
.preview-head h3 { margin: 5px 0 0; font-size: 17px; }
.preview-stage { position: relative; flex: 1; min-height: 450px; border-radius: 22px; overflow: hidden; background: linear-gradient(145deg, rgba(167,188,255,.20), rgba(255,192,215,.12) 45%, rgba(255,223,155,.18)); border: 1px solid rgba(255,255,255,.30); display: grid; place-items: center; }
.empty-state, .loading-state { width: min(410px, 88%); text-align: center; padding: 34px 20px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.empty-visual { position: relative; width: 150px; height: 124px; filter: drop-shadow(0 20px 28px rgba(83, 88, 130, .12)); }
.empty-frame { position: absolute; width: 108px; height: 82px; border-radius: 23px; border: 1px solid rgba(255,255,255,.48); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.empty-frame-back { left: 12px; top: 19px; transform: rotate(-9deg); background: linear-gradient(145deg, rgba(178,199,255,.64), rgba(225,199,255,.38)); box-shadow: inset 0 1px 0 rgba(255,255,255,.46); }
.empty-frame-front { right: 10px; top: 18px; transform: rotate(7deg); display: grid; place-items: center; background: linear-gradient(145deg, rgba(255,255,255,.82), rgba(255,209,225,.48) 55%, rgba(255,232,171,.42)); box-shadow: inset 0 1px 0 rgba(255,255,255,.68), 0 14px 28px rgba(70,72,100,.10); color: rgba(55,58,80,.60); }
.empty-frame-front svg { width: 30px; height: 30px; stroke-width: 1.4; }
.empty-spark { position: absolute; color: var(--accent); line-height: 1; text-shadow: 0 8px 18px rgba(95,103,245,.22); }
.spark-a { right: 1px; top: 6px; font-size: 17px; transform: rotate(16deg); }
.spark-b { left: 5px; bottom: 5px; font-size: 10px; opacity: .62; }
.empty-copy { max-width: 330px; }
.empty-kicker { display: inline-flex; align-items: center; justify-content: center; min-height: 23px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.25); color: var(--text-3); font-size: 8px; font-weight: 800; letter-spacing: .18em; }
.empty-state h3, .loading-state h3 { margin: 8px 0 0; font-size: 18px; letter-spacing: -.025em; }
.empty-state p, .loading-state p { margin: 8px auto 0; color: var(--text-2); font-size: 12px; line-height: 1.65; }
.loader-ring { width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid rgba(110,116,245,.13); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-meta { display: flex; justify-content: center; gap: 14px; margin-top: 15px; color: var(--text-3); font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.result-grid { width: 100%; height: 100%; padding: 8px; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-content: center; }
.result-grid.single { grid-template-columns: 1fr; }
.result-item { position: relative; min-height: 180px; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,.05); }
.result-item img { width: 100%; height: 100%; max-height: 440px; object-fit: contain; display: block; background: repeating-conic-gradient(rgba(127,127,140,.06) 0 25%, transparent 0 50%) 50% / 20px 20px; }
.result-overlay { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; opacity: 0; transition: .18s ease; }
.result-item:hover .result-overlay { opacity: 1; }
.result-overlay button { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.32); border-radius: 11px; background: rgba(19,20,26,.66); backdrop-filter: blur(12px); color: white; cursor: pointer; display: grid; place-items: center; }

.history-panel { border-radius: var(--radius-xl); padding: 18px; min-height: 620px; }
.history-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 8px 4px 18px; }
.history-intro h2 { margin: 6px 0 0; font-size: 21px; letter-spacing: -.035em; }
.history-intro p { max-width: 540px; margin: 0; color: var(--text-3); font-size: 10px; line-height: 1.65; text-align: right; }
.history-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.search-box { height: 44px; min-width: 320px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(127,127,140,.045); }
.search-box svg { width: 17px; color: var(--text-3); }
.search-box input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font-size: 12px; }
.toolbar-actions { display: flex; gap: 8px; }
.file-label { cursor: pointer; }
.danger-soft { color: var(--danger); }
.history-list { display: flex; flex-direction: column; gap: 9px; padding-top: 15px; }
.history-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px; border: 1px solid var(--line); background: rgba(127,127,140,.025); border-radius: 17px; }
.history-thumb { width: 74px; height: 74px; border-radius: 13px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg, rgba(181,197,255,.35), rgba(255,205,226,.24)); color: var(--text-3); }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-main { min-width: 0; }
.history-main p { margin: 0; font-size: 13px; font-weight: 670; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { padding: 4px 7px; border-radius: 8px; background: rgba(127,127,140,.07); color: var(--text-2); font-size: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge.success { color: var(--success); background: rgba(45,166,110,.09); }
.badge.failed { color: var(--danger); background: rgba(222,93,105,.09); }
.badge.pending { color: var(--accent); background: var(--accent-soft); }
.history-actions { display: flex; gap: 6px; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr); gap: 18px; align-items: start; }
.settings-card { border-radius: var(--radius-xl); padding: 26px; }
.settings-grid .settings-card:first-child { grid-row: span 2; }
.settings-card-head { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.settings-icon { width: 43px; height: 43px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.field-label { margin-top: 18px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; }
.field-hint { color: var(--text-3); font-size: 9px; font-weight: 600; }
.api-key-field { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 15px; padding: 6px 7px 6px 12px; background: rgba(127,127,140,.035); }
.api-key-field input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.endpoint-box { min-height: 52px; border: 1px solid var(--line); border-radius: 15px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(127,127,140,.035); }
.endpoint-box code { font-size: 11px; color: var(--text-2); overflow-wrap: anywhere; }
.lock { color: var(--text-3); }
.helper { color: var(--text-2); font-size: 11px; line-height: 1.65; }
.helper.large { font-size: 12px; }
.settings-actions { display: flex; align-items: center; gap: 9px; margin-top: 24px; }
.primary-small { min-height: 42px; border: 0; padding: 0 17px; border-radius: 13px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 750; }
.link-btn { color: var(--text-2); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 4px; background: rgba(127,127,140,.065); border: 1px solid var(--line); border-radius: 15px; margin-top: 11px; }
.segmented button { min-height: 38px; border: 0; border-radius: 11px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 11px; font-weight: 650; }
.segmented button.active { background: var(--card-strong); color: var(--text); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.disabled-dropzone { height: 150px; border: 1px dashed var(--line); border-radius: 19px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); background: rgba(127,127,140,.025); }
.disabled-dropzone svg { width: 27px; height: 27px; }
.disabled-dropzone span { font-size: 11px; }

.ratio-picker-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 22px; background: rgba(11,12,17,.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); opacity: 0; transition: opacity .16s ease; }
.ratio-picker-backdrop.open { opacity: 1; }
.ratio-picker-panel { width: min(520px, calc(100vw - 32px)); border-radius: 26px; padding: 21px; transform: translateY(8px) scale(.985); opacity: .92; transition: transform .18s ease, opacity .18s ease; }
.ratio-picker-backdrop.open .ratio-picker-panel { transform: none; opacity: 1; }
.ratio-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 1px 1px 16px; }
.ratio-picker-head h2 { margin: 5px 0 0; font-size: 19px; letter-spacing: -.035em; }
.ratio-picker-head .icon-btn { font-size: 20px; }
.ratio-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.ratio-option { min-height: 118px; border: 1px solid var(--line); border-radius: 17px; background: rgba(127,127,140,.035); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.ratio-option:hover { transform: translateY(-2px); background: rgba(127,127,140,.07); }
.ratio-option.selected { border-color: rgba(95,103,245,.34); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(95,103,245,.08); }
.ratio-option strong { font-size: 12px; font-weight: 760; letter-spacing: .015em; }
.ratio-shape { height: 45px; max-width: 68px; aspect-ratio: var(--ratio); border: 1.5px solid currentColor; border-radius: 7px; color: var(--text-3); background: linear-gradient(145deg, rgba(171,190,255,.22), rgba(255,197,220,.16)); box-shadow: inset 0 1px 0 rgba(255,255,255,.2); }
.ratio-option.selected .ratio-shape { color: var(--accent); }

.toast-stack { position: fixed; z-index: 50; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { max-width: min(420px, calc(100vw - 44px)); padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--card-strong); box-shadow: var(--shadow); backdrop-filter: var(--blur); color: var(--text); font-size: 11px; line-height: 1.5; animation: toastIn .25s ease both; }
.toast.error { border-color: rgba(222,93,105,.25); }
.toast.success { border-color: rgba(45,166,110,.25); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; }
  .preview-card { min-height: 540px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .settings-card:first-child { grid-row: auto; }
}

@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  body { padding-bottom: 10px; }
  .app-shell { display: block; width: calc(100vw - 20px); min-height: 100vh; margin: calc(84px + env(safe-area-inset-top, 0px)) auto 10px; }
  .sidebar { position: fixed; z-index: 40; left: 10px; right: 10px; top: max(10px, env(safe-area-inset-top, 0px)); bottom: auto; width: auto; height: 64px; border-radius: 21px; padding: 6px 8px; flex-direction: row; box-shadow: var(--shadow); }
  .brand-mark, .side-bottom { display: none; }
  .side-nav { width: 100%; flex-direction: row; justify-content: space-around; gap: 4px; }
  .nav-btn { flex: 1; height: 50px; max-width: 120px; border-radius: 14px; flex-direction: row; gap: 7px; }
  .nav-btn span { font-size: 10px; }
  .topbar { min-height: 76px; padding: 4px 4px 14px; }
  .topbar h1 { font-size: 30px; }
  .eyebrow .sep, .eyebrow span:last-child { display: none; }
  .composer-card, .preview-card, .history-panel, .settings-card { border-radius: 23px; }
  .composer-card { min-height: 520px; padding: 20px; }
  .composer-head h2 { font-size: 18px; }
  .reference-entry > span:not(.soon) { display: none; }
  #promptInput { min-height: 235px; font-size: 19px; }
  .control-row { display: grid; grid-template-columns: minmax(0, 1fr) 82px; }
  .generate-btn { grid-column: 1 / -1; height: 54px; margin-left: 0; }
  .preview-card { padding: 14px; min-height: 450px; }
  .preview-stage { min-height: 370px; }
  .history-intro { align-items: flex-start; flex-direction: column; gap: 8px; }
  .history-intro p { text-align: left; }
  .history-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; width: 100%; }
  .toolbar-actions { overflow-x: auto; padding-bottom: 2px; }
  .history-row { grid-template-columns: 62px minmax(0, 1fr); }
  .history-thumb { width: 62px; height: 62px; }
  .history-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .result-grid { grid-template-columns: 1fr; }
  .result-overlay { opacity: 1; }
  .ratio-picker-backdrop { align-items: end; padding: 10px; }
  .ratio-picker-panel { width: 100%; border-radius: 24px; padding: 19px; transform: translateY(20px); }
  .ratio-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .ratio-option { min-height: 102px; border-radius: 15px; }
  .ratio-shape { height: 38px; max-width: 58px; }
  .toast-stack { right: 14px; bottom: 14px; }
}

@media (max-width: 430px) {
  .ratio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ratio-option { min-height: 92px; }
  .composer-head { align-items: center; }
  .settings-card { padding: 20px; }
  .segmented button { font-size: 10px; }
}

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

/* v6: model routing labels in custom aspect picker */
.ratio-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ratio-option small { display:block; margin-top:4px; color:var(--text-3); font-size:9px; font-weight:650; white-space:nowrap; }
@media (max-width: 560px) { .ratio-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ratio-option small { font-size:8px; } }


/* v7 model switcher */
.control-row-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.model-picker-backdrop, .model-picker-panel { }
.model-picker-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 22px; background: rgba(11,12,17,.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); opacity: 0; transition: opacity .16s ease; }
.model-picker-backdrop.open { opacity: 1; }
.model-picker-panel { width: min(560px, calc(100vw - 32px)); border-radius: 26px; padding: 21px; transform: translateY(8px) scale(.985); opacity: .92; transition: transform .18s ease, opacity .18s ease; }
.model-picker-backdrop.open .model-picker-panel { transform: none; opacity: 1; }
.model-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.model-option { min-height: 116px; align-items: flex-start; justify-content: flex-start; padding: 14px; gap: 8px; text-align: left; }
.model-option strong { font-size: 13px; font-weight: 760; }
.model-option small { white-space: normal; line-height: 1.5; color: var(--text-2); font-size: 10px; }
.ratio-option.disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.ratio-option.disabled .ratio-shape { color: var(--text-3) !important; }
@media (max-width: 760px) { .control-row-wide { grid-template-columns: 1fr 1fr; } .control-row-wide .generate-btn { grid-column: 1 / -1; } .model-picker-backdrop { align-items: end; padding: 10px; } .model-picker-panel { width: 100%; border-radius: 24px; padding: 19px; transform: translateY(20px); } }
@media (max-width: 560px) { .model-grid { grid-template-columns: 1fr; } }


/* v7 model selector polish */
.model-control { min-width: 0; }
.model-trigger { width: 100%; min-height: 27px; margin-top: 1px; padding: 0; border: 0; outline: none; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; text-align: left; }
.model-trigger strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 720; letter-spacing: -.01em; }
.model-trigger svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-3); transition: transform .18s ease; }
.model-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.ratio-option:disabled, .ratio-option.unavailable { opacity: .42; cursor: not-allowed; transform: none !important; }
.ratio-option:disabled:hover, .ratio-option.unavailable:hover { background: rgba(127,127,140,.035); box-shadow: none; }
.model-option.selected { border-color: rgba(95,103,245,.34); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(95,103,245,.08); }
@media (max-width: 760px) {
  .control-row-wide { grid-template-columns: minmax(0, 1.35fr) minmax(92px, .65fr); }
  .model-trigger strong { font-size: 12px; }
}
