/* ============================================================
   DualStar · 设置 app
   ============================================================ */

.settings-view {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100lvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.settings-shell {
  position: relative;
  width: var(--phone-w);
  height: var(--phone-h);
  max-height: 100vh;
  background: var(--bg);
  border-radius: var(--phone-radius);
  box-shadow:
    0 0 0 12px var(--bg-elevated),
    0 0 0 13px var(--border-strong),
    var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .settings-shell {
    width: 100vw;
    height: 100vh;
    height: 100lvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* —— 全屏模式 —— */
/* 基础样式已由 base.css 统一处理（窗口化） */

/* 平板/桌面端全屏模式：双栏布局 */
@media (min-width: 769px) {
  [data-display-mode="fullscreen"] .settings-dual {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: row;
  }

  [data-display-mode="fullscreen"] .settings-sidebar {
    width: 260px;
    min-width: 240px;
    max-width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
    overflow: hidden;
  }

  [data-display-mode="fullscreen"] .settings-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-header {
    padding: 20px 20px 16px;
    padding-top: calc(20px + var(--safe-area-top, env(safe-area-inset-top, 0px)));
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
  }

  [data-display-mode="fullscreen"] .settings-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    padding: 16px 12px 8px;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
    margin-bottom: 2px;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-item:hover {
    background: var(--surface);
    color: var(--text);
  }

  [data-display-mode="fullscreen"] .settings-sidebar-item.active {
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-weight: 500;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  [data-display-mode="fullscreen"] .settings-sidebar-item-label {
    font-size: 14px;
    flex: 1;
  }

  [data-display-mode="fullscreen"] .settings-main-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding: 24px 32px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }

  [data-display-mode="fullscreen"] .settings-main-header {
    padding: 16px 32px;
    padding-top: calc(16px + var(--safe-area-top, env(safe-area-inset-top, 0px)));
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: none;
  }

  [data-display-mode="fullscreen"] .settings-main-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
  }
}

/* 桌面端更宽的侧栏 */
@media (min-width: 1200px) {
  [data-display-mode="fullscreen"] .settings-sidebar {
    width: 280px;
    max-width: 320px;
  }
}

.settings-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
  padding-top: calc(14px + var(--safe-area-top, env(safe-area-inset-top, 0px)));
}

.settings-nav-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
}

.settings-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
}
.settings-nav-btn:hover { background: var(--surface); }

.settings-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 16px 32px;
  -webkit-overflow-scrolling: touch;
}

/* —— 设置项分组 —— */
.settings-section {
  margin-bottom: 28px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 0 4px;
}

.settings-group {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast);
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: var(--bg-soft); }

.settings-row-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-row-body {
  flex: 1;
  min-width: 0;
}

.settings-row-title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
}

.settings-row-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-row-value {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-row-arrow {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* —— API 表单 —— */
.api-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.api-status.ok {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.api-status.err {
  background: var(--danger);
  color: var(--text-inverse, #fff);
}

.api-status.idle {
  background: var(--surface);
  color: var(--text-secondary);
}

.api-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* —— 相册管理 —— */
.album-manager-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.album-manager-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--surface);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.album-manager-item:not([style*="background-image"]) {
  animation: albumMgrPulse 1.2s ease-in-out infinite;
}
@keyframes albumMgrPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.3; }
}

.album-manager-item-empty {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
}
.album-manager-item-empty:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.album-manager-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.album-manager-item:hover .album-manager-delete {
  opacity: 1;
}

/* —— 纪念日管理 —— */
.anniv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.anniv-manage-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-elevated));
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-deep, var(--text));
  transition: background var(--dur-fast);
}
.anniv-manage-hero:hover { background: var(--accent-soft); }
.anniv-manage-hero svg { color: var(--text-tertiary); }

.anniv-mng-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.anniv-mng-item:hover { background: var(--bg-soft); transform: translateY(-1px); }

.anniv-mng-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--anniv-accent, var(--accent)) 18%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.anniv-mng-body {
  flex: 1;
  min-width: 0;
}

.anniv-mng-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anniv-mng-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}

.anniv-mng-days {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  margin-right: 6px;
}
.anniv-mng-days.today {
  background: #ff8fab;
  color: #fff;
}

.anniv-mng-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.anniv-mng-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}
.anniv-mng-btn:hover { background: var(--surface); color: var(--text); }

/* —— 纪念日编辑器 —— */
.anniv-editor {
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}

.anniv-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.anniv-type-pill {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--dur-fast);
}
.anniv-type-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.anniv-type-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.anniv-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.anniv-color-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform var(--dur-fast), border-color var(--dur-fast);
  position: relative;
}
.anniv-color-dot:hover { transform: scale(1.08); }
.anniv-color-dot.active {
  border-color: var(--text);
  transform: scale(1.05);
}
.anniv-color-dot.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* 图标选择器 */
.anniv-icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.anniv-icon-dot {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast);
  padding: 0;
}

.anniv-icon-dot:hover {
  border-color: var(--border-strong);
  color: var(--text);
  transform: scale(1.05);
}

.anniv-icon-dot.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep, var(--text));
}

/* 编辑器里 SVG 容器 */
.anniv-editor .anniv-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.anniv-editor .anniv-icon-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* 类型 pill 里的图标 */
.anniv-type-pill .anniv-icon-svg {
  vertical-align: middle;
  margin-right: 2px;
}

/* —— 主题选择 —— */
.theme-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
}
.theme-option:hover { background: var(--bg-soft); }
.theme-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-option-preview {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
}
.theme-option-preview .half {
  flex: 1;
}

.theme-option-label {
  flex: 1;
  font-size: 15px;
  color: var(--text);
}

/* —— 密码管理 —— */
.password-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   API 模型选择面板
   ============================================================ */
.model-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.model-row .input { flex: 1; }
.model-row .btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.models-panel {
  margin-top: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  animation: panelSlide 0.22s var(--ease-out);
}
@keyframes panelSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.models-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.models-search {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  min-height: 32px;
}
.models-count {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.models-list {
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elevated);
}
.model-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-mono, monospace);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast);
  letter-spacing: 0.2px;
}
.model-item:last-child { border-bottom: none; }
.model-item:hover { background: var(--accent-soft); color: var(--accent-deep); }
.model-item:active { background: var(--surface); }

.models-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* 错误详情 */
.models-error {
  padding: 10px 12px;
  background: rgba(180, 60, 60, 0.06);
  border-top: 1px solid rgba(180, 60, 60, 0.15);
  max-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.models-error-line {
  font-size: 11px;
  color: #b44;
  font-family: var(--font-mono, monospace);
  line-height: 1.6;
  word-break: break-all;
}

/* 手动输入 */
.models-manual {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.models-manual-input {
  width: 100%;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

/* 面板底部 */
.models-panel-foot {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-soft);
}

/* 小 spinner */
.spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   外观设置：主题色 / 字体 / CSS / App 图标
   ============================================================ */
.appearance-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* —— 主题色预设 —— */
.accent-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.accent-preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
}
.accent-preset:hover { background: var(--bg-soft); }
.accent-preset.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.accent-preset-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0;
}
.accent-preset-default {
  background: linear-gradient(135deg, #E8E2D5, #B5C9B8, #D4B896);
  color: var(--text);
  font-size: 8px;
}
.accent-preset-name {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}
.accent-preset.selected .accent-preset-name {
  color: var(--accent-deep);
  font-weight: 500;
}

.accent-custom {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.accent-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.accent-picker-row input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.accent-picker-row .input { flex: 1; }

/* —— 字体大小 —— */
.font-scale-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.font-scale-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}
.font-scale-label-lg {
  font-size: 20px;
}
.font-scale-slider {
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.font-scale-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.font-scale-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.font-scale-value {
  text-align: center;
  font-size: 13px;
  color: var(--accent-deep);
  font-weight: 500;
  letter-spacing: 0.5px;
}
.font-scale-preview {
  background: var(--bg-soft);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.3px;
  border: 1px solid var(--border);
}

/* —— 自定义 CSS —— */
.custom-css-textarea {
  font-family: var(--font-mono, 'SF Mono', Consolas, Monaco, monospace);
  font-size: 12px;
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}
.custom-css-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.custom-css-actions .btn { flex: 1; }

/* —— App 图标 —— */
.app-icons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.app-icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.app-icon-preview {
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.app-icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-icon-preview svg {
  width: 100%;
  height: 100%;
}
.app-icon-default {
  font-size: 18px;
}
.app-icon-name {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}
.app-icon-btn {
  font-size: 10px;
  padding: 2px 8px !important;
  min-height: 22px !important;
  margin-top: 2px;
}
.app-icon-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* —— TTS / 生图测试结果 —— */
.tts-test-area,
.img-test-area {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: center;
}
.tts-test-area audio {
  width: 100%;
  height: 40px;
}
.img-test-area img {
  max-width: 100%;
  border-radius: var(--r-sm);
  display: block;
  margin: 0 auto;
}

/* ============================================================
   参考图 / 画风参考 UI
   ============================================================ */
.img-ref-area {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.img-ref-preview {
  width: 100%;
  height: 160px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
}

.img-ref-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.img-ref-empty {
  color: var(--text-tertiary);
  font-size: 13px;
}

.img-ref-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.img-ref-actions .btn-sm {
  font-size: 12px;
  padding: 6px 12px;
}

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
}

/* 相册选择网格（参考图） */
.photo-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
}

.photo-picker-item {
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--bg-soft);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
}

.photo-picker-item:hover {
  transform: scale(0.97);
}

.photo-picker-item.loading::after {
  content: '';
  position: absolute;
  inset: 30%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.gs-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.5;
  padding: 0 4px;
}

/* ============================================================
   多预设列表（TTS / 生图共用）
   ============================================================ */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.preset-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  background: var(--bg-soft);
  border-radius: var(--r-sm);
  border: 1px dashed var(--border);
}

.preset-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
}
.preset-item:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
.preset-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.preset-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--dur-fast);
}
.preset-item.active .preset-radio {
  border-color: var(--accent);
}
.preset-radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: radioPop 0.2s var(--ease-out);
}
@keyframes radioPop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.preset-info {
  flex: 1;
  min-width: 0;
}
.preset-name {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preset-model {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 6px;
  font-family: var(--font-mono, monospace);
}
.preset-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.preset-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.preset-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
}
.preset-btn:hover {
  background: var(--surface);
  color: var(--text);
}
.preset-btn[data-act="delete"]:hover {
  color: var(--danger);
}

/* —— 全宽按钮 —— */
.btn-block {
  width: 100%;
  justify-content: center;
  gap: 6px;
}

/* —— 小尺寸按钮（设置页专用，比 components.css 的 .btn-sm 更小） —— */
.btn-xs {
  padding: 6px 10px;
  font-size: 12px;
  min-height: 28px;
}

/* —— 通用 caption / code —— */
.caption {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.6;
  margin: 0 0 8px;
  letter-spacing: 0.3px;
}
.caption code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--accent-deep);
}

/* ============================================================
   微信美化设置
   ============================================================ */
.wx-beauty-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.wx-beauty-choices-3 {
  grid-template-columns: repeat(3, 1fr);
}
.wx-beauty-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 10px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border);
  background: var(--bg-soft);
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
  text-align: center;
}
.wx-beauty-choice:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.wx-beauty-choice.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.wx-beauty-choice-preview {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.wx-beauty-choice-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.3px;
}
.wx-beauty-choice.selected .wx-beauty-choice-name {
  color: var(--accent-deep);
}
.wx-beauty-choice-desc {
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0.2px;
}

/* —— 气泡预览 —— */
.wx-bp-bubble {
  padding: 6px 12px;
  background: var(--wechat-sent, #b5c9b8);
  color: #1a1a1a;
  font-size: 12px;
  max-width: 80px;
  position: relative;
}
:root[data-theme="dark"] .wx-bp-bubble { color: #F0F0F0; }
.wx-bp-bubble-tail {
  border-radius: 10px 10px 10px 2px;
}
.wx-bp-bubble-tail::before {
  content: '';
  position: absolute;
  top: 8px;
  left: -5px;
  border: 5px solid transparent;
  border-right-color: var(--wechat-sent, #b5c9b8);
}
.wx-bp-bubble-square {
  border-radius: 2px;
}
.wx-bp-bubble-rounded {
  border-radius: 18px;
}

/* —— 头像预览 —— */
.wx-bp-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}
.wx-bp-avatar-rounded { border-radius: 10px; }
.wx-bp-avatar-circle  { border-radius: 50%; }
.wx-bp-avatar-square  { border-radius: 0; }

/* —— 暗色模式适配 —— */
[data-theme="dark"] .wx-bp-bubble {
  color: #fff;
}

/* ============================================================
   显示模式选项
   ============================================================ */
.display-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

.display-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  background: var(--bg-soft);
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
  text-align: center;
}

.display-option:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.display-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.display-option-preview {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

/* 手机壳预览 */
.phone-preview-shell {
  width: 60px;
  height: 110px;
  border: 3px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.phone-preview-shell::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
}

.phone-preview-screen {
  position: absolute;
  inset: 6px;
  background: var(--accent-soft);
  border-radius: 4px;
}

/* 全屏预览 */
.phone-preview-fullscreen {
  width: 70px;
  height: 110px;
  background: var(--bg);
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.phone-preview-fullscreen::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
}

.display-option-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}

.display-option.selected .display-option-label {
  color: var(--accent-deep);
}

.display-option-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.2px;
  line-height: 1.4;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .display-options {
    grid-template-columns: 1fr;
  }

  .display-option {
    flex-direction: row;
    align-items: center;
    padding: 16px;
    gap: 16px;
  }

  .display-option-preview {
    width: 80px;
    height: 60px;
    flex-shrink: 0;
  }

  .phone-preview-shell,
  .phone-preview-fullscreen {
    transform: scale(0.6);
  }
}

/* —— 提示词预设 —— */
.prompt-preset-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prompt-preset-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s;
}
.prompt-preset-item.enabled {
  border-color: var(--accent, #5a7363);
}
.prompt-preset-toggle {
  flex-shrink: 0;
  padding-top: 2px;
}
.prompt-preset-body {
  flex: 1;
  min-width: 0;
}
.prompt-preset-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.prompt-preset-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.prompt-preset-details {
  margin-top: 8px;
}
.prompt-preset-details summary {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.prompt-preset-details summary:hover {
  color: var(--text);
}
.prompt-preset-content {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 240px;
  overflow-y: auto;
}

/* ============================================================
   壁纸管理
   ============================================================ */
.wallpaper-current {
  display: flex;
  gap: 14px;
  padding: 12px;
  align-items: center;
}

.wallpaper-current-preview {
  width: 90px;
  height: 160px;
  border-radius: var(--r-lg);
  background: var(--bg-soft);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.wallpaper-current-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  opacity: 0.55;
}
.wallpaper-current-empty svg { width: 28px; height: 28px; }

.wallpaper-current-info {
  flex: 1;
  min-width: 0;
}

.wallpaper-current-status {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
}

.wallpaper-current-actions {
  display: flex;
  gap: 8px;
}

.wallpaper-range {
  flex-shrink: 0;
  width: 120px;
  accent-color: var(--accent);
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  padding: 4px 0;
}

.wallpaper-item {
  aspect-ratio: 9 / 16;
  border-radius: var(--r-md);
  background-size: cover;
  background-position: center;
  background-color: var(--bg-soft);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.wallpaper-item:hover { transform: scale(0.97); }
.wallpaper-item.selected {
  border-color: var(--accent);
}

.wallpaper-item-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.wallpaper-item-del svg { width: 12px !important; height: 12px !important; stroke-width: 2.4; }
.wallpaper-item:hover .wallpaper-item-del { opacity: 1; }

.wallpaper-item-check {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}
.wallpaper-item-check svg { width: 11px !important; height: 11px !important; fill: currentColor; stroke: none; }
.wallpaper-item.selected .wallpaper-item-check { display: flex; }

