:root {
  --bg: #08090a; --panel: #0f1011; --surface: rgba(255,255,255,.03);
  --surface-hover: rgba(255,255,255,.05); --border: rgba(255,255,255,.08);
  --text: #f7f8f8; --secondary: #d0d6e0; --muted: #8a8f98;
  --brand: #5e6ad2; --brand-hover: #828fff; --success: #10b981;
  font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif;
  color: var(--text); background: var(--bg); font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
.topbar { min-height: 64px; padding: 12px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 24px; background: rgba(8,9,10,.92); }
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; }
.mark { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-hover); font-size: 13px; }
.deck-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.deck-nav::-webkit-scrollbar { display: none; }
.deck-pill, .quiet-button { border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); padding: 7px 10px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.deck-pill:hover, .quiet-button:hover { color: var(--secondary); background: var(--surface); }
.deck-pill.active { color: var(--text); background: var(--surface-hover); border-color: var(--border); }
.header-tools { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.progress { color: var(--secondary); font-variant-numeric: tabular-nums; font-size: 14px; }
.quiet-button { border-color: var(--border); color: var(--secondary); }
.mode-switch { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch span { width: 32px; height: 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-hover); padding: 2px; }
.mode-switch span::after { content: ''; display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .2s; }
.mode-switch input:checked + span::after { transform: translateX(14px); background: var(--secondary); }
main { min-height: calc(100vh - 65px); padding: 48px 20px; display: flex; flex-direction: column; align-items: center; }
.status { color: var(--muted); margin-bottom: 18px; font-size: 14px; }
.status.error { color: #e89292; }
.study-view { width: min(680px, 92vw); }
.card-meta { display: flex; justify-content: space-between; margin: 0 3px 10px; color: var(--muted); font-size: 13px; }
.flashcard { width: 100%; height: 390px; padding: 0; border: 0; background: transparent; perspective: 1200px; cursor: pointer; text-align: left; }
.card-inner { position: relative; width: 100%; height: 100%; display: block; transform-style: preserve-3d; transition: transform 200ms ease; }
.flashcard.flipped .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; padding: 42px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; overflow: auto; }
.card-face::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--surface); pointer-events: none; }
.card-back { transform: rotateY(180deg); }
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 24px; }
.card-front strong { margin: auto 0; color: var(--text); font-size: 24px; line-height: 1.42; font-weight: 590; }
.flip-hint { color: var(--muted); font-size: 13px; align-self: center; }
.answer { color: var(--secondary); white-space: pre-line; line-height: 1.75; margin: auto 0; font-size: 16px; }
.code { white-space: pre-wrap; margin-top: 20px; padding: 14px; border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,.02); color: var(--secondary); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.tags span { padding: 3px 7px; border-radius: 5px; background: var(--surface-hover); color: var(--muted); font-size: 12px; }
.study-actions { min-height: 72px; margin-top: 18px; display: grid; place-items: center; }
.primary-button { border: 0; border-radius: 8px; padding: 11px 18px; background: var(--brand); color: #fff; cursor: pointer; font-weight: 550; }
.primary-button:hover { background: var(--brand-hover); }
kbd { padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; color: inherit; font-family: inherit; font-size: 11px; background: rgba(255,255,255,.04); }
.grade-actions { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade { min-height: 48px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--secondary); display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.grade:hover { background: var(--surface-hover); }
.grade-1 { color: #e89292; }.grade-2 { color: #dca66f; }.grade-3 { color: #86c9aa; }
.grade-4 { color: #fff; border-color: transparent; background: var(--brand); }.grade-4:hover { background: var(--brand-hover); }
.browse-actions { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.empty-view { width: min(560px, 92vw); margin: auto; padding: 56px 28px; text-align: center; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.complete-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(16,185,129,.1); }
.empty-view h1 { margin: 18px 0 8px; font-size: 24px; font-weight: 590; }
.empty-view p { color: var(--muted); margin: 0 0 28px; }
.empty-actions { display: flex; justify-content: center; gap: 10px; }
.sync-toast { position: fixed; right: 20px; bottom: 20px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: #171819; color: var(--secondary); box-shadow: 0 12px 30px rgba(0,0,0,.3); font-size: 13px; }
.sync-toast button { margin-left: 8px; padding: 0; border: 0; background: transparent; color: var(--secondary); text-decoration: underline; cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible + span { outline: 2px solid var(--secondary); outline-offset: 2px; }
@media (max-width: 780px) {
  .topbar { padding: 12px 14px; gap: 12px; flex-wrap: wrap; }
  .wordmark { flex: 1; }.deck-nav { order: 3; flex-basis: 100%; }.header-tools { gap: 8px; }
  .mode-switch { font-size: 0; }.mode-switch span { font-size: initial; }
  main { padding: 28px 12px; }.flashcard { height: 58vh; min-height: 350px; max-height: 520px; }
  .card-face { padding: 28px 24px; }.grade-actions { grid-template-columns: repeat(2, 1fr); }
  .browse-actions span { display: none; }.empty-actions { flex-direction: column-reverse; }
}
@media (prefers-reduced-motion: reduce) { .card-inner { transition: none; } }
