/* 咪咪画室 · Mimi Studio —— 手机优先，奶油色调 */
:root {
  --bg: #f5f0e6;
  --bg-deep: #ede6d8;
  --surface: #fffcf6;
  --surface-2: #faf5ea;
  --line: #e7dfce;
  --line-strong: #d7ccb6;
  --ink: #2a2621;
  --ink-2: #5d5549;
  --ink-3: #8d8374;
  --accent: #b9684a;
  --accent-soft: #f4e1d6;
  --sage: #5f7d66;
  --sage-soft: #e3ecdd;
  --amber: #9a6f25;
  --amber-soft: #f5e8c9;
  --danger: #ad4b3b;
  --danger-soft: #f6dfd8;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --shadow-1: 0 1px 2px rgba(70, 52, 24, .05), 0 6px 20px rgba(70, 52, 24, .05);
  --shadow-2: 0 2px 6px rgba(70, 52, 24, .07), 0 18px 48px rgba(70, 52, 24, .12);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", Georgia, "PingFang SC", "Microsoft YaHei UI", serif;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
code { font: 12.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--bg-deep); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 基础组件 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.label em { font-style: normal; font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; font-weight: 400; }
.form-error { font-size: 13px; color: var(--danger); line-height: 1.5; }
.form-error:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; font-weight: 600; font-size: 14.5px; white-space: nowrap;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.btn .icon { width: 18px; height: 18px; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary { background: var(--ink); color: #fffaf0; box-shadow: 0 6px 16px rgba(42, 38, 33, .18); }
.btn-primary:hover:not(:disabled) { background: #3a342d; }
.btn-primary:disabled { background: #b9b0a0; box-shadow: none; }
.btn-secondary { background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #c6b99f; }
.btn-danger { background: var(--danger); color: #fff8f4; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.btn-block { width: 100%; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; font-size: 13px; font-weight: 600; color: var(--ink-2); border-radius: 8px; padding: 0 4px; }
.link-btn:hover { color: var(--ink); }
.link-btn .icon { width: 15px; height: 15px; }
.link-btn.danger { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--ink-2); transition: background-color .15s ease; }
.icon-btn:hover { background: rgba(42, 38, 33, .07); color: var(--ink); }

.input, .select, .input-wrap {
  width: 100%; min-height: 44px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input, .select { padding: 0 14px; font-size: 15px; font-weight: 400; color: var(--ink); }
.label > .input, .label > .select { margin-top: 6px; }
.label > .hint { display: block; margin-top: 6px; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d8374' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.input:focus, .select:focus, .input-wrap:focus-within, .prompt-box:focus-within { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 4px rgba(42, 38, 33, .07); }
.input::placeholder, textarea::placeholder, .input-wrap input::placeholder { color: #b0a696; }
.input-wrap { display: flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--ink-3); }
.input-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; min-height: 42px; font-size: 15px; color: var(--ink); }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-deep); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--sage-soft); color: var(--sage); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.busy { background: var(--accent-soft); color: var(--accent); }
.badge { position: absolute; left: 10px; top: 10px; height: 24px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; background: rgba(42, 38, 33, .78); color: #fffaf0; backdrop-filter: blur(6px); pointer-events: none; }

.meter { display: block; height: 6px; border-radius: 999px; background: var(--bg-deep); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink); transition: width .4s ease; }
.meter.warn > span { background: var(--accent); }

.segmented { display: inline-flex; justify-self: start; width: fit-content; padding: 3px; background: var(--bg-deep); border-radius: 999px; }
.segmented button { min-width: 58px; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--ink-3); transition: background-color .15s ease, color .15s ease, box-shadow .15s ease; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(70, 52, 24, .14); }
.segmented-sm button { min-width: 44px; padding: 0 10px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); padding: 2px; transition: background-color .2s ease; flex: none; }
.switch-track span { display: block; width: 18px; height: 18px; border-radius: 50%; background: #fffdf8; box-shadow: 0 1px 2px rgba(0, 0, 0, .18); transition: transform .2s ease; }
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track span { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; color: var(--ink); flex: none; }
.brand strong { display: block; font: 600 17px/1.2 var(--serif); letter-spacing: .04em; }
.brand small { display: block; font-size: 11px; color: var(--ink-3); letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }
.brand-sm .brand-mark { width: 28px; height: 28px; }
.brand-sm strong { font-size: 16px; }

.mode-chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--sage-soft); color: var(--sage); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.mode-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mode-chip.live { background: var(--accent-soft); color: var(--accent); }

/* ---------- 登录 ---------- */
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 28px 18px calc(28px + var(--safe-b)); background: radial-gradient(1200px 520px at 50% -10%, #fbf6ea 0%, var(--bg) 62%); }
.login-wrap { width: min(100%, 400px); }
.login-tiles { display: flex; justify-content: center; margin-bottom: -34px; position: relative; z-index: 0; }
.login-tiles img { width: 31%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center 30%; border-radius: 16px; border: 4px solid var(--surface); box-shadow: var(--shadow-2); }
.login-tiles img:nth-child(1) { transform: rotate(-7deg) translate(10px, 10px); }
.login-tiles img:nth-child(2) { transform: translateY(-8px); z-index: 1; }
.login-tiles img:nth-child(3) { transform: rotate(7deg) translate(-10px, 10px); }
.login-card { position: relative; z-index: 2; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-2); padding: 30px 24px 24px; display: grid; gap: 12px; }
.login-card h1 { font: 600 26px/1.3 var(--serif); margin-top: 10px; }
.login-lede { color: var(--ink-2); font-size: 14px; margin-bottom: 6px; }
.login-help { font-size: 12.5px; color: var(--ink-3); line-height: 1.9; margin-top: 4px; }
.login-help code { white-space: nowrap; }

/* ---------- 外壳 ---------- */
.shell { min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: rgba(245, 240, 230, .86); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: rgba(255, 252, 246, .94); border-top: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.tab-item { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); transition: color .15s ease; }
.tab-item .icon { width: 22px; height: 22px; }
.tab-item.active { color: var(--ink); }
.tab-item.active .icon { stroke-width: 2; color: var(--accent); }

.page { padding: 8px 16px 0; max-width: 1360px; margin: 0 auto; animation: page-in .28s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { padding: 10px 2px 16px; }
.page-head h1 { font: 600 25px/1.3 var(--serif); letter-spacing: .01em; }
.page-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 4px; }
.page-head-row { display: grid; gap: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2, .section-head h3 { font-size: 15px; font-weight: 700; }

/* ---------- 创作台 ---------- */
.workbench { display: grid; gap: 18px; }
.composer { position: relative; padding: 16px; display: grid; gap: 20px; align-content: start; }
.composer-top { display: grid; gap: 10px; }
.mode-notice { font-size: 12.5px; line-height: 1.55; color: var(--sage); background: var(--sage-soft); border-radius: var(--r-sm); padding: 8px 12px; }
.mode-notice.warn { color: var(--amber); background: var(--amber-soft); }
.mode-notice.live { color: var(--accent); background: var(--accent-soft); }
.field { display: grid; gap: 8px; min-width: 0; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 24px; }
.field-aside { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.field-inline { grid-template-columns: 1fr auto; align-items: center; }

.prompt-box { border: 1px solid var(--line-strong); border-radius: var(--r-md); background: #fffefa; transition: border-color .15s ease, box-shadow .15s ease; }
.prompt-box textarea { display: block; width: 100%; min-height: 128px; resize: vertical; border: 0; outline: 0; background: transparent; padding: 14px 14px 6px; font-size: 16px; line-height: 1.65; border-radius: var(--r-md); }
.prompt-foot { display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px; }
.idea-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; mask-image: linear-gradient(90deg, #000 86%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 86%, transparent); padding-right: 18px; }
.idea-chips::-webkit-scrollbar { display: none; }
.idea-chips button { flex: none; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); transition: background-color .15s ease, border-color .15s ease; }
.idea-chips button:hover { background: var(--bg-deep); border-color: var(--line-strong); }

.model-list { display: grid; gap: 12px; max-height: 320px; overflow-y: auto; margin: 0 -4px; padding: 2px 4px; }
.model-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.model-options { display: grid; gap: 8px; }
.model-option { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 9px 14px 9px 12px; text-align: left; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease; }
.model-option:hover { border-color: var(--line-strong); background: var(--surface-2); }
.model-check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: transparent; transition: all .15s ease; }
.model-list.multi .model-check { border-radius: 7px; }
.model-check .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.model-text { min-width: 0; }
.model-text strong { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-text small { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-price { font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.model-price small { font-weight: 400; color: var(--ink-3); }
.model-option.selected { border-color: var(--ink); background: #fffefa; box-shadow: 0 0 0 1px var(--ink) inset; }
.model-option.selected .model-check { background: var(--ink); border-color: var(--ink); color: #fffaf0; }
.model-empty { border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: 18px 16px; text-align: center; display: grid; gap: 10px; justify-items: center; color: var(--ink-2); font-size: 13.5px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 5px 14px 5px 11px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-align: left; transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease; }
.chip:hover { border-color: var(--line-strong); background: var(--surface-2); }
.chip strong { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.chip small { display: block; font-size: 11.5px; color: var(--ink-3); line-height: 1.25; font-variant-numeric: tabular-nums; }
.chip.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; background: #fffefa; }
.chip-plain { padding: 5px 16px; }
.ratio-box { width: 22px; height: 22px; display: grid; place-items: center; flex: none; }
.ratio-icon { display: block; border: 1.6px solid var(--ink-3); border-radius: 3.5px; width: 16px; height: 16px; }
.chip.selected .ratio-icon { border-color: var(--ink); background: var(--bg-deep); }
.ratio-icon.auto { border-style: dashed; }

.reference-row { display: flex; flex-wrap: wrap; gap: 8px; }
.reference-list { display: contents; }
.reference-thumb { position: relative; width: 72px; height: 72px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--bg-deep); }
.reference-thumb img { width: 100%; height: 100%; object-fit: cover; }
.reference-thumb button { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(42, 38, 33, .72); color: #fff; display: grid; place-items: center; }
.reference-thumb button .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.upload-zone { position: relative; overflow: hidden; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 104px; height: 72px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-3); font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .15s ease, background-color .15s ease, color .15s ease; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--ink-2); color: var(--ink); background: var(--surface-2); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone.disabled { opacity: .5; cursor: not-allowed; }
.upload-zone.disabled:hover { border-color: var(--line-strong); color: var(--ink-3); background: none; }

.submit-bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 10; display: grid; gap: 8px; margin: 0 -8px -6px; padding: 10px 10px 10px 16px; background: rgba(255, 252, 246, .96); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.submit-bar .form-error { padding-right: 6px; }
.estimate { display: grid; min-width: 0; line-height: 1.3; }
.estimate-label { font-size: 11.5px; color: var(--ink-3); }
.estimate strong { font: 700 21px/1.25 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.estimate-detail { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-generate { min-height: 50px; padding: 0 22px; font-size: 15.5px; flex: none; }
.btn-generate .icon { color: #e8b59e; }

/* ---------- 结果 ---------- */
.stage { min-width: 0; display: grid; gap: 22px; align-content: start; }
.job-panel { padding: 16px; display: grid; gap: 14px; }
.job-head { display: grid; gap: 8px; }
.job-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--ink-3); }
.job-meta .timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); }
.job-prompt { font-size: 15px; line-height: 1.65; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.job-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.job-actions .danger { margin-left: auto; }
@media (max-width: 619px) { .job-actions .danger span { display: none; } .job-actions .danger { min-width: 32px; justify-content: center; } }
.job-progress { display: grid; gap: 6px; }
.job-progress .meter > span { background: var(--accent); }
.job-progress p { font-size: 12.5px; color: var(--ink-3); }

.result-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.result { margin: 0; min-width: 0; display: grid; gap: 8px; align-content: start; }
.result-frame { --ratio: 1; position: relative; width: 100%; aspect-ratio: var(--ratio); border-radius: var(--r-md); overflow: hidden; background: var(--bg-deep); border: 1px solid var(--line); }
.result-grid.n-1 .result-frame { width: min(100%, calc(68dvh * var(--ratio))); margin: 0 auto; }
.result-open { display: block; width: 100%; height: 100%; }
.result-open img { width: 100%; height: 100%; object-fit: contain; background: var(--bg-deep); animation: fade-in .4s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.result-tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; }
.result-tools a, .result-tools button { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 252, 246, .92); color: var(--ink); box-shadow: 0 2px 8px rgba(42, 38, 33, .18); transition: transform .15s ease; }
.result-tools a:hover, .result-tools button:hover { transform: translateY(-1px); }
.result-tools .icon { width: 18px; height: 18px; }
.result-state { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 8px; padding: 18px; text-align: center; color: var(--ink-2); }
.result-state strong { font-size: 14px; }
.result-state p { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; max-width: 26em; overflow-wrap: anywhere; }
.result-state .state-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--ink-3); }
.result.failed .result-frame { background: #f8ece6; border-color: #ecd3c9; }
.result.failed .state-icon { color: var(--danger); }
.result.uncertain .result-frame { background: #f8f0db; border-color: #ead9ae; }
.result.uncertain .state-icon { color: var(--amber); }
.result.running .result-frame, .result.queued .result-frame { background: linear-gradient(100deg, var(--bg-deep) 30%, #f6f0e3 50%, var(--bg-deep) 70%); background-size: 240% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid rgba(42, 38, 33, .14); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px; min-width: 0; }
.result figcaption strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result figcaption span { font-size: 12px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 44px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--ink-2); }
.empty h3 { font: 600 18px/1.4 var(--serif); color: var(--ink); }
.empty p { font-size: 13.5px; color: var(--ink-3); max-width: 30em; }
.empty .btn { margin-top: 8px; }
.empty-sm { padding: 28px 18px; border: 0; }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-deep); color: var(--ink-2); margin-bottom: 4px; }
.empty-art { display: flex; margin-bottom: 8px; }
.empty-art img { width: 84px; aspect-ratio: 3 / 4; object-fit: cover; object-position: center 30%; border-radius: 12px; border: 3px solid var(--surface); box-shadow: var(--shadow-1); }
.empty-art img:nth-child(1) { transform: rotate(-6deg) translateX(10px); }
.empty-art img:nth-child(2) { transform: translateY(-6px); z-index: 1; }
.empty-art img:nth-child(3) { transform: rotate(6deg) translateX(-10px); }

.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.thumb { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--bg-deep); transition: transform .15s ease, box-shadow .15s ease; }
.thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-state { display: grid; place-items: center; width: 100%; height: 100%; color: var(--ink-3); font-size: 11.5px; text-align: center; padding: 4px; }

/* ---------- 历史 ---------- */
.history-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-width: 0; }
.page-head-row > * { min-width: 0; }
.history-tools .select { width: auto; min-width: 116px; }
.history-list { display: grid; gap: 14px; }
.history-card { padding: 14px; display: grid; gap: 12px; }
.history-thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.history-body { display: grid; gap: 8px; min-width: 0; }
.history-models { font-size: 12.5px; color: var(--ink-3); overflow-wrap: anywhere; }

/* ---------- 设置 ---------- */
.settings-layout, .settings-main, .settings-aside { display: grid; gap: 16px; align-content: start; min-width: 0; }
.settings-card { padding: 18px; display: grid; gap: 14px; min-width: 0; }
.settings-card h2 { font-size: 16px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.card-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--sage-soft); color: var(--sage); }
.provider-list { display: grid; gap: 10px; }
.provider-list:empty { display: none; }
.provider-item { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: grid; gap: 10px; background: #fffefa; min-width: 0; }
.provider-head { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; min-width: 0; }
.provider-emblem { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-deep); font: 600 17px var(--serif); color: var(--ink-2); }
.provider-title { min-width: 0; }
.provider-title h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.provider-title p { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.model-tags span { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; max-width: 100%; overflow-wrap: anywhere; }
.model-tags small { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.provider-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; border-top: 1px solid var(--line); padding-top: 8px; }
.budget-grid { display: grid; gap: 14px; }
.budget-block { display: grid; gap: 8px; }
.budget-line { display: flex; align-items: baseline; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.budget-line strong { font: 700 17px var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.budget-line strong small { font: 400 12.5px var(--sans); color: var(--ink-3); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-row div { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; display: grid; }
.stat-row strong { font: 700 17px var(--sans); font-variant-numeric: tabular-nums; }
.stat-row span { font-size: 12px; color: var(--ink-3); }
.limits-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.limits-form .btn { grid-column: 1 / -1; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-list li { display: grid; grid-template-columns: auto 1fr; gap: 8px; font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.check-list .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--sage); stroke-width: 2.2; }
.runtime-steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }

/* ---------- 弹层 ---------- */
dialog { border: 0; padding: 0; color: inherit; background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(42, 38, 33, .42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet { width: 100%; margin: auto 0 0; max-height: 92dvh; }
.sheet[open] { animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-body { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 22px 18px calc(18px + var(--safe-b)); display: grid; gap: 14px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-body h2 { font: 600 20px/1.35 var(--serif); }
.sheet-text { font-size: 14px; color: var(--ink-2); line-height: 1.65; }
.sheet-text:empty { display: none; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; position: sticky; bottom: calc(-18px - var(--safe-b)); background: linear-gradient(transparent, var(--surface) 28%); padding: 14px 0 calc(18px + var(--safe-b)); margin-bottom: calc(-18px - var(--safe-b)); }
.confirm-summary { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); padding: 4px 14px; }
.confirm-summary div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.confirm-summary div:last-child { border-bottom: 0; font-weight: 700; }
.confirm-summary span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confirm-summary span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.form-grid { display: grid; gap: 14px; }
.models-editor { display: grid; }
.model-rows { display: grid; gap: 10px; }
.model-row { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); padding: 12px; display: grid; gap: 10px; }
.model-row-head { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.model-row-head .icon-btn { width: 32px; height: 32px; margin: -6px -6px -6px 0; }
.model-fields { display: grid; gap: 10px; }
.field-with-action { display: flex; justify-content: space-between; align-items: center; }
.advanced { border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 14px; }
.advanced summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); padding: 13px 0; list-style-position: inside; }
.advanced[open] { padding-bottom: 14px; }

.lightbox { width: 100vw; height: 100dvh; margin: 0; background: #1f1c18; }
.lightbox[open] { display: block; animation: fade-in .2s ease both; }
.lightbox-inner { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.lightbox-canvas { position: relative; min-height: 0; display: grid; place-items: center; padding: 12px; }
.lightbox-canvas img { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; border-radius: 10px; }
.lightbox-canvas .badge { left: 16px; top: calc(16px + env(safe-area-inset-top, 0px)); }
.lightbox-nav { position: absolute; top: 50%; margin-top: -22px; width: 44px; height: 44px; background: rgba(255, 252, 246, .9); color: var(--ink); }
.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }
.lightbox-nav:hover { background: #fff; }
.lightbox-panel { position: relative; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 18px 18px calc(18px + var(--safe-b)); display: grid; gap: 8px; max-height: 46dvh; overflow-y: auto; }
.lightbox-close { position: absolute; right: 10px; top: 10px; }
.lightbox-panel h2 { font: 600 18px/1.35 var(--serif); padding-right: 44px; }
.lightbox-meta { font-size: 12.5px; color: var(--ink-3); }
.lightbox-prompt { font-size: 14px; color: var(--ink-2); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.lightbox-actions { display: grid; gap: 8px; margin-top: 6px; }

.toast-region { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 86px); z-index: 100; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { max-width: min(100%, 420px); background: rgba(42, 38, 33, .94); color: #fffaf0; padding: 10px 16px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; box-shadow: var(--shadow-2); animation: toast-in .22s ease both; }
.toast.error { background: #8f3b2e; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 平板 ---------- */
@media (min-width: 620px) {
  .page { padding: 12px 24px 0; }
  .result-grid.n-2, .result-grid.n-3, .result-grid.n-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-card { grid-template-columns: 300px 1fr; align-items: start; }
  .page-head-row { grid-template-columns: 1fr auto; align-items: end; }
  .history-tools { grid-template-columns: 260px auto; }
  .form-grid, .model-fields { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
  .budget-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
  .limits-form { grid-template-columns: 1fr 1fr auto; }
  .limits-form .btn { grid-column: auto; }
  .sheet { width: min(480px, calc(100vw - 32px)); margin: auto; }
  .sheet-wide { width: min(720px, calc(100vw - 32px)); }
  .sheet-body { border-radius: var(--r-xl); padding: 26px; box-shadow: var(--shadow-2); max-height: min(88dvh, 860px); }
  .sheet-actions { display: flex; justify-content: flex-end; bottom: -26px; padding: 14px 0 26px; margin-bottom: -26px; }
  .sheet-actions .btn { min-width: 108px; }
  .lightbox-actions { grid-template-columns: repeat(3, auto); justify-content: start; }
}

/* ---------- 桌面 ---------- */
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100dvh; padding: 26px 16px 18px; border-right: 1px solid var(--line); background: #f8f3e9; }
  .sidebar .brand { padding: 0 10px; }
  .side-nav { display: grid; gap: 4px; }
  .nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); transition: background-color .15s ease, color .15s ease; }
  .nav-item:hover { background: rgba(42, 38, 33, .05); color: var(--ink); }
  .nav-item.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
  .nav-item.active .icon { color: var(--accent); }
  .nav-count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
  .nav-quiet { font-weight: 500; color: var(--ink-3); font-size: 13.5px; }
  .sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
  .sidebar-foot .mode-chip { justify-self: start; margin-left: 4px; }
  .side-budget { display: grid; gap: 8px; text-align: left; padding: 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); transition: border-color .15s ease; }
  .side-budget:hover { border-color: var(--line-strong); }
  .side-budget-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--ink-3); }
  .side-budget-top strong { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
  .side-budget-note { font-size: 11.5px; color: var(--ink-3); }
  .topbar, .tabbar { display: none; }
  .main { padding-bottom: 0; }
  .page { padding: 30px 36px 40px; }
  #page-workbench { height: 100dvh; display: flex; flex-direction: column; padding-bottom: 24px; }
  .page-head { padding: 0 2px 22px; }
  .page-head h1 { font-size: 30px; }
  .page-head p { font-size: 14.5px; }
  .workbench { flex: 1; min-height: 0; grid-template-columns: minmax(380px, 440px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 22px; }
  .composer { height: 100%; overflow-y: auto; padding: 20px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
  .stage { height: 100%; overflow-y: auto; padding: 0 4px 12px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
  .submit-bar { bottom: -20px; margin: 0 -20px -20px; border-radius: 0 0 var(--r-lg) var(--r-lg); border-width: 1px 0 0; box-shadow: 0 -10px 24px rgba(70, 52, 24, .06); padding: 14px 20px; }
  .job-panel { padding: 22px; }
  .result-grid.n-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .result-grid.n-1 .result-frame { width: min(100%, calc((100dvh - 350px) * var(--ratio))); }
  .recent-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  .settings-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; }
  .settings-card { padding: 22px; }
  .toast-region { bottom: 32px; left: 236px; }
  .lightbox-inner { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) 360px; }
  .lightbox-canvas { padding: 32px; }
  .lightbox-panel { border-radius: 0; max-height: none; padding: 30px 26px; align-content: start; gap: 12px; }
  .lightbox-actions { grid-template-columns: 1fr; margin-top: 14px; }
  .lightbox-prompt { -webkit-line-clamp: 12; }
  .result-tools { opacity: 0; transition: opacity .15s ease; }
  .result-frame:hover .result-tools, .result-frame:focus-within .result-tools { opacity: 1; }
  .empty { padding: 72px 24px; }
}
@media (min-width: 1440px) {
  .result-grid.n-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (hover: none) {
  .result-tools { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
