/* ==========================================================
   VoiceType — Apple-inspired liquid-glass UI
   Auto light / dark, mobile-first, safe-area aware
   ========================================================== */

:root {
  /* Apple system fonts */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* Apple's spring easing */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  /* core radii */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  /* shared neutrals (overridden per theme) */
  --ok: #30d158;
  --warn: #ffd60a;
  --err: #ff453a;
}

/* ==========================================================
   Apple-style theme palettes — low saturation, high readability
   Design rules:
     · 主色 (--accent) 用于点缀，不大面积铺
     · 背景 deep neutral，不用饱和色
     · 文字对比度 95% / 60% / 36% 严格分级
     · 玻璃面 surface 0.85 不透明度，文字始终清楚
     · 装饰性 blob 全部 ≤ 0.20 opacity，不抢戏
   ========================================================== */

/* THEME: Tahu — 磨砂玻璃 · iOS 18 风
   奶油暖底 + 三色光晕 + 半透明玻璃面板 + 焦糖橙强调
   特点：surface 半透明、backdrop-filter blur(40px)、阴影柔和大模糊 */
[data-theme="tahu"] {
  color-scheme: light;
  --bg: #fbf8f3;
  --bg-grad-1: #ffe4cc;       /* 桃 */
  --bg-grad-2: #d4f1ff;       /* 天蓝 */
  --bg-grad-3: #ffe6f2;       /* 樱 */

  --surface: rgba(255, 253, 250, 0.72);
  --surface-2: rgba(255, 253, 250, 0.58);
  --surface-3: rgba(255, 253, 250, 0.42);
  --hairline: rgba(40, 30, 20, 0.08);
  --hairline-strong: rgba(40, 30, 20, 0.16);

  --text: #1d1d1f;            /* Apple 标准最深灰 */
  --text-2: #515154;
  --text-3: #86868b;

  --accent: #f59e0b;          /* 焦糖橙 */
  --accent-2: #d97706;
  --accent-3: #b45309;
  --accent-rgb: 245, 158, 11;

  --ok: #34c759;
  --warn: #ff9500;
  --err: #ff3b30;

  --blob-show: 0.35;
  --shadow-1: 0 1px 2px rgba(120,80,30,0.06), 0 4px 16px rgba(120,80,30,0.08);
  --shadow-2: 0 4px 12px rgba(120,80,30,0.10), 0 16px 40px rgba(120,80,30,0.14);
}

/* THEME: Squirrel — 磨砂玻璃之前 · OS X Aqua / Yosemite 风
   榛果暖纸 + 实心面板 + 1px 描边 + 线性渐变按钮，零透明零模糊 */
[data-theme="squirrel"] {
  color-scheme: light;
  --bg: #f5efe6;
  --bg-grad-1: #ede4d0;
  --bg-grad-2: #f5efe6;
  --bg-grad-3: #faf6ee;

  --surface: #ffffff;          /* 实心 */
  --surface-2: #faf6ee;
  --surface-3: #ede4d0;
  --hairline: #d4c8b0;
  --hairline-strong: #b8a888;

  --text: #2c1810;             /* 暖深棕 */
  --text-2: #5a4632;
  --text-3: #8b7355;

  --accent: #c45a2b;           /* 燃烧橙红 */
  --accent-2: #a04823;
  --accent-3: #7a3618;
  --accent-rgb: 196, 90, 43;

  --ok: #4a7c2a;               /* 苔藓绿 */
  --warn: #d4a017;             /* 橡子金 */
  --err: #a8281e;

  --blob-show: 0;              /* 不需要装饰光斑 */
  --shadow-1: 0 1px 0 rgba(0,0,0,0.06), 0 2px 4px rgba(101,67,33,0.10);
  --shadow-2: 0 1px 0 rgba(0,0,0,0.08), 0 4px 8px rgba(101,67,33,0.12),
              0 8px 24px rgba(101,67,33,0.10);
}

/* fallback (no data-theme) = Tahu（新默认）*/
:root:not([data-theme]) {
  color-scheme: light;
  --bg: #fbf8f3;
  --bg-grad-1: #ffe4cc;
  --bg-grad-2: #d4f1ff;
  --bg-grad-3: #ffe6f2;
  --surface: rgba(255, 253, 250, 0.72);
  --surface-2: rgba(255, 253, 250, 0.58);
  --surface-3: rgba(255, 253, 250, 0.42);
  --hairline: rgba(40, 30, 20, 0.08);
  --hairline-strong: rgba(40, 30, 20, 0.16);
  --text: #1d1d1f;
  --text-2: #515154;
  --text-3: #86868b;
  --accent: #f59e0b;
  --accent-2: #d97706;
  --accent-3: #b45309;
  --accent-rgb: 245, 158, 11;
  --blob-show: 0.35;
  --shadow-1: 0 1px 2px rgba(120,80,30,0.06), 0 4px 16px rgba(120,80,30,0.08);
  --shadow-2: 0 4px 12px rgba(120,80,30,0.10), 0 16px 40px rgba(120,80,30,0.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  overflow-x: hidden;
  /* 启用 SF Pro 风格的等宽数字（不影响中英文）+ contextual alternates */
  font-feature-settings: "tnum" 1, "cv01" 1, "ss01" 1;
}

/* === 全局排版细则（修复中文逐字竖排 / 数字漂移） === */
/* 数字类元素一律用 tabular-nums，避免列对齐时跳动 */
.num,
[data-num],
.stat-card .num,
.lt-count, .lt-fail, .lt-time,
.lsum-num, .audit-time, .access-tag,
.history-item-len, .audit-stats, .audit-page,
.login-page, .login-stats-overall {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* 中文段落微调字间距（在实心面板上更松，玻璃面板上保持） */
:lang(zh-CN), [lang="zh-CN"], [lang="zh"] {
  letter-spacing: 0.01em;
}

/* 标题类显式收窄（Apple SF Display 风） */
h1, h2, h3, .stat-card .num, .lsum-num {
  letter-spacing: -0.02em;
}

/* 强制 grid/flex 子项允许文字截断（最常见的"中文逐字竖排"根因） */
.flex-min, .grid-min { min-width: 0; }
body { touch-action: manipulation; }

.hidden { display: none !important; }
.view { min-height: 100dvh; position: relative; z-index: 1; }

/* =========== Animated background blobs =========== */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-show, 0.4);
  mix-blend-mode: screen;
  animation: drift 28s var(--ease) infinite;
}
/* Squirrel 主题：实色面板，blob 装饰隐藏（已通过 --blob-show:0 控制） */
[data-theme="squirrel"] .blob { display: none; }

.blob-1 { background: var(--accent);   top: -25vmax; left: -10vmax; animation-delay: 0s; }
.blob-2 { background: var(--accent-2); top: 25vmax;  right: -25vmax; animation-delay: -10s; }
.blob-3 { background: var(--accent-3); bottom: -30vmax; left: 30vmax; animation-delay: -20s; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(8vmax, -6vmax) scale(1.1); }
  66%      { transform: translate(-6vmax, 8vmax) scale(0.95); }
}

/* =========== Surface material =========== */
/* 默认实色 + 1px 锐边（Apple/Linear 风），不再用厚 blur */
.glass {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
/* 仅在主题显式声明 --use-blur 时启用毛玻璃 */
[data-use-blur="1"] .glass {
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

/* === Tahu 主题：强制启用磨砂玻璃，背景三色光晕，按钮内描边 === */
[data-theme="tahu"] .glass,
[data-theme="tahu"] .modal-card,
[data-theme="tahu"] .stat-card,
[data-theme="tahu"] .bulk-bar,
[data-theme="tahu"] .audit-section,
[data-theme="tahu"] .login-section,
[data-theme="tahu"] .table-wrap,
[data-theme="tahu"] .toolbar,
[data-theme="tahu"] .admin-header {
  backdrop-filter: saturate(180%) blur(40px);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
[data-theme="tahu"] body {
  background:
    radial-gradient(at 18% 12%, var(--bg-grad-1) 0%, transparent 52%),
    radial-gradient(at 86% 28%, var(--bg-grad-2) 0%, transparent 55%),
    radial-gradient(at 50% 92%, var(--bg-grad-3) 0%, transparent 60%),
    var(--bg);
}
[data-theme="tahu"] .blob { display: none; }
[data-theme="tahu"] .btn-primary {
  box-shadow:
    0 8px 24px rgba(var(--accent-rgb), 0.30),
    inset 0 1px 0 rgba(255,255,255,0.45);
  border: 1px solid rgba(var(--accent-rgb), 0.5);
}

/* === Squirrel 主题：彻底关闭模糊，按钮 Aqua 渐变，分隔线硬朗 === */
[data-theme="squirrel"] .glass,
[data-theme="squirrel"] .modal-card,
[data-theme="squirrel"] .stat-card,
[data-theme="squirrel"] .bulk-bar,
[data-theme="squirrel"] .audit-section,
[data-theme="squirrel"] .login-section,
[data-theme="squirrel"] .table-wrap,
[data-theme="squirrel"] .toolbar,
[data-theme="squirrel"] .admin-header,
[data-theme="squirrel"] .pin-card,
[data-theme="squirrel"] .login-card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-radius: 8px;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.06),
    0 2px 4px rgba(101,67,33,0.10),
    inset 0 1px 0 rgba(255,255,255,0.95);
}
[data-theme="squirrel"] body {
  background: var(--bg);
}
[data-theme="squirrel"] .blob { display: none; }
[data-theme="squirrel"] .btn-primary {
  background: linear-gradient(180deg, #d97047 0%, #b04a1f 100%);
  border: 1px solid var(--accent-3);
  border-radius: 6px;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
  box-shadow: 0 1px 0 rgba(0,0,0,0.10),
              0 2px 4px rgba(122,54,24,0.20),
              inset 0 1px 0 rgba(255,255,255,0.35);
}
[data-theme="squirrel"] .btn-primary:hover {
  background: linear-gradient(180deg, #e88259 0%, #c45a2b 100%);
  filter: none;
}
[data-theme="squirrel"] .btn-primary:active {
  background: var(--accent-3);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.20);
  transform: none;
}
[data-theme="squirrel"] .ghost-btn,
[data-theme="squirrel"] .btn-ghost,
[data-theme="squirrel"] .btn-ghost-sm {
  background: linear-gradient(180deg, #ffffff 0%, #f0e8d6 100%);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  color: var(--text);
}
[data-theme="squirrel"] .ghost-btn:hover,
[data-theme="squirrel"] .btn-ghost:hover {
  background: linear-gradient(180deg, #faf6ee 0%, #ede4d0 100%);
}

/* =========== LOGIN — Apple x sci-fi (Vision Pro / spatial computing 风) =========== */

/* CSS @property 用于动画 conic-gradient 的角度 */
@property --grad-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

#login-view {
  display: grid;
  place-items: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
  position: relative;
}

/* 登录页特殊背景：在 main blobs 基础上额外加一层 mesh，提升科技感深度 */
#login-view::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(800px 500px at 30% 20%, rgba(var(--accent-rgb), 0.12), transparent 70%),
    radial-gradient(700px 400px at 80% 90%, rgba(var(--accent-rgb), 0.08), transparent 65%);
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 2.4rem 1.85rem 1.9rem;
  border-radius: var(--r-xl);
  box-shadow:
    var(--shadow-2),
    0 0 60px rgba(var(--accent-rgb), 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  isolation: isolate;
  z-index: 2;
}

/* 登录卡片右上角的语言选择器 */
.login-lang {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
}
.login-lang .ui-lang-picker {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-1, currentColor);
  font: inherit;
  font-size: 12px;
  padding: 5px 24px 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1l4 4 4-4' stroke='currentColor' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: background 0.15s, border-color 0.15s;
}
.login-lang .ui-lang-picker:hover {
  background-color: rgba(255, 255, 255, 0.10);
  border-color: rgba(var(--accent-rgb), 0.4);
}
.login-lang .ui-lang-picker:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.6);
  outline-offset: 2px;
}

/* 登录卡片：旋转的霓虹光弧（重点科技感） */
.login-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--r-xl);
  padding: 1.5px;
  background: conic-gradient(
    from var(--grad-angle, 0deg),
    transparent 0deg,
    rgba(var(--accent-rgb), 0.55) 30deg,
    rgba(var(--accent-rgb), 0.20) 60deg,
    transparent 90deg,
    transparent 270deg,
    rgba(var(--accent-rgb), 0.20) 300deg,
    rgba(var(--accent-rgb), 0.55) 330deg,
    transparent 360deg
  );
  -webkit-mask:
    linear-gradient(black, black) content-box,
    linear-gradient(black, black);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: -1;
  animation: gradRotate 6s linear infinite;
}
@keyframes gradRotate {
  to { --grad-angle: 360deg; }
}

/* （已移除 scanline + 卡片浮动 — 苹果原则：克制） */

.brand { text-align: center; margin-bottom: 1.85rem; position: relative; z-index: 1; }

.brand-logo {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 1.1rem;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: white;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 60%),
    linear-gradient(135deg, var(--accent), var(--accent-2) 70%, var(--accent-3));
  box-shadow:
    0 12px 36px rgba(var(--accent-rgb), 0.40),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset,
    0 1px 0 rgba(255, 255, 255, 0.30) inset;
  isolation: isolate;
}
.brand-logo svg { position: relative; z-index: 2; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25)); }

/* logo 周围的 3 圈呼吸光环（依次扩散） */
.logo-ring {
  position: absolute;
  inset: -2px;
  border-radius: 24px;
  border: 1.5px solid rgba(var(--accent-rgb), 0.55);
  pointer-events: none;
  opacity: 0;
  animation: ringPulse 3.6s cubic-bezier(0.25, 0.6, 0.3, 1) infinite;
}
.logo-ring.r1 { animation-delay: 0s; }
.logo-ring.r2 { animation-delay: 1.2s; }
.logo-ring.r3 { animation-delay: 2.4s; }
@keyframes ringPulse {
  0%   { transform: scale(0.95); opacity: 0; border-radius: 22px; }
  20%  { opacity: 0.55; }
  100% { transform: scale(2.1); opacity: 0; border-radius: 36px; }
}

.brand-title {
  margin: 0 0 0.35em;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, var(--text), var(--text-2));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tag {
  margin: 0;
  color: var(--text-2);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  font-weight: 500;
}

.field { margin-bottom: 0.75rem; }

/* === Login/Register tab toggle === */
.auth-tabs {
  position: relative;
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 1rem;
}
.auth-tab {
  position: relative;
  z-index: 2;
  flex: 1;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  padding: 0.55rem 0.5rem;
  border-radius: 9px;
  cursor: pointer;
  transition: color 220ms var(--ease);
}
.auth-tab.active { color: var(--text); }
.auth-tab.hidden { display: none; }
.auth-tab-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(100% - 6px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
  transition: transform 280ms var(--ease), width 280ms var(--ease);
  z-index: 1;
}
.auth-tabs.has-register .auth-tab-pill { width: calc(50% - 4px); }
.auth-tabs.tab-register .auth-tab-pill { transform: translateX(100%); }
.auth-form.hidden { display: none; }

/* Code input + send button row — grid 比例固定，按钮宽度跟字数走 */
.code-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.code-field input { letter-spacing: 0.15em; font-variant-numeric: tabular-nums; }

/* 注册表单底部小字提示（取代过长 placeholder） */
.register-hint {
  margin: -0.3rem 0 0.5rem;
  font-size: 0.74rem;
  text-align: center;
  color: var(--text-3);
  letter-spacing: 0.01em;
}
.send-code-btn {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 0 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 180ms var(--ease);
  min-width: 110px;
}
.send-code-btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--hairline-strong);
}
.send-code-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  font-variant-numeric: tabular-nums;
}
.send-code-btn.sent {
  color: var(--ok);
  border-color: var(--ok);
}

/* Turnstile (Cloudflare CAPTCHA) — auto-hidden until configured */
.turnstile-mount {
  display: flex;
  justify-content: center;
  margin: 0.6rem 0 0.4rem;
}

/* Terms checkbox row in register form */
.terms-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.4rem 0 0.85rem;
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.45;
  cursor: pointer;
  user-select: none;
}
.terms-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}
.terms-row a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}
.terms-row a:hover { opacity: 0.8; }

/* Policy modal — long-form content */
.policy-card {
  max-width: 640px;
  width: 100%;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem 1.25rem;
}
.policy-body {
  overflow-y: auto;
  padding: 0.5rem 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}
.policy-body h3 {
  font-size: 1rem;
  margin: 1.2em 0 0.5em;
  color: var(--text);
}
.policy-body h3:first-child { margin-top: 0; }
.policy-body p { margin: 0 0 0.85em; color: var(--text-2); }
.policy-body ul { margin: 0 0 0.85em; padding-left: 1.5em; color: var(--text-2); }
.policy-body li { margin-bottom: 0.35em; }
.policy-body strong { color: var(--text); }
.policy-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

input[type="password"],
input[type="text"],
input[type="email"],
input[type="search"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 0.85rem 1rem;
  outline: none;
  transition: border-color 200ms var(--ease), background 200ms var(--ease), box-shadow 200ms var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow:
    0 0 0 4px rgba(var(--accent-rgb), 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
/* 登录页输入框增强：顶部光泽线 */
.login-card input {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 30%),
    var(--surface-2);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23999' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.btn-primary {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.30), inset 0 1px 0 rgba(255,255,255,0.20);
  transition: transform 120ms var(--ease), box-shadow 200ms var(--ease), filter 200ms var(--ease);
  position: relative;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  cursor: wait;
  opacity: 0.85;
  filter: none;
}

/* 登录按钮：hover 时来一道光（科技感） */
.login-card .btn-primary {
  overflow: hidden;
  isolation: isolate;
}
.login-card .btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 0%,
    transparent 35%,
    rgba(255, 255, 255, 0.28) 50%,
    transparent 65%,
    transparent 100%
  );
  transform: translateX(-100%);
  transition: transform 700ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 1;
}
.login-card .btn-primary:hover::before {
  transform: translateX(100%);
}
.login-card .btn-primary > * {
  position: relative;
  z-index: 2;
}
.btn-primary .btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn-primary.loading .btn-spinner { display: inline-block; }
.btn-primary.loading .btn-arrow { display: none; }

/* Top progress bar — visible during slow login / API calls */
.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 200;
  pointer-events: none;
  background: transparent;
  overflow: hidden;
}
.top-progress .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 30%;
  border-radius: 0 4px 4px 0;
  animation: topProgress 1.4s var(--ease) infinite;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.55);
}
@keyframes topProgress {
  0%   { transform: translateX(-100%); width: 25%; }
  50%  { width: 45%; }
  100% { transform: translateX(420%); width: 25%; }
}

.error-text {
  margin: 0.6rem 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--err);
  text-align: center;
}

/* =========== APP =========== */
#app-view {
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  padding: max(0.5rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  padding: 0 0.25rem;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.brand-mini {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mini svg { color: var(--accent); }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 200ms var(--ease), color 200ms var(--ease), transform 120ms var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}

/* === Trial period badge in header === */
.trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 30px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: help;
  white-space: nowrap;
  transition: all 200ms var(--ease);
}
.trial-badge.warn {
  background: rgba(255, 214, 10, 0.15);
  color: #c98a00;
  border-color: rgba(255, 214, 10, 0.4);
}
.trial-badge.danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--err);
  border-color: rgba(255, 69, 58, 0.4);
  animation: trialPulse 2s var(--ease) infinite;
}
@keyframes trialPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 69, 58, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(255, 69, 58, 0); }
}

/* Trial expiring/expired banner inside main */
.trial-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, rgba(255, 149, 0, 0.18), rgba(255, 69, 58, 0.18));
  border: 1px solid rgba(255, 149, 0, 0.35);
  border-radius: var(--r-md);
  color: var(--text);
}
.trial-banner.expired {
  background: linear-gradient(135deg, rgba(255, 69, 58, 0.22), rgba(175, 82, 222, 0.18));
  border-color: rgba(255, 69, 58, 0.5);
}
.trial-banner svg { color: var(--err); flex-shrink: 0; }
.trial-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  line-height: 1.4;
}
.trial-banner-text strong { font-size: 0.92rem; color: var(--text); }
.trial-banner-text span { color: var(--text-2); }

/* === Queue (offline) badge button === */
.queue-btn {
  position: relative;
  background: linear-gradient(135deg, #ffd60a, #ff9500);
  color: #1d1d1f;
  border-color: transparent;
  animation: queuePulse 2s var(--ease) infinite;
}
.queue-btn:hover { filter: brightness(1.08); color: #1d1d1f; background: linear-gradient(135deg, #ffd60a, #ff9500); }
@keyframes queuePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 149, 0, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 149, 0, 0); }
}
.queue-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--err);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--bg);
}

.queue-card {
  max-width: 560px;
  width: 100%;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}
.queue-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.5;
  background: var(--surface-2);
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--hairline);
}
.queue-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-3);
  font-size: 0.92rem;
}
.queue-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  margin-bottom: 0.4rem;
}
.queue-row .qmeta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.queue-row .qtime { font-size: 0.85rem; color: var(--text); font-weight: 500; }
.queue-row .qdetail { font-size: 0.75rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.queue-row .qerror { font-size: 0.75rem; color: var(--err); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.queue-row .qactions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.queue-row .qbtn {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
  transition: all 180ms var(--ease);
}
.queue-row .qbtn:hover { background: var(--surface); color: var(--text); }
.queue-row .qbtn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}
.queue-row .qbtn.danger:hover { background: var(--err); color: white; border-color: var(--err); }
.queue-row.processing {
  opacity: 0.6;
  pointer-events: none;
}
.queue-row.processing .qmeta::after {
  content: " · 重试中…";
  color: var(--accent);
}

/* === Hide PWA-only buttons inside the Electron desktop client ===
 * The desktop client already IS the installed app + has its own tray-based
 * pinning, so the "install as desktop app" and "pin to floating window"
 * buttons are confusing duplicates. Hide them when app.js detects Electron
 * and adds .desktop on <html>. */
html.desktop #install-btn,
html.desktop #pin-btn,
html.desktop #pinned-placeholder { display: none !important; }

/* === Pin button: prominent labeled pill instead of small icon === */
.pin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.85rem 0 0.7rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 200ms var(--ease), border-color 200ms var(--ease),
              transform 120ms var(--ease), box-shadow 240ms var(--ease);
}
.pin-btn svg { color: var(--accent); flex-shrink: 0; }
.pin-btn:hover {
  background: var(--surface-3);
  border-color: var(--hairline-strong);
}
.pin-btn:active { transform: scale(0.96); }
.pin-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(var(--accent-rgb), 0.45);
}
.pin-btn.active svg { color: white; }
.pin-btn.attention,
#copy-btn.attention {
  animation: pinAttention 2.4s var(--ease) infinite;
}
@keyframes pinAttention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); }
}
@media (max-width: 480px) {
  .pin-btn .pin-label { display: none; }
  .pin-btn { padding: 0; width: 38px; justify-content: center; }
}

/* pinned placeholder (when DOM is moved into PiP window) */
.pinned-placeholder {
  display: grid;
  place-items: center;
  padding: 3rem 1.5rem;
  min-height: 50vh;
}
.pin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 320px;
  border-radius: var(--r-xl);
}
.pin-card svg { color: var(--accent-2); opacity: 0.85; }
.pin-card p { margin: 0; color: var(--text-2); font-size: 1rem; }
.pin-card .btn-primary { width: auto; padding: 0.7rem 1.5rem; }

/* main */
.app-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

/* =========== Record button =========== */
.record-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0 1rem;
}
.record-btn {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent), var(--accent-2) 50%, var(--accent-3));
  color: white;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 180ms var(--ease), box-shadow 240ms var(--ease);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.30) inset,
    0 -16px 32px rgba(0, 0, 0, 0.20) inset,
    0 18px 48px rgba(255, 55, 95, 0.32),
    0 4px 12px rgba(0, 0, 0, 0.25);
}
.record-btn::before {
  /* glossy highlight */
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,0.25), transparent 70%);
  pointer-events: none;
}
.record-icon {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}
.record-glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 55, 95, 0.55), transparent 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms var(--ease);
}
.record-btn:active { transform: scale(0.97); }
.record-btn.recording {
  animation: pulse 1.4s var(--ease) infinite;
}
.record-btn.recording .record-glow { opacity: 1; animation: glow 1.4s var(--ease) infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
@keyframes glow {
  0%, 100% { transform: scale(1);   opacity: 0.6; }
  50%      { transform: scale(1.4); opacity: 0; }
}
.record-btn.processing {
  background: var(--surface-3);
  color: var(--text-2);
  box-shadow: var(--shadow-1);
  cursor: wait;
}
.record-btn.processing::before { display: none; }
.record-btn.processing .record-icon { animation: spin 1s linear infinite; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

.meter {
  width: 200px;
  height: 3px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
#meter-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2), var(--accent));
  border-radius: 999px;
  transition: width 80ms linear;
}

.status {
  font-size: 0.92rem;
  color: var(--text-2);
  min-height: 1.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0 1rem;
}

/* =========== Result =========== */
.result {
  padding: 0.75rem;
  border-radius: var(--r-lg);
}
.result-tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.25rem 0.5rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 0.5rem;
}
.tab {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--surface-3);
}
.tab-spacer { flex: 1; }
.tab-action {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 180ms var(--ease);
}
.tab-action:hover { background: var(--surface-3); color: var(--text); border-color: var(--hairline-strong); }
.tab-action.copied {
  background: var(--ok);
  color: #003817;
  border-color: var(--ok);
}

.result textarea {
  border: none;
  background: transparent;
  padding: 0.5rem 0.5rem 0.25rem;
  font-size: 1rem;
  line-height: 1.55;
  resize: none;
  min-height: 100px;
}
.result textarea:focus { box-shadow: none; background: transparent; }

/* =========== Settings =========== */
.settings { padding: 0; overflow: hidden; }
.settings summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.95rem;
  color: var(--text);
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary svg { color: var(--text-2); }
.settings summary .chev {
  margin-left: auto;
  transition: transform 240ms var(--ease);
}
.settings[open] summary .chev { transform: rotate(180deg); }
.settings-body {
  padding: 0.5rem 1rem 1rem;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* 3-tab toggle inside settings */
.settings-tabs {
  position: relative;
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  margin-top: 0.4rem;
}
.settings-tab {
  flex: 1;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  cursor: pointer;
  transition: color 200ms var(--ease), background 200ms var(--ease);
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}
.settings-pane { display: none; }
.settings-pane.active { display: flex; flex-direction: column; gap: 0.85rem; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 36px;
}
.setting-row.stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}
.diary-weather-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb), 0.08), transparent 58%),
    var(--surface-2);
}
.diary-weather-panel.hidden { display: none; }
.diary-weather-panel input {
  width: 100%;
  min-height: 42px;
  border-radius: 10px;
}
.setting-row label {
  font-size: 0.95rem;
  color: var(--text);
  flex-shrink: 0;
}
.setting-row select {
  width: auto;
  min-width: 140px;
  padding: 0.45rem 2.2rem 0.45rem 0.8rem;
  font-size: 0.9rem;
  border-radius: var(--r-sm);
}

/* iOS-style segmented control */
.segmented {
  position: relative;
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 2px;
  border: 1px solid var(--hairline);
}
.seg-item {
  position: relative;
  z-index: 2;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  padding: 0.4rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  transition: color 220ms var(--ease);
  min-width: 60px;
}
.seg-item.active { color: var(--text); }
.seg-item.disabled {
  color: var(--text-3);
  cursor: not-allowed;
  text-decoration: line-through;
}
.seg-pill {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 280ms var(--ease);
  z-index: 1;
}
.segmented.right .seg-pill { transform: translateX(100%); }

/* iOS-style switch */
.switch {
  position: relative;
  width: 51px;
  height: 31px;
  display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 999px;
  cursor: pointer;
  transition: background 240ms var(--ease);
}
.switch .slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 260ms var(--ease);
}
.switch input:checked + .slider {
  background: var(--ok);
}
.switch input:checked + .slider::before { transform: translateX(20px); }

.hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-3);
  margin: 0.5rem 0 0;
}
.hint-secondary {
  font-size: 0.74rem;
  margin-top: 0.25rem;
  opacity: 0.85;
}

/* =========== Daily feedback =========== */
.feedback-card {
  max-width: 440px;
}
.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.feedback-q {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.feedback-q label {
  font-size: 0.92rem;
  color: var(--text);
}
.rating-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}
.rating-row button {
  font-family: inherit;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}
.rating-row button:hover {
  color: var(--text);
  transform: translateY(-1px);
}
.rating-row button.active {
  color: white;
  background: var(--accent);
  border-color: transparent;
}
.feedback-q textarea {
  min-height: 86px;
  resize: vertical;
}
.hint-secondary b {
  color: var(--text-2);
  font-weight: 600;
  background: var(--surface-2);
  padding: 0 0.3em;
  border-radius: 4px;
}
.row-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-left: 0.35rem;
  font-weight: 400;
}

/* === Vocabulary list (pill chips with × delete) === */
.vocab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 0;
}
.vocab-list:empty + .vocab-add { margin-top: 0; }
.vocab-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.4rem 0.32rem 0.7rem;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text);
  transition: background 180ms var(--ease);
  user-select: none;
}
.vocab-chip:hover { background: var(--surface-2); }
.vocab-chip-x {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  border: none;
  font-family: inherit;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}
.vocab-chip-x:hover { background: var(--err); color: white; }
.vocab-add {
  display: flex;
  gap: 0.5rem;
}
.vocab-add input { flex: 1; }
.vocab-add-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 120ms var(--ease), filter 200ms var(--ease);
}
.vocab-add-btn:hover { filter: brightness(1.1); }
.vocab-add-btn:active { transform: scale(0.94); }
.vocab-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-3);
}

.vocab-tools {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* === 词汇建议横幅 === */
.vocab-suggest {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid rgba(var(--accent-rgb), 0.32);
  border-radius: 14px;
  flex-wrap: wrap;
  animation: slideUp 240ms var(--ease);
}
.vs-icon { font-size: 1.1rem; flex-shrink: 0; }
.vs-text {
  font-size: 0.85rem;
  color: var(--text-2);
  flex-shrink: 0;
}
.vs-chips { display: flex; gap: 0.3rem; flex: 1; flex-wrap: wrap; }
.vs-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem 0.2rem 0.7rem;
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.30);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text);
}
.vs-chip-add, .vs-chip-skip, .vs-chip-filler {
  font-family: inherit;
  font-size: 0.75rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 150ms var(--ease);
}
.vs-chip-add { background: var(--accent); color: white; }
.vs-chip-add:hover { filter: brightness(1.1); }
.vs-chip-filler { background: var(--surface-3); color: var(--text-2); font-size: 0.7rem; }
.vs-chip-filler:hover { background: var(--warn); color: white; }
.vs-chip-skip { background: var(--surface-3); color: var(--text-3); }
.vs-chip-skip:hover { background: var(--err); color: white; }
.vs-dismiss {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.vs-dismiss:hover { background: var(--surface-3); color: var(--text); }

/* === Account info === */
.account-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  color: var(--text);
}
.account-username { font-weight: 500; }
.account-role {
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.account-role.admin {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.setting-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.btn-ghost-sm {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: all 180ms var(--ease);
}
.btn-ghost-sm:hover { background: var(--surface-3); color: var(--text); }
.btn-compact {
  padding: 0.55rem 0.95rem;
  font-size: 0.9rem;
}

/* === Admin 入口卡片（设置面板内，仅管理员可见，链接到 /admin.html） === */
/* 桌面：图标 / 文字 / 按钮 三列横排；移动端：堆叠成两行 */
.admin-link-card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  margin-top: 0.5rem;
  /* 关键：禁止文字竖排（中文容器太窄会逐字换行） */
  writing-mode: horizontal-tb;
}
.admin-link-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.30);
}
.admin-link-text {
  min-width: 0;          /* 让 grid item 接受 overflow */
  overflow: hidden;
}
.admin-link-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.15rem;
  /* 强制单行 + 省略号 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.admin-link-text p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 关键修复：覆盖 .btn-primary 的 width:100%，让按钮按内容宽 */
.admin-link-btn {
  width: auto !important;
  flex-shrink: 0;
  padding: 0.55rem 1.1rem !important;
  text-decoration: none;
  white-space: nowrap;
  justify-self: end;
}

/* 移动端：堆叠（图标+文字一行，按钮自占一行 44px） */
@media (max-width: 480px) {
  .admin-link-card {
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
    row-gap: 0.7rem;
  }
  .admin-link-btn {
    grid-column: 1 / -1;
    width: 100% !important;
    justify-self: stretch;
    height: 44px;             /* iOS HIG 触控目标 */
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* === Admin user list === */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 0.4rem;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: var(--surface);
}
.user-row .uname { font-weight: 500; flex: 1; }
.user-row .urole { font-size: 0.72rem; color: var(--text-2); }
.user-row .uvocab { font-size: 0.72rem; color: var(--text-3); }
.user-row .udel {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--hairline);
  cursor: pointer;
  font-family: inherit;
  display: grid;
  place-items: center;
  transition: all 180ms var(--ease);
}
.user-row .udel:hover { background: var(--err); color: white; border-color: var(--err); }
.user-row .urole-toggle {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all 180ms var(--ease);
}
.user-row .urole-toggle:hover { background: var(--surface); color: var(--text); }
.user-row .urole-toggle.is-admin {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}
.user-row .uaccess {
  font-size: 0.7rem;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.user-row .uaccess.expired { color: var(--err); }
.user-row .uaccess.unlimited { color: var(--ok); }
.user-row .access-actions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.user-row .access-btn {
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
  transition: all 180ms var(--ease);
}
.user-row .access-btn:hover { background: var(--surface); color: var(--text); }
.user-row .access-btn.unlimited:hover { background: var(--ok); color: #003817; border-color: var(--ok); }

.new-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.5rem;
}
.new-user-form select { min-width: 100px; }
@media (max-width: 540px) {
  .new-user-form {
    grid-template-columns: 1fr 1fr;
  }
  .new-user-form select,
  .new-user-form .btn-compact {
    grid-column: span 2;
  }
}

/* === Generic modal === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: fadeIn 200ms var(--ease);
}
.modal-card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem 1.5rem 1.25rem;
  border-radius: var(--r-xl);
}
.modal-card h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-weight: 700;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--hairline);
  padding: 0.55rem 1rem;
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ==========================================================
   History modal — list of past transcripts with search + copy + delete
   ========================================================== */
.history-card {
  max-width: 600px;
  width: 100%;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.25rem 1rem;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.history-head h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }

.history-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.history-search {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.history-search svg {
  position: absolute;
  left: 0.7rem;
  color: var(--text-3);
  pointer-events: none;
}
.history-search input {
  padding: 0.55rem 0.85rem 0.55rem 2.2rem;
  border-radius: 999px;
  font-size: 0.92rem;
}
.history-stats {
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.25rem 0;
  margin: 0 -0.25rem;
  scroll-padding: 8px;
}
.history-list::-webkit-scrollbar { width: 8px; }
.history-list::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
}
.history-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-3);
  font-size: 0.92rem;
}

.history-item {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  transition: background 180ms var(--ease), border-color 180ms var(--ease);
  cursor: pointer;
}
.history-item:hover { background: var(--surface-3); border-color: var(--hairline-strong); }
.history-item.expanded { background: var(--surface); border-color: var(--accent); }

.history-item-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.history-item-time { color: var(--text-2); }
.history-item-badge {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.history-item-spacer { flex: 1; }
.history-item-len { color: var(--text-3); }

.history-item-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.history-item.expanded .history-item-text {
  display: block;
  -webkit-line-clamp: unset;
  white-space: pre-wrap;
}

.history-item-raw {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--hairline);
  font-size: 0.85rem;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.history-item-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.history-item-action {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 180ms var(--ease);
}
.history-item-action:hover { background: var(--surface); color: var(--text); }
.history-item-action.copied {
  background: var(--ok);
  color: #003817;
  border-color: var(--ok);
}
.history-item-action.danger:hover {
  background: var(--err);
  color: white;
  border-color: var(--err);
}

.history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--hairline);
  margin-top: 0.5rem;
}
.history-page-label {
  font-size: 0.85rem;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: center;
}
.history-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.history-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--hairline);
}
.history-clear:hover {
  background: var(--err);
  color: white;
  border-color: var(--err);
}

/* ===== 工具栏第二行（全选 / 复制全部 / 导出） ===== */
.history-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.history-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
}
.history-select-all input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ===== 列表项内的多选 + 行级复制 ===== */
.history-item-checkbox {
  display: inline-flex;
  align-items: center;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.history-item-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.history-item.row-selected {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.32);
}
.history-item-quickcopy {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: all 180ms var(--ease);
  font-size: 0.85rem;
}
.history-item { position: relative; }
.history-item:hover .history-item-quickcopy {
  opacity: 1;
  transform: translateY(0);
}
.history-item-quickcopy:hover {
  background: var(--accent);
  color: white;
  border-color: transparent;
}
.history-item-quickcopy.copied {
  background: var(--ok);
  color: white;
  border-color: transparent;
  opacity: 1;
}

/* ===== 多选浮条（仅在 history modal 内） ===== */
.history-bulk {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem 0.55rem 1rem;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  z-index: 5;
  animation: slideUp 220ms var(--ease);
}
.history-bulk .bulk-info { font-size: 0.82rem; color: var(--text-2); white-space: nowrap; }
.history-bulk .bulk-info b { color: var(--accent); font-variant-numeric: tabular-nums; }
.history-bulk .bulk-actions { display: flex; gap: 0.3rem; }
.history-bulk .bulk-actions button {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  color: var(--text);
  cursor: pointer;
  transition: all 150ms var(--ease);
}
.history-bulk .bulk-actions button:hover { background: var(--surface); }
.history-bulk .bulk-actions button.danger:hover { background: var(--err); color: white; border-color: var(--err); }
.history-bulk .bulk-close {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.75rem;
}

/* ===== 顶部 toast ===== */
.toast {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 1000;
  padding: 0.7rem 1.1rem;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  font-size: 0.88rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: var(--ok); }
.toast.error { border-color: var(--err); }
.toast.warn { border-color: #d97706; }
.toast.show { pointer-events: auto; }
.toast-action {
  margin-left: 0.7rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
}
.toast-action:hover { background: var(--hairline); }

/* ===== Password modal: strength rules + match hint ===== */
#pw-form .field { margin-bottom: 0.85rem; }
#pw-form .field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-2);
  margin-bottom: 0.3rem;
}
.pw-strength {
  list-style: none;
  padding: 0.5rem 0.7rem;
  margin: 0.4rem 0 0;
  background: var(--hairline);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.pw-rule {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.15rem 0;
  transition: color 150ms var(--ease);
}
.pw-rule .pw-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(220, 60, 60, 0.12);
  color: var(--err);
}
.pw-rule.ok { color: var(--text); }
.pw-rule.ok .pw-icon {
  background: rgba(40, 170, 100, 0.16);
  color: var(--ok);
}
.pw-match-hint {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  min-height: 1em;
}
.pw-match-hint.ok { color: var(--ok); }
.pw-match-hint.err { color: var(--err); }
#pw-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 540px) {
  .history-card { max-height: 92dvh; padding: 1rem; }
  .history-toolbar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .history-stats { text-align: right; }
}
kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-2);
}

/* =========== Mobile tweaks =========== */
@media (max-width: 480px) {
  .record-btn { width: 148px; height: 148px; }
  .record-icon { width: 38px; height: 38px; }
  .login-card { padding: 1.75rem 1.25rem 1.5rem; }
  .brand h1 { font-size: 1.5rem; }
  #app-view { padding-left: 0.85rem; padding-right: 0.85rem; }
  .setting-row select { min-width: 120px; }
}

@media (hover: none) {
  /* on touch devices, tap-and-hold should still feel snappy */
  .record-btn { transition-duration: 100ms; }
}

/* ==========================================================
   THEME PICKER — full-screen on first launch, modal afterwards
   ========================================================== */
.theme-picker {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: saturate(140%) blur(20px);
  -webkit-backdrop-filter: saturate(140%) blur(20px);
  animation: fadeIn 280ms var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.theme-picker-card {
  width: 100%;
  max-width: 560px;
  padding: 2rem 1.5rem 1.5rem;
  border-radius: var(--r-xl);
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-2);
}
.theme-picker-card h2 {
  margin: 0 0 0.4em;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}
.theme-picker-card .sub {
  margin: 0 0 1.5em;
  text-align: center;
  color: var(--text-2);
  font-size: 0.95rem;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 0.85rem 0.95rem;
  border-radius: var(--r-md);
  border: 2px solid var(--hairline);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 200ms var(--ease), border-color 200ms var(--ease),
              box-shadow 240ms var(--ease);
  overflow: hidden;
}
.theme-card:hover {
  transform: translateY(-2px);
  border-color: var(--hairline-strong);
}
.theme-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
}
.theme-card.selected::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center / 14px no-repeat;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
/* preview swatches */
.theme-card .swatch {
  width: 100%;
  height: 70px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.theme-card .swatch::before {
  /* simulated mic button */
  content: "";
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--card-accent, #fff);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.theme-card .swatch::after {
  /* simulated card */
  content: "";
  position: absolute;
  top: 12px;
  left: 12px;
  width: 60%;
  height: 28px;
  border-radius: 6px;
  background: var(--card-surface, rgba(255,255,255,0.15));
  border: 1px solid var(--card-border, rgba(255,255,255,0.2));
}
.theme-card .name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.theme-card .desc {
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.35;
}

/* per-theme preview swatch — confident accent colors */
.tc-tahu      { --card-accent: #f59e0b; --card-surface: rgba(255,253,250,0.92); --card-border: rgba(245,158,11,0.34); }
.tc-tahu      .swatch {
  background:
    radial-gradient(at 25% 20%, #ffd9b3 0%, transparent 55%),
    radial-gradient(at 80% 75%, #d4f1ff 0%, transparent 55%),
    linear-gradient(135deg, #fbf8f3 0%, #ffe6f2 100%);
}
.tc-squirrel  { --card-accent: #c45a2b; --card-surface: #ffffff; --card-border: rgba(196,90,43,0.40); }
.tc-squirrel  .swatch {
  background: linear-gradient(180deg, #d97047 0%, #b04a1f 70%, #f5efe6 70%, #f5efe6 100%);
  border: 1px solid #d4c8b0;
}

.theme-picker-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.theme-picker-actions .btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--hairline);
  padding: 0.6rem 1rem;
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

/* ==========================================================
   ONBOARDING TOUR — multi-step spotlight with tooltip
   ========================================================== */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  animation: fadeIn 200ms var(--ease);
}
.tour-spotlight {
  position: fixed;
  z-index: 121;
  border-radius: 16px;
  box-shadow:
    0 0 0 6px rgba(var(--accent-rgb), 0.45),
    0 0 0 9999px rgba(0, 0, 0, 0.62);
  pointer-events: none;
  transition: top 280ms var(--ease), left 280ms var(--ease),
              width 280ms var(--ease), height 280ms var(--ease);
  animation: spotlightPulse 1.8s var(--ease) infinite;
}
@keyframes spotlightPulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.45), 0 0 0 9999px rgba(0, 0, 0, 0.62); }
  50%      { box-shadow: 0 0 0 12px rgba(var(--accent-rgb), 0.20), 0 0 0 9999px rgba(0, 0, 0, 0.62); }
}
.tour-tip {
  position: fixed;
  z-index: 122;
  max-width: 320px;
  padding: 1rem 1.25rem 0.85rem;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  transition: top 280ms var(--ease), left 280ms var(--ease);
}
.tour-tip h3 {
  margin: 0 0 0.35em;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.tour-tip p {
  margin: 0 0 0.85em;
  font-size: 0.92rem;
  color: var(--text-2);
  line-height: 1.5;
}
.tour-tip-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}
.tour-progress {
  font-size: 0.78rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.tour-buttons { display: flex; gap: 0.4rem; }
.tour-btn {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all 180ms var(--ease);
}
.tour-btn:hover { background: var(--surface-3); color: var(--text); }
.tour-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}
.tour-btn.primary:hover { filter: brightness(1.08); }

/* ==========================================================
   PiP / floating window mode — when app-main is moved into a
   Document Picture-in-Picture window, body gets .pip-mode
   ========================================================== */
body.pip-mode {
  padding: max(0.5rem, env(safe-area-inset-top)) 0.85rem max(0.5rem, env(safe-area-inset-bottom));
  background: var(--bg);
  /* HARD FLOOR — no matter how small the user drags PiP, body content
     stays at least this big so the screenshot layout (mic + copy + text)
     remains visible. JS additionally clamps the PiP window itself to
     these dimensions on resize. */
  min-width: 280px;
  min-height: 460px;
  /* PiP root is a flex column so the result/textarea can grow/shrink and
     never push the record button off-screen. Critical elements (record
     btn, polished textarea, copy icon) are always given visual priority. */
  display: flex;
  flex-direction: column;
}
body.pip-mode .bg { display: none; }   /* skip animated blobs in tiny window for perf */
body.pip-mode .app-main {
  margin-top: 0;
  gap: 0.85rem;
  max-width: none;
  flex: 1;
  min-height: 0;          /* allow children with overflow to shrink properly */
  display: flex;
  flex-direction: column;
}
body.pip-mode .record-zone {
  padding: 1rem 0 0.25rem;
  flex-shrink: 0;          /* never shrink the record button area */
}
body.pip-mode .record-btn { width: 124px; height: 124px; }
body.pip-mode .record-icon { width: 34px; height: 34px; }
body.pip-mode .meter { width: 160px; }
body.pip-mode .status { font-size: 0.85rem; }
body.pip-mode .result {
  padding: 0.5rem 0.6rem;
  border-radius: 14px;
  flex: 1 1 auto;         /* polished result grows to fill, can also shrink */
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.pip-mode .result textarea {
  min-height: 70px;
  font-size: 0.95rem;
  flex: 1;
  resize: none;
}
body.pip-mode .settings { border-radius: 14px; }
body.pip-mode .settings summary { padding: 0.7rem 0.85rem; font-size: 0.9rem; }
body.pip-mode .settings-body { padding: 0.4rem 0.85rem 0.85rem; }
body.pip-mode .hint { display: none; }
body.pip-mode .trial-banner { display: none; }            /* not essential in PiP */
body.pip-mode .pinned-placeholder { display: none; }      /* lives in main window */
body.pip-mode .admin-link-card { display: none; }         /* admin entry: keep main only */

/* ─────────────────────────────────────────────────────────────
   PiP shrink tiers — progressive disclosure as window narrows.
   Priority pyramid (always visible at every size):
     1. polished text (#polished-text textarea)
     2. record button (#record-btn .record-icon)
     3. copy icon (#copy-btn svg)
   Everything else can drop off as space disappears.
   ───────────────────────────────────────────────────────────── */

/* TIER 1 — small window (≤ 360px): hide vocab + settings noise. */
@media (max-width: 360px) {
  body.pip-mode { padding: 0.5rem 0.55rem; }
  body.pip-mode .app-main { gap: 0.5rem; }
  body.pip-mode .vocab-suggest,
  body.pip-mode .settings { display: none; }
  body.pip-mode .record-btn { width: 96px; height: 96px; }
  body.pip-mode .record-icon { width: 28px; height: 28px; }
  body.pip-mode .meter { width: 120px; }
}

/* TIER 2 — at the FLOOR (≤ 280px wide): this is the minimum allowed size.
   JS resize-clamp prevents going smaller. Layout matches the user-provided
   screenshot: large mic button + status + tabs + copy button + textarea.
   The record button stays at 96px (the FLOOR — never smaller). */
@media (max-width: 320px) {
  body.pip-mode { padding: 0.5rem 0.55rem; }
  body.pip-mode .app-main { gap: 0.5rem; }
  body.pip-mode .record-zone { padding: 0.6rem 0 0.2rem; gap: 0.4rem; }
  /* FLOOR: record button never below 96px — matches the visual weight in screenshot */
  body.pip-mode .record-btn {
    width: 96px;
    height: 96px;
    min-width: 96px;
    min-height: 96px;
  }
  body.pip-mode .record-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
  }
  body.pip-mode .meter { width: 100px; height: 4px; }
  body.pip-mode .status {
    font-size: 0.78rem;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  body.pip-mode .result { padding: 0.4rem 0.55rem; }
  body.pip-mode .result textarea { min-height: 56px; font-size: 0.88rem; }
  /* Compact copy button but keep BOTH icon AND label visible (matches screenshot) */
  body.pip-mode #copy-btn { padding: 0.32rem 0.7rem; }
  body.pip-mode #copy-btn svg { width: 14px; height: 14px; }
  body.pip-mode #copy-btn span { font-size: 0.82rem; }
}
