/* ==========================================================================
   K·绘 / KreaCanvas — 设计系统（撞色浅色：奶白纸 + 深 teal 主色 + 珊瑚红点缀）
   单一视觉事实来源。亮色为默认；[data-theme="dark"] 覆盖。
   双色系统：--accent = 深 teal（主操作/链接/聚焦/选中态）；
            --accent2 = 珊瑚红（收藏星/放大角标/管理箭头等强调处）。
   ========================================================================== */

/* ---------- 设计 Token：亮色（默认） ---------- */
:root {
  /* 配色（撞色浅色：奶白纸 + 深 teal 主色 + 珊瑚红点缀） */
  --bg: #fbf7ef;
  --surface: #ffffff;
  --surface-2: #f3f0e6;
  --surface-3: #e9e5d6;
  --border: #e4e0d0;
  --border-strong: #cfcab5;
  --text: #14201c;
  --text-2: #45544c;
  --text-3: #7f8a81;
  --accent: #0f6b5c;
  --accent-hover: #0c5c4f;
  --accent-press: #094a40;
  --accent-soft: rgba(15, 107, 92, 0.1);
  --accent-soft-2: rgba(15, 107, 92, 0.18);
  --accent2: #d64541;
  --accent2-hover: #c23732;
  --accent2-soft: rgba(214, 69, 65, 0.1);
  --ok: #3f8f6b;
  --error: #c23732;

  /* 阴影（中性偏绿黑） */
  --shadow-sm: 0 1px 2px rgba(20, 32, 28, 0.05), 0 1px 3px rgba(20, 32, 28, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 32, 28, 0.08), 0 2px 6px rgba(20, 32, 28, 0.05);
  --shadow-lg: 0 24px 60px -18px rgba(20, 32, 28, 0.22), 0 8px 24px -12px rgba(20, 32, 28, 0.12);

  /* 圆角 */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;

  /* 字体 */
  --font-serif: "Newsreader", "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* 节奏 */
  --maxw: 1240px;
  --nav-h: 66px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: light;
}

/* ---------- Token：暗色（同方向：深绿黑底 + 亮 teal + 珊瑚） ---------- */
[data-theme="dark"] {
  --bg: #0e1513;
  --surface: #18201a;
  --surface-2: #1f2a22;
  --surface-3: #273329;
  --border: #2a352c;
  --border-strong: #3b463b;
  --text: #e8efe9;
  --text-2: #b7c5bb;
  --text-3: #7e8c80;
  --accent: #3cc0a5;
  --accent-hover: #56cdb3;
  --accent-press: #2aa890;
  --accent-soft: rgba(60, 192, 165, 0.14);
  --accent-soft-2: rgba(60, 192, 165, 0.24);
  --accent2: #e2685f;
  --accent2-hover: #ec7c74;
  --accent2-soft: rgba(226, 104, 95, 0.16);
  --ok: #6cb98a;
  --error: #e0685e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
img {
  max-width: 100%;
  display: block;
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: none;
  background: none;
}
a {
  color: var(--accent);
  text-decoration: none;
}
::selection {
  background: var(--accent-soft-2);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 排版 ---------- */
.serif {
  font-family: var(--font-serif);
}
h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   布局
   ========================================================================== */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---------- 顶栏 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-serif);
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand__mark {
  width: 30px;
  height: 30px;
  flex: none;
}
.nav__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 图标按钮（语言/主题/关于） */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.lang-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-strong);
}

/* 账户：导航用户名 chip + 登出 */
.nav__user {
  font-size: 0.8rem;
  color: var(--text-2);
  padding: 0 6px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-signout {
  font-size: 0.82rem;
  color: var(--text-2);
  border: 1px solid var(--border-strong);
}
.nav-signout:hover {
  color: var(--error);
  border-color: var(--error);
}

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 28px;
  text-align: center;
  max-width: 760px;
  margin-inline: auto;
}
.hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.hero__kicker::before,
.hero__kicker::after {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--accent-soft-2);
}
.hero__title {
  font-size: clamp(2.1rem, 5.2vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.hero__title em {
  font-style: italic;
  color: var(--accent);
}
.hero__sub {
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  color: var(--text-2);
  max-width: 560px;
  margin-inline: auto;
}

/* ---------- 工作区（两栏） ---------- */
.workspace {
  display: grid;
  grid-template-columns: 416px 1fr;
  gap: 28px;
  align-items: start;
  padding: 12px 0 64px;
}

/* 控制面板（左） */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--nav-h) + 20px);
}
.field {
  margin-bottom: 20px;
}
.field:last-child {
  margin-bottom: 0;
}
.field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 9px;
  letter-spacing: 0.01em;
}
.field__label .hint {
  font-weight: 500;
  color: var(--text-3);
  font-size: 0.76rem;
}

/* 文本域 */
.textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  padding: 14px 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.textarea::placeholder {
  color: var(--text-3);
}
.input {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 灵感芯片行 */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-2);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.chip:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-soft-2);
}

/* 分段控件（比例） */
.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
}
.segmented__btn {
  padding: 8px 4px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.segmented__btn:hover {
  color: var(--text);
}
.segmented__btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* 滑块 */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  cursor: pointer;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-val {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text-2);
  min-width: 42px;
  text-align: right;
}

/* 种子行 */
.seed-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.seed-row .input {
  flex: 1;
  font-family: var(--font-mono);
}

/* 高级（内联折叠） */
.advanced {
  border-top: 1px dashed var(--border);
  padding-top: 14px;
  margin-top: 4px;
}
.adv-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-3);
  background: none;
  border: none;
  transition: color 0.2s var(--ease);
}
.adv-toggle:hover {
  color: var(--accent);
}
.adv-caret {
  width: 12px;
  height: 12px;
  transition: transform 0.28s var(--ease);
}
.advanced[data-open="true"] .adv-caret {
  transform: rotate(180deg);
}

/* 平滑展开：grid-template-rows 0fr → 1fr */
.adv-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s var(--ease);
}
.adv-panel__inner {
  overflow: hidden;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.24s var(--ease);
}
.adv-panel__inner .field {
  margin-bottom: 0;
}
.advanced[data-open="true"] .adv-panel {
  grid-template-rows: 1fr;
}
.advanced[data-open="true"] .adv-panel__inner {
  opacity: 1;
  padding-top: 16px;
}
.adv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 640px) {
  .adv-grid {
    grid-template-columns: 1fr;
  }
}

/* 较小文本域（负向提示词） */
.textarea--sm {
  min-height: 64px;
}

/* 字段下提示文字 */
.field__hint {
  margin-top: 9px;
  font-size: 0.76rem;
  color: var(--text-3);
  line-height: 1.5;
}

/* 画质档位分段 */
/* 画质档位：单行不换行，两两细线分隔，标签+倍率横向排 */
.segmented--quality {
  display: flex;
  grid-template-columns: none; /* 覆盖 .segmented 的 grid */
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
}
.q-btn {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 8px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
    box-shadow 0.18s var(--ease), opacity 0.18s var(--ease);
}
/* 细线分隔（非首项左侧） */
.q-btn:not(:first-child)::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  height: 56%;
  width: 1px;
  background: var(--border);
}
.q-btn:hover {
  color: var(--text);
}
.q-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.q-btn[aria-pressed="true"]::before {
  background: transparent; /* 选中项不显示左侧分隔线 */
}
.q-btn__label {
  font-size: 0.82rem;
  font-weight: 600;
}
.q-btn__mult {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
}
.q-btn[aria-pressed="true"] .q-btn__mult {
  color: var(--accent);
}
/* 每图 HD 放大选择器（浮层） */
.upscale-menu {
  margin: 4px auto 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 264px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  padding: 6px;
  animation: pop 0.2s var(--ease);
}
.upscale-menu.popover {
  position: fixed;
  margin: 0;
  z-index: 300; /* 高于灯箱(200)，防止浮层被遮 */
}
.upscale-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--text-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.upscale-menu__item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.upscale-menu__label {
  font-size: 0.9rem;
  font-weight: 600;
}
.upscale-menu__hint {
  font-size: 0.72rem;
  color: var(--text-3);
}
.upscale-menu__cancel {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  color: var(--text-3);
  text-align: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.upscale-menu__cancel:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

/* 生成按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px 20px;
  border-radius: var(--r);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.2s var(--ease), transform 0.12s var(--ease), box-shadow 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:active {
  transform: translateY(1px);
}
.btn--primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}
.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}
.btn--primary:active {
  background: var(--accent-press);
}
.btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-strong);
}
.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn--soft {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn--soft:hover {
  background: var(--accent-soft-2);
}
.btn--soft:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--soft:disabled:hover {
  background: var(--accent-soft);
}
.btn--sm {
  padding: 9px 14px;
  font-size: 0.85rem;
  border-radius: var(--r-sm);
}
.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.btn--sm svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   画布（右）
   ========================================================================== */
.canvas {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.canvas__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: relative;
}

/* 空态 */
.empty {
  text-align: center;
  color: var(--text-3);
  max-width: 320px;
}
.empty__mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  opacity: 0.5;
}
.empty__title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--text-2);
  margin-bottom: 6px;
}

/* 等待态（签名） */
.loading {
  text-align: center;
}
.loading__visual {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 26px;
}
.loading__spark {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  animation: breathe 2.4s var(--ease) infinite;
}
.loading__visual::before,
.loading__visual::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ripple 2.4s var(--ease) infinite;
}
.loading__visual::after {
  animation-delay: 1.2s;
}
.loading__phase {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 12px;
  min-height: 1.5em;
}
.loading__timer {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--accent);
  margin-bottom: 6px;
}
.loading__usual {
  font-size: 0.86rem;
  color: var(--text-3);
}

/* 结果 */
.result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.result__img-wrap {
  position: relative;
  max-width: 100%;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--surface-2);
}
.result__img {
  display: block;
  max-width: 100%;
  max-height: min(68vh, 720px);
  width: auto;
  height: auto;
  border-radius: var(--r-lg);
}
.result__img.reveal {
  animation: reveal 0.6s var(--ease) both;
}
.result__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  font-size: 0.86rem;
  color: var(--text-2);
}
.result__meta span b {
  color: var(--text);
  font-weight: 600;
}
.result__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ==========================================================================
   历史
   ========================================================================== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 8px 0 18px;
}
.section-head h2 {
  font-size: 1.4rem;
}
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding-bottom: 64px;
}
.history-item {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.history-item__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.history-item:hover .history-item__overlay {
  opacity: 1;
}
.history-item__btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.92);
  color: #1a1915;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.history-item__btn:hover {
  background: #fff;
}
.history-item__btn svg {
  width: 15px;
  height: 15px;
}
.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-3);
  padding: 40px 0;
  font-size: 0.95rem;
}

/* ==========================================================================
   页脚
   ========================================================================== */
.footer {
  border-top: 1px solid var(--border);
  padding: 34px 0 48px;
  color: var(--text-3);
  font-size: 0.86rem;
}
.footer__top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.footer__disclaimer {
  max-width: 560px;
  line-height: 1.65;
}

/* ==========================================================================
   模态（密码门 / 关于）
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 60%, rgba(0, 0, 0, 0.28));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.3s var(--ease);
}
.overlay[hidden] {
  display: none;
}
.modal {
  width: 100%;
  max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  text-align: center;
  animation: pop 0.32s var(--ease);
}
.modal__mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
}
.modal__title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin-bottom: 8px;
}
.modal__sub {
  color: var(--text-2);
  font-size: 0.94rem;
  margin-bottom: 24px;
}
.modal .input {
  text-align: center;
  padding: 13px 15px;
  font-size: 1rem;
  margin-bottom: 10px;
}
.modal__error {
  color: var(--error);
  font-size: 0.84rem;
  min-height: 1.2em;
  margin-bottom: 8px;
}
.modal__hint {
  color: var(--text-3);
  font-size: 0.8rem;
  margin-top: 18px;
  line-height: 1.6;
}
.modal__body {
  text-align: left;
  color: var(--text-2);
  font-size: 0.96rem;
  line-height: 1.7;
  margin-bottom: 24px;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 460px);
  padding: 13px 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease);
}
.toast--error {
  border-color: color-mix(in srgb, var(--error) 45%, var(--border));
}
.toast--error .toast__dot {
  background: var(--error);
}
.toast--ok .toast__dot {
  background: var(--ok);
}
.toast__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ==========================================================================
   动效
   ========================================================================== */
@keyframes breathe {
  0%, 100% { transform: scale(0.86); opacity: 0.65; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes ripple {
  0% { transform: scale(0.7); opacity: 0.55; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes reveal {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fade 0.5s var(--ease) both;
}

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .panel {
    position: static;
  }
  .canvas {
    min-height: 440px;
    order: -1; /* 移动端：画布在上 */
  }
}
@media (max-width: 640px) {
  .container {
    padding-inline: 16px;
  }
  .hero {
    padding: 36px 0 20px;
  }
  .panel,
  .modal {
    padding: 20px;
    border-radius: var(--r-lg);
  }
  .canvas {
    border-radius: var(--r-lg);
    min-height: 360px;
  }
  .result__img {
    max-height: 56vh;
  }
  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }
  .nav__actions .icon-btn[data-hide-sm] {
    display: none;
  }
}

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .loading__spark {
    animation: none;
    opacity: 0.85;
  }
  .loading__visual::before,
  .loading__visual::after {
    display: none;
  }
}

/* 工具类 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}

/* ==========================================================================
   Phase C —— 视图 / home / workspace / 聊天时间线 / turn 卡 / composer
   ========================================================================== */
/* 视图切换：默认隐藏，按 data-view 显示对应视图 */
.view {
  display: none;
  padding-top: 6px;
}
[data-view="home"] #view-home,
[data-view="library"] #view-library,
[data-view="trash"] #view-trash,
[data-view="tokens"] #view-tokens,
[data-view="admin"] #view-admin {
  display: block;
}
/* workspace 是 flex 分栏布局（单独声明，避免 .view--workspace 的 flex 常驻覆盖隐藏） */
[data-view="workspace"] #view-workspace {
  display: flex;
}

/* ---------- HOME（提示词为核心，居中克制） ---------- */
.home {
  max-width: 640px;
  margin: 0 auto;
  padding: 44px 0 80px;
}
.home__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.home__kicker::before,
.home__kicker::after {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--accent-soft-2);
}
.home__title {
  font-size: clamp(1.85rem, 4.6vw, 2.7rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.home__sub {
  color: var(--text-2);
  font-size: 1rem;
  margin-bottom: 26px;
}
.home__compose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.home__generate {
  margin-top: 4px;
}
.textarea--home {
  min-height: 110px;
  font-size: 1.02rem;
}

/* ---------- WORKSPACE ---------- */
.ws-topbar {
  position: sticky;
  top: var(--nav-h);
  z-index: 20;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 0 12px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.ws-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  color: var(--text-2);
}
.ws-count {
  color: var(--accent);
  margin-left: 6px;
  font-size: 0.9rem;
}

/* ---------- 聊天时间线 ---------- */
.timeline {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 0 200px; /* 底部留给 sticky composer */
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.timeline__empty {
  text-align: center;
  color: var(--text-3);
  padding: 72px 0;
  font-size: 0.96rem;
}

/* ---------- turn 卡 ---------- */
.turn {
  animation: fade 0.4s var(--ease) both;
}
.turn__prompt {
  display: flex;
  justify-content: flex-start; /* 左对齐提示词气泡 */
  margin-bottom: 12px;
}
.turn__prompt-inner {
  max-width: 82%;
}
.turn__prompt-text {
  display: inline-block;
  max-width: 88%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); /* 对称圆角（不再是聊天气泡角） */
  padding: 12px 15px;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
.turn__prompt-meta {
  display: none; /* 已废弃：尺寸/档位信息在图下方 meta 区，提示词旁不再显示 */
}
.turn__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* 左对齐（图片/元信息/按钮） */
  gap: 14px;
  border-top: 1px solid var(--border); /* 提示词框与图片之间的细线 */
  padding-top: 16px;
}
.turn__status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.turn__error {
  color: var(--error);
  font-size: 0.9rem;
}

/* turn 等待态（呼吸动效，复用品牌 spark） */
.turn__loader {
  text-align: left;
  padding: 10px 0;
}
.turn__loader-visual {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 0 14px;
}
.turn__spark {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 40px;
  height: 40px;
  animation: breathe 2.4s var(--ease) infinite;
}
.turn__loader-visual::before,
.turn__loader-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ripple 2.4s var(--ease) infinite;
}
.turn__loader-visual::after {
  animation-delay: 1.2s;
}
.turn__phase {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
  min-height: 1.2em;
  transition: opacity 0.18s var(--ease);
}
.turn__timer {
  font-size: 0.82rem;
  color: var(--accent);
}

/* turn 媒体 */
.turn__media {
  width: 100%;
  display: flex;
  justify-content: flex-start; /* 图片左对齐 */
}
.turn__img {
  max-width: 100%;
  max-height: min(62vh, 680px);
  width: auto;
  height: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  background: var(--surface-2);
}
.turn__img.reveal {
  animation: reveal 0.6s var(--ease) both;
}
.turn__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px 20px;
  font-size: 0.82rem;
  color: var(--text-2);
}
.turn__meta span b {
  color: var(--text);
  font-weight: 600;
}
.turn__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

/* ---------- composer（sticky 底栏） ---------- */
.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding: 12px 0 16px;
}
.composer__inner,
.composer__bar,
.composer__input {
  max-width: 820px;
  margin: 0 auto;
}
.composer__inner {
  padding: 0 4px;
}
.composer__bar {
  display: flex;
  flex-direction: column; /* 比例与画质各占一行，避免窄栏内互相挤压换行 */
  align-items: stretch;
  gap: 8px;
  padding: 0 24px 8px;
}
.composer__bar .segmented {
  flex: 0 1 auto;
}
.composer__adv {
  margin-left: auto;
  padding: 6px 4px;
}
.composer .advanced {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.composer__input {
  display: flex;
  flex-direction: column; /* 竖排：输入框整宽在上，发送键整宽在下，左右与分段对齐 */
  align-items: stretch;
  gap: 10px;
  padding: 0 24px;
}
.composer__textarea {
  flex: 1;
  width: 100%;
  min-height: 88px; /* 默认 ~3 行，便于看清多行提示词 */
  max-height: 200px; /* 可拖至约 2×+，超长提示词框内滚动 */
  resize: vertical; /* 允许用户自由拉高/缩短 */
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.96rem;
  line-height: 1.5;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.composer__textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer__send {
  flex: none;
  width: 100%; /* 整宽条，与输入框/分段左右对齐 */
  height: 48px;
  padding: 0 18px;
}

/* 紧凑分段控件（composer 用） */
.segmented--mini {
  padding: 3px;
}
/* 数量分段：4 个选项（覆盖 .segmented 默认 5 列） */
.segmented--count {
  grid-template-columns: repeat(4, 1fr);
}
.segmented--mini .segmented__btn,
.segmented--mini .q-btn {
  padding: 6px 4px;
  font-size: 0.74rem;
}
.segmented--mini .q-btn__label {
  font-size: 0.74rem;
}
.segmented--mini .q-btn__mult {
  font-size: 0.62rem;
}

/* ---------- 顶栏视图按钮 ---------- */
.nav-view-btn {
  font-weight: 600;
}

/* ---------- 响应式（Phase C） ---------- */
@media (max-width: 640px) {
  .home {
    padding: 28px 0 60px;
  }
  .home__compose {
    padding: 18px;
    border-radius: var(--r-lg);
  }
  .composer__bar {
    gap: 6px;
  }
  .composer__bar .segmented {
    flex: 1 1 auto;
  }
  .composer__adv {
    margin-left: 0;
  }
  .turn__img {
    max-height: 56vh;
  }
}

/* 尊重减少动效（turn 加载动效） */
@media (prefers-reduced-motion: reduce) {
  .turn__spark {
    animation: none;
    opacity: 0.85;
  }
  .turn__loader-visual::before,
  .turn__loader-visual::after {
    display: none;
  }
}

/* ==========================================================================
   Stage 2 —— 工作区 app shell（聊天+画布分栏 / 移动端 tab）+ 会话分镜板
   覆盖 Stage 1 的 fixed composer / 普通文档流布局。
   ========================================================================== */
.view--workspace {
  flex-direction: column;
  height: calc(100vh - var(--nav-h) - 10px);
  min-height: 0;
  /* 全幅：突破 container 的 1240 居中，让画布拿到更大宽度 */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding-inline: 20px;
  box-sizing: border-box;
}
body {
  overflow-x: clip; /* 防止 100vw 引起的横向滚动条，且不破坏 sticky nav */
}
.view--workspace .ws-topbar {
  position: relative;
  top: auto;
  flex: none;
}
.ws-split {
  flex: 1;
  display: flex;
  gap: 16px;
  min-height: 0;
}
.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  flex: 1 1 0;
}
.pane--chat {
  overflow: hidden;
}
.view--workspace .timeline {
  flex: 1;
  overflow-y: auto;
  padding: 20px 4px 16px;
  max-width: none;
  overscroll-behavior: contain;
}
/* composer 改为 chat 面板内 in-flow（覆盖 Stage 1 的 position:fixed） */
.view--workspace .composer {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  flex: none;
  padding: 8px 0 12px;
}
.view--workspace .composer__bar,
.view--workspace .composer__input {
  max-width: none;
  padding-inline: 0;
}

/* 画布面板 */
.pane--canvas {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.board-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.board-zoom {
  display: flex;
  gap: 4px;
}
.board-zoom-btn {
  min-width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: 700;
}
.board-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle at 1px 1px, var(--border-strong) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
}
.board-viewport:active {
  cursor: grabbing;
}
.board-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.board-node {
  position: absolute;
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  outline: 2px solid transparent;
  transition: box-shadow 0.2s var(--ease), outline-color 0.2s var(--ease);
}
.board-node:hover {
  box-shadow: var(--shadow-lg);
  outline-color: var(--accent-soft-2);
}
.board-node img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.board-node__badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 0.62rem;
  color: #fff;
  background: var(--accent2); /* 珊瑚红：放大角标 */
  padding: 1px 6px;
  border-radius: var(--r-pill);
  pointer-events: none;
}
.board-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-3);
  padding: 40px;
  font-size: 0.92rem;
  pointer-events: none;
}
.board-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 0.68rem;
  color: var(--text-3);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  pointer-events: none;
}

/* tabs（移动端） */
.ws-tabs {
  display: none;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
}
.ws-tab {
  padding: 5px 14px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.ws-tab[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* 画布浮层菜单（复用 .upscale-menu 视觉） */
.board-menu {
  position: fixed;
  z-index: 300; /* 高于灯箱(200) */
  max-width: 240px;
}
.board-menu__item {
  justify-content: flex-start !important;
}

/* 响应式：桌面分栏 / 移动 tab */
@media (min-width: 981px) {
  .ws-tabs {
    display: none !important;
  }
  .ws-split {
    flex-direction: row;
  }
  .pane--chat {
    flex: 0 0 440px;
    max-width: 480px;
  }
  .pane--canvas {
    flex: 1 1 0;
    min-width: 0;
  }
}
@media (max-width: 980px) {
  .ws-tabs {
    display: flex;
  }
  .ws-split {
    flex-direction: column;
  }
  .view--workspace[data-active-pane="chat"] #pane-canvas,
  .view--workspace[data-active-pane="canvas"] #pane-chat {
    display: none;
  }
}
@media (max-width: 640px) {
  .view--workspace {
    height: calc(100vh - var(--nav-h) - 4px);
  }
  .board-toolbar {
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   灯箱（图片详情 / 缩放查看）
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 9, 8, 0.93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  animation: fade 0.25s var(--ease);
}
.lightbox[hidden] {
  display: none;
}
.lightbox__stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.lightbox__stage:active {
  cursor: grabbing;
}
.lightbox__img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 94vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%) translate(0px, 0px) scale(1);
  transform-origin: center;
  will-change: transform;
  border-radius: var(--r);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.35s var(--ease);
}
/* 渐进加载：全图未就绪时缩略图模糊占位，加载完去模糊淡入 */
.lightbox__img--loading {
  filter: blur(14px) saturate(0.92);
}
.lightbox__close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 5;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease);
}
.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.26);
}
.lightbox__bar {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 26px;
}
.lightbox__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
}
.lightbox__meta span b {
  color: #fff;
  font-weight: 600;
}
.lightbox__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.lightbox__actions .btn--soft {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.lightbox__actions .btn--soft:hover {
  background: rgba(255, 255, 255, 0.26);
}
.lightbox__hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

/* ==========================================================================
   作品库 / 回收站 / 超管后台（账户系统）
   ========================================================================== */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 0 56px;
}
.page__head {
  margin-bottom: 22px;
}
.page__title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  margin-bottom: 4px;
}
.page__sub {
  color: var(--text-2);
  font-size: 0.92rem;
}

/* 工具栏 */
.lib-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.lib-search {
  flex: 1 1 240px;
  min-width: 200px;
}
.lib-search.input {
  padding: 10px 14px;
  font-size: 0.92rem;
}

/* 网格 */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.lib-card {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
  border: 1px solid var(--border);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.lib-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.lib-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lib-card__fav {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease);
}
.lib-card:hover .lib-card__fav,
.lib-card__fav.is-fav {
  opacity: 1;
}
.lib-card__fav.is-fav {
  background: var(--accent2); /* 珊瑚红：收藏强调 */
}
.lib-card__badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: var(--accent2); /* 珊瑚红：放大角标 */
  color: #fff;
  font-size: 0.66rem;
  padding: 2px 7px;
  border-radius: var(--r-pill);
}
.lib-card__check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}
.lib-empty {
  text-align: center;
  color: var(--text-3);
  padding: 56px 0;
  font-size: 0.92rem;
}
.lib-more {
  text-align: center;
  margin-top: 22px;
}

/* 回收站操作条 */
.trash-bar {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.trash-select-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  color: var(--text-2);
  cursor: pointer;
}
.trash-count {
  font-size: 0.82rem;
  color: var(--text-3);
}
.trash-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.trash-delete:hover {
  color: var(--error);
  border-color: var(--error);
}

/* 令牌 */
.tokens-create {
  margin-bottom: 16px;
}
.tokens-usage {
  margin-top: 20px;
  font-size: 0.78rem;
  line-height: 1.6;
  word-break: break-all;
}
.token-reveal__box {
  margin: 8px 0 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  word-break: break-all;
  user-select: all;
  text-align: left;
}

/* 超管：首页管理入口卡 */
.admin-entry {
  margin-top: 26px;
}
.admin-entry__card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: left;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.admin-entry__card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.admin-entry__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.admin-entry__title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
}
.admin-entry__sub {
  font-size: 0.84rem;
  color: var(--text-2);
}
.admin-entry__arrow {
  width: 20px;
  height: 20px;
  color: var(--accent2); /* 珊瑚红点缀 */
  flex: none;
  transition: transform 0.2s var(--ease);
}
.admin-entry__card:hover .admin-entry__arrow {
  transform: translateX(3px);
}

/* 超管：统计卡 */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 18px 16px;
}
.stat-card__label {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card__value {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  line-height: 1;
}

/* 超管：区块 + 表格 */
.admin-section {
  margin-bottom: 34px;
}
.admin-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.admin-section__head h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
}
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 640px;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-table .role-tag {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.admin-table .role-tag--admin {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.admin-table .status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}
.admin-table .status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3aa66a;
}
.admin-table .status-dot.is-disabled::before {
  background: var(--text-3);
}
.admin-table .row-actions {
  display: flex;
  gap: 6px;
}
.admin-table .row-actions button {
  font-size: 0.76rem;
  padding: 5px 9px;
}

@media (max-width: 640px) {
  .lib-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .trash-actions {
    margin-left: 0;
    width: 100%;
  }
}

/* ==================== 功能增强：风格 / LoRA / ✨改写（PLAN-FEATURES §7） ==================== */
.enhancer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 0 2px;
}
.enhancer__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.enhancer__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}
.enhancer__tools {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.enhancer .styleGroup {
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  max-width: 460px;
}
.chip--tool {
  cursor: pointer;
  font-weight: 500;
  background: var(--surface);
}
.chip--tool:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.chip__count {
  font-size: 0.72rem;
  opacity: 0.8;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
}
/* composer 内的紧凑版 */
.enhancer--composer {
  padding: 6px 0;
  gap: 8px 12px;
}
.enhancer--composer .enhancer__tools {
  margin-left: 0;
}
.enhancer--composer .styleGroup {
  grid-template-columns: repeat(6, auto);
}
.slider--sm {
  width: 84px;
  height: 4px;
}

/* ---- LoRA 弹层 ---- */
.modal--lora {
  max-width: 640px;
  width: 100%;
  text-align: left;
  padding: 24px 0 0;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.lora__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px 12px;
}
.lora__head .modal__title {
  margin: 0;
  font-size: 1.25rem;
}
.lora__slots {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
}
.lora__close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-2);
  cursor: pointer;
  padding: 0 4px;
}
.lora__close:hover {
  color: var(--accent2);
}
.lora__hint {
  padding: 0 28px 14px;
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-2);
}
.lora__body {
  overflow-y: auto;
  padding: 0 28px 28px;
}
.lora__section {
  margin-bottom: 18px;
}
.lora__section h4 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lora-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.lora-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.lora-card--sel {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lora-card--bound {
  cursor: default;
  background: var(--surface-2);
  border-style: dashed;
}
.lora-card__img {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-3);
}
.lora-card__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lora-card__name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.lora-card__desc {
  font-size: 0.76rem;
  color: var(--text-2);
  line-height: 1.35;
}
.lora-card__trig {
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0.85;
}
.lora-card__tag {
  font-size: 0.72rem;
  color: var(--accent2);
  font-weight: 500;
}
.lora-card__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.lora-card__check {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 700;
  min-height: 18px;
}

/* ---- timeline 提示词详情 ---- */
.turn__prompt {
  cursor: default;
}
.turn__detail-toggle {
  display: inline-block;
  margin-left: 8px;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-weight: 600;
}
.turn__detail-toggle:hover {
  background: var(--accent-soft-2);
}
.turn__detail-toggle[hidden] {
  display: none;
}
.turn__detail {
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.turn__drow {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  align-items: baseline;
}
.turn__drow > span {
  color: var(--text-2);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 64px;
}
.turn__drow code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}
.turn__drow b {
  color: var(--accent);
}

@media (max-width: 640px) {
  .enhancer__tools {
    margin-left: 0;
    width: 100%;
  }
  .modal--lora {
    padding: 20px 0 0;
  }
  .lora__head,
  .lora__hint,
  .lora__body {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* ==================== composer 排版重构（2026-08-12）：标签上移 + 发丝分隔 + 风格/Lora + 网格横排 pill ==================== */
/* 首页：控件组之间发丝线分隔 */
.home__compose .field--divider {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 6px;
}

/* 风格区：chips 单行 + Lora 按钮 */
.style-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.style-chips {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
  scrollbar-width: thin;
}
.style-chips::-webkit-scrollbar { height: 4px; }
.style-chips::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.style-chips .segmented__btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 7px 12px;
}

/* 画布 composer：控件组（标签在上 + 发丝竖线分隔） */
.composer__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
}
.composer__controls .cc {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 14px;
  min-width: 0;
}
.composer__controls .cc:first-child { padding-left: 0; }
.composer__controls .cc + .cc { border-left: 1px solid var(--border); }
.cc__label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cc--style { flex: 1 1 220px; }
.composer__chiprow {
  padding: 8px 0 4px;
  gap: 8px;
}

/* 优化扩写 / 翻译 按钮活动态 */
.chip--act { cursor: pointer; }
.chip--act.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-soft-2);
  font-weight: 600;
}

/* 网格 / 横排：两个独立 pill 按钮 */
.board-layout {
  display: flex;
  gap: 8px;
}
.board-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.board-pill svg { width: 16px; height: 16px; }
.board-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.board-pill[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 720px) {
  .composer__controls .cc { padding: 0 10px; }
  .composer__controls .cc + .cc { border-left: none; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
}

/* 动作按钮加载态（处理中脉冲，消除卡顿无反馈感） */
.chip--act.is-loading {
  opacity: 0.75;
  cursor: wait;
  animation: chipPulse 1.1s ease-in-out infinite;
  border-color: var(--accent-soft-2);
  color: var(--accent);
}
@keyframes chipPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
