html { touch-action: manipulation; min-height: 100dvh; }
/* Claude Design System — warm cream canvas, coral accent (light) / immersive dark (dark) */
:root {
  --bg: #faf9f5;
  --card-bg: #ffffff;
  --text: #3d3d3a;
  --text-secondary: #787670;
  --border: #e6dfd8;
  --primary: #cc785c;
  --primary-active: #a9583e;
  --primary-disabled: #e6dfd8;
  --primary-subtle: rgba(204,120,92,0.12);
  --danger: #c64545;
  --warning: #d4a017;
  --success: #52c41a;
  --shadow: 0 1px 4px rgba(20,20,19,0.06);
  --shadow-hover: 0 2px 10px rgba(20,20,19,0.1);
  --shadow-lg: 0 4px 20px rgba(20,20,19,0.1);
  --input-bg: #faf9f5;
  --modal-overlay: rgba(20,20,19,0.6);
  --toolbar-bg: #f5f0e8;
  --mask-editor-border: #e6dfd8;
  --hairline: #eeeae2;
  --surface-card: #f8f5ef;
  --ink: #141413;
  --muted: #6c6a64;
  --on-primary: #ffffff;
  --on-surface: #3d3d3a;
  --accent-blue: #3498db;
  --accent-green: #2ecc71;
  --accent: #cc785c;
  --text-tertiary: #a09d96;
  --bg-secondary: #f5f5f0;
  --font-serif: "Cormorant Garamond", "EB Garamond", "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* ── Design tokens: spacing / font-size / radius / timing ── */
  --sp-1: 2px;  --sp-2: 4px;  --sp-3: 6px;  --sp-4: 8px;
  --sp-5: 12px; --sp-6: 16px; --sp-7: 20px; --sp-8: 24px;
  --fs-3xs: 9px; --fs-2xs: 10px; --fs-xs: 11px; --fs-sm: 12px;
  --fs-md: 13px; --fs-lg: 14px;  --fs-xl: 16px;  --fs-2xl: 18px;
  --r-sm: 4px;   --r-md: 6px;   --r-lg: 8px;   --r-xl: 12px;  --r-full: 9999px;
  --t-fast: 0.1s; --t-normal: 0.2s; --t-slow: 0.35s;
  --z-dropdown: 100; --z-sticky: 200; --z-modal: 300; --z-toast: 400; --z-overlay: 500;
}

/* 暗色模式（默认） */
html.theme-dark, html:not(.theme-light) {
  --bg: #0e0e10;
  --card-bg: #1c1c1e;
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --border: #2a2a2e;
  --primary: #a78bfa;
  --primary-active: #8b6fcf;
  --primary-disabled: #3d3d3a;
  --primary-subtle: rgba(167,139,250,0.12);
  --danger: #ef4444;
  --warning: #fbbf24;
  --success: #5db872;
  --shadow: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-hover: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.5);
  --input-bg: #1c1c1e;
  --modal-overlay: rgba(0,0,0,0.85);
  --toolbar-bg: #151517;
  --mask-editor-border: #3d3d3a;
  --hairline: #2a2a2e;
  --surface-card: #1c1c1e;
  --ink: #f4f4f5;
  --muted: #8a8a92;
  --on-primary: #1c1c1e;
  --on-surface: #f4f4f5;
  --accent-blue: #5dade2;
  --accent-green: #27ae60;
  --accent: #a78bfa;
  --text-tertiary: #6b6b75;
  --bg-secondary: #151517;
}
/* 亮色模式（手动切换） */
html.theme-light {
  --bg: #faf9f5;
  --card-bg: #ffffff;
  --text: #3d3d3a;
  --text-secondary: #787670;
  --border: #e6dfd8;
  --primary: #cc785c;
  --primary-active: #a9583e;
  --primary-disabled: #e6dfd8;
  --primary-subtle: rgba(204,120,92,0.12);
  --danger: #c64545;
  --warning: #d4a017;
  --success: #52c41a;
  --shadow: 0 1px 4px rgba(20,20,19,0.06);
  --shadow-hover: 0 2px 10px rgba(20,20,19,0.1);
  --shadow-lg: 0 4px 20px rgba(20,20,19,0.1);
  --input-bg: #faf9f5;
  --modal-overlay: rgba(20,20,19,0.6);
  --toolbar-bg: #f5f0e8;
  --mask-editor-border: #e6dfd8;
  --hairline: #eeeae2;
  --surface-card: #f8f5ef;
  --ink: #141413;
  --muted: #6c6a64;
  --on-primary: #ffffff;
  --on-surface: #3d3d3a;
  --accent-blue: #3498db;
  --accent-green: #2ecc71;
  --accent: #cc785c;
  --text-tertiary: #a09d96;
  --bg-secondary: #f5f5f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[v-cloak] { display: none !important; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* --sat / --sab 由 APK 原生注入（Android WebView 不支持 env(safe-area-*)） */
  padding-top: var(--sat, env(safe-area-inset-top, 0px));
  padding-bottom: var(--sab, env(safe-area-inset-bottom, 0px));
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  min-height: 100dvh;
  overflow-x: hidden;
}
.container { max-width: 500px; margin: 0 auto; padding: 12px 16px 16px; }
.card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 16px;
  position: relative;
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) {
  .card {
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.05);
  }
}
button.card {
  display: block;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  line-height: inherit;
  height: auto;
  min-height: unset;
}
.card-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 19px;
  margin-bottom: 8px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
button {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.2s;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:active {
  background: var(--primary-active);
  transform: scale(0.97);
}
button:disabled {
  background: var(--primary-disabled);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}
button.secondary {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  font-weight: 400;
}
button.secondary:active { background: var(--hairline); }
button.active { background: var(--primary); color: var(--on-primary); }
input, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--input-bg);
  color: var(--ink);
  transition: border-color 0.15s;
  height: 40px;
}
textarea {
  height: auto;
  min-height: 80px;
  max-height: 30vh;
  line-height: 1.55;
  field-sizing: content;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}
.text-muted { color: var(--text-secondary); font-size: 13px; }
.img-thumb { width: 100%; border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.modal-mask {
  position: fixed;
  top:0; left:0; right:0; bottom:0;
  background: var(--modal-overlay);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:200;
  overscroll-behavior: contain;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-mask.show {
  opacity: 1;
}
.modal-content {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--card-bg);
  border-radius:12px;
  padding:16px;
  max-width:90%;
  width:320px;
  max-height:80vh;
  overflow-y:auto;
  color: var(--text);
  border: 1px solid var(--hairline);
  transform: scale(0.95) translateY(4px);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}
.modal-content.show {
  transform: scale(1) translateY(0);
  opacity: 1;
}
}
.btn-sm {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 500;
  height: auto;
  line-height: 1.4;
}
.btn-sm.primary {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
}
.btn-sm.danger {
  background: var(--danger);
  color: var(--on-primary);
  border: none;
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  height: auto;
  line-height: 1.4;
  white-space: nowrap;
}
.btn-ghost:active { background: var(--border); }
.card-actions {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  height: auto;
  line-height: 1.4;
}
.action-btn:active { background: var(--border); }
.favorite-btn .star { font-size: 14px; color: var(--muted); }
.favorite-btn.active {
  background: #fff3e0;
  border-color: #e8a55a;
}
.favorite-btn.active .star { color: #e8a55a; }
.filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.filters input { flex: 1; min-width: 120px; }
.filter-btn {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  font-family: var(--font-sans);
  border-radius: 8px;
  padding: 8px 14px;
  height: auto;
  line-height: 1.4;
  border: none;
}
.filter-btn.active {
  background: var(--surface-card);
  color: var(--ink);
  border: none;
}
.mask-editor {
  position: relative;
  margin: 8px 0;
  overflow: hidden;
  border: 1px solid var(--mask-editor-border);
  border-radius: 8px;
  background: #000;
  width: 100%;
}
.mask-editor canvas { display: block; transform-origin: top left; }
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  background: var(--toolbar-bg);
  padding: 8px;
  border-radius: 8px;
}
.toolbar input[type="range"] { width: 80px; }

.task-progress {
  padding: 12px 0;
  text-align: center;
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #e8a55a);
  border-radius: 3px;
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}
.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.15) 50%,
    transparent 100%);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.progress-text {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.generating-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 高频 inline style 抽取，减少 template token */
.css-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.css-section-hdr { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.css-filter-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.css-flex-cell { display: flex; gap: 4px; align-items: center; }
.css-grid-btn { padding: 8px 4px; font-size: 12px; }
.css-full-btn { width: 100%; padding: 10px 0; text-align: center; }
.css-res-btn { padding: 6px 8px; font-size: 11px; border-radius: 6px; }
.css-select { flex: 1; min-width: 0; padding: 4px 4px; font-size: 12px; }
.res-active { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }

/* ===== 底部 Tab 栏 ===== */
.bottom-tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--surface-card);
  border-top: 1px solid var(--hairline);
  z-index: 100; padding-bottom: var(--sab, 0px);
  height: 64px;
}
@media (prefers-color-scheme: dark) {
  .bottom-tabs {
    background: rgba(18,18,20,0.86);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(255,255,255,0.08);
  }
}
.bottom-tabs .tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; border: none; background: none;
  color: var(--text-secondary); font-size: 11px; padding: 6px 0;
  transition: color var(--t-normal) ease; user-select: none; -webkit-tap-highlight-color: transparent;
}
.bottom-tabs .tab-item.active { color: var(--primary); }
.bottom-tabs .tab-item.active::after {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%;
  height: 2.5px; background: var(--primary); border-radius: 0 0 2px 2px;
}
.bottom-tabs .tab-item .tab-icon { font-size: 22px; line-height: 1; pointer-events: none; -webkit-touch-callout: none; }
.bottom-tabs .tab-item span { font-size: 10px; }
.container { padding-bottom: calc(16px + var(--sab, 0px)); }

/* ===== 折叠卡片 ===== */
.collapsible-header {
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.collapsible-header .collapse-arrow {
  font-size: 12px; color: var(--text-secondary); transition: transform 0.2s;
}
.collapsible-header .collapse-arrow.open { transform: rotate(180deg); }

@media (max-width: 360px) {
  .container { padding: 8px; }
  .card { padding: 12px; margin-bottom: 8px; }
  button { padding: 8px 16px; font-size: 13px; height: 36px; }
}

@media (min-width: 768px) {
  .container { max-width: 960px; }
  .desktop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .desktop-grid .card { margin-bottom: 0; }
  .desktop-grid .full-width { grid-column: 1 / -1; }
  .history-masonry { column-count: 5; column-gap: 12px; }
  .history-masonry > div { margin-bottom: 12px; }
  .modal-content { max-width: 600px !important; width: auto !important; }
  .card:hover { box-shadow: var(--shadow-hover); }
  button:not(:disabled):hover { background: var(--primary-active); box-shadow: 0 2px 8px rgba(204,120,92,0.25); }
  button.secondary:not(:disabled):hover { background: var(--border); }
}

.hist-filter-sticky {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  padding-bottom: 4px;
}
.hist-loading {
  text-align: center; padding: 16px; font-size: 12px;
  color: var(--text-secondary); grid-column: 1 / -1;
}

.zoom-grab { cursor: grab; }
.zoom-grab:active { cursor: grabbing; }
.zoom-content { position: relative; z-index: 1; }

/* ===== 弹窗固定关闭按钮 ===== */
.modal-close-area {
  position: sticky; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center;
  padding: 12px 0; padding-bottom: calc(12px + var(--sab, 0px));
  background: linear-gradient(transparent, var(--modal-overlay) 40%);
  z-index: 1000; pointer-events: none;
}
.modal-close-btn {
  pointer-events: auto;
  display: inline-block; padding: 10px 40px;
  background: var(--card-bg); color: var(--text);
  border-radius: 24px; font-size: 15px; font-weight: 500;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2); cursor: pointer;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.modal-close-btn:active { opacity: 0.8; }

.toast-container {
  position: fixed;
  top: calc(16px + var(--sat, 24px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 90%;
}
.toast {
  pointer-events: auto;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--on-primary);
  box-shadow: 0 4px 16px rgba(20,20,19,0.15);
  animation: toastIn 0.3s ease;
  cursor: pointer;
  text-align: center;
  word-break: break-word;
}
.toast-success { background: #5db872; }
.toast-error { background: #c64545; }
.toast-info { background: var(--primary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-fade-enter-active,
.page-fade-leave-active {
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.page-fade-enter-from {
  opacity: 0;
  transform: translateY(8px);
}
.page-fade-leave-to {
  opacity: 0;
  transform: translateY(-8px);
}

.preview-modal {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}
.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(20,20,19,0.6);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
  padding: 0;
  margin: 0;
}
.preview-nav:hover { background: rgba(20,20,19,0.8); }
.preview-nav:active { transform: translateY(-50%) scale(0.95); }
.preview-prev { left: 8px; }
.preview-next { right: 8px; }
.preview-counter {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,19,0.7);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  z-index: 10;
}

/* 图片详情翻页导航 — 全高固定侧边，点击区域大 */
.detail-nav {
  position: fixed;
  top: 0; bottom: 0;
  width: 48px;
  background: transparent;
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.detail-nav-prev { left: 0; }
.detail-nav-next { right: 0; }
.detail-counter {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 3px 14px;
  border-radius: 14px;
  font-size: 12px;
  z-index: 9999;
  line-height: 1.6;
  pointer-events: none;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-state-text {
  font-size: 14px;
  margin-bottom: 4px;
}
.empty-state-hint {
  font-size: 12px;
  opacity: 0.7;
}

.history-masonry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.history-masonry > div {
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  transition: transform 0.2s, box-shadow 0.2s;
  aspect-ratio: 1;
}
.history-masonry > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 6px rgba(20,20,19,0.08);
}
.history-masonry > div[draggable="true"] {
  cursor: grab;
}
.history-masonry > div[draggable="true"]:active {
  cursor: grabbing;
  opacity: 0.8;
}
.history-masonry > div.drag-over {
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.02);
}
.history-masonry img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.hist-tag {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text);
  padding: 2px 8px;
  border-radius: 9999px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
}
.hist-tag-expand { background: #f5f0e8; }
.hist-tag-model { background: #f5f0e8; }
.hist-tag-lora { background: #f5f0e8; }
.hist-tag-source { background: #f5f0e8; }
.hist-page-info {
  font-size: 13px;
  color: var(--text-secondary);
}
.hist-page-select {
  padding: 6px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--input-bg);
  color: var(--ink);
  height: auto;
}
.hist-count {
  font-size: 12px;
  color: var(--text-secondary);
}
/* 长按多选（样式定义在底部重复区域，此处为占位） */
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--card-bg);
  border-top: 1px solid var(--hairline);
  margin-top: 4px;
  margin-bottom: 8px;
  border-radius: 8px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
@media (min-width: 768px) {
  .history-masonry { grid-template-columns: repeat(5, 1fr); gap: 12px; }
}

/* ===== 全屏图片查看器 (ImageViewer) ===== */
.iv-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 300;
  background: rgba(0,0,0,0);
  opacity: 0;
  transition: opacity 0.3s ease, background 0.3s ease;
  touch-action: none;
  display: flex;
  flex-direction: column;
}

/* 顶栏 */
.iv-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
  background: linear-gradient(rgba(0,0,0,0.4), transparent);
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.iv-topbar > * { pointer-events: auto; }
.iv-topbar-hide { opacity: 0; }

.iv-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.iv-counter {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

/* 图片区域 */
.iv-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.iv-img-wrap:active { cursor: grabbing; }

.iv-img-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}
.iv-img-inner img, .iv-img-inner video {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* 底部 Sheet */
.iv-sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  min-height: 64px;
  max-height: 70vh;
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  z-index: 301;
  transform: translateY(100%);
  will-change: transform;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}

.iv-sheet-handle {
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.iv-handle-bar {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline);
}

.iv-sheet-body {
  padding: 0 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.iv-sheet-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 12px;
}
.iv-s-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--hairline);
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s;
}
.iv-s-btn:active { background: var(--border); }
.iv-s-btn-link { text-decoration: none; }

/* 非提示词区域不触发浏览器默认滚动，由 JS 拖拽控制 */
.iv-sheet-actions, .iv-sheet-meta { touch-action: none; }

.iv-sheet-meta {
  font-size: 12px;
  line-height: 1.8;
  margin-bottom: 8px;
}
.iv-meta-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}
.iv-meta-row span:first-child {
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 48px;
}
.iv-meta-row span:last-child {
  color: var(--text);
}

.iv-sheet-prompt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
  max-height: 160px;
  overflow-y: auto;
  word-break: break-all;
  margin-bottom: 0;
}
.iv-prompt-wrap {
  position: relative;
}
.iv-prompt-copy {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  border: none;
  border-radius: 4px;
  background: rgba(0,0,0,0.35);
  color: #fff;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  z-index: 2;
  padding: 0;
}
.iv-prompt-copy:hover {
  opacity: 1;
}

.iv-sheet-body { padding-bottom: calc(20px + var(--sab, 0px)); }

.history-masonry > div {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* 历史页多选 */
.hist-item-selected {
  outline: 2px solid var(--primary, #e67e22);
  outline-offset: -2px;
  border-radius: 4px;
}
.hist-checkbox {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 10;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.hist-checkbox.checked {
  background: var(--primary, #e67e22);
  border-color: var(--primary, #e67e22);
}
.hist-checkbox span {
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}
.hist-batch-bar {
  position: sticky;
  bottom: 60px;
  background: var(--card-bg, #fff);
  border-top: 1px solid var(--hairline, #eee);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
}

/* ===== Utility Classes (内联样式抽取) ===== */

/* --- Layout --- */
.flex-1 { flex: 1; }
.flex-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.flex-center { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.mw-0 { min-width: 0; }
.text-center { text-align: center; }
.justify-center { justify-content: center; }
.pos-relative { position: relative; }
.hidden { display: none !important; }
.clickable { cursor: pointer; }
.fw-medium { font-weight: 500; }

/* --- Grid --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 4px; }

/* --- Spacing --- */
.mt-2 { margin-top: 2px; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mb-4 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }

/* --- Typography --- */
.text-secondary { color: var(--text-secondary); }
.text-xs { font-size: 10px; color: var(--text-secondary); }
.text-sm { font-size: 11px; color: var(--text-secondary); }
.text-caption { font-size: 12px; color: var(--text-secondary); }
.text-micro { font-size: 9px; color: var(--text-secondary); }
.text-nowrap { white-space: nowrap; }
.text-highlight { font-size: 16px; font-weight: 600; color: var(--accent); }
.watermark { font-size: 28px; opacity: 0.3; line-height: 1; }
.icon-lg { font-size: 24px; color: #bbb; line-height: 1; }

/* --- Sizing --- */
.w-full { width: 100%; }
.w-50 { width: 50px; flex-shrink: 0; }
.w-52 { width: 52px; padding: 2px 4px; font-size: 10px; }
.w-56 { width: 56px; flex-shrink: 0; }
.w-label { width: 50px; text-align: right; color: var(--text-secondary); }
.h-90 { height: 90px; }
.icon-16 { width: 16px; height: 16px; }
.radius-6 { border-radius: 6px; }

/* --- Upload Zone --- */
.upload-zone {
  aspect-ratio: 3/4;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
}

/* --- Buttons (inline extracted) --- */
.btn-block { flex: 1; padding: 4px 0; font-size: 10px; }
.btn-block-sm { flex: 1; padding: 6px 0; font-size: 11px; }
.btn-block-xs { flex: 1; padding: 3px 0; font-size: 10px; }
.btn-tight { padding: 6px 0; font-size: 10px; }
.btn-compact { padding: 6px 0; font-size: 11px; }
.btn-narrow { padding: 4px 0; font-size: 10px; }
.btn-micro { padding: 2px 6px; font-size: 10px; }
.btn-ghost-lg { padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px; background: transparent; font-size: 16px; cursor: pointer; }
.chip-res { padding: 3px 8px; font-size: 10px; border-radius: 4px; cursor: pointer; border: 1px solid var(--hairline); background: var(--card-bg); color: var(--text); }
.chip-res-sm { padding: 4px 4px; font-size: 10px; border-radius: 4px; cursor: pointer; border: 1px solid var(--hairline); background: var(--card-bg); color: var(--text); }
.clickable-row-sm { font-size: 11px; cursor: pointer; display: flex; align-items: center; gap: 2px; }

/* --- High-frequency utilities (added Phase 1 design tokens) --- */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 2px; }
.gap-3 { gap: 3px; }
.radius-4 { border-radius: var(--r-sm); }
.radius-8 { border-radius: var(--r-lg); }
.radius-12 { border-radius: var(--r-xl); }
.text-3xs { font-size: var(--fs-3xs); }
.text-2xs { font-size: var(--fs-2xs); }
.text-on-primary { color: var(--on-primary); }
.bordered { border: 1px solid var(--border); }
.transition { transition: all var(--t-normal) ease; }
.pressable { transition: transform var(--t-fast) ease; }
.pressable:active { transform: scale(0.97); }

/* --- Cards --- */
.card-plain { padding: 8px; border: 1px solid var(--hairline); border-radius: 8px; }
.card-plain-center { padding: 8px; border: 1px solid var(--hairline); border-radius: 8px; text-align: center; }

/* --- Misc --- */
.badge-close {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,0.5); color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer;
  z-index: 1;
}
.badge-sm { font-size: 11px; padding: 3px 4px; }
.checkbox-fake { margin: 0; width: 12px; height: 12px; }
.progress-track { flex: 1; height: 6px; background: var(--hairline); border-radius: 3px; margin: 0 8px; overflow: hidden; }
.scroll-area { max-height: min(80dvh, 500px); overflow-y: auto; }
.select-sm { width: 100%; padding: 6px 8px; font-size: 12px; }
.preview-img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.abs-cover { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; }
.btn-lg-wide { width: 100%; padding: 12px 0; font-size: 15px; font-weight: 500; }
.btn-danger-xs { font-size: 10px; color: var(--danger); cursor: pointer; padding: 4px; }
.btn-full { width: 100%; padding: 10px 0; font-size: 14px; font-weight: 600; }
.btn-strip { padding: 5px 0; font-size: 11px; }
.section-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }

/* --- Thumbnails & Upload --- */
.upload-thumb { width: 64px; height: 64px; border-radius: 6px; margin: 0 auto; background: #f0f0f0; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.upload-thumb-placeholder { width: 64px; height: 64px; border-radius: 6px; margin: 0 auto; background: #f0f0f0; display: flex; align-items: center; justify-content: center; }
.badge-remove { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid var(--card-bg); z-index: 2; }

/* --- Dividers --- */
.divider-v { width: 1px; background: var(--border); align-self: center; height: 20px; }
.divider-v-sm { width: 1px; height: 14px; background: var(--border); }

/* --- Input/Textarea variants --- */
.textarea-sm { width: 100%; font-size: 12px; resize: vertical; }
.textarea-focused { width: 100%; box-sizing: border-box; font-size: 12px; padding: 8px; border: 1px solid var(--primary); border-radius: 8px; min-height: 80px; resize: vertical; font-family: inherit; line-height: 1.5; }
.input-sm { width: 100%; font-size: 12px; padding: 6px; border-radius: 6px; border: 1px solid var(--border); }
.input-xs { width: 100%; font-size: 11px; padding: 4px; }
.input-micro { width: 100%; font-size: 11px; padding: 3px 4px; }

/* --- Lists & Expand --- */
.list-item-divider { padding: 6px 0; font-size: 12px; border-bottom: 1px solid var(--hairline); }
.expand-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 12px; cursor: pointer; }
.expand-card { padding: 12px; border: 1px solid var(--hairline); border-radius: 8px; margin-bottom: 8px; text-align: left; }
.badge-pill { padding: 6px 10px; font-size: 11px; white-space: nowrap; }

/* --- Misc --- */
.abs-fill { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.py-4 { padding: 4px 0; }
.m-0 { margin: 0; }
.w-120 { width: 120px; }
.w-60 { width: 60px; padding: 4px; font-size: 12px; }
.h-120 { height: 120px; }
.rounded { border-radius: 6px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.bordered-radius { border: 1px solid var(--hairline); border-radius: 8px; overflow: hidden; }
.count-primary { color: var(--primary); font-size: 12px; font-weight: 600; }
.dim-input { width: 60px; padding: 4px 8px; font-size: 12px; text-align: center; }
.abs-close { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff; border: none; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; z-index: 10; }
.grid-btn { padding: 6px; font-size: 11px; border: 1px solid var(--hairline); border-radius: 6px; background: var(--card-bg); cursor: pointer; text-align: center; }
.prompt-area-xs { width: 100%; min-height: 60px; padding: 8px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 12px; font-family: inherit; resize: vertical; box-sizing: border-box; background: var(--input-bg); color: var(--ink); }
.prompt-area-sm { width: 100%; min-height: 80px; padding: 8px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical; box-sizing: border-box; background: var(--input-bg); color: var(--ink); }

/* ===== 绫消息特殊样式 ===== */
.chat-msg-ling {
  background: linear-gradient(135deg, #e8dff5 0%, #d8c8f0 100%) !important;
  border-left: 3px solid var(--primary) !important;
  color: #2a2235 !important;
}
@media (prefers-color-scheme: dark) {
  .chat-msg-ling {
    background: linear-gradient(135deg, #3d2f54 0%, #4a3465 100%) !important;
    border-left: 3px solid var(--primary) !important;
    color: #f0eaf8 !important;
  }
}

/* ===== 绫侧聊抽屉 ===== */
.ling-drawer-mask {
  position: fixed; inset: 0; z-index: 160;
  background: rgba(0,0,0,0.4);
  display: flex; justify-content: flex-end;
}
.ling-drawer {
  width: 85%; max-width: 420px; height: 100%;
  background: var(--card-bg);
  display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  animation: lingSlideIn 0.22s ease;
}
@keyframes lingSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.ling-drawer-head {
  flex-shrink: 0; display: flex; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--hairline);
  background: linear-gradient(135deg, #e8dff5 0%, #d8c8f0 100%);
}
@media (prefers-color-scheme: dark) {
  .ling-drawer-head { background: linear-gradient(135deg, #3d2f54 0%, #4a3465 100%); }
}
.ling-drawer-body {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.ling-msg { display: flex; }
.ling-msg-user { justify-content: flex-end; }
.ling-msg-ling { justify-content: flex-start; }
.ling-msg-bubble {
  max-width: 82%; padding: 9px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.55; word-break: break-word; white-space: pre-wrap;
}
.ling-msg-user .ling-msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ling-msg-ling .ling-msg-bubble {
  background: linear-gradient(135deg, #e8dff5 0%, #d8c8f0 100%);
  color: #2a2235; border-bottom-left-radius: 4px; border-left: 3px solid var(--primary);
}
@media (prefers-color-scheme: dark) {
  .ling-msg-ling .ling-msg-bubble {
    background: linear-gradient(135deg, #3d2f54 0%, #4a3465 100%); color: #f0eaf8;
  }
}
.ling-drawer-quick {
  flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 12px; border-top: 1px solid var(--hairline);
}
.ling-drawer-quick button {
  flex: 1; min-width: 80px; padding: 8px 6px; font-size: 11px;
  border: 1px solid var(--primary); border-radius: 10px;
  background: var(--primary-subtle); color: var(--primary);
  cursor: pointer; height: auto; min-height: unset; white-space: nowrap;
}
.ling-drawer-quick button:disabled { opacity: 0.5; cursor: default; }
.ling-drawer-input {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 12px; border-top: 1px solid var(--hairline);
}

/* ===== 滚动条美化 (暗色) ===== */
@media (prefers-color-scheme: dark) {
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
}

/* ===== 图片结果渐入动画 ===== */
.result-fade-enter-active {
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.result-fade-enter-from {
  opacity: 0;
  transform: scale(0.95) translateY(8px);
}

/* ===== 模态框（无动画，避免浏览器卡死） ===== */

/* ===== 自定义范围滑块 ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ===== AI 女仆管家聊天页 ===== */
.chat-page { position:fixed;top:var(--sat, env(safe-area-inset-top, 0px));bottom:var(--sab, env(safe-area-inset-bottom, 0px));left:0;right:0;max-width:500px;margin:0 auto;display:flex;flex-direction:column;overflow:hidden; }
.chat-header { display:flex;justify-content:space-between;align-items:center;padding:4px 0 8px;border-bottom:1px solid var(--hairline);flex-shrink:0;background:var(--bg); }
/* 汉堡图标 — 4条不同长度横杠 */
.hamburger {
  width:36px; height:36px; padding:8px 6px; border:none; background:none;
  display:flex; flex-direction:column; justify-content:center; gap:4px;
  cursor:pointer; border-radius:8px; min-height:unset;
}
.hamburger span { display:block; height:2px; border-radius:1px; background:var(--text); transition:all var(--t-normal) ease; }
.hamburger span:nth-child(1) { width:18px; }
.hamburger span:nth-child(2) { width:24px; }
.hamburger span:nth-child(3) { width:20px; }
.hamburger span:nth-child(4) { width:14px; }
.hamburger:active { background:var(--hairline); }
/* 抽屉 */
.drawer-overlay {
  position:fixed; top:0; left:0; right:0; bottom:0;
  background:rgba(0,0,0,0.4); z-index:150;
  transition:opacity var(--t-normal) ease;
}
.drawer {
  position:fixed; top:0; left:0; bottom:0; width:min(300px, 82vw);
  background:var(--card-bg); z-index:151;
  transform:translateX(-100%); transition:transform var(--t-normal) ease;
  display:flex; flex-direction:column;
  box-shadow:2px 0 20px rgba(0,0,0,0.2);
}
.drawer-right { left:auto; right:0; transform:translateX(100%); box-shadow:-2px 0 20px rgba(0,0,0,0.2); }
.drawer-open { transform:translateX(0); }
.drawer-header { display:flex;align-items:center;justify-content:space-between;padding:16px 18px;padding-top:calc(16px + var(--sat, 24px));border-bottom:1px solid var(--hairline); }
.drawer-body { flex:1; overflow-y:auto; padding:12px 0; overscroll-behavior:contain; -webkit-overscroll-behavior:contain; scrollbar-gutter:stable; }
.drawer-section { padding:0 14px; margin-bottom:12px; padding-bottom:12px; border-bottom:1px solid var(--hairline); }
.drawer-section:last-child { border-bottom:none; margin-bottom:0; padding-bottom:0; }
.drawer-label { font-size:10px; color:var(--text-tertiary); text-transform:uppercase; letter-spacing:0.06em; margin-bottom:6px; padding:0 4px; }
.drawer-chars { display:flex; flex-direction:column; gap:2px; }
.drawer-char-item {
  display:flex; align-items:center; gap:10px; padding:8px 12px;
  border-radius:10px; font-size:12px; cursor:pointer; border:none;
  background:transparent; color:var(--text); transition:background var(--t-fast);
  height:auto; min-height:unset; justify-content:flex-start;
}
.drawer-char-item.active { background:var(--primary-subtle); color:var(--primary); font-weight:600; }
.drawer-char-item:active { background:var(--hairline); }
.drawer-menu-btn {
  display:block; width:100%; text-align:left; padding:9px 14px;
  border:none; border-radius:10px; background:transparent; color:var(--text);
  font-size:12px; cursor:pointer; height:auto; min-height:unset;
  justify-content:flex-start;
}
.drawer-menu-btn:active { background:var(--hairline); }
.chat-messages { flex:1; min-height:0; overflow-y:auto; padding:8px 4px; display:flex; flex-direction:column; gap:8px; }
.chat-welcome { text-align:center;padding:40px 16px; }
.chat-msg { display:flex;gap:6px;margin-bottom:8px; }
.chat-msg-user { flex-direction:row-reverse; }
.chat-msg-assistant { flex-direction:row; }
.chat-msg-avatar { width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0;background:var(--hairline); }
.chat-msg-body { max-width:85%;display:flex;flex-direction:column; }
.chat-msg-user .chat-msg-body { align-items:flex-end; }
.chat-msg-assistant .chat-msg-body { align-items:flex-start; }
.chat-bubble { padding:10px 12px;border-radius:12px;font-size:13px;line-height:1.5;word-break:break-word;white-space:pre-wrap; }
.chat-msg-user .chat-bubble { background:var(--primary);color:#fff;border-bottom-right-radius:4px; }
.chat-msg-assistant .chat-bubble { background:var(--card-bg);border:1px solid var(--hairline);border-bottom-left-radius:4px;color:var(--text); }
.chat-msg-time { font-size:8px;color:var(--text-tertiary);padding:2px 4px 0; }
.chat-thinking { color:var(--text-secondary) !important;font-style:italic; }
.dot-anim { animation:dotPulse 1.5s infinite; }
@keyframes dotPulse { 0%,100%{opacity:0.3} 50%{opacity:1} }
/* 聊天输入栏 — 一整条圆角bar */
.chat-input-bar {
  flex-shrink:0; margin:8px 0 4px; padding:4px;
  display:flex; align-items:center; gap:8px;
  background:var(--card-bg); border:1px solid var(--border);
  border-radius:28px; position:relative;
}
.chat-input-wrap { position:relative; }
.chat-mode-tag {
  font-size:10px; padding:3px 8px; border-radius:10px;
  border:1px solid var(--hairline); cursor:pointer;
  color:var(--text-secondary); user-select:none;
}
.chat-mode-tag.active {
  background:var(--primary); color:var(--on-primary); border-color:var(--primary);
}
.chat-bar-plus {
  width:38px; height:38px; min-width:38px;
  border-radius:50%; border:2px solid var(--border);
  background:transparent; color:var(--text-secondary);
  font-size:24px; font-weight:300; line-height:1;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; padding:0;
}
.chat-bar-plus:active { background:var(--hairline); }
.chat-bar-send {
  width:38px; height:38px; min-width:38px;
  border-radius:50%; border:none;
  background:var(--primary); color:var(--on-primary);
  font-size:20px; font-weight:600;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; padding:0;
}
.chat-bar-send:active { opacity:0.8; transform:scale(0.93); }
.chat-bar-send:disabled { opacity:0.4; }
.chat-plus-backdrop { position:fixed; top:0; left:0; right:0; bottom:0; z-index:49; }
.chat-plus-menu {
  position:absolute; bottom:52px; left:4px;
  background:var(--card-bg); border:1px solid var(--border);
  border-radius:14px; padding:6px; z-index:50;
  display:flex; flex-direction:column; gap:2px;
  box-shadow:0 4px 20px rgba(0,0,0,0.3);
  min-width:140px;
}
.chat-plus-item {
  display:flex; align-items:center; gap:10px;
  padding:10px 14px; border:none; border-radius:10px;
  background:transparent; color:var(--text);
  font-size:13px; cursor:pointer; white-space:nowrap;
  height:auto; min-height:unset; justify-content:flex-start;
}
.chat-plus-item:active { background:var(--hairline); }
.chat-plus-icon { font-size:18px; width:24px; text-align:center; }
/* 图片生成占位卡片 */
.chat-img-placeholder {
  margin-top:6px; padding:32px 20px;
  background:var(--card-bg); border:1px solid var(--hairline);
  border-radius:10px; text-align:center;
  color:var(--text-secondary); font-size:12px;
  min-height:160px; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:8px;
}
.chat-img-spinner {
  width:28px; height:28px;
  border:2px solid var(--hairline);
  border-top-color:var(--primary);
  border-radius:50%;
  animation:imgSpin 0.8s linear infinite;
}
@keyframes imgSpin { to { transform: rotate(360deg); } }
/* 快捷操作按钮（出图后） */
.chat-quick-actions {
  display:flex; flex-wrap:wrap; gap:6px; margin-top:8px;
}
.chat-quick-actions span {
  font-size:11px; padding:6px 14px;
  border:1px solid var(--border); border-radius:16px;
  cursor:pointer; user-select:none;
  color:var(--text); background:var(--card-bg);
  transition:all var(--t-fast) ease;
}
.chat-quick-actions span:active {
  background:var(--primary); color:var(--on-primary); border-color:var(--primary);
}
.chat-quick-actions .chat-quick-done {
  background:var(--primary); color:var(--on-primary); border-color:var(--primary);
  font-weight:600;
}
/* 提示词/指令卡片毛玻璃 */
.chat-glass-card {
  background:rgba(255,255,255,0.04) !important;
  backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(255,255,255,0.08) !important;
}

/* ===== 顶部导航栏 ===== */
.app-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:4px 0 8px; position:sticky; top:0; z-index:90;
  background:var(--bg);
}
.header-title { letter-spacing:-0.01em; }
/* 页面切换按钮 — 九宫格图标 */
.page-switch-btn {
  width:36px; height:36px; padding:6px; border:none; background:none;
  display:grid; grid-template-columns:repeat(3,1fr); gap:3px;
  cursor:pointer; border-radius:8px; min-height:unset;
}
.page-switch-btn span {
  display:block; width:6px; height:6px; border-radius:1.5px;
  background:var(--text-secondary);
}
.page-switch-btn:active { background:var(--hairline); }
/* ===== 固定底部输入栏（text2img / expand / inpaint 复用） ===== */
.page-with-input {
  display:flex; flex-direction:column;
  height:calc(100vh - 64px - var(--sab, 0px) - var(--sat, 24px));
  height:calc(100dvh - 64px - var(--sab, 0px) - var(--sat, 24px));
}
.page-scroll { flex:1; overflow-y:auto; padding-bottom:8px; -webkit-overflow-scrolling:touch; }
.page-input-bar {
  flex-shrink:0; padding:4px 0 8px;
  border-top:1px solid var(--hairline);
  background:var(--bg);
}

/* ===== 平板断点 (480-768px) ===== */
@media (min-width: 480px) {
  .container { max-width: 720px; }
  .history-masonry { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 600px) {
  .container { max-width: 860px; }
}

.chat-hdr-btn{padding:4px 10px;font-size:12px;cursor:pointer;color:var(--text-secondary);border:1px solid var(--border);border-radius:6px;background:none;font-family:inherit;touch-action:manipulation;-webkit-tap-highlight-color:transparent;}
.btn-press:active{transform:scale(0.95);opacity:0.8;transition:all 0.08s;}