:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-2: #efeff2;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #9b9ba1;
  --line: #e6e6eb;
  --accent: #1d1d1f;
  --on-accent: #ffffff;
  --blue: #0071e3;
  --danger: #d93c15;
  --success: #237a45;
  --sidebar: 248px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #aaaab0;
    --text-3: #78787e;
    --line: #303033;
    --accent: #f5f5f7;
    --on-accent: #101011;
    --blue: #4aa8ff;
    --danger: #ff694a;
    --success: #53b97b;
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .48; }
button:not(:disabled), a, [role="button"] { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.danger { color: var(--danger) !important; }
.blue { color: var(--blue) !important; }

.boot-screen {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--text-2);
  font-size: 14px;
}
.boot-screen img { border-radius: 15px; }

.auth-page {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 76px 1fr;
}
.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
}
.auth-wordmark { width: 112px; filter: var(--brand-filter, none); }
.auth-home { font-size: 13px; color: var(--text-2); }
.auth-main { display: grid; place-items: center; padding: 40px 20px 60px; }
.auth-form { width: min(420px, 100%); display: grid; gap: 14px; }
.auth-mark { width: 48px; height: 48px; border-radius: 15px; }
.auth-form h1 { margin: 4px 0 -5px; font-size: 32px; line-height: 1.1; letter-spacing: -.8px; }
.auth-form > p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; }
.field input, .field textarea, .field select, .search-input {
  width: 100%;
  border: 1px solid transparent;
  background: var(--surface);
  border-radius: 16px;
  min-height: 52px;
  padding: 0 16px;
  font-size: 15px;
}
.field textarea { min-height: 96px; resize: vertical; padding-block: 14px; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder, .search-input::placeholder { color: var(--text-3); opacity: 1; }
.field input:focus, .field textarea:focus, .field select:focus, .search-input:focus { border-color: var(--text); outline: none; }
/* 文件选择框的原生高度撑不满 52px，单独放开 */
.field input[type="file"] { padding-block: 14px; min-height: auto; font-size: 14px; }
.field select { appearance: none; color: var(--text); }
.helper { font-size: 12px; line-height: 1.55; color: var(--text-3); text-align: center; }
.auth-switch { text-align: center; font-size: 13px; color: var(--text-2); background: transparent; padding: 8px; }
.auth-switch strong { color: var(--blue); }
.form-error { margin: 0; color: var(--danger); font-size: 13px; line-height: 1.45; }

.primary-button, .secondary-button, .ghost-button, .pill-button, .danger-button {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .16s ease, opacity .16s ease, background-color .16s ease;
}
.primary-button { color: var(--on-accent); background: var(--accent); }
.secondary-button { color: var(--text); background: var(--surface); }
.ghost-button { min-height: 40px; background: transparent; border: 1px solid var(--line); font-weight: 500; }
.danger-button { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.pill-button { min-height: 38px; background: var(--surface); font-size: 13px; font-weight: 500; }
.primary-button:not(:disabled):active, .secondary-button:not(:disabled):active,
.ghost-button:not(:disabled):active, .pill-button:not(:disabled):active,
.danger-button:not(:disabled):active { transform: scale(.98); }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar-wordmark { width: 108px; filter: var(--brand-filter, none); margin-left: 10px; }
.nav-list { display: grid; gap: 4px; }
.nav-button {
  position: relative;
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 13px;
  padding: 0 14px;
  color: var(--text-2);
  background: transparent;
  font-size: 15px;
  text-align: left;
  transition: background .18s ease, color .18s ease;
}
.nav-button:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.nav-button:active { transform: scale(.985); }
.nav-button[aria-current="page"] {
  background: var(--bg);
  color: var(--text);
  font-weight: 650;
  box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 6px 16px -10px rgb(0 0 0 / .32);
}
/* 选中态左侧的小竖条。用伪元素而不是 border-left，免得文字跟着位移。 */
.nav-button[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 3px;
  background: var(--text);
  transform: translateY(-50%);
}
.nav-label { flex: 1; min-width: 0; }
.nav-glyph { flex: none; width: 22px; height: 22px; display: grid; place-items: center; color: var(--text-3); transition: color .18s ease; }
.nav-glyph svg { width: 20px; height: 20px; }
.nav-button:hover .nav-glyph, .nav-button[aria-current="page"] .nav-glyph { color: currentColor; }
.sidebar-account {
  margin-top: auto;
  padding: 14px;
  border-radius: 16px;
  background: var(--bg);
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.sidebar-account-row { display: flex; justify-content: space-between; gap: 12px; }
.sidebar-account span { color: var(--text-2); }
.sidebar-account strong { font-variant-numeric: tabular-nums; }
.main-view { min-width: 0; min-height: 100dvh; padding: 32px clamp(28px, 4vw, 56px) 44px; }
.mobile-dock { display: none; }

.view-header { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.view-header h1 { margin: 0; font-size: 25px; letter-spacing: -.45px; }
.credits-chip { min-height: 38px; border-radius: 999px; padding: 0 13px; background: var(--surface); font-weight: 650; font-size: 13px; }
/* 舞台这一行必须能被压缩：结果图和骨架屏都按舞台实际高度收，
   否则出图后输入框会被顶出视口，每次生成完都得往下滚才能接着输入。 */
/* 这里必须是确定的 height 而不是 min-height：min-height 下 1fr 轨道会跟着
   内容一起长，舞台高度就成了「由图片决定」，子元素的 max-height:100% 循环
   依赖、直接失效，结果图又会把输入框顶出视口。 */
.create-view { height: calc(100dvh - 76px); min-height: 420px; display: grid; grid-template-rows: auto minmax(220px, 1fr) auto; }
.create-stage { display: grid; place-items: center; min-height: 0; padding: 20px 0; overflow: hidden; }
.empty-state { display: grid; place-items: center; gap: 9px; text-align: center; }
.empty-mark { width: 96px; height: 96px; border-radius: 50%; background: linear-gradient(145deg, var(--surface), var(--surface-2)); display: grid; place-items: center; }
.empty-mark img { width: 44px; height: 44px; border-radius: 13px; }
.empty-state h2 { margin: 8px 0 0; font-size: 20px; }
.empty-state p { margin: 0; color: var(--text-2); font-size: 14px; }
.suggestions { margin-top: 10px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.suggestion { border-radius: 999px; background: transparent; border: 1px solid var(--line); padding: 9px 14px; color: var(--text-2); font-size: 13px; }

/* 网格项默认 min-height:auto（= min-content），不清零的话它会盖掉
   height:100%，图片按原始尺寸把容器撑爆 */
.generation-loading { width: min(560px, 100%); height: 100%; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; text-align: center; color: var(--text-2); }
.skeleton-image { height: 100%; width: auto; max-width: 100%; margin-inline: auto; aspect-ratio: var(--ratio, 1); border-radius: var(--radius-lg); background: linear-gradient(105deg, var(--surface) 25%, var(--surface-2) 42%, var(--surface) 60%); background-size: 250% 100%; animation: shimmer 1.4s ease infinite; display: grid; place-items: center; }
.generation-error { width: min(520px, 100%); border-radius: var(--radius-lg); padding: 28px; background: color-mix(in srgb, var(--danger) 7%, var(--surface)); text-align: left; }
.generation-error h2 { margin: 0 0 8px; font-size: 19px; }
.generation-error p { margin: 0 0 18px; color: var(--text-2); line-height: 1.55; }
.result-layout { width: min(1020px, 100%); height: 100%; min-height: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: center; gap: 30px; }
/* stretch 是为了给图片一个确定高度，max-height:100% 才有的算 */
.result-image-wrap { display: grid; place-items: center; align-self: stretch; min-height: 0; }
.result-image { max-height: 100%; min-height: 0; width: auto; border-radius: var(--radius-lg); background: var(--surface); object-fit: contain; }
.result-panel { display: grid; gap: 12px; }
.result-panel h2 { margin: 0; font-size: 20px; }
.result-panel p { margin: 0 0 8px; color: var(--text-2); line-height: 1.55; }
.result-actions { display: grid; gap: 9px; }

/* 限宽居中：不限宽的话 1920 全屏下输入框有 1700px，一行塞得下 100 多个字，
   看着是「又宽又扁的一条缝」，眼睛左右扫一趟很累。收到 820px 后同样的文字
   自然折成更多行，配合上面那个跟视口走的高度上限，就是「更高更聚焦」。 */
.create-controls { display: grid; gap: 10px; width: 100%; max-width: 820px; margin-inline: auto; }
.segmented { width: fit-content; max-width: 100%; display: flex; gap: 3px; padding: 3px; border-radius: 999px; background: var(--surface); overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segment { flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; color: var(--text-2); background: transparent; font-size: 12px; white-space: nowrap; }
.segment[aria-pressed="true"] { color: var(--text); background: var(--bg); box-shadow: 0 1px 4px color-mix(in srgb, var(--text) 14%, transparent); font-weight: 650; }
/* NEW 角标跟在文字后面，不用绝对定位：胶囊本身会被 overflow 裁掉，
   探出边界的角标在窄屏上会被切掉一半。 */
.segment-badge { margin-left: 5px; padding: 1px 5px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .4px; vertical-align: 1px; }
.quality-picker { position: relative; width: fit-content; max-width: 100%; }
.quality-group { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.segment-icon { width: 14px; height: 14px; fill: currentColor; flex: none; }
.segment-caret { width: 14px; height: 14px; fill: var(--text-3); flex: none; margin-left: -2px; }
.segment[aria-pressed="true"] .segment-caret { fill: var(--text-2); }
/* 档位菜单从分组按钮上方弹出：按钮下面就是输入框，往下弹会盖住它 */
.quality-menu { position: absolute; z-index: 5; bottom: calc(100% + 6px); left: 0; min-width: 200px; padding: 6px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); box-shadow: 0 10px 30px color-mix(in srgb, var(--text) 14%, transparent); display: grid; gap: 2px; }
.quality-option { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 9px 12px; border-radius: 11px; background: transparent; color: var(--text); text-align: left; }
.quality-option:hover { background: var(--surface); }
.quality-option[aria-checked="true"] { background: var(--surface-2); }
.quality-option-main { font-size: 13px; font-weight: 550; }
.quality-option[aria-checked="true"] .quality-option-main { font-weight: 650; }
.quality-option-cost { flex: none; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.composer { border-radius: 20px; background: var(--surface); padding: 12px; display: grid; gap: 11px; }
.reference-list { display: flex; flex-wrap: wrap; gap: 9px; }
.reference-thumb { width: 62px; height: 62px; position: relative; }
.reference-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.reference-remove { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; color: var(--on-accent); background: var(--accent); display: grid; place-items: center; font-size: 15px; }
.reference-pick { display: block; width: 100%; height: 100%; padding: 0; background: transparent; border-radius: var(--radius-sm); }
.reference-pick:disabled { cursor: default; }
/* 角标摆在图片内部：探出去的部分会被容器裁掉，而它要一直看得见。 */
.reference-index { position: absolute; left: 4px; top: 4px; width: 17px; height: 17px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 600; }
.reference-hint { margin: 0; font-size: 12px; color: var(--text-3); }
.composer-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: end; gap: 10px; }
.round-button { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: 22px; }
.send-button { background: var(--accent); color: var(--on-accent); font-size: 19px; }
/* 输入框和它下面那层染色镜像叠在同一个网格单元里：宽高由同一个格子决定，
   两边的换行位置才不会算出两样。镜像只负责显示，textarea 只留光标。 */
/* 镜像用绝对定位铺满输入框：它要是参与布局，输入框每次量高度都会先被镜像
   撑到上一次的高度，删字之后就再也缩不回去了。 */
.prompt-field { position: relative; min-width: 0; }
.prompt-field textarea { display: block; width: 100%; }
.composer textarea { border: 0; outline: 0; resize: none; background: transparent; min-height: 42px; max-height: clamp(132px, 24dvh, 340px); padding: 10px 0 7px; line-height: 1.45; color: transparent; caret-color: var(--text); }
.prompt-mirror { position: absolute; inset: 0; padding: 10px 0 7px; line-height: 1.45; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word; pointer-events: none; }
/* 淡蓝底 + 品牌蓝字：一整句里插一块深蓝会把视线全吸过去，标记只要能认出来。 */
/* 不加粗：镜像的字宽一旦和 textarea 不一致，光标就会从标记后面开始偏。 */
.ref-token { color: var(--blue); background: color-mix(in srgb, var(--blue) 15%, transparent); border-radius: 3px; }
/* 文字是透明的，选中时得让底色自己撑出可读的对比。 */
.composer textarea::selection { background: color-mix(in srgb, var(--blue) 32%, transparent); }
.composer textarea::placeholder { color: var(--text-3); opacity: 1; }

.history-toolbar { display: flex; align-items: center; gap: 12px; }
.search-input { min-height: 42px; width: min(310px, 42vw); border-radius: 999px; }
.history-content { display: grid; gap: 26px; }
.history-group { display: grid; gap: 11px; }
.history-group h2 { margin: 0; color: var(--text-2); font-size: 13px; font-weight: 550; }
.history-grid { columns: 3 220px; column-gap: 14px; }
.history-card { width: 100%; display: block; break-inside: avoid; margin-bottom: 14px; border-radius: var(--radius-md); overflow: hidden; background: var(--surface); text-align: left; position: relative; }
.history-card img { width: 100%; height: auto; min-height: 140px; max-height: 420px; object-fit: cover; }
.history-card:active { transform: scale(.992); }
.history-empty { min-height: 55dvh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 14px; color: var(--text-2); }
.load-more { justify-self: center; }

.profile-view { max-width: 1080px; }
.identity { display: flex; align-items: center; gap: 15px; margin: 10px 0 22px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--text-2); font-size: 22px; font-weight: 650; }
.identity h2 { margin: 0 0 4px; font-size: 18px; }
.identity p { margin: 0; color: var(--text-2); font-size: 13px; }
.profile-overview { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 18px; margin-bottom: 20px; }
.credits-card, .membership-card { min-height: 250px; border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; }
.credits-card { background: var(--accent); color: var(--on-accent); }
.credits-card > span { color: color-mix(in srgb, var(--on-accent) 60%, transparent); font-size: 13px; }
.credits-number { margin: 8px 0 0; font-size: 48px; line-height: 1; letter-spacing: -1.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.credits-estimate { margin: 10px 0 0; color: color-mix(in srgb, var(--on-accent) 54%, transparent); font-size: 13px; }
.credits-actions { margin-top: auto; display: flex; gap: 10px; }
.credits-actions .primary-button { flex: 1; background: var(--on-accent); color: var(--accent); }
.credits-actions .secondary-button { background: color-mix(in srgb, var(--on-accent) 13%, transparent); color: var(--on-accent); }
.membership-card { background: var(--surface); }
.membership-card h2 { margin: 16px 0 5px; font-size: 20px; }
.membership-card p { margin: 0; color: var(--text-2); font-size: 14px; }
.membership-card button { margin-top: auto; align-self: flex-start; background: transparent; color: var(--blue); font-weight: 650; padding: 8px 0; }
.settings-list { display: grid; gap: 9px; }
.settings-row { width: 100%; min-height: 62px; border-radius: 17px; background: var(--surface); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 0 17px; text-align: left; }
.settings-row strong { font-size: 15px; font-weight: 550; }
.settings-row span { color: var(--text-2); font-size: 13px; }

.api-view { max-width: 1120px; margin: 0 auto; }
.api-view-header > div { display: grid; gap: 4px; }
.api-view-header h1 { margin: 0; }
.api-view-header p { margin: 0; color: var(--text-2); font-size: 13px; }
.back-link { width: fit-content; padding: 0 0 7px; background: transparent; color: var(--blue); font-size: 13px; }
.api-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr); gap: 18px; align-items: start; }
.api-card { border-radius: var(--radius-lg); background: var(--surface); padding: 24px; min-width: 0; }
.api-card h2 { margin: 0; font-size: 19px; }
.api-card h3 { margin: 24px 0 9px; font-size: 14px; }
.api-card > p { color: var(--text-2); font-size: 13px; line-height: 1.6; }
.api-card-title { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.api-card-title p { margin: 5px 0 0; color: var(--text-2); font-size: 13px; }
.key-count { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.api-upgrade { border-radius: var(--radius-md); background: var(--bg); padding: 18px; display: grid; gap: 10px; }
.api-upgrade p { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.api-upgrade .primary-button { width: fit-content; }
.api-key-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; margin-bottom: 16px; }
.api-key-list { display: grid; gap: 1px; border-radius: var(--radius-md); overflow: hidden; }
.api-key-row { min-height: 78px; padding: 13px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--bg); }
.api-key-row strong, .api-key-row code, .api-key-row span { display: block; }
.api-key-row code { margin-top: 4px; color: var(--text-2); font-size: 12px; }
.api-key-row span { margin-top: 4px; color: var(--text-3); font-size: 11px; }
.new-key { margin-bottom: 16px; padding: 15px; border-radius: var(--radius-md); background: color-mix(in srgb, #2ebf6b 10%, var(--bg)); border: 1px solid color-mix(in srgb, #2ebf6b 30%, transparent); }
.new-key > p { margin: 5px 0 10px; color: var(--text-2); font-size: 12px; }
.new-key > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.new-key code { padding: 10px; border-radius: 9px; background: var(--surface); overflow-wrap: anywhere; font-size: 12px; }
.new-key button, .code-line button { padding: 9px 11px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 12px; }
.api-rule { margin-top: 17px; padding: 14px; border-radius: var(--radius-md); background: var(--bg); display: grid; gap: 5px; }
.api-rule strong { font-size: 13px; }
.api-rule span { color: var(--text-2); font-size: 12px; line-height: 1.55; }
.code-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.code-line code, .code-block { background: var(--bg); }
.code-line code { min-width: 0; padding: 11px; border-radius: 10px; overflow-wrap: anywhere; font-size: 12px; }
.code-block { margin: 9px 0; padding: 14px; border-radius: 12px; overflow-x: auto; white-space: pre; font-size: 12px; line-height: 1.65; }
.copy-code { min-height: 34px; padding: 0 13px; font-size: 12px; }
.api-example-block { margin-top: 15px; }
.api-example-block > strong { display: block; color: var(--text-2); font-size: 12px; }
.api-params { display: grid; margin-top: 16px; border-top: 1px solid var(--line); }
.api-params > div { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.api-params span { color: var(--text-2); line-height: 1.55; }
.api-note { margin-bottom: 0; }

.modal { width: min(940px, calc(100vw - 32px)); max-height: min(90dvh, 920px); border: 0; padding: 0; border-radius: 26px; color: var(--text); background: var(--bg); box-shadow: 0 28px 90px rgba(0, 0, 0, .28); overflow: hidden; }
.modal::backdrop { background: rgba(0, 0, 0, .42); backdrop-filter: blur(10px); }
.modal-shell { max-height: min(90dvh, 920px); display: grid; grid-template-rows: auto minmax(0, 1fr); }
.modal-header { min-height: 64px; padding: 12px 20px 8px 26px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.close-button { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: 20px; }
.modal-body { min-height: 0; overflow: auto; padding: 0 26px 28px; }
.modal-loading { min-height: 360px; display: grid; place-items: center; color: var(--text-2); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 28px; align-items: center; }
.detail-image-frame { min-height: 520px; border-radius: var(--radius-lg); background: var(--surface); display: grid; place-items: center; overflow: hidden; }
.detail-image-frame img { max-height: 70dvh; width: 100%; height: 100%; object-fit: contain; }
.detail-info { display: grid; gap: 14px; }
.detail-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 12px; }
.detail-prompt { margin: 0; line-height: 1.6; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.vip-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 38px; }
.vip-intro h3 { margin: 0 0 7px; font-size: 32px; letter-spacing: -.7px; }
.vip-intro > p { margin: 0 0 20px; color: var(--text-2); line-height: 1.55; }
.benefits { display: grid; gap: 3px; }
.benefit { padding: 12px 0; display: grid; gap: 4px; }
.benefit strong { font-size: 14px; }
.benefit span { color: var(--text-2); font-size: 13px; }
.plans { display: grid; gap: 10px; }
.plan-row { width: 100%; min-height: 82px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; text-align: left; }
.plan-row[aria-pressed="true"] { border: 2px solid var(--text); padding: 13px 15px; }
.plan-row strong, .plan-row span { display: block; }
.plan-row span { margin-top: 3px; color: var(--text-2); font-size: 12px; }
.plan-price { font-size: 15px; font-weight: 650; }
.payment-note { color: var(--text-3); font-size: 12px; line-height: 1.5; text-align: center; }
.credit-pack-row { background: color-mix(in srgb, var(--blue) 5%, var(--surface)); }
.credit-pack-row:disabled { opacity: .55; cursor: not-allowed; }
.plans-panel { display: grid; gap: 14px; align-content: start; }
.vip-segmented { width: 100%; }
.vip-segmented .segment { flex: 1; }
.pack-locked { padding: 12px 14px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--blue) 10%, transparent); display: grid; gap: 3px; }
.pack-locked strong { font-size: 13px; color: var(--blue); }
.pack-locked span { color: var(--text-2); font-size: 12px; line-height: 1.5; }

.balance-block { margin-bottom: 18px; }
.balance-block span { color: var(--text-2); font-size: 13px; }
.balance-block strong { display: block; margin-top: 4px; font-size: 34px; letter-spacing: -.5px; }
.ledger-list, .invite-list { border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.ledger-row, .invite-row { min-height: 66px; padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.ledger-row:last-child, .invite-row:last-child { border-bottom: 0; }
.ledger-row strong, .ledger-row span, .invite-row strong, .invite-row span { display: block; }
.ledger-row span, .invite-row span { margin-top: 3px; color: var(--text-2); font-size: 12px; }
.ledger-amount { text-align: right; }
.invite-code-card { border-radius: var(--radius-lg); background: var(--accent); color: var(--on-accent); padding: 24px; display: grid; gap: 10px; }
.invite-code-card > span { color: color-mix(in srgb, var(--on-accent) 60%, transparent); font-size: 13px; }
.invite-code { font-size: clamp(29px, 6vw, 38px); letter-spacing: 6px; font-weight: 650; }
.invite-code-card p { margin: 0; color: color-mix(in srgb, var(--on-accent) 54%, transparent); font-size: 13px; }
.invite-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 20px; }
.stat { border-radius: var(--radius-md); background: var(--surface); padding: 16px; }
.stat span { color: var(--text-2); font-size: 13px; }
.stat strong { display: block; margin-top: 7px; font-size: 27px; }

.support-layout { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(0, 1.15fr); gap: 26px; }
.support-card { border-radius: var(--radius-lg); background: var(--surface); padding: 24px; display: grid; justify-items: center; gap: 10px; text-align: center; }
.support-card h3 { margin: 0; font-size: 16px; }
.support-card p { margin: 0; color: var(--text-2); font-size: 13px; }
.support-qr { width: min(238px, 70vw); aspect-ratio: 1; border-radius: var(--radius-sm); background: #fff; padding: 10px; margin: 7px 0; }
.faq-list { display: grid; align-content: center; gap: 10px; }
.faq-row { border-radius: var(--radius-md); background: var(--surface); padding: 18px; }
.faq-row summary { font-weight: 600; cursor: pointer; }
.faq-row p { color: var(--text-2); line-height: 1.6; font-size: 13px; }
.account-form { max-width: 480px; display: grid; gap: 14px; }
.about-center { display: grid; justify-items: center; text-align: center; gap: 10px; margin-bottom: 24px; }
.about-center img { width: 58px; height: 58px; border-radius: 18px; }

.retouch-modal { width: min(1180px, calc(100vw - 24px)); }
/* 按弹窗实际高度铺满，别用固定 620/520px —— 那在 1280×720 的窗口里
   会把「撤销 / 清除 / 开始优化」整排顶到视口外面去。 */
.retouch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; height: 100%; min-height: 360px; }
.retouch-canvas-wrap { position: relative; min-height: 0; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); display: grid; place-items: center; }
.retouch-canvas-wrap img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.retouch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.retouch-tools { display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; min-height: 0; overflow-y: auto; }
.brush-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.brush-row input { width: 100%; accent-color: var(--accent); }
.brush-preview { width: 28px; height: 28px; display: grid; place-items: center; }
.brush-preview::after { content: ""; width: var(--brush-preview, 14px); height: var(--brush-preview, 14px); border-radius: 50%; background: var(--surface-2); }
.retouch-hint { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.55; }

.toast-stack { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; width: min(440px, calc(100vw - 32px)); display: grid; gap: 8px; pointer-events: none; }
.toast { border-radius: 15px; padding: 13px 18px; background: var(--accent); color: var(--on-accent); text-align: center; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.18); animation: toast-in .22s ease both; }
.toast.error { background: var(--danger); color: #fff; }
/* 带按钮的提示要能点，所以单独把 toast-stack 上的 pointer-events: none 收回来 */
.toast.has-action { pointer-events: auto; display: flex; align-items: center; justify-content: center; gap: 12px; text-align: left; }
.toast.has-action > span { flex: 1; }
.toast-action { flex: none; border: 0; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; background: rgba(255,255,255,.22); color: inherit; }
.toast-action:hover { background: rgba(255,255,255,.34); }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-color-scheme: dark) {
  :root { --brand-filter: invert(1); }
  .auth-mark, .empty-mark img, .about-center img { filter: none; }
  .modal::backdrop { background: rgba(0,0,0,.66); }
}

@media (max-width: 899px) {
  .auth-page { grid-template-rows: 64px 1fr; }
  .auth-main { align-items: start; padding-top: 48px; }
  .app-shell { display: block; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main-view { min-height: calc(100dvh - 82px); padding: 12px 20px 24px; }
  .mobile-dock { position: fixed; left: 16px; right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 8; height: 58px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 5px; border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: 29px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(24px) saturate(150%); box-shadow: 0 14px 38px rgba(0,0,0,.16); }
  .dock-button { border-radius: 24px; display: grid; place-items: center; align-content: center; gap: 2px; background: transparent; color: var(--text-2); font-size: 10px; }
  .dock-button[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; }
  .dock-button .nav-glyph { width: 22px; height: 22px; color: inherit; }
  .dock-button .nav-glyph svg { width: 21px; height: 21px; }
  .view-header { margin-bottom: 12px; }
  .view-header h1 { display: none; }
  .create-view { height: auto; min-height: calc(100dvh - 126px); grid-template-rows: auto minmax(240px, 1fr) auto; }
  /* 窄屏是整页滚动，桌面那套「按舞台高度收」的约束这里要放开 */
  .create-stage { padding: 10px 0 14px; overflow: visible; }
  .generation-loading { height: auto; grid-template-rows: auto auto; }
  .skeleton-image { width: 100%; height: auto; max-height: 42dvh; }
  .empty-mark { width: 88px; height: 88px; }
  .suggestions { max-width: 330px; }
  .create-controls { gap: 8px; }
  .segmented, .quality-picker { width: 100%; }
  .segment { flex: 1; padding-inline: 9px; }
  .composer { border-radius: 18px; }
  .result-layout { display: grid; grid-template-columns: 1fr; height: auto; gap: 14px; }
  .result-image-wrap { align-self: auto; }
  .result-image { max-height: 48dvh; }
  .result-panel { text-align: center; }
  .result-actions { grid-template-columns: 1fr 1fr 1fr; }
  .result-actions .primary-button { grid-column: 1 / -1; }
  .history-toolbar { width: 100%; justify-content: flex-end; }
  .search-input { width: min(240px, 72vw); }
  .history-grid { columns: 2 130px; column-gap: 10px; }
  .history-card { margin-bottom: 10px; }
  .profile-overview { grid-template-columns: 1fr; }
  .api-grid { grid-template-columns: 1fr; }
  .api-view-header h1 { display: block; }
  .credits-card, .membership-card { min-height: 190px; }
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 24px); border-radius: 24px; }
  .modal-shell { max-height: calc(100dvh - 24px); }
  .modal-header { padding-inline: 18px 14px; }
  .modal-body { padding-inline: 18px; }
  .detail-layout, .vip-layout, .support-layout, .retouch-layout { grid-template-columns: 1fr; }
  .detail-image-frame { min-height: 42dvh; }
  .detail-image-frame img { max-height: 50dvh; }
  .vip-intro h3 { font-size: 28px; }
  .support-layout { gap: 16px; }
  .retouch-layout { height: auto; min-height: auto; }
  .retouch-canvas-wrap { min-height: 52dvh; }
  .retouch-tools { padding-bottom: 4px; overflow-y: visible; }
  .retouch-modal { width: calc(100vw - 12px); }
}

@media (max-width: 480px) {
  .main-view { padding-inline: 14px; }
  .empty-state p { max-width: 300px; }
  .segment { font-size: 11px; }
  .profile-overview { gap: 12px; }
  .settings-row { min-height: 56px; }
  .api-card { padding: 18px; }
  .api-key-form { grid-template-columns: 1fr; }
  .invite-stats { grid-template-columns: 1fr 1fr; }
}

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

@media (prefers-reduced-transparency: reduce) {
  .mobile-dock { background: var(--bg); backdrop-filter: none; }
  .modal::backdrop { backdrop-filter: none; }
}

/* --- 微信登录 ---
   用微信品牌绿而不是 --accent：微信登录是一个用户认得的第三方入口，
   长得跟本站主按钮一样反而会让人犹豫要不要点。深色模式下压暗一档，
   原色在深背景上过亮。 */
.wechat-button {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  background: #07c160;
  border: none;
  cursor: pointer;
}
.wechat-button:not(:disabled):active { transform: scale(.98); }
.wechat-glyph {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #07c160;
  background: #ffffff;
}
.wechat-hint { margin: -4px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }

/* 「或使用用户名」——两侧各一条线，靠 grid 而不是伪元素定位，
   文字变长变短都不用改数值。 */
.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  color: var(--text-3);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

@media (prefers-color-scheme: dark) {
  .wechat-button { background: #06a854; }
  .wechat-glyph { color: #06a854; }
}

/* 关掉自助注册后，「立即注册」按钮的位置换成一句说明，
   保持原来的间距，不然表单底部会突然缩一块。 */
.auth-switch-note {
  margin: 0;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}


/* ---------- 晒教程领会员 ---------- */
/* 奖励卡沿用邀请码卡那套深底反白，两个入口在「我的」页里是并排的一组，
   点开之后长得像同一件事才对。 */
.promo-reward-card {
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--on-accent);
  padding: 22px;
  display: grid;
  gap: 10px;
}
.promo-reward-card > span { color: color-mix(in srgb, var(--on-accent) 60%, transparent); font-size: 13px; }
.promo-reward-card p { margin: 4px 0 0; color: color-mix(in srgb, var(--on-accent) 50%, transparent); font-size: 12px; }
.promo-tier { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.promo-tier em {
  flex: none;
  font-style: normal;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--on-accent) 14%, transparent);
  color: var(--on-accent);
}
.promo-tier.highlight em { background: var(--on-accent); color: var(--accent); }
.promo-tier b { font-size: 15px; font-weight: 500; }

.promo-heading { margin: 22px 0 10px; font-size: 13px; font-weight: 600; }

/* 步骤：三段一行的面包屑，不再是带解释的列表 */
.promo-steps {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  /* 居中成组而不是 space-between：弹窗比手机宽得多，两端对齐会把三段拉到
     天各一方，中间的 › 看着像掉在那儿的标点。 */
  gap: 14px;
  font-size: 15px;
}
.promo-steps i { font-style: normal; color: var(--text-3); }
/* 窄屏收紧，逼它留在一行：一旦换行，行尾会甩下一个没有下文的 ›，
   比字小一号难看得多。 */
@media (max-width: 480px) {
  .promo-steps { gap: 8px; font-size: 14px; padding-inline: 12px; }
}

.promo-rules { margin-top: 20px; }
.promo-rules p { margin: 0 0 4px; color: var(--text-3); font-size: 13px; line-height: 1.9; }

/* 链接在窄屏上会把整行撑破，截断掉 */
.promo-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-text { color: var(--danger); }

/* 行动按钮放在奖励卡正下方，不放页尾也不用 sticky：规则和投稿记录加起来
   很长，按钮吸底会一直悬在内容上方挡住记录（窄屏尤其明显），而放页尾又要
   用户滚到最后才够得着。 */
.promo-actions { margin-top: 16px; display: grid; gap: 9px; }
.promo-actions .primary-button:disabled { opacity: .45; cursor: not-allowed; }
.promo-form { gap: 16px; }
