:root {
  color-scheme: dark;
  --base: #10171e;
  --panel: #18232c;
  --inset: #111b23;
  --line: #344651;
  --text: #f1f6f6;
  --muted: #a7b9c2;
  --accent: #b3efe9;
  --error: #ffc1ac;
  font-family: "DM Sans", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--base); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: default; opacity: .65; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .ratios input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.shell { width: min(1200px, calc(100% - 80px)); margin-inline: auto; }
.topbar { border-bottom: 1px solid #25353f; background: #10181fd9; }
.top-inner { height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand, .nav, .control { display: flex; align-items: center; }
.brand { gap: 11px; font-size: 19px; font-weight: 700; white-space: nowrap; letter-spacing: .05em; }
.brand small { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .015em; margin-left: 9px; }
.brand-symbol { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #48776f; border-radius: 10px; background: #183938; color: var(--accent); }
.brand-symbol svg { fill: var(--accent); stroke-width: 1; width: 20px; height: 20px; }
.nav { gap: 9px; }
.model-toggle { color: var(--accent); }
.control { min-height: 38px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--text); font-size: 12px; gap: 7px; justify-content: center; white-space: nowrap; }
.control:hover { background: #273943; border-color: #617a86; }
.control svg { width: 16px; height: 16px; }
.connect { color: var(--accent); border-color: #42615f; }
.status-dot { height: 7px; width: 7px; border: 1px solid currentColor; border-radius: 100%; }
.connect[data-connected="true"] .status-dot { background: var(--accent); }
.intro { padding: 41px 0 24px; }
.intro h1 { font-weight: 680; font-size: clamp(29px, 4vw, 47px); margin: 0; line-height: 1.16; letter-spacing: -.045em; }
.intro p { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.desk { display: grid; grid-template-columns: minmax(345px, .85fr) minmax(0, 1.35fr); gap: 22px; align-items: start; padding-bottom: max(34px, env(safe-area-inset-bottom)); }
.editor, .preview { min-width: 0; border: 1px solid var(--line); background: var(--panel); border-radius: 18px; }
.editor { padding: 21px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #2a3a46; border-radius: 12px; padding: 4px; background: var(--inset); gap: 4px; margin-bottom: 22px; }
.mode-switch button { min-height: 42px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 13px; border: 1px solid transparent; border-radius: 8px; background: transparent; }
.mode-switch button[aria-pressed="true"] { color: var(--accent); border-color: #4c666d; background: #263c43; }
.mode-switch button:hover:not([aria-pressed="true"]) { background: #1e2c37; }
.mode-switch svg { width: 16px; height: 16px; }
.label-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; font-weight: 650; }
.label-line span { color: var(--muted); font-size: 11px; font-weight: 450; font-variant-numeric: tabular-nums; }
textarea, select, input[type="password"] { width: 100%; border: 1px solid var(--line); background: var(--inset); color: var(--text); border-radius: 9px; }
textarea { display: block; padding: 12px 13px; line-height: 1.65; font-size: 15px; min-height: 124px; resize: vertical; }
textarea::placeholder, input::placeholder { color: #869eaa; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; min-height: 32px; }
.example { font-size: 12px; padding: 6px 9px; min-height: 32px; border: 1px solid #41545e; border-radius: 20px; color: #c6d5d9; background: transparent; }
.example:hover { border-color: var(--accent); color: var(--accent); }
.settings { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(105px, 1fr); gap: 11px; margin-top: 20px; }
.model-price { color: var(--muted); margin: 8px 0 0; font-size: 12px; line-height: 1.55; }
.field { display: grid; gap: 8px; min-width: 0; font-weight: 650; font-size: 13px; }
.select-wrap { position: relative; display: block; min-width: 0; }
.select-wrap svg { position: absolute; right: 9px; top: 13px; width: 17px; height: 17px; pointer-events: none; color: var(--muted); }
select, input[type="password"] { min-height: 44px; padding: 0 11px; font-size: 14px; font-weight: 450; }
select { appearance: none; padding-right: 28px; text-overflow: ellipsis; }
.ratio-field { margin: 17px 0 0; padding: 0; border: 0; min-width: 0; }
.ratio-field legend { padding: 0; margin-bottom: 8px; font-weight: 650; font-size: 13px; }
.ratios { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ratios label { cursor: pointer; position: relative; }
.ratios input { margin: 0; position: absolute; opacity: 0; width: 1px; height: 1px; }
.ratios span { min-height: 39px; display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; background: var(--inset); font-size: 11px; white-space: nowrap; }
.ratios input:checked + span { color: var(--accent); border-color: #72a39e; background: #1f3b40; }
.ratios i { border: 1px solid currentColor; border-radius: 2px; width: 12px; height: 12px; }
.ratios .r-portrait { width: 10px; height: 13px; }
.ratios .r-story { width: 8px; height: 14px; }
.ratios .r-wide { width: 14px; height: 8px; }
.primary { position: relative; width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid #d0fff7; border-radius: 10px; background: var(--accent); color: #102522; font-size: 15px; font-weight: 750; }
.primary:hover { background: #d2fff8; }
.primary .action-arrow { position: absolute; right: 15px; width: 18px; }
#generate { margin-top: 20px; }
.billing { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 11px; }
#reference-section { margin-bottom: 18px; }
.references { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 8px; }
.references:empty { display: none; }
.reference { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; aspect-ratio: 1; }
.reference img { display: block; width: 100%; height: 100%; object-fit: cover; }
.reference button { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 28px; height: 28px; background: #12212bea; border: 1px solid #6b818b; border-radius: 7px; color: white; }
.reference button svg { width: 15px; }
.upload { min-height: 48px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px dashed #56717b; border-radius: 9px; color: var(--accent); background: var(--inset); font-size: 13px; }
.upload small { color: var(--muted); font-size: 11px; }
.upload:hover { border-color: var(--accent); }
.form-message { margin: 13px 0 0; color: var(--error); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.form-message[data-info="true"] { color: var(--accent); }
.preview { overflow: hidden; }
.preview-header, .preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; }
.preview-header h2 { font-size: 15px; margin: 0; }
.preview-header p { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.icon-button { padding: 8px; min-width: 38px; }
.art { position: relative; overflow: hidden; margin: 0 12px; border: 1px solid #3c5666; border-radius: 12px; background: #101920; aspect-ratio: 1.51; }
.art > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.art[data-result="true"] > img { object-fit: contain; }
.art-caption { position: absolute; inset: auto 0 0; padding: 35px 21px 17px; display: grid; gap: 4px; background: linear-gradient(transparent, #07121be6); pointer-events: none; }
.art-caption small { font-size: 11px; color: #bfd2dc; }
.art-caption span { font-size: clamp(22px, 3vw, 32px); font-weight: 670; letter-spacing: .025em; }
.preview-footer { min-height: 60px; }
#result-meta { color: var(--muted); font-size: 12px; min-width: 0; overflow-wrap: anywhere; }
.result-actions { display: flex; gap: 6px; }
.result-actions .control { color: var(--accent); }
.working { position: absolute; inset: 0; background: #07121bde; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-size: 15px; }
.working > span:last-child { color: var(--muted); font-size: 12px; }
.spinner { width: 30px; height: 30px; border: 2px solid #4a6f73; border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog { width: min(460px, calc(100% - 26px)); max-height: 84dvh; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: #041018ca; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-heading h2 { font-size: 20px; margin: 0; }
dialog p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }
.dialog-actions .primary { width: auto; min-height: 43px; padding: 0 14px; }
dialog .key-note { font-size: 12px; }
.remember-key { display: flex; align-items: center; gap: 7px; margin-top: 12px; font-size: 13px; }
.remember-key input { accent-color: var(--accent); }
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
.history-list p { grid-column: 1 / -1; }
.history-list button { display: grid; gap: 5px; min-width: 0; padding: 0 0 6px; text-align: left; color: var(--text); border: 1px solid var(--line); border-radius: 8px; background: var(--inset); overflow: hidden; }
.history-list img { width: 100%; aspect-ratio: 1.2; object-fit: cover; }
.history-list span { padding-inline: 6px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: 12px; }
.model-dialog { width: min(620px, calc(100% - 26px)); }
#search-model { width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--inset); color: var(--text); font-size: 16px; }
.ranking-list { list-style: none; display: grid; gap: 5px; margin: 12px 0 0; padding: 0; }
.ranking-list button { text-align: left; display: grid; grid-template-columns: 29px minmax(0, 1fr); width: 100%; gap: 8px; padding: 8px; border-radius: 8px; border: 1px solid transparent; color: var(--text); background: transparent; }
.ranking-list button:hover, .ranking-list button[aria-current="true"] { background: var(--inset); border-color: var(--line); }
.rank-number { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; padding: 2px 0; text-align: center; }
.rank-name { display: block; font-weight: 670; font-size: 14px; }
.rank-price { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 4px; }
.zoom { width: fit-content; max-width: calc(100% - 24px); max-height: 92dvh; padding: 5px; }
.zoom button { position: absolute; top: 10px; right: 10px; background: #152128ee; }
.zoom img { display: block; max-width: 100%; max-height: calc(92dvh - 12px); object-fit: contain; border-radius: 10px; }
@media (max-width: 850px) {
  .shell { width: calc(100% - 36px); }
  .desk { grid-template-columns: minmax(315px, 1fr) minmax(0, 1fr); gap: 13px; }
  .editor { padding: 15px; }
}
@media (max-width: 665px) {
  .shell { width: calc(100% - 28px); }
  .top-inner { height: 59px; }
  .brand small { display: none; }
  .nav { gap: 5px; }
  .nav .control { min-height: 36px; padding-inline: 6px; }
  .history-toggle span { display: none; }
  .intro { padding: 24px 0 16px; }
  .intro p { font-size: 12px; margin-top: 7px; }
  .desk { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .editor, .preview { border-radius: 14px; }
  .editor { padding: 13px; }
  .mode-switch { margin-bottom: 14px; }
  textarea, select, input[type="password"] { font-size: 16px; }
  textarea { min-height: 100px; }
  .settings { margin-top: 14px; }
  .ratio-field { margin-top: 13px; }
  #generate { margin-top: 14px; }
  .preview-header, .preview-footer { padding: 10px 13px; }
  .art { margin-inline: 8px; }
}
@media (max-width: 352px) {
  .brand { gap: 6px; font-size: 16px; }
  .brand-symbol { width: 29px; height: 29px; }
  .nav { gap: 4px; }
  .nav .control { font-size: 11px; padding-inline: 5px; }
  .nav .status-dot { display: none; }
  .history-toggle span, .ratios i { display: none; }
  .settings { grid-template-columns: minmax(0, 1.7fr) minmax(83px, 1fr); }
  .result-actions .control { padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
