:root {
  --bg: #0f172a; --panel: #1e293b; --panel2: #273449; --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8; --accent2: #a78bfa;
  --good: #34d399; --bad: #f87171; --warn: #fbbf24; --border: #334155;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; }
.small { font-size: 13px; }
a { color: var(--accent); }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #082f49; border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin: 0 0 14px; }
.card h1 { margin: 0 0 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

header { position: sticky; top: 0; z-index: 5; background: rgba(15,23,42,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 700; font-size: 20px; }
.brand .sub { font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 8px; }
.hdrStats { font-size: 12px; color: var(--muted); text-align: right; }
main { padding: 16px 16px 90px; max-width: 760px; margin: 0 auto; }
nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
nav#tabs button { flex: 1; background: none; border: 0; padding: 4px 0; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); border-radius: 8px; }
nav#tabs button span { font-size: 11px; }
nav#tabs button.active { color: var(--accent); }

.he { direction: rtl; text-align: right; font-family: "Arial Hebrew", "Noto Sans Hebrew", "David", Arial, sans-serif; unicode-bidi: isolate; }
.reader { font-size: 24px; line-height: 2; }
.reader .w { cursor: pointer; border-radius: 6px; padding: 0 2px; }
.reader .w:hover, .reader .w.sel { background: rgba(56,189,248,.18); }
.reader .w.learning { border-bottom: 2px dotted var(--warn); }
.reader .w.unknown { border-bottom: 2px dotted var(--accent2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 14px; cursor: pointer; }
.chip.active { background: var(--accent); color: #082f49; border-color: transparent; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .04em; }
.list .item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list .item:last-child { border-bottom: 0; }
.kw { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kw .he { font-size: 22px; }
.kw .g { color: var(--muted); font-size: 14px; direction: ltr; text-align: left; }
.big { font-size: 22px; }
.diff .miss { color: var(--bad); text-decoration: underline; }
.diff .extra { color: var(--warn); text-decoration: line-through; }
.diff .fuzzy { color: var(--warn); }
.diff .match { color: var(--good); }
.score { font-size: 32px; font-weight: 700; }
.recbtn { width: 84px; height: 84px; border-radius: 50%; font-size: 32px; background: var(--panel2); border: 3px solid var(--border); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.recbtn.rec { background: var(--bad); border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(248,113,113,.6);} 100% { box-shadow: 0 0 0 18px rgba(248,113,113,0);} }
.compare { display: grid; gap: 10px; }
.compare .box { background: var(--panel2); border-radius: 12px; padding: 12px; }
.compare .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
mark { background: rgba(167,139,250,.35); color: inherit; border-radius: 4px; padding: 0 2px; }
.flash { text-align: center; padding: 24px 12px; }
.flash .front { font-size: 22px; }
.flash .back { margin-top: 16px; }
.flash .back .he { font-size: 34px; }
.rating { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.rating button:nth-child(1) { border-color: var(--bad); } .rating button:nth-child(3) { border-color: var(--good); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; max-height: 220px; overflow: auto; background: #0b1220; padding: 8px; border-radius: 8px; }
.band { display: flex; gap: 6px; flex-wrap: wrap; }
.band .chip { font-size: 20px; padding: 6px 14px; }
.band .chip.known { background: var(--good); color: #052e16; border-color: transparent; }
#popup { position: fixed; left: 12px; right: 12px; bottom: 80px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 14px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,.5); max-width: 520px; margin: 0 auto; }
#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); padding: 8px 14px; border-radius: 10px; z-index: 30; font-size: 14px; }
.spin::after { content: ""; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; margin-left: 8px; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg);} }
.speeds button.active { background: var(--accent); color: #082f49; }
.q { padding: 10px; background: var(--panel2); border-radius: 12px; margin-top: 8px; cursor: pointer; }
.drill .item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.drill input { margin-top: 6px; direction: rtl; font-size: 20px; }
.ok { color: var(--good); } .no { color: var(--bad); }
