:root {
  --bg: #f6f7fb; --surface: #fff; --text: #1d2130; --muted: #6a7085; --border: #e2e5ef;
  --accent: #4f46e5; --accent-text: #fff; --know: #16a34a; --learn: #ea580c; --danger: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11131b; --surface: #1a1d29; --text: #eceef6; --muted: #9aa0b8; --border: #2a2f42;
          --accent: #818cf8; --accent-text: #11131b; --know: #4ade80; --learn: #fb923c; --danger: #f87171; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }
h1 { font-size: 1.6rem; margin: .4em 0 .2em; }
h2 { font-size: 1.15rem; margin: 1.6em 0 .5em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.narrow { max-width: 420px; margin: 12vh auto 0; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.top nav { display: flex; gap: 14px; align-items: center; }
.top form { margin: 0; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.who { color: var(--muted); font-size: .9rem; }
.crumbs { margin: 0; font-size: .9rem; }
.stack { display: flex; flex-direction: column; gap: 12px; }
input[type=text], input[type=search], input:not([type]) { width: 100%; padding: 12px 14px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
input:focus-visible, button:focus-visible, a:focus-visible, .deck:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .button { font: inherit; cursor: pointer; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
.error { color: var(--danger); margin: 0; }
.callout { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.error-box { border-color: var(--danger); }
.cards { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.item-main { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.item form { margin: 0; }
.item img, .noposter { width: 46px; height: 68px; border-radius: 6px; object-fit: cover; background: var(--border); flex: none; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pct { font-weight: 600; color: var(--muted); }
.bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.bar.big { height: 10px; margin: 8px 0; }

.deck { position: relative; height: 320px; margin: 18px auto 10px; max-width: 360px; touch-action: pan-y; user-select: none; }
.flash { position: absolute; inset: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 14px; will-change: transform; }
.flash.behind { transform: scale(.94) translateY(12px); opacity: .7; }
.flash.top { cursor: grab; touch-action: none; }
.flash.top:active { cursor: grabbing; }
.flash .word { font-size: 2.2rem; font-weight: 700; overflow-wrap: anywhere; }
.flash .tr { font-size: 1.15rem; color: var(--muted); overflow-wrap: anywhere; }
.flash .stamp { position: absolute; top: 18px; font-weight: 800; letter-spacing: .08em; padding: 2px 10px; border: 3px solid; border-radius: 8px; opacity: 0; }
.flash .stamp.know { left: 18px; color: var(--know); transform: rotate(-12deg); }
.flash .stamp.learn { right: 18px; color: var(--learn); transform: rotate(12deg); }
.actions { display: flex; gap: 28px; justify-content: center; margin: 16px 0 6px; }
.round { width: 64px; height: 64px; border-radius: 50%; font-size: 1.6rem; padding: 0; border-width: 2px; }
.round.undo { width: 44px; height: 44px; font-size: 1.2rem; align-self: center; color: var(--muted); border-width: 1px; }
.round.undo:disabled { opacity: .35; cursor: default; }
.round.know { color: var(--know); border-color: var(--know); } .round.learn { color: var(--learn); border-color: var(--learn); }
@media (prefers-reduced-motion: reduce) { .bar > span { transition: none; } }

.deck.review { height: 390px; max-width: 420px; }
.flash.review { align-items: stretch; justify-content: flex-start; text-align: left; gap: 10px; padding-top: 44px; overflow: hidden; }
.flash.review .head { display: flex; align-items: center; gap: 12px; }
.flash.review .word { font-size: 1.9rem; flex: 1; }
.flash.review .tr { font-size: 1.05rem; }
.speak { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 1.2rem; flex: none; }
.ctx { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.sentence { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.sentence.en { color: var(--muted); }
.sentence mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 4px; padding: 0 2px; }
.ctx-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.loading { display: flex; gap: 12px; align-items: center; margin: 14px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.tr.wait { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .spinner, .tr.wait { animation: none; } }

.rootline { font-size: .9rem; color: var(--muted); }
.rootline strong { color: var(--text); }
