/* drag · 单词卡 — Vercel Geist design language.
   Tokens from vercel.com/design.md: 4px spacing, 6/12/16px radius, layered
   translucent borders, defined shadow ramps, motion only to clarify. */

:root {
  --bg-100: #ffffff;
  --bg-200: #fafafa;
  --fg: #171717;     /* gray-1000 primary */
  --fg-2: #666666;   /* secondary */
  --fg-3: #8f8f8f;   /* tertiary / disabled */
  --border: rgba(0, 0, 0, .08);
  --border-2: rgba(0, 0, 0, .14);
  --accent: #0070f3;
  --accent-fg: #ffffff;
  --green: #16a34a;
  --amber: #b45309;
  --radius: 6px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-card: 0 2px 2px rgba(0, 0, 0, .04);
  --shadow-pop: 0 1px 1px rgba(0, 0, 0, .02), 0 4px 8px -4px rgba(0, 0, 0, .04), 0 16px 24px -8px rgba(0, 0, 0, .06);
  --ease: cubic-bezier(.175, .885, .32, 1.1);
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
[data-theme="dark"], :root:not([data-theme="light"]) {
  /* dark values applied via the media query below to avoid clobbering light */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-100: #0a0a0a; --bg-200: #161616; --fg: #ededed; --fg-2: #a1a1a1; --fg-3: #6f6f6f;
    --border: rgba(255, 255, 255, .10); --border-2: rgba(255, 255, 255, .18);
    --shadow-card: 0 2px 2px rgba(0, 0, 0, .25);
    --shadow-pop: 0 1px 1px rgba(0, 0, 0, .25), 0 4px 8px -4px rgba(0, 0, 0, .35), 0 16px 24px -8px rgba(0, 0, 0, .45);
  }
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg-100: #0a0a0a; --bg-200: #161616; --fg: #ededed; --fg-2: #a1a1a1; --fg-3: #6f6f6f;
  --border: rgba(255, 255, 255, .10); --border-2: rgba(255, 255, 255, .18);
  --shadow-card: 0 2px 2px rgba(0, 0, 0, .25);
  --shadow-pop: 0 1px 1px rgba(0, 0, 0, .25), 0 4px 8px -4px rgba(0, 0, 0, .35), 0 16px 24px -8px rgba(0, 0, 0, .45);
}
[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-200);
  color: var(--fg);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  font-feature-settings: 'cv11', 'ss01';
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
:focus:not(:focus-visible) { outline: none; }
[hidden] { display: none !important; } /* beat element display rules (e.g. .reveal flex) */

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 20px; padding-top: env(safe-area-inset-top, 0);
  border-bottom: 1px solid var(--border); background: var(--bg-100);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: -.01em; }
.brand .dot { width: 9px; height: 9px; border-radius: 9999px; background: var(--accent); }
.brand .sep { color: var(--fg-3); font-weight: 400; }
.muted { color: var(--fg-2); font-weight: 500; }
.chip-sample {
  font-size: 11px; font-weight: 500; color: var(--amber);
  border: 1px solid var(--border-2); border-radius: 9999px; padding: 1px 8px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.counter { color: var(--fg-2); font-size: 13px; min-width: 44px; text-align: right; }
.icon-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-100); color: var(--fg-2);
  width: 32px; height: 32px; border-radius: var(--radius); cursor: pointer; font-size: 14px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-200); color: var(--fg); }

/* ── progress bar ── */
.progress { display: flex; gap: 3px; padding: 10px 20px 0; background: var(--bg-200); }
.progress:empty { display: none; }
.seg {
  flex: 1; height: 4px; border-radius: 9999px; background: var(--border);
  position: relative; transition: background .2s var(--ease);
}
.seg.known { background: var(--accent); }
.seg.review { background: transparent; border: 1px solid var(--amber); }
.seg.current { box-shadow: 0 0 0 2px var(--bg-200), 0 0 0 3px var(--accent); }

/* ── stage ── */
.stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 28px 20px; }

/* ── card ── */
.card {
  width: 100%; max-width: 560px;
  background: var(--bg-100); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); padding: 40px;
}
.card.in-right { animation: in-right .26s var(--ease) both; }
.card.in-left { animation: in-left .26s var(--ease) both; }
@keyframes in-right { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes in-left { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }

.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.word { font-size: 40px; line-height: 44px; font-weight: 600; letter-spacing: -.02em; overflow-wrap: anywhere; }
.pron { font-family: var(--mono); color: var(--fg-2); font-size: 15px; }
.pos {
  font-size: 12px; font-weight: 500; color: var(--fg-2);
  border: 1px solid var(--border-2); border-radius: 9999px; padding: 1px 8px; align-self: center;
}
.count { margin-left: auto; align-self: center; font-size: 12px; color: var(--fg-3); }

/* reveal affordance (front) */
.reveal { margin-top: 28px; display: flex; justify-content: center; }
.reveal-btn {
  appearance: none; cursor: pointer; font-family: var(--font); font-size: 14px; color: var(--fg-2);
  background: var(--bg-200); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 16px; transition: background .15s var(--ease), color .15s var(--ease);
}
.reveal-btn:hover { background: var(--bg-100); color: var(--fg); border-color: var(--border-2); }
.reveal-btn .k { font-family: var(--mono); font-size: 11px; color: var(--fg-3); margin-left: 8px; }

/* body (revealed) */
.body { margin-top: 4px; }
.body > * { animation: rise .26s var(--ease) both; }
.body > *:nth-child(2) { animation-delay: .03s; }
.body > *:nth-child(3) { animation-delay: .06s; }
.body > *:nth-child(4) { animation-delay: .09s; }
.body > *:nth-child(5) { animation-delay: .12s; }
.body > *:nth-child(n+6) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.gloss { font-size: 22px; line-height: 28px; font-weight: 500; letter-spacing: -.01em; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.section + .section { margin-top: 20px; }
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--fg-3); margin-bottom: 8px;
}
.senses { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.sense { display: flex; gap: 8px; flex-wrap: wrap; }
.sense .zh { font-weight: 500; }
.sense .en { color: var(--fg-2); }
.examples { display: flex; flex-direction: column; gap: 12px; }
.eg { border-left: 2px solid var(--border-2); padding-left: 12px; }
.eg .src { font-size: 15px; }
.eg .zh { color: var(--fg-2); margin-top: 2px; }
.note {
  background: var(--bg-200); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; color: var(--fg-2); font-style: italic;
}
.mnemonic { color: var(--fg); }
.muted-text { color: var(--fg-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 13px; color: var(--fg-2); background: var(--bg-200);
  border: 1px solid var(--border); border-radius: 9999px; padding: 2px 10px;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
button.chip { cursor: pointer; font-family: var(--font); }
button.chip:hover { color: var(--accent); border-color: var(--accent); }
.sources { display: flex; flex-direction: column; gap: 6px; }
.source { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--fg-2); flex-wrap: wrap; }
.source a { color: var(--fg-2); text-decoration: none; border-bottom: 1px solid var(--border-2); }
.source a:hover { color: var(--fg); }
.source .ctx { color: var(--fg-3); }

/* actions */
.actions { display: flex; gap: 8px; margin-top: 28px; }
.btn {
  appearance: none; cursor: pointer; flex: 1; min-height: 44px; border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  border: 1px solid var(--border-2); background: var(--bg-100); color: var(--fg);
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--bg-200); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--fg); color: var(--bg-100); border-color: var(--fg); }
.btn.primary:hover { opacity: .9; background: var(--fg); }
.btn .k { font-family: var(--mono); font-size: 11px; color: var(--fg-3); margin-left: 6px; }
.btn.primary .k { color: rgba(255, 255, 255, .5); }
[data-theme="light"] .btn.primary .k { color: rgba(255, 255, 255, .5); }

/* ── loading / error / empty / done ── */
.skeleton { width: 100%; max-width: 560px; border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--bg-100); box-shadow: var(--shadow-card); padding: 40px; }
.sk-line { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--bg-200), var(--border), var(--bg-200)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.sk-line.lg { height: 40px; width: 60%; margin-bottom: 24px; }
.sk-line.md { width: 80%; margin-top: 12px; }
.sk-line.sm { width: 40%; margin-top: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.panel { text-align: center; color: var(--fg-2); max-width: 440px; }
.panel h2 { font-size: 20px; font-weight: 600; color: var(--fg); letter-spacing: -.01em; margin: 0; }
.panel p { margin: 8px 0 0; }
.panel code, .panel .api { font-family: var(--mono); background: var(--bg-100); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 13px; word-break: break-all; }
.panel .panel-actions { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
.panel .btn { flex: 0 0 auto; padding: 0 20px; }
.summary-stats { display: flex; gap: 24px; justify-content: center; margin-top: 16px; }
.summary-stats .stat { display: flex; flex-direction: column; gap: 2px; }
.summary-stats .num { font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.summary-stats .num.known { color: var(--accent); }
.summary-stats .num.review { color: var(--amber); }
.summary-stats .lbl { font-size: 12px; color: var(--fg-3); }

/* ── hints ── */
.hints {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--bg-100); color: var(--fg-3); font-size: 12px;
}
.hints kbd {
  font-family: var(--mono); font-size: 11px; background: var(--bg-200);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  padding: 1px 5px; margin: 0 1px; color: var(--fg-2);
}

/* ── notice ── */
.notice {
  position: fixed; left: 50%; bottom: calc(64px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg-100); font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 20;
}

@media (max-width: 600px) {
  .card, .skeleton { padding: 28px 22px; }
  .word { font-size: 32px; line-height: 36px; }
  .gloss { font-size: 19px; line-height: 25px; }
  .hints span:nth-child(n+3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, .card.in-right, .card.in-left, .body > * { animation: none !important; transition: none !important; }
}
