/* Cairo (SIL OFL 1.1, see fonts/LICENSE-Cairo-OFL.txt): hosted here so nothing is fetched from another site. */
@font-face { font-family: "Cairo"; font-weight: 200 1000; font-display: swap; src: url("/fonts/cairo-arabic-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 200 1000; font-display: swap; src: url("/fonts/cairo-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f4f3ee; --surface: #ffffff; --ink: #1d2320; --muted: #5f6b66; --line: #dcd9cf;
  --brand: #1f6f5c; --brand-ink: #ffffff; --warn: #a55a00; --bad: #b3261e; --good: #1d7a43;
  --again: #b3261e; --hard: #a55a00; --goodc: #1f6f5c; --easy: #2a5db0;
  --glass: color-mix(in srgb, var(--surface) 72%, transparent);
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 10px 30px rgba(20, 30, 25, .07);
  --radius: 16px; --radius-lg: 24px; --gap: 16px; --ease: 200ms ease-in-out;
  font-family: "Cairo", system-ui, "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
}
:root[data-theme="dark"] {
  --bg: #101412; --surface: #1d2320; --ink: #eceee9; --muted: #a2aea8; --line: #323a36;
  --brand: #4fb89c; --brand-ink: #0b1a15; --warn: #e0a24a; --bad: #f0877f; --good: #67c88a;
  --again: #f0877f; --hard: #e0a24a; --goodc: #4fb89c; --easy: #7ea7ea;
  --glass: color-mix(in srgb, var(--surface) 70%, transparent); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101412; --surface: #1d2320; --ink: #eceee9; --muted: #a2aea8; --line: #323a36;
    --brand: #4fb89c; --brand-ink: #0b1a15; --warn: #e0a24a; --bad: #f0877f; --good: #67c88a;
    --again: #f0877f; --hard: #e0a24a; --goodc: #4fb89c; --easy: #7ea7ea;
    --glass: color-mix(in srgb, var(--surface) 70%, transparent); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); line-height: 1.65; font-size: 16px; min-height: 100vh;
  background: radial-gradient(900px 480px at 85% -8%, color-mix(in srgb, var(--brand) 16%, transparent), transparent),
    radial-gradient(700px 420px at 0% 12%, color-mix(in srgb, var(--easy) 10%, transparent), transparent), var(--bg);
  background-attachment: fixed; }
#app { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; min-height: 100vh; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 24px 0 8px; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 24px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: .92rem; }
.mixed, [dir="auto"] { unicode-bidi: plaintext; }
.en { direction: ltr; text-align: start; unicode-bidi: isolate; }
.icon { flex: none; }
:root[dir="rtl"] .icon-dir { transform: scaleX(-1); }

/* glass surfaces */
.card, .stat, .nav, .banner { background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent); box-shadow: var(--shadow); }
.card { border-radius: var(--radius-lg); padding: 20px; margin: 14px 0; transition: box-shadow var(--ease), transform var(--ease), background var(--ease); }
.card > h2:first-child { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { border-radius: var(--radius); padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.2; font-weight: 700; }

.nav { position: fixed; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 460px; margin-inline: auto;
  border-radius: 28px; display: flex; justify-content: center; gap: 4px; padding: 6px; z-index: 5; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border-radius: 22px; color: var(--muted);
  text-decoration: none; font-size: .78rem; font-weight: 600; transition: all var(--ease); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 40%, transparent); }

button, .btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: var(--glass); color: var(--ink); border-radius: 14px; padding: 10px 18px; cursor: pointer; min-height: 44px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: all var(--ease); }
button:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(20, 30, 25, .1); }
button:active { transform: scale(.98); box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 70%, transparent); outline-offset: 2px; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 12px; }
button.round { width: 48px; height: 48px; min-height: 0; padding: 0; border-radius: 50%; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; gap: 16px; }
.spread { justify-content: space-between; }

label { display: block; margin: 14px 0 4px; font-weight: 600; font-size: .95rem; }
input, select, textarea { font: inherit; width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 70%, var(--surface)); color: var(--ink); min-height: 44px; transition: border-color var(--ease), box-shadow var(--ease); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); }
textarea { min-height: 88px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 6px 0; }

.q { font-size: 1.55rem; font-weight: 700; margin: 8px 0; overflow-wrap: anywhere; }
.ctx { color: var(--muted); border-inline-start: 3px solid color-mix(in srgb, var(--brand) 45%, var(--line)); padding-inline-start: 14px; margin: 12px 0; overflow-wrap: anywhere; }
.answer { background: color-mix(in srgb, var(--brand) 11%, transparent); border-radius: var(--radius); padding: 14px; margin: 14px 0; }
.answer b { font-size: 1.25rem; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.grades button { flex-direction: column; padding: 12px 4px; font-weight: 600; border-width: 2px; }
.grades .g1 { border-color: var(--again); color: var(--again); }
.grades .g2 { border-color: var(--hard); color: var(--hard); }
.grades .g3 { border-color: var(--goodc); color: var(--goodc); }
.grades .g4 { border-color: var(--easy); color: var(--easy); }
.grades button.suggested { box-shadow: 0 0 0 3px color-mix(in srgb, var(--again) 35%, transparent); }
.grades small { display: block; font-weight: 400; color: var(--muted); }

/* flashcards, quiz, study guide */
.flash { position: relative; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; gap: 8px; border-radius: 32px; }
.flash:hover { transform: translateY(-2px); }
.flash.flipped { background: color-mix(in srgb, var(--goodc) 16%, var(--glass)); }
.flash-badge { position: absolute; top: 14px; inset-inline-end: 14px; background: var(--ink); color: var(--bg); border-radius: 99px; padding: 2px 14px; font-size: .82rem; font-weight: 600; }
.flash-tools { position: absolute; bottom: 12px; inset-inline-end: 12px; display: flex; gap: 6px; }
.flash-tools button { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; }
.meter-row { display: flex; align-items: center; gap: 8px; }
.meter { flex: 1; max-width: 160px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; transition: width 400ms ease-in-out; }
.meter .hi { background: var(--goodc); } .meter .mid { background: var(--hard); } .meter .lo { background: var(--again); }
.guide-entry { padding: 12px 0; border-bottom: 1px solid var(--line); }
.segs { display: flex; gap: 5px; margin: 12px 0; }
.qseg { flex: 1; height: 6px; border-radius: 3px; background: var(--line); transition: background var(--ease); }
.qseg.cur { outline: 2px solid var(--brand); outline-offset: 2px; }
.qseg.ok { background: var(--goodc); }
.qseg.bad { background: var(--again); }
.choices { display: grid; gap: 10px; margin: 16px 0; }
.choice { justify-content: flex-start; text-align: start; padding: 14px 16px; font-size: 1.05rem; border-radius: var(--radius); display: block; }
.choice .row { margin: 0; }
.choice.ok { border-color: var(--goodc); background: color-mix(in srgb, var(--goodc) 12%, var(--glass)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--goodc) 40%, transparent); }
.choice.bad { border-color: var(--again); background: color-mix(in srgb, var(--again) 10%, var(--glass)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--again) 40%, transparent); }
progress { width: 100%; height: 6px; margin: 8px 0; accent-color: var(--goodc); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 40px; box-shadow: none; transform: none; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.tag { display: inline-block; font-size: .78rem; padding: 1px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.demo { border-color: var(--warn); color: var(--warn); }
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
ul.list li:last-child { border-bottom: 0; }
.tree ul { list-style: none; padding-inline-start: 18px; margin: 4px 0; }
.error { color: var(--bad); }
.banner { background: color-mix(in srgb, var(--warn) 12%, var(--glass)); border-color: var(--warn); border-radius: var(--radius); padding: 14px; margin: 14px 0; }
#toast { position: fixed; inset-inline: 16px; bottom: 96px; max-width: 560px; margin-inline: auto; background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 18px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--ease), transform var(--ease); z-index: 10; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--bad); color: #fff; }
details summary { cursor: pointer; padding: 6px 0; }
details { margin: 8px 0; } details ol { padding-inline-start: 22px; margin: 6px 0; }
.pre { white-space: pre-line; }
@media (max-width: 480px) { .grades { grid-template-columns: repeat(2, 1fr); } .q { font-size: 1.3rem; } .flash { min-height: 220px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } button:hover, .flash:hover { transform: none; } }
@media print { .nav, button { display: none !important; } body { background: #fff; } .card { box-shadow: none; backdrop-filter: none; background: #fff; } }

.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
