/* ══════════════════════════════════════════════════════════════════════════
   BingoWords Design System v2
   —— 一套变量，两种模式：深色（深海暗夜）/ 浅色（纸感白）
   —— 由 <html data-theme="dark|light"> 切换，脚本持久化到 localStorage
   ══════════════════════════════════════════════════════════════════════════ */

/* ───────────────────────── 设计令牌 ───────────────────────── */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-serif: 'Charter', 'Iowan Old Style', Georgia, 'Songti SC', serif;

  --r-xs: 8px;
  --r-sm: 11px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* 语义色：两套模式共用 */
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --violet: #8b5cf6;
}

/* ── 深色：深海暗夜 ── */
html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #08090c;
  --bg-2: #0b0d12;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.065);
  --surface-3: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: #f2f4f8;
  --text-2: #99a1b3;
  --text-3: #646b7c;
  --accent: #5ac8fa;
  --accent-ink: #04202e;
  --accent-soft: rgba(90, 200, 250, 0.14);
  --accent-line: rgba(90, 200, 250, 0.32);
  --primary: #1a95f7;
  --primary-hover: #0a84ff;
  --on-primary: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  --shadow-up: 0 -8px 24px -12px rgba(0, 0, 0, 0.8);
  --glass: blur(28px) saturate(170%);
  --orb-a: rgba(56, 120, 255, 0.42);
  --orb-b: rgba(0, 190, 170, 0.26);
  --orb-c: rgba(122, 92, 255, 0.3);
  --tint: rgba(255, 255, 255, 0.055);
}

/* ── 浅色：纸感白（与深色同构，不刺眼） ── */
html[data-theme='light'] {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #f1f3f7;
  --stroke: rgba(16, 24, 40, 0.08);
  --stroke-2: rgba(16, 24, 40, 0.14);
  --text: #0e1219;
  --text-2: #5b6577;
  --text-3: #8b93a3;
  --accent: #0a84ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 132, 255, 0.09);
  --accent-line: rgba(10, 132, 255, 0.3);
  --primary: #0a84ff;
  --primary-hover: #0071e3;
  --on-primary: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px -12px rgba(16, 24, 40, 0.18);
  --shadow-up: 0 -6px 20px -12px rgba(16, 24, 40, 0.2);
  --glass: blur(20px) saturate(180%);
  --orb-a: rgba(56, 120, 255, 0.14);
  --orb-b: rgba(0, 190, 170, 0.1);
  --orb-c: rgba(122, 92, 255, 0.1);
  --tint: rgba(16, 24, 40, 0.035);
}

/* ───────────────────────── 基础 ───────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  touch-action: manipulation;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; line-height: 1.65; }
.tiny { font-size: 11px; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
b { font-weight: 600; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* 背景氛围球：静态，不跑动画 */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); }
.orb-a { width: 48vw; height: 48vw; min-width: 320px; min-height: 320px; left: -14vw; top: -16vw; background: radial-gradient(circle, var(--orb-a), transparent 68%); }
.orb-b { width: 40vw; height: 40vw; min-width: 280px; min-height: 280px; right: -10vw; top: 6vh; background: radial-gradient(circle, var(--orb-b), transparent 68%); }
.orb-c { width: 52vw; height: 52vw; min-width: 340px; min-height: 340px; left: 20vw; bottom: -28vw; background: radial-gradient(circle, var(--orb-c), transparent 66%); }

/* 卡片基础：深色用毛玻璃，浅色用实心白 + 细边 */
.surface {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
html[data-theme='dark'] .surface {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022));
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow);
}

/* ───────────────────────── 图标 ───────────────────────── */
.ico { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }

/* ───────────────────────── 按钮 ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; letter-spacing: -0.01em;
  transition: transform 0.16s var(--ease), background 0.18s, border-color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 14px -6px rgba(10, 132, 255, 0.6); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--stroke-2); }
.btn-quiet { background: transparent; border: 1px dashed var(--stroke-2); color: var(--text-2); }
.btn-quiet:hover { color: var(--text); border-style: solid; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { height: 48px; font-size: 15px; border-radius: var(--r-md); }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after {
  content: ''; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; opacity: 0.8;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn { width: 34px; height: 34px; border-radius: var(--r-xs); display: grid; place-items: center; color: var(--text-2); transition: 0.18s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

/* ───────────────────────── 表单 ───────────────────────── */
.field { display: grid; gap: 7px; position: relative; }
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field-label small { color: var(--text-3); font-weight: 400; }
.input {
  width: 100%; height: 44px; padding: 0 13px;
  background: var(--tint); color: var(--text);
  border: 1px solid var(--stroke); border-radius: var(--r-sm);
  font-size: 15px; outline: none; font-family: inherit;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
html[data-theme='light'] .input { background: #fff; }
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { height: auto; padding: 11px 13px; line-height: 1.65; resize: vertical; min-height: 84px; }
.input-flat { height: 34px; font-size: 13px; border-radius: var(--r-xs); }
@media (max-width: 640px) { .input { font-size: 16px; } .input-flat { font-size: 16px; } }
.counter { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.hint { margin: 2px 0 0; font-size: 11.5px; color: var(--text-3); }
.row-gap { display: flex; gap: 8px; }
.code-input { letter-spacing: 0.2em; flex: 1; min-width: 0; }
.btn-send { flex: none; height: 44px; }

/* 分段控制器 */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--tint); border: 1px solid var(--stroke); border-radius: var(--r-md);
}
.seg-item {
  padding: 6px 16px; border-radius: var(--r-xs); font-size: 13px; font-weight: 500;
  color: var(--text-2); transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}
.seg-item.is-active { background: var(--bg-2); color: var(--text); box-shadow: var(--shadow); }
.seg-mini .seg-item { padding: 4px 11px; font-size: 12px; }

/* 主题切换 */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 99px; background: var(--tint); border: 1px solid var(--stroke);
  color: var(--text-2); font-size: 12px; transition: 0.18s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--stroke-2); }

/* ═══════════════ 认证页 ═══════════════ */
.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center; gap: 56px;
  padding: 32px 20px calc(32px + var(--safe-b));
  grid-template-columns: minmax(0, 400px);
}
.auth-card { padding: 32px 28px; width: 100%; max-width: 400px; }
.auth-theme { position: fixed; top: calc(18px + var(--safe-t)); right: 18px; }
.auth-title { font-size: 29px; line-height: 1.24; font-weight: 600; letter-spacing: -0.03em; margin: 22px 0 10px; }
.auth-title em { font-style: normal; background: linear-gradient(96deg, var(--accent), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { color: var(--text-2); font-size: 13.5px; margin: 0 0 22px; line-height: 1.6; }
.auth-form { display: grid; gap: 14px; margin-top: 18px; }
.auth-form .btn-block { margin-top: 4px; }
.demo-btn { margin-top: 12px; }
.auth-aside { display: none; }
@media (min-width: 1024px) {
  .auth-wrap { grid-template-columns: minmax(0, 400px) minmax(0, 360px); align-items: center; }
  .auth-aside { display: block; }
}

.pill {
  display: inline-block; padding: 4px 11px; border-radius: 99px; font-size: 11.5px;
  letter-spacing: 0.04em; color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.auth-aside h2 { font-size: 23px; letter-spacing: -0.02em; margin: 16px 0 22px; font-weight: 600; }
.feat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.feat-list li {
  display: grid; gap: 3px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--stroke);
}
.feat-list b { font-size: 14px; }
.feat-list span { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.brand-name b { color: var(--accent); font-weight: 600; }

/* ═══════════════ 主框架 ═══════════════ */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + var(--safe-t));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--stroke);
}
.page-title { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.page-sub { display: none; font-size: 12px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 7px; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px;
  background: var(--tint); border: 1px solid var(--stroke); font-size: 12px; color: var(--text-2);
}
.stat-pill b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); }
.dot-accent { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.canvas { min-width: 0; padding-bottom: calc(84px + var(--safe-b)); }
.panes { padding: 16px; max-width: 1200px; margin: 0 auto; }
.pane { display: none; animation: fade 0.3s var(--ease); }
.pane.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  border-top: 1px solid var(--stroke);
}
.bn-item { display: grid; justify-items: center; gap: 3px; padding: 6px 0; border-radius: var(--r-sm); color: var(--text-3); font-size: 10.5px; transition: color 0.18s, background 0.18s; }
.bn-item.is-active { color: var(--accent); background: var(--accent-soft); }
.bn-item .ico { width: 19px; height: 19px; }

@media (min-width: 641px) {
  .panes { padding: 22px 24px; }
  .page-sub { display: block; margin-top: 2px; }
  .page-title { font-size: 19px; }
  .topbar { padding: 14px 24px; }
}
@media (min-width: 1024px) {
  .shell { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px;
    position: sticky; top: 0; height: 100dvh; padding: 22px 12px;
    border-right: 1px solid var(--stroke);
    background: color-mix(in srgb, var(--bg-2) 70%, transparent);
    backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  }
  .sidebar .brand { padding: 0 8px 20px; }
  .nav { display: grid; gap: 2px; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 11px;
    border-radius: var(--r-sm); font-size: 13.5px; color: var(--text-2); text-align: left;
    transition: background 0.18s, color 0.18s;
  }
  .nav-item:hover { background: var(--tint); color: var(--text); }
  .nav-item.is-active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
  .nav-item.is-active .ico { color: var(--accent); }
  .sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--stroke); }
  .user-chip { display: flex; align-items: center; gap: 9px; padding: 4px; }
  .avatar {
    width: 30px; height: 30px; border-radius: var(--r-xs); display: grid; place-items: center;
    font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--accent-line); flex: none;
  }
  .user-meta { display: grid; min-width: 0; flex: 1; }
  .user-meta b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-meta small { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav { display: none; }
  .canvas { padding-bottom: 24px; }
}

/* ═══════════════ 查词 ═══════════════ */
.search-hero { padding: 14px; margin-bottom: 16px; }
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--tint); border: 1px solid var(--stroke); border-radius: var(--r-md);
  padding: 4px 5px 4px 14px; transition: border-color 0.18s, box-shadow 0.18s;
}
html[data-theme='light'] .search-bar { background: var(--surface-3); }
.search-bar:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { color: var(--text-3); }
.search-input { flex: 1; min-width: 0; height: 38px; background: none; border: 0; outline: none; color: var(--text); font-size: 16px; font-family: inherit; }
.search-input::placeholder { color: var(--text-3); font-size: 14.5px; }
.search-bar .btn { height: 38px; padding: 0 15px; }
.quick-words { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 12px; }
.quick-label { font-size: 11.5px; color: var(--text-3); }
.chip {
  padding: 4px 10px; border-radius: 99px; font-size: 12px; color: var(--text-2);
  background: var(--tint); border: 1px solid var(--stroke); transition: 0.18s;
  font-family: var(--font-mono);
}
.chip:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip:active { transform: scale(0.96); }

.empty-state, .story-empty, .review-empty {
  display: grid; justify-items: center; gap: 8px; text-align: center;
  padding: 44px 24px; color: var(--text-2);
  border: 1px dashed var(--stroke-2); border-radius: var(--r-lg);
}
.empty-ico { width: 38px; height: 38px; color: var(--text-3); fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.empty-state p, .story-empty p, .review-empty p { margin: 0; font-size: 14px; }
.empty-state small, .story-empty small { font-size: 12px; color: var(--text-3); }

/* ── 3D 闪卡 ── */
.flashcard-stage { perspective: 1600px; }
.flashcard {
  position: relative; width: 100%; height: 420px;
  transform-style: preserve-3d;
  transition: transform 0.7s var(--ease), height 0.3s var(--ease);
  will-change: transform;
  outline: none;
}
.flashcard.is-flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; padding: 22px;
  border-radius: var(--r-xl);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow-y: auto;
}
html[data-theme='dark'] .face {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.022));
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  border-color: var(--stroke-2);
}
.face-back { transform: rotateY(180deg); }

.face-top { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.badge {
  padding: 3px 9px; border-radius: 7px; font-size: 11.5px; font-weight: 500;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.badge-ghost { color: var(--text-2); background: var(--tint); border-color: var(--stroke); }
.card-word { font-size: clamp(30px, 6.5vw, 42px); font-weight: 600; letter-spacing: -0.035em; margin: 16px 0 6px; word-break: break-word; }
.card-phonetic { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); }
.card-def { font-size: 16px; margin: 18px 0 4px; line-height: 1.55; }
.card-def-en { font-size: 13px; color: var(--text-3); margin: 0; line-height: 1.6; }
.face-foot { margin-top: auto; padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.flip-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); }

/* Bento */
.bento { display: grid; grid-template-columns: 1fr; gap: 9px; margin-top: 14px; }
.bento-cell { padding: 13px 14px; border-radius: var(--r-md); background: var(--tint); border: 1px solid var(--stroke); }
.bento-cell.accent { background: var(--accent-soft); border-color: var(--accent-line); }
.cell-label { display: block; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.cell-breakdown { margin: 0; font-size: 15px; font-family: var(--font-mono); color: var(--accent); word-break: break-word; }
.cell-sub { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.cell-mnemonic { margin: 0; font-size: 14px; line-height: 1.7; }
.cell-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.cell-list li { padding-left: 12px; position: relative; }
.cell-list li::before { content: ''; position: absolute; left: 0; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: 0.75; }
.cell-list em { color: var(--text); font-style: normal; font-weight: 500; }

/* 骨架 */
.card-skeleton { padding: 24px; border-radius: var(--r-xl); border: 1px solid var(--stroke); background: var(--surface); display: grid; gap: 12px; }
.sk-row, .sk-grid span { border-radius: var(--r-xs); background: linear-gradient(90deg, var(--tint), var(--surface-3), var(--tint)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.sk-lg { height: 40px; width: 55%; }
.sk-md { height: 16px; width: 80%; }
.sk-sm { height: 16px; width: 40%; }
.sk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.sk-grid span { height: 72px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ═══════════════ 双栏 ═══════════════ */
.panel-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .panel-grid { grid-template-columns: minmax(280px, 336px) minmax(0, 1fr); } }
.card { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h4 { margin: 0; font-size: 14px; font-weight: 600; }

.word-picker { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; margin-bottom: 14px; }
.pick-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 99px;
  font-size: 12.5px; background: var(--tint); border: 1px solid var(--stroke);
  color: var(--text-2); transition: 0.18s; font-family: var(--font-mono);
}
.pick-chip:hover { border-color: var(--stroke-2); color: var(--text); }
.pick-chip.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.pick-chip .tick { width: 0; overflow: hidden; transition: width 0.18s var(--ease); display: grid; }
.pick-chip.is-on .tick { width: 12px; }
.seg-style { display: flex; width: 100%; margin-bottom: 12px; }
.seg-style .seg-item { flex: 1; text-align: center; }

.story-card { min-height: 300px; }
.story-body { animation: fade 0.3s var(--ease); }
.story-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.story-head h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.02em; }
.story-text { font-size: 15.5px; line-height: 2; margin: 0 0 20px; font-family: var(--font-serif); letter-spacing: 0.002em; }
.word-pill {
  position: relative; display: inline; padding: 1px 7px; margin: 0 1px; border-radius: 7px;
  color: var(--accent); background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-line);
  cursor: help; transition: background 0.18s, box-shadow 0.18s;
  font-family: var(--font-sans); font-size: 0.96em;
}
.word-pill:hover, .word-pill.is-open { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: 0 0 0 1px var(--accent-line); }
.word-tip {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  min-width: 150px; max-width: 260px; padding: 8px 11px; border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px solid var(--accent-line);
  color: var(--text); font-size: 12px; line-height: 1.55; font-weight: 400;
  box-shadow: var(--shadow); z-index: 5; pointer-events: none;
  opacity: 0; transition: opacity 0.16s;
}
.word-pill:hover .word-tip, .word-pill.is-open .word-tip { opacity: 1; }
.story-notes { border-top: 1px solid var(--stroke); padding-top: 14px; }
.story-notes h5 { margin: 0 0 10px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.story-notes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.story-notes li { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.story-notes li b { color: var(--accent); font-family: var(--font-mono); font-weight: 500; }
.story-takeaway {
  margin: 16px 0 0; padding: 11px 14px; border-radius: var(--r-sm); font-size: 13px;
  background: var(--tint); border-left: 2px solid var(--accent); color: var(--text-2);
}

/* ═══════════════ 造句批改 ═══════════════ */
.score-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.score-ring {
  --v: 0; position: relative; width: 88px; height: 88px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--v) * 1%), var(--tint) 0);
  display: grid; place-items: center; transition: background 0.6s var(--ease);
}
.score-ring::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg-2); }
.score-ring span { position: relative; font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.score-dims { flex: 1; min-width: 180px; display: grid; gap: 9px; }
.dim { display: grid; grid-template-columns: 48px 1fr 30px; gap: 9px; align-items: center; font-size: 12px; color: var(--text-2); }
.dim-bar { height: 5px; border-radius: 99px; background: var(--tint); overflow: hidden; }
.dim-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--violet)); transition: width 0.7s var(--ease); }
.dim b { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.issue-list { display: grid; gap: 8px; margin-bottom: 16px; }
.issue {
  padding: 11px 13px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.6;
  background: color-mix(in srgb, var(--amber) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 22%, transparent);
}
.issue .origin { color: var(--amber); font-family: var(--font-mono); text-decoration: line-through; }
.issue .fix { color: var(--green); font-family: var(--font-mono); }
.issue p { margin: 4px 0 0; color: var(--text-2); }
.polish-box {
  position: relative; padding: 15px; border-radius: var(--r-md); margin-bottom: 14px;
  background: color-mix(in srgb, var(--green) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 22%, transparent);
}
.polish-en { margin: 0 0 6px; font-size: 15.5px; line-height: 1.7; font-family: var(--font-serif); padding-right: 32px; }
.polish-cn { margin: 0 0 8px; font-size: 13px; color: var(--text-2); }
.polish-why { margin: 0; font-size: 12.5px; color: var(--text-3); line-height: 1.6; }
.variant-list { display: grid; gap: 7px; margin-bottom: 14px; }
.variant {
  padding: 10px 13px; border-radius: var(--r-sm); background: var(--tint);
  border: 1px solid var(--stroke); font-size: 13px; font-family: var(--font-serif);
  display: flex; align-items: center; gap: 8px;
}
.variant span { flex: 1; }
.next-step {
  margin: 0; font-size: 12.5px; color: var(--text-2); padding: 11px 13px;
  border-radius: var(--r-sm); background: color-mix(in srgb, var(--violet) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--violet) 22%, transparent); line-height: 1.6;
}

/* ═══════════════ 生词本工作台 ═══════════════ */
.workbench { padding: 0; overflow: hidden; }
.wb-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--stroke); flex-wrap: wrap;
}
.wb-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.search-inline {
  display: flex; align-items: center; gap: 7px; padding: 0 10px; border-radius: var(--r-xs);
  background: var(--tint); border: 1px solid var(--stroke); color: var(--text-3); min-width: 150px;
}
html[data-theme='light'] .search-inline { background: var(--surface-3); }
.search-inline .input { border: 0; background: none; padding: 0; }
.search-inline .input:focus { box-shadow: none; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); font-weight: 500; padding: 10px 16px; white-space: nowrap;
  border-bottom: 1px solid var(--stroke); background: var(--tint);
}
.data-table td { padding: 11px 16px; font-size: 13px; border-bottom: 1px solid var(--stroke); white-space: nowrap; vertical-align: middle; }
.data-table tbody tr { transition: background 0.16s; }
.data-table tbody tr:hover { background: var(--tint); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.ta-right { text-align: right; }
.td-word { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-weight: 500; color: var(--text); }
.td-def { color: var(--text-2); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.fam { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.fam-dot { width: 6px; height: 6px; border-radius: 50%; }
.fam-dot.n0 { background: var(--text-3); }
.fam-dot.n1 { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); }
.fam-dot.n2 { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.src-tag { font-size: 11px; color: var(--text-3); padding: 2px 7px; border-radius: 6px; background: var(--tint); }
.row-actions { display: inline-flex; border: 1px solid var(--stroke); border-radius: var(--r-xs); overflow: hidden; }
.row-actions button { padding: 5px 9px; font-size: 11.5px; color: var(--text-2); transition: 0.16s; }
.row-actions button + button { border-left: 1px solid var(--stroke); }
.row-actions button:hover { background: var(--surface-3); color: var(--text); }
.row-actions button[data-act='del']:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.wb-foot { padding: 40px 16px; text-align: center; }

/* 进度环（艾宾浩斯保持率） */
.retention { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.retention i { width: 18px; height: 18px; border-radius: 50%; display: block; }

/* ═══════════════ 词书 ═══════════════ */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.book-card {
  display: grid; gap: 5px; padding: 14px; border-radius: var(--r-md);
  background: var(--tint); border: 1px solid var(--stroke); text-align: left;
  transition: 0.18s var(--ease); min-height: 78px; align-content: start;
}
html[data-theme='light'] .book-card { background: var(--surface-3); }
.book-card:hover { border-color: var(--accent-line); background: var(--accent-soft); transform: translateY(-1px); }
.book-card.is-active { border-color: var(--accent-line); background: var(--accent-soft); }
.book-tag { font-size: 10.5px; color: var(--accent); letter-spacing: 0.04em; }
.book-name { font-size: 14px; font-weight: 600; }
.book-count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.book-picker { display: flex; flex-wrap: wrap; gap: 6px; max-height: 130px; overflow-y: auto; margin: 12px 0; }
.book-word {
  padding: 3px 8px; border-radius: 7px; font-size: 11.5px; font-family: var(--font-mono);
  background: var(--tint); border: 1px solid var(--stroke); color: var(--text-2);
}
.book-word em { color: var(--text-3); font-style: normal; margin-left: 5px; font-family: var(--font-sans); }

/* ═══════════════ 记忆曲线 ═══════════════ */
.forecast { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 96px; margin-bottom: 8px; align-items: end; }
.forecast-bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.forecast-bar i {
  display: block; width: 100%; border-radius: 5px 5px 2px 2px; min-height: 4px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 35%, transparent));
  transition: height 0.5s var(--ease);
}
.forecast-bar b { font-size: 10.5px; color: var(--text-2); font-variant-numeric: tabular-nums; line-height: 1; }
.forecast-label { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.forecast-label span { font-size: 10px; color: var(--text-3); text-align: center; }

/* ═══════════════ 刷词 ═══════════════ */
.review-stage { display: grid; gap: 14px; }
.grade-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grade-btn {
  height: 46px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--stroke); background: var(--tint); transition: 0.16s;
}
.grade-btn:active { transform: scale(0.97); }
.grade-btn.g0 { color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); background: color-mix(in srgb, var(--red) 8%, transparent); }
.grade-btn.g1 { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); background: color-mix(in srgb, var(--amber) 8%, transparent); }
.grade-btn.g2 { color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); background: color-mix(in srgb, var(--green) 8%, transparent); }
.progress-line { height: 4px; border-radius: 99px; background: var(--tint); overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s var(--ease); }

/* ── 导入 ── */
.import-preview { min-height: 150px; max-height: 340px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; margin-bottom: 14px; }
.import-chip { padding: 4px 10px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent); font-family: var(--font-mono); }

/* ═══════════════ 发音按钮 ═══════════════ */
.speak-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-xs);
  color: var(--text-2); flex: none; background: var(--tint); border: 1px solid var(--stroke);
  transition: color 0.18s, background 0.18s, border-color 0.18s, transform 0.14s var(--ease);
}
.speak-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.speak-btn:active { transform: scale(0.94); }
.speak-btn.is-speaking { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); animation: pulse-speak 1.1s ease-in-out infinite; }
.speak-btn.sm { width: 22px; height: 22px; border-radius: 6px; }
.speak-btn.sm .ico { width: 12px; height: 12px; }
@keyframes pulse-speak {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-line); }
  50% { box-shadow: 0 0 0 5px transparent; }
}
.card-phonetic .ph { display: inline-flex; align-items: center; gap: 7px; }
.ph-label { font-size: 9.5px; letter-spacing: 0.1em; color: var(--text-3); text-transform: uppercase; }

.examples { display: grid; gap: 10px; }
.example { padding: 10px 12px; border-radius: var(--r-sm); background: var(--tint); border: 1px solid var(--stroke); display: grid; gap: 4px; }
.example-row { display: flex; align-items: flex-start; gap: 8px; }
.example-en { flex: 1; margin: 0; font-size: 13.5px; line-height: 1.6; font-family: var(--font-serif); }
.example-cn { margin: 0; font-size: 12px; color: var(--text-2); line-height: 1.55; padding-left: 30px; }

.tts-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--tint); border: 1px solid var(--stroke); flex-wrap: wrap; }
.tts-tip { font-size: 11px; color: var(--text-3); margin-left: auto; }

/* ═══════════════ Toast ═══════════════ */
.toast-stack {
  position: fixed; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  z-index: 100; display: grid; gap: 8px; width: min(100% - 24px, 420px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-radius: var(--r-md);
  font-size: 13px; line-height: 1.5; background: var(--bg-2); border: 1px solid var(--stroke-2);
  box-shadow: var(--shadow); animation: toast-in 0.3s var(--ease); pointer-events: auto;
}
.toast.is-out { animation: toast-out 0.22s var(--ease) forwards; }
.toast .dot { width: 7px; height: 7px; }
.toast.ok .dot { background: var(--green); }
.toast.err .dot { background: var(--red); }
.toast.info .dot { background: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
