:root {
  --bg: #0f1220;
  --bg2: #171b2e;
  --card: #1d2338;
  --card-hover: #252c47;
  --border: #2e3657;
  --text: #e8eaf6;
  --muted: #8b91ad;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --gold: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 0.2s;

  /* 内联图标（CSS ::before 用，与 js/core/icons.js 同一套 Lucide 路径） */
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  --icon-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; }

/* ============ 全局滚动条（Mac 桌面端） ============ */
/* 覆盖 QtWebEngine/Chromium 的原生滚动条，统一为贴合深色主题的浮动细滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(139, 145, 173, 0.35); /* var(--muted) 半透明 */
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box; /* 与滚动槽留出空隙，呈现悬浮细条效果 */
  min-height: 40px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139, 145, 173, 0.7); background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: rgba(139, 145, 173, 0.95); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ============ 图标系统（js/core/icons.js 输出的内联 SVG） ============ */
.icon {
  width: 20px; height: 20px; flex: none;
  display: inline-block; vertical-align: -0.15em;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  overflow: visible;
}
/* [data-icon] 占位元素：统一居中，避免填充前后跳动 */
[data-icon] {
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  vertical-align: middle;
}
[data-icon] > .icon { display: block; }
.icon-inline { vertical-align: -0.16em; }
.icon-preview { width: 26px; height: 26px; }
.link-icon { vertical-align: -0.2em; margin-left: 3px; opacity: 0.85; }
.btn-icon { vertical-align: -0.18em; }

/* ============ 顶栏 ============ */
.topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 58px; padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 27, 46, 0.85);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--text); cursor: pointer; padding: 0;
}
.logo { font-size: 24px; }
.title { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }

.account { display: flex; align-items: center; gap: 10px; }
.account-badge {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
}
.account-badge.premium {
  color: #1f1300; background: var(--gold); border-color: var(--gold); font-weight: 600;
}

/* 右上角登录按钮 + hover 下拉（桌面端） */
.account-menu { position: relative; }
.account-trigger {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px;
}
.account-trigger:hover { background: var(--card-hover); }
.account-trigger .arrow { font-size: 10px; color: var(--muted); }

.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 180px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; display: none; z-index: 30;
}
/* 账号下拉：仅点击（.open）展开，hover 不弹出（Mac 端用户要求） */
.account-menu.open .dropdown { display: block; }
.dropdown-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px;
  background: none; border: none; color: var(--text); border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.dropdown-item:hover { background: var(--card-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }

/* ============ 屏幕容器 ============ */
.app {
  height: calc(100% - 58px);
  position: relative;
  overflow: hidden;
}
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

.scroll-body { flex: 1; overflow-y: auto; padding: 20px; }

.screen-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.screen-header h1 { font-size: 18px; flex: 1; text-align: center; }
.back-btn {
  width: 34px; height: 34px; border-radius: 10px; font-size: 24px; line-height: 1;
  background: var(--card); border: 1px solid var(--border); color: var(--text); cursor: pointer;
}
.back-btn:hover { background: var(--card-hover); }
/* 仅在桌面端显示的返回按钮（历史/我的为移动端 Tab 根） */
.back-desktop { display: none; }
.header-spacer { width: 34px; }
.header-action {
  background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 10px;
}
.header-action:hover { color: var(--danger); }
.header-actions { display: flex; align-items: center; gap: 2px; }
.header-actions .header-action { flex-shrink: 0; }
#btn-manage-history:hover, #btn-clear-history:hover { color: var(--danger); }
#btn-manage-history.active { color: var(--primary); font-weight: 600; }

/* ============ 首页卡片 ============ */
#screen-home { align-items: center; justify-content: center; }
.home-wrap { width: 100%; max-width: 880px; padding: 24px; }
.home-title {
  text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 32px;
  background: linear-gradient(90deg, #818cf8, #c084fc);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cards-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;
}
.card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 28px 24px; text-align: left;
  background: linear-gradient(160deg, var(--card), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); cursor: pointer; transition: transform .18s, border-color .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow); }
.card-icon { font-size: 34px; }
.card-name { font-size: 20px; font-weight: 700; }
.card-desc { font-size: 13px; color: var(--muted); }

/* ============ 第 1 步：样本设置 ============ */
.setup-body { max-width: 640px; margin: 0 auto; width: 100%; }
/* 设置页底部常驻操作栏：「开始」按钮固定在屏幕底部，内容再长也不会被顶出首屏 */
.setup-footer {
  flex-shrink: 0;
  padding: 10px 20px 12px;
  border-top: 1px solid var(--border);
  background: rgba(23, 27, 46, 0.95);
  backdrop-filter: blur(8px);
}
.setup-footer-inner { max-width: 640px; margin: 0 auto; width: 100%; }
/* 校验错误：紧跟按钮上方显示（用户点完按钮就能看到，不用回头找） */
.setup-error {
  margin-bottom: 8px; text-align: center;
  font-size: 12px; line-height: 1.5; color: var(--danger);
}
.setup-error[hidden] { display: none; }
.source-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.past-samples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.past-sample-chip {
  padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  transition: all .15s;
}
.past-sample-chip:hover { border-color: var(--primary); color: var(--text); }
.count-hint { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: right; }
.count-hint.error { color: var(--danger); }

/* 输入方式切换（一列 / 多列） */
.input-mode-toggle {
  display: flex; gap: 4px; margin-bottom: 8px;
  padding: 4px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--border);
}
.input-mode-toggle[hidden] { display: none; }
.input-mode-btn {
  flex: 1; padding: 8px 10px; font-size: 13px; text-align: center; white-space: nowrap;
  background: none; border: none; color: var(--muted); border-radius: 8px; cursor: pointer;
  transition: color .15s, background .15s;
}
.input-mode-btn.active { background: var(--primary); color: #fff; font-weight: 600; }

/* 音效开关（设置页 / 运行控制条 / 设置弹窗共用同一状态）：
   整行可点（role=switch），左侧状态文字 + 右侧胶囊开关 */
.sound-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 10px 14px; cursor: pointer; text-align: left;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; transition: border-color .15s, background .15s;
}
.sound-row:hover { background: var(--card-hover); }
.sound-row .sound-value { color: var(--muted); font-weight: 600; font-size: 13px; }
.sound-row.on { border-color: var(--primary); }
.sound-row.on .sound-value { color: var(--primary); }
.sound-switch {
  position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px;
  background: rgba(120, 130, 160, 0.35); transition: background .18s;
}
.sound-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform .18s;
}
.sound-row.on .sound-switch { background: var(--primary); }
.sound-row.on .sound-knob { transform: translateX(20px); }
/* 快照 / 视频开关行（复用 .sound-row）：左侧状态文字 + 非会员锁标 */
.sound-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sound-lock { color: var(--gold); display: inline-flex; align-items: center; }
.sound-lock[hidden] { display: none; }
/* 运行控制条里的音效按钮：图标随开关切换（volume-2 / volume-x） */
.run-controls-bar .btn .btn-icon { margin-right: 6px; }

/* 多列输入：网格编辑 */
.items-grid { display: flex; flex-direction: column; gap: 6px; }
.items-grid[hidden] { display: none; }
.grid-row { display: flex; gap: 6px; align-items: center; }
.grid-row.grid-header { margin-bottom: 2px; }
.grid-cell { flex: 1; min-width: 0; }
.grid-cell.grid-head {
  font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 2px 4px; text-align: center;
}
.grid-cell.grid-del-head { flex: 0 0 28px; }
.grid-input {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 14px; outline: none; resize: none;
}
.grid-input:focus { border-color: var(--primary); }
.grid-cell.grid-del { flex: 0 0 28px; display: flex; justify-content: center; }
.grid-del-btn {
  width: 26px; height: 26px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
  transition: all .15s;
}
.grid-del-btn:hover { color: var(--danger); background: rgba(239, 68, 68, 0.12); }
.grid-actions { margin-top: 8px; }
.grid-actions[hidden] { display: none; }
.grid-actions .btn { width: 100%; }

.field { margin-bottom: 18px; }
.field label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text);
}
.hint { font-weight: 400; color: var(--muted); }
.link-btn { background: none; border: none; color: var(--primary); font-size: 12px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }

textarea, input[type="number"], input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  outline: none;
}
textarea:focus, input:focus { border-color: var(--primary); }

/* 数字步进器：隐藏原生 spin 按钮，改用 −/+ 自定义按钮（Mac 原生样式太丑） */
.num-stepper { display: flex; align-items: center; gap: 8px; }
.num-stepper input[type="number"] {
  flex: 1; width: auto; min-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: none;
  -moz-appearance: textfield;
}
.num-stepper input[type="number"]::-webkit-inner-spin-button,
.num-stepper input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper-btn {
  flex: none; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  border-radius: 10px; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.stepper-btn:hover { border-color: var(--primary); color: var(--text); }
.stepper-btn:active { background: var(--card-hover); }

/* 风格快捷选择 chips */
.style-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.style-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  transition: all .15s;
}
.style-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.style-chip .lock { color: var(--gold); flex: none; }
/* 已购主题状态标记：已下载就绪 ✓ / 已购未下载 ⬇（与主题列表的判定保持一致） */
.style-chip .owned { color: var(--success); flex: none; }
.style-chip .dl { color: var(--primary-hover); flex: none; }
/* 快捷切换 chip 内的效果缩略图 */
.style-chip .chip-thumb {
  width: 18px; height: 18px; border-radius: 6px; object-fit: cover;
  flex: none;
  border: 1px solid rgba(255,255,255,.12);
}
.style-chip .chip-name { flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px; cursor: pointer; font-size: 14px;
  padding: 10px 16px; transition: all .15s; font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.12); }
.btn-start { width: 100%; padding: 14px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* 会员功能按钮的锁图标（结果页：保存到云端 / 导出图片 / 导出表格；无资格时 JS 显隐）
   ⚠️ [hidden] 必须显式声明，否则被上面的 display 覆盖而总是显示 */
.btn-lock { flex: none; display: inline-flex; color: var(--gold); }
.btn-lock[hidden] { display: none; }

/* 结果页动作区：导出视频按钮「本次未录制」时需真正隐藏（.btn 的 display 会覆盖 [hidden]） */
.result-actions .btn[hidden] { display: none; }

/* ============ 第 2 步：全屏运行 ============ */
.run-screen {
  position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(circle at 50% 40%, #1a2140 0%, #0b0e1a 100%);
}
.run-screen .stage {
  position: absolute; inset: 0; border: none; border-radius: 0;
  background: transparent;
}
.stage { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); }
.stage-inner { position: absolute; inset: 0; }

/* 悬浮 / 触摸显示的运行控制条 */
.run-controls {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  padding: 16px; pointer-events: none;
  opacity: 0; transition: opacity .2s;
  background: linear-gradient(180deg, rgba(10,12,24,.88), transparent);
}
.run-screen.show-controls .run-controls { opacity: 1; }
.run-controls-bar {
  pointer-events: auto; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.run-controls-bar .btn { min-width: 88px; }
.run-hint {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  color: var(--muted); font-size: 13px; pointer-events: none; z-index: 15;
}
.run-toast {
  /* position:fixed → 全局可见（购买/恢复/错误提示不再只出现在运行界面） */
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(8px);
  max-width: 80%; padding: 10px 18px; border-radius: 999px; z-index: 1000;
  background: rgba(23, 27, 46, 0.92); border: 1px solid var(--primary);
  color: var(--text); font-size: 14px; font-weight: 600; text-align: center;
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
}
.run-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* 可点击提示（如次数提示 → 点击直接开通会员）：恢复指针事件 + 金色描边与 › 指示 */
.run-toast.clickable { pointer-events: auto; cursor: pointer; border-color: var(--gold); }
.run-toast.clickable::after { content: ' ›'; color: var(--gold); font-weight: 700; }

/* ============ 第 3 步：结果定制 ============ */
.result-body { max-width: 640px; margin: 0 auto; width: 100%; }
.result-editor { display: flex; flex-direction: column; gap: 14px; }
.editor-group {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.editor-group .group-name {
  width: 140px; flex-shrink: 0; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text); font-size: 14px;
}
.editor-group .group-members { display: flex; flex-wrap: wrap; gap: 8px; }
.editor-single { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.chip {
  padding: 6px 12px; border-radius: 999px; background: var(--bg2);
  border: 1px solid var(--border); font-size: 13px;
}
.chip.winner { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.chip.odd { background: transparent; border: 1px dashed var(--gold); color: var(--gold); }
.result-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.result-actions .btn { flex: 1; min-width: 90px; }

/* ============ 主题选择 ============ */
.style-list { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.style-item {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); transition: all .15s;
}
.style-item:hover { background: var(--card-hover); }
.style-item.selected { border-color: var(--primary); background: rgba(99, 102, 241, 0.14); }
.style-item.locked { opacity: 0.55; cursor: not-allowed; }
.style-item .s-preview {
  width: 96px; height: 60px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--bg2); border: 1px solid var(--border); overflow: hidden;
}
/* 主题效果缩略图（来自数据库 preview_url：SVG data URI 或图片 URL） */
.style-item .s-thumb {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 9px;
}
.style-item .s-info { flex: 1; }
.style-item .s-name { font-weight: 600; font-size: 15px; }
.style-item .s-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.style-item .s-tag { font-size: 11px; color: var(--muted); margin-top: 2px; }
/* 购买次数（仅 >1000 时展示）：金色小字，突出人气 */
.style-item .s-sold { font-size: 11px; font-weight: 600; color: var(--gold); margin-top: 2px; }
.style-item .s-action { font-size: 13px; }
.style-item .s-action.free { color: #34d399; }
.style-item .s-action.premium { color: var(--gold); }
.style-item .s-action.current { color: var(--primary); font-weight: 600; }
/* 已解锁但未下载 → 「下载」按钮 */
.style-item .s-action.download {
  color: var(--primary); font-weight: 600;
  padding: 4px 12px; border: 1px solid var(--primary); border-radius: 999px;
}
/* 已购且有新版本 → 「更新」按钮 */
.style-item .s-action.update {
  color: var(--gold); font-weight: 600;
  padding: 4px 12px; border: 1px solid var(--gold); border-radius: 999px;
}
/* 付费主题体验券：「体验」= 金色描边按钮；「体验中 · 剩 X」= 金色文字（与已购区分） */
.style-item .s-action.trial {
  color: var(--gold); font-weight: 600;
  padding: 4px 12px; border: 1px solid var(--gold); border-radius: 999px;
}

/* ============ 主题效果一览（运行截图画廊） ============ */
/* 入口卡（主题列表页顶部）：与 .style-item 同宽同风格，图片图标 + 文案 + 箭头 */
.gallery-entry {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 640px; margin: 0 auto 10px;
  padding: 12px 16px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px dashed var(--border); background: var(--card); color: var(--text);
  transition: all .15s;
}
.gallery-entry:hover { background: var(--card-hover); border-color: var(--primary); }
.gallery-entry-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(99, 102, 241, 0.14); color: var(--primary);
}
.gallery-entry-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gallery-entry-title { font-size: 14px; font-weight: 600; }
.gallery-entry-sub { font-size: 12px; color: var(--muted); }
.gallery-entry-arrow { color: var(--muted); display: flex; flex: none; }

/* 画廊页：提示行 + 卡片网格（宽屏自动多列，移动端两列） */
.gallery-hint { max-width: 900px; margin: 0 auto 14px; font-size: 12px; color: var(--muted); }
.gallery-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-width: 900px; margin: 0 auto;
}
.gallery-card {
  padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--card); cursor: pointer; color: var(--text); text-align: left;
  display: flex; flex-direction: column; transition: all .15s;
}
.gallery-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.gallery-shot {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  background: var(--bg2);
}
.gallery-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.gallery-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-badge {
  font-size: 11px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px; flex: none;
}
.gallery-badge.premium { color: var(--gold); border-color: var(--gold); }

/* 大图查看器：全屏覆盖；点图片外关闭，←/→ 或左右滑动切换 */
.gallery-viewer {
  position: fixed; inset: 0; z-index: 1200; background: rgba(6, 8, 16, 0.94);
  display: flex; align-items: center; justify-content: center;
}
.gallery-viewer[hidden] { display: none; }
.gallery-viewer-img {
  max-width: calc(100% - 108px); max-height: calc(100% - 104px);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); background: #0b0e1a;
}
.gallery-viewer-close {
  position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.gallery-viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.gallery-viewer-nav.prev { left: 18px; }
.gallery-viewer-nav.next { right: 18px; }
.gallery-viewer-close:hover, .gallery-viewer-nav:hover { background: rgba(255, 255, 255, 0.14); }
.gallery-viewer-caption {
  position: absolute; left: 0; right: 0; bottom: 18px; text-align: center;
  font-size: 13px; color: var(--text); pointer-events: none;
}

/* ============ 主题下载进度 ============ */
.download-card { max-width: 320px; text-align: center; }
.download-progress {
  height: 10px; border-radius: 999px; overflow: hidden; margin-top: 6px;
  background: var(--bg2); border: 1px solid var(--border);
}
.download-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  transition: width .2s ease;
}
/* 未知总大小（无 Content-Length）→ 不确定进度动画 */
.download-bar.indeterminate {
  width: 32%; animation: downloadSlide 1.1s ease-in-out infinite;
}
@keyframes downloadSlide {
  0% { margin-left: -32%; }
  100% { margin-left: 100%; }
}
.download-pct { margin-top: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }

/* ============ 历史记录 ============ */
.history-list { display: flex; flex-direction: column; gap: 10px; max-width: 680px; margin: 0 auto; }
.history-empty { text-align: center; color: var(--muted); padding: 60px 20px; }
/* 未登录时历史页登录提示占位 */
.history-gate { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.history-gate-icon { font-size: 42px; line-height: 1; }
.history-gate-text { font-size: 14px; color: var(--text); margin: 0; }
.history-gate .btn { max-width: 220px; width: 100%; }
.history-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.history-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--bg2); border: 1px solid var(--border);
}
.history-main { flex: 1; min-width: 0; }
.history-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.history-mode {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(99, 102, 241, 0.18); color: #a5b4fc; font-weight: 600;
}
.history-time { font-size: 11px; color: var(--muted); }
.history-summary { font-size: 13px; color: var(--text); line-height: 1.6; }
.history-del {
  background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer;
  padding: 4px 8px; border-radius: 8px; flex-shrink: 0;
}
.history-del:hover { color: var(--danger); background: rgba(239, 68, 68, 0.12); }

/* 历史条目：可点打开详情窗口（列表只展示简单信息，完整结果在详情中显示） */
.history-item.viewable { cursor: pointer; transition: border-color .15s, background .15s; }
.history-item.viewable:hover { border-color: var(--primary); background: var(--card-hover); }
.history-summary-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.history-summary-sub { font-size: 11px; color: var(--muted); }
/* 查看详情指示箭头（非管理模式行右侧） */
.history-go {
  align-self: center; flex-shrink: 0; margin-left: 2px;
  font-size: 24px; line-height: 1; color: var(--muted);
  transition: color .15s, transform .15s;
}
.history-item.viewable:hover .history-go { color: var(--primary); transform: translateX(2px); }
.hdr-row { display: flex; flex-wrap: wrap; gap: 6px; }
.hdr-pair { display: flex; align-items: center; gap: 6px; padding: 5px 0; flex-wrap: wrap; }
.hdr-pair .hdr-label { font-size: 11px; color: var(--muted); min-width: 46px; }
.hdr-vs { color: var(--muted); font-size: 12px; }
.hdr-odd-row .hdr-label { color: var(--gold); }
.hdr-teams { display: flex; flex-wrap: wrap; gap: 10px; }
.hdr-team {
  flex: 1 1 150px; min-width: 132px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg2);
}
.hdr-team-name { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 7px; }
.hdr-team-members { display: flex; flex-wrap: wrap; gap: 6px; }

/* 历史记录详情弹窗 */
.history-detail-card { width: min(470px, 94%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; padding: 24px; }
.history-detail-card .history-detail-meta { margin-bottom: 12px; }
/* 快照（本轮每次揭晓各一张）：详情顶部按顺序堆叠展示；无快照时整个容器 hidden */
.history-detail-snapshot { margin-bottom: 12px; max-height: 42vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.history-detail-snapshot[hidden] { display: none; }
.history-detail-snapshot img {
  display: block; width: 100%; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg2);
}
.history-detail-body {
  flex: 1; min-height: 60px; overflow-y: auto; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
}
.history-detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.history-detail-actions .btn { flex: 1; min-width: 90px; }

/* 导出弹窗（结果页 / 历史详情）：图片预览 / 表格预览 + 格式选择（图片与表格分开入口，弹窗内无标签页） */
.export-card { width: min(430px, 94%); display: flex; flex-direction: column; padding: 24px; }
.export-preview {
  flex: 1; min-height: 120px; margin-bottom: 16px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.export-preview img {
  display: block; max-width: 100%; max-height: 46vh; width: auto; height: auto;
  border-radius: 8px; object-fit: contain;
}
.export-preview img[hidden] { display: none; }
/* 表格预览：横向/纵向都可滚动，表头吸顶 */
.export-table-wrap { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.export-table-wrap[hidden] { display: none; }
.export-table-scroll {
  max-height: 38vh; overflow: auto; border-radius: 8px; border: 1px solid var(--border);
}
.export-table-scroll table { border-collapse: collapse; width: 100%; font-size: 12px; }
.export-table-scroll th,
.export-table-scroll td {
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; color: var(--text);
}
.export-table-scroll thead th {
  position: sticky; top: 0; background: var(--bg2); color: var(--muted); font-weight: 600;
}
.export-table-scroll tbody tr:last-child td { border-bottom: none; }
.export-rows-hint { font-size: 11px; color: var(--muted); text-align: center; }
.export-rows-hint[hidden] { display: none; }
.export-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.export-actions .btn { flex: 1; min-width: 92px; }
.export-actions .btn[hidden] { display: none; }
.export-actions .btn[disabled] { opacity: .55; cursor: default; }

/* 历史记录：配额提示 + 多选管理 */
.quota-hint {
  max-width: 680px; margin: 0 auto 10px;
  font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6;
}
.quota-hint b { color: var(--gold); font-weight: 600; }
.history-item.selectable { cursor: pointer; }
.history-item.selected { border-color: var(--primary); background: rgba(99, 102, 241, 0.14); }
.history-check {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; margin-top: 9px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border); background: var(--bg2); color: transparent;
  font-size: 13px; font-weight: 700; transition: all .15s;
}
.history-item.selected .history-check {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.history-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0;
  background: rgba(23, 27, 46, 0.95); backdrop-filter: blur(8px);
}
.history-actions[hidden] { display: none; }
.history-actions .btn { min-width: 80px; }
.history-selected-count { font-size: 13px; color: var(--text); }

/* ============ 我的 ============ */
#me-body { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.me-card {
  padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
}
.me-card h2 { font-size: 15px; margin-bottom: 14px; color: var(--text); }
.me-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.me-row:last-child { margin-bottom: 0; }
.me-label { color: var(--muted); }
.me-value { color: var(--text); font-weight: 600; }
.me-row-clickable {
  cursor: pointer; border-radius: 10px; padding: 8px 10px; margin: -8px -10px;
  transition: background .15s;
}
.me-row-clickable:hover { background: var(--card-hover); }
.theme-tag {
  padding: 6px 12px; border-radius: 999px; font-size: 13px;
  background: var(--bg2); border: 1px solid var(--border);
}
.theme-tag.premium { border-color: var(--gold); color: var(--gold); }
.btn-block { width: 100%; }
.me-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 10px; }
/* 账户卡片内的分区（会员 / 已购买的主题 / 退出登录等，原独立卡片内容并入） */
.me-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.me-subtitle { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
/* 账号资料（昵称 + 头像） */
.me-profile { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.me-profile .me-profile-info { flex: 1; min-width: 0; }
.me-profile .me-profile-name { font-size: 16px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-profile .me-profile-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

/* 圆形头像：无图时以邮箱首字母做占位（--avatar-bg 由 JS 按首字母随机色） */
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff; user-select: none;
  background: var(--avatar-bg, var(--primary));
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 28px; height: 28px; font-size: 13px; }

/* ============ 编辑资料弹窗 ============ */
.profile-modal-card { width: min(380px, 90%); }

/* 头像选择区 */
.profile-avatar-box { display: flex; flex-direction: column; align-items: center; margin-bottom: 18px; }
.profile-avatar-ring {
  width: 104px; height: 104px; border-radius: 50%;
  padding: 4px; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.profile-avatar-preview {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--bg2); border: 3px solid var(--card); overflow: hidden;
}
.profile-avatar-preview .avatar { width: 100%; height: 100%; font-size: 40px; }
.profile-avatar-actions { display: flex; gap: 10px; }
.profile-avatar-actions .btn-mini { flex: none; width: auto; padding: 9px 16px; font-size: 13px; }
.profile-avatar-actions .btn-mini.danger { color: var(--danger); border-color: var(--danger); }
.profile-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ============ 语言选择弹窗 ============ */
.lang-card { width: min(340px, 90%); }
.lang-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; max-height: 60vh; overflow-y: auto; }
.lang-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px 14px; text-align: left;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.lang-item:hover { background: var(--card-hover); }
.lang-item.active { border-color: var(--primary); }
.lang-item .lang-check { color: var(--primary); font-weight: 700; }

/* ============ 设置弹窗（桌面端顶栏「设置」入口，与「我的」页设置卡片同源内容） ============ */
.settings-card { width: min(340px, 90%); }
.settings-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.settings-list .me-row { margin-bottom: 0; }

/* ============ 等待状态（异步加载占位：历史 / 我的 / 主题等页面的「等待页面」） ============ */
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 200px; padding: 40px 20px;
  color: var(--muted); text-align: center;
}
.loading-state.inline { flex-direction: row; min-height: 0; padding: 10px 4px; gap: 8px; }
.loading-spinner {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: loadingSpin .8s linear infinite;
}
.loading-state.inline .loading-spinner { width: 15px; height: 15px; border-width: 2px; }
.loading-text { font-size: 13px; }
@keyframes loadingSpin { to { transform: rotate(360deg); } }

/* ============ 登录弹窗 ============ */
.modal {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 20, 0.72); backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: min(360px, 90%); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.modal-card h2 { font-size: 18px; margin-bottom: 6px; }
.modal-tip { font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.modal-tip.ok { color: var(--gold); }
.modal-card form { display: flex; flex-direction: column; gap: 10px; }
/* 输入框占位提示：缩小字号并省略溢出，避免长提示被裁切 */
.modal-card input::placeholder {
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
}

/* 登录 / 注册 tab 切换 */
.auth-tabs {
  display: flex; gap: 4px; margin: 12px 0 4px;
  padding: 4px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--border);
}
.auth-tabs[hidden] { display: none; }
.auth-tab {
  flex: 1; padding: 8px; font-size: 13px; text-align: center;
  background: none; border: none; color: var(--muted); border-radius: 8px; cursor: pointer;
  transition: color .15s, background .15s;
}
.auth-tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.auth-links { display: flex; justify-content: center; margin-top: 2px; }
.link-btn:hover { text-decoration: underline; }

/* ============ 第三方登录（Google / Apple，Supabase OAuth） ============ */
.oauth-block { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.oauth-block[hidden] { display: none; }
.oauth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.oauth-divider::before,
.oauth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 14px; font-size: 14px; font-weight: 600;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.oauth-btn:hover { background: var(--card-hover); border-color: var(--primary); }
.oauth-btn[disabled] { opacity: .55; cursor: default; }
.oauth-btn[hidden] { display: none; }
.oauth-icon { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; }
.oauth-hint { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.5; }

.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1;
}
.btn-mini { flex: 1; padding: 8px; font-size: 12px; background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; cursor: pointer; }
.btn-mini-gold { color: var(--gold); border-color: var(--gold); }

/* 注册模式：两次密码比对提示 */
.password-match-hint {
  font-size: 12px; color: var(--danger); margin-top: -4px;
}
.password-match-hint[hidden] { display: none; }

/* 登录/注册：字段级即时校验提示（邮箱格式等） */
.field-hint {
  font-size: 12px; color: var(--danger); margin: -2px 0 4px;
}
.field-hint[hidden] { display: none; }

/* 注册模式：密码规则即时校验清单 */
.pwd-rule {
  list-style: none; margin: 0 0 8px; padding: 8px 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  display: grid; gap: 3px;
}
.pwd-rule[hidden] { display: none; }
.pwd-rule .pwd-rule-item { font-size: 12px; color: var(--muted); }
/* 未通过：× 图标（mask 染色，尺寸随字号） */
.pwd-rule .pwd-rule-item::before {
  content: '';
  display: inline-block; width: 12px; height: 12px;
  margin-right: 7px; vertical-align: -1px;
  background-color: var(--danger);
  -webkit-mask: var(--icon-x) center / contain no-repeat;
  mask: var(--icon-x) center / contain no-repeat;
}
.pwd-rule .pwd-rule-item.pass { color: var(--text); }
/* 已通过：✓ 图标 */
.pwd-rule .pwd-rule-item.pass::before {
  background-color: var(--success);
  -webkit-mask-image: var(--icon-check);
  mask-image: var(--icon-check);
}

/* ============ 滑块人机验证 ============ */
.captcha-card { width: min(340px, 90%); }
.captcha-track {
  position: relative; height: 46px; border-radius: 23px; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--border);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.captcha-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  transition: width .15s ease;
}
.captcha-track.captcha-dragging .captcha-fill { transition: none; }
.captcha-track[data-state="ok"] .captcha-fill { background: #22c55e; }
.captcha-text {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); letter-spacing: 1px;
}
.captcha-text.captcha-text-ok { color: #fff; font-weight: 600; }
.captcha-knob {
  position: absolute; top: 3px; left: 3px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-size: 16px; cursor: grab; touch-action: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.captcha-knob:active { cursor: grabbing; }
.captcha-track[data-state="ok"] .captcha-knob {
  background: #22c55e; border-color: #22c55e; color: #fff; cursor: default;
}
.captcha-knob .captcha-check { display: none; }
.captcha-track[data-state="ok"] .captcha-knob .captcha-arrow { display: none; }
.captcha-track[data-state="ok"] .captcha-knob .captcha-check { display: block; }
.captcha-actions { display: flex; gap: 10px; margin-top: 16px; }
.captcha-actions .btn { flex: 1; }

/* ============ 通用确认弹窗 ============ */
.confirm-card { width: min(340px, 90%); text-align: center; }
.confirm-card h2 { margin-bottom: 12px; }
.confirm-message { font-size: 14px; color: var(--text); line-height: 1.6; margin-bottom: 22px; word-break: break-word; }
.confirm-actions { display: flex; gap: 10px; }
/* 主操作按内容宽度起步并吃掉剩余宽度；取消按其文案宽度（不再等分）——
   等分在中/俄/德/葡等语言下会把「开通会员」挤成两行（原生端更会截断成「Become a mem…」，用户报障 2026-10-13） */
.confirm-actions .btn { flex: 1 1 auto; }
.confirm-actions:not(.has-secondary) #confirm-cancel { flex: 0 1 auto; }
/* 有三个动作的弹窗（反馈：打开邮件应用 / 复制邮箱 / 关闭）：主操作独占一行，
   下面两个次要操作同排 —— 三个并排在中/俄/德等长文案下会被挤爆。
   次要操作同样不吃等分宽度：「复制邮箱」在俄语（Скопировать адрес）下会超出一半宽度被挤成两行 */
.confirm-actions.has-secondary { flex-wrap: wrap; }
.confirm-actions.has-secondary #confirm-secondary { flex: 1 1 auto; }
.confirm-actions.has-secondary #confirm-cancel { flex: 0 1 auto; }
.confirm-actions.has-secondary #confirm-ok { order: -1; flex: 1 1 100%; }

/* ============ 历史样本选择弹层 ============ */
.sample-modal-card { width: min(420px, 92%); display: flex; flex-direction: column; padding: 24px; }
.sample-modal-card h2 { margin-bottom: 4px; }
.sample-modal-card .modal-tip { margin-bottom: 12px; }
.sample-history-list {
  flex: 1; min-height: 120px; max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding-right: 2px;
}
.sample-history-empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 13px; }
.sample-history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg2); cursor: pointer; transition: border-color .15s, background .15s;
}
.sample-history-item:hover { border-color: var(--primary); background: var(--card-hover); }
.sample-history-main { flex: 1; min-width: 0; }
.sample-history-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.sample-mode-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(99, 102, 241, 0.18); color: #a5b4fc; font-weight: 600; flex-shrink: 0;
}
.sample-history-time { font-size: 11px; color: var(--muted); }
.sample-history-names {
  font-size: 13px; color: var(--text); line-height: 1.5; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sample-history-del {
  background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer;
  padding: 4px 8px; border-radius: 8px; flex-shrink: 0;
}
.sample-history-del:hover { color: var(--danger); background: rgba(239, 68, 68, 0.12); }
.sample-history-footer {
  display: flex; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.sample-history-footer .btn { flex: 1; }

/* ============ 移动端底部导航 ============ */
.tabbar {
  display: none;
  height: 60px; border-top: 1px solid var(--border);
  background: rgba(23, 27, 46, 0.95); backdrop-filter: blur(8px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--muted); font-size: 11px; cursor: pointer;
}
.tab.active { color: var(--primary); }
.tab-icon { font-size: 18px; }

/* ============ 移动端（iOS/Android 壳） ============ */
@media (max-width: 760px) {
  html, body { overflow: hidden; }
  .app { height: calc(100% - 58px - 60px); }
  .tabbar { display: flex; }
  /* 移动端隐藏顶栏右侧账号（账号能力在「我的」Tab） */
  .account { display: none; }

  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .card { padding: 22px 18px; }
  .home-title { font-size: 20px; margin-bottom: 24px; }

  .setup-body { padding: 0; }
  .setup-footer { padding: 8px 14px 10px; }
  /* 主题 chips：单行横向滑动（主题变多后不再换行堆高，设置页基本一屏放下） */
  .style-chips {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding-bottom: 2px;
  }
  .style-chips::-webkit-scrollbar { display: none; }
  .style-chip { flex: none; }
  .screen-header { padding: 10px 12px; }
  .back-btn { width: 30px; height: 30px; }
  .header-spacer { width: 30px; }
  .scroll-body { padding: 14px; }

  /* 主题效果一览：两列网格 + 紧凑查看器（导航按钮贴边） */
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .gallery-meta { padding: 8px 10px; }
  .gallery-name { font-size: 13px; }
  .gallery-viewer-img { max-width: calc(100% - 24px); max-height: calc(100% - 150px); }
  .gallery-viewer-nav { width: 40px; height: 40px; }
  .gallery-viewer-nav.prev { left: 8px; }
  .gallery-viewer-nav.next { right: 8px; }
}

/* ============ 桌面端（Mac 壳） ============ */
@media (min-width: 761px) {
  .tabbar { display: none; }
  .back-desktop { display: block; }
}
