:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #1f2a2e;
  --muted: #6b7377;
  --line: #e4dccb;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --new: #9aa3a7;
  --learning: #d08a2e;
  --reviewing: #2f7fb5;
  --known: #3c8d5a;
  --again: #b8473b;
  --radius: 14px;
  --he: "Assistant", "Rubik", sans-serif;
  --ui: "Rubik", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b1e;
    --surface: #1f262a;
    --ink: #ece7dc;
    --muted: #98a0a4;
    --line: #2f383d;
    --accent: #6fb0dc;
    --accent-ink: #0f1416;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--ui); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 880px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 .25em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 2em 0 .75em; }
code { font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--again); margin: 0; }
.he { font-family: var(--he); direction: rtl; unicode-bidi: isolate; }
.he.big { font-size: 3rem; font-weight: 500; margin: 0; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 880px; margin: 0 auto; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.brand { font-family: var(--he); font-size: 1.6rem; color: var(--ink); font-weight: 700; }
.top nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.top form { margin: 0; }
.nikud-toggle span[lang="he"] { font-family: var(--he); font-size: 1.1em; }
.nikud-toggle[aria-pressed="true"] { color: var(--accent); }

/* buttons */
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
.btn.big { padding: 14px 26px; font-size: 1.05rem; }
.link { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.link:hover { color: var(--accent); }
kbd { font: .75em var(--ui); opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
input { font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); width: 100%; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* login */
.login { max-width: 340px; margin: 12vh auto 0; text-align: center; }

/* home */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.hero p { margin: 0 0 4px; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.count { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; border-top: 4px solid var(--new); }
.count b { font-size: 1.6rem; font-weight: 600; }
.count span { color: var(--muted); font-size: .85rem; text-transform: capitalize; }
.count.learning { border-top-color: var(--learning); }
.count.reviewing { border-top-color: var(--reviewing); }
.count.known { border-top-color: var(--known); }
.small-counts { grid-template-columns: repeat(5, 1fr); }
.small-counts b { font-size: 1.2rem; }
.plan { margin-top: 16px; padding: 14px 18px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.plan p { margin: 0; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.cat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.cat:hover { border-color: var(--accent); text-decoration: none; }
.cat .he { font-size: 1.8rem; line-height: 1.2; text-align: right; }
.cat-en { font-weight: 500; }
.bar { position: relative; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--learning); }
.bar i.k { background: var(--known); }

/* category list */
.items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.item .he { font-size: 1.6rem; line-height: 1.25; }
.item.sentence .he { font-size: 1.3rem; }
.he-col, .en-col { display: flex; flex-direction: column; min-width: 0; }
.he-col { text-align: right; order: 2; }
.en-col { order: 1; }
.item .pill { order: 3; }
.translit { color: var(--muted); font-style: italic; font-size: .9rem; direction: ltr; }
.pill { font-size: .75rem; padding: 2px 10px; border-radius: 999px; color: #fff; background: var(--new); text-transform: capitalize; }
.pill.learning { background: var(--learning); }
.pill.reviewing { background: var(--reviewing); }
.pill.known { background: var(--known); }
.play { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  color: var(--accent); cursor: pointer; font-size: .9rem; flex-shrink: 0; }
.play:hover { border-color: var(--accent); }
.play.loading { opacity: .5; }
.play.err { color: var(--again); }

/* practice */
.practice { max-width: 560px; margin: 0 auto; }
.practice-head { display: flex; justify-content: space-between; margin-bottom: 16px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  min-height: 300px; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.badge { position: absolute; top: 14px; left: 16px; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.prompt .he { font-size: 3rem; line-height: 1.2; }
.prompt .en { font-size: 1.6rem; font-weight: 500; }
.answer { border-top: 1px dashed var(--line); padding-top: 18px; width: 100%; display: flex; flex-direction: column; gap: 4px; }
.answer .he { font-size: 2.2rem; }
.answer .en { font-size: 1.3rem; }
.answer .notes { color: var(--muted); font-size: .9rem; }
.big-play { position: absolute; top: 10px; right: 12px; }
.actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.grades .btn { flex: 1; justify-content: center; min-width: 110px; }
.btn.again { border-color: var(--again); color: var(--again); }
.btn.hard { border-color: var(--learning); color: var(--learning); }
.btn.good { border-color: var(--reviewing); color: var(--reviewing); }
.btn.easy { border-color: var(--known); color: var(--known); }
.done { text-align: center; margin-top: 10vh; }

/* admin */
.admin-user { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 20px 16px; margin-bottom: 16px; }
.admin-user h2 { margin-top: 16px; }
.log { padding-left: 18px; font-size: .9rem; }

@media (max-width: 600px) {
  .counts { grid-template-columns: repeat(2, 1fr); }
  .small-counts { grid-template-columns: repeat(3, 1fr); }
  .item { grid-template-columns: auto 1fr; }
  .item .he-col { order: 1; }
  .item .en-col { order: 2; grid-column: 2; }
  .item .pill { display: none; }
  .prompt .he { font-size: 2.4rem; }
  .grades .btn { min-width: 40%; }
}
