:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef2f7; --text: #15202b; --muted: #55606d; --line: #d9dfe7;
  --primary: #0f4c81; --primary-ink: #ffffff; --primary-soft: #e3eef9;
  --accent: #b7791f; --ok: #1e7b45; --ok-soft: #e3f4ea; --bad: #b42318; --bad-soft: #fdecea; --warn-soft: #fff6d6;
  --hl: #fff176; --hl-ink: #15202b; --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 14px; --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #182029; --surface-2: #212b36; --text: #e8edf2; --muted: #a3afbb; --line: #2e3a46;
    --primary: #6cb4f5; --primary-ink: #0b1a28; --primary-soft: #1b3047;
    --accent: #f2c14e; --ok: #5fd08b; --ok-soft: #173826; --bad: #ff8a80; --bad-soft: #3d1f1d; --warn-soft: #3a3217;
    --hl: #8a7a12; --hl-ink: #fffbe0; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #182029; --surface-2: #212b36; --text: #e8edf2; --muted: #a3afbb; --line: #2e3a46;
  --primary: #6cb4f5; --primary-ink: #0b1a28; --primary-soft: #1b3047;
  --accent: #f2c14e; --ok: #5fd08b; --ok-soft: #173826; --bad: #ff8a80; --bad-soft: #3d1f1d; --warn-soft: #3a3217;
  --hl: #8a7a12; --hl-ink: #fffbe0; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  line-height: 1.6;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 48px; padding: .55em 1.1em; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 1.05rem; width: 100%; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidenav {
  width: 250px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; padding: 1.2rem .8rem; display: flex; flex-direction: column; gap: .25rem;
}
.brand { font-weight: 800; font-size: 1.25rem; padding: .2rem .7rem 1rem; display: flex; gap: .5rem; align-items: center; }
.navlink {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600; min-height: 48px;
}
.navlink:hover { background: var(--surface-2); }
.navlink.active { background: var(--primary-soft); color: var(--primary); }
.navlink .ic { font-size: 1.25rem; width: 1.6rem; text-align: center; }
.navlink .badge { margin-left: auto; }
main { flex: 1; min-width: 0; padding: 1.5rem 1.25rem 3rem; }
.wrap { max-width: 900px; margin: 0 auto; }
.bottomnav { display: none; }

@media (max-width: 860px) {
  .sidenav { display: none; }
  main { padding: 1rem 1rem calc(var(--nav-h) + 1.5rem); }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; height: var(--nav-h);
    background: var(--surface); border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; position: relative;
  }
  .bottomnav a .ic { font-size: 1.4rem; line-height: 1; }
  .bottomnav a.active { color: var(--primary); }
  .bottomnav .badge { position: absolute; top: 6px; right: calc(50% - 26px); }
}

/* ---------- kartu & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .num { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; min-width: 1.5em; padding: 0 .45em; border-radius: 99px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.5; }
.chip { display: inline-block; padding: .1em .65em; border-radius: 99px; background: var(--surface-2); font-size: .8rem; font-weight: 600; color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.bad { background: var(--bad-soft); color: var(--bad); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.hero { background: linear-gradient(135deg, var(--primary), #1d6fb0); color: #fff; border: 0; }
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #17406a, #0f2c4a); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: linear-gradient(135deg, #17406a, #0f2c4a); } }
.hero .muted { color: rgba(255, 255, 255, .85); }
.countdown { font-size: 2.6rem; font-weight: 800; line-height: 1; }

.task { display: flex; align-items: center; gap: 1rem; padding: .9rem 1rem; border: 1.5px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--surface); min-height: 64px; }
.task:hover { border-color: var(--primary); }
.task .ic { font-size: 1.7rem; }
.task .t { font-weight: 700; } .task .d { color: var(--muted); font-size: .88rem; }
.task .go { margin-left: auto; font-size: 1.3rem; color: var(--muted); }
.task.done { opacity: .6; }

.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bar.ok > i { background: var(--ok); }

.bab-row { display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--text); }
.bab-row:hover { border-color: var(--primary); }
.bab-row .ic { font-size: 1.6rem; }
.bab-row .info { flex: 1; min-width: 0; }
.bab-row .ttl { font-weight: 700; }

/* ---------- pembaca materi ---------- */
.reader-tools { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: .5rem 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.reader-tools .btn { min-height: 44px; padding: .4em .8em; }
.toc { columns: 2 220px; margin: 0; padding-left: 1.2rem; }
.toc a { text-decoration: none; }
.md { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; overflow-wrap: anywhere; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.3rem; margin-top: 1.8em; padding-top: .6em; border-top: 2px solid var(--line); }
.md h3 { font-size: 1.12rem; margin-top: 1.4em; color: var(--primary); }
.md table { border-collapse: collapse; width: 100%; font-size: .92rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: .45em .6em; vertical-align: top; text-align: left; }
.md th { background: var(--surface-2); }
.md blockquote { margin: 1em 0; padding: .6em 1em; border-left: 4px solid var(--accent); background: var(--warn-soft); border-radius: 0 8px 8px 0; }
.md code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; font-size: .92em; }
.md li { margin: .25em 0; }
.md li::marker { color: var(--primary); }
mark.hl { background: var(--hl); color: var(--hl-ink); padding: 0 .1em; border-radius: 3px; cursor: pointer; }
mark.hl.c2 { background: #b9f6ca; } mark.hl.c3 { background: #ffcdd2; }
:root[data-theme="dark"] mark.hl.c2 { background: #1f6b3a; } :root[data-theme="dark"] mark.hl.c3 { background: #7a2a2a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark.hl.c2 { background: #1f6b3a; } :root:not([data-theme="light"]) mark.hl.c3 { background: #7a2a2a; } }
.speaking { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 4px; background: var(--warn-soft); }
.selbar { position: absolute; z-index: 50; display: flex; gap: .3rem; background: var(--text); padding: .35rem; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.selbar button { min-height: 44px; min-width: 44px; border: 0; border-radius: 9px; font-weight: 700; cursor: pointer; padding: 0 .7rem; }
.selbar .y { background: #fff176; color: #222; } .selbar .g { background: #b9f6ca; color: #222; } .selbar .r { background: #ffcdd2; color: #222; }
.selbar .x { background: var(--surface); color: var(--text); }

/* ---------- soal ---------- */
.q-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .6rem; }
.q-text { font-size: 1.12rem; font-weight: 600; margin: .3rem 0 1rem; white-space: pre-line; }
.opts { display: grid; gap: .6rem; }
.opt {
  display: flex; gap: .8rem; align-items: flex-start; text-align: left; width: 100%; min-height: 56px;
  padding: .75rem .9rem; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; line-height: 1.45;
}
.opt:hover:not(:disabled) { border-color: var(--primary); }
.opt .L { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.sel .L { background: var(--primary); color: var(--primary-ink); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .L { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .L { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; color: var(--text); }
.explain { margin-top: 1rem; padding: .9rem 1rem; border-radius: 12px; background: var(--surface-2); border-left: 5px solid var(--primary); }
.explain.ok { border-left-color: var(--ok); } .explain.bad { border-left-color: var(--bad); }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.timer.low { color: var(--bad); }
.qnav { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: .35rem; }
.qnav button { min-height: 42px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }
.qnav button.ans { background: var(--primary-soft); border-color: var(--primary); }
.qnav button.cur { outline: 3px solid var(--accent); }
.qnav button.flag { border-color: var(--accent); background: var(--warn-soft); }
.qnav button.r { background: var(--ok-soft); border-color: var(--ok); } .qnav button.w { background: var(--bad-soft); border-color: var(--bad); }
.score-big { font-size: 3.2rem; font-weight: 800; line-height: 1; }

/* ---------- kartu hafalan ---------- */
.flash { min-height: 260px; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 1.6rem 1.3rem; cursor: pointer; }
.flash .front { font-size: 1.3rem; font-weight: 700; }
.flash .back { font-size: 1.15rem; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 2px dashed var(--line); white-space: pre-line; }
.flash .mn { margin-top: 1rem; padding: .7rem .9rem; background: var(--warn-soft); border-radius: 10px; font-size: .98rem; text-align: left; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: 1rem; }
.rate .btn { flex-direction: column; gap: 0; min-height: 64px; }
.rate .btn small { font-weight: 500; opacity: .85; font-size: .78rem; }

/* ---------- form ---------- */
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 50px; padding: .55rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
}
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 48px; border: 0; background: var(--surface); cursor: pointer; font-weight: 600; padding: 0 .8rem; }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button.on { background: var(--primary); color: var(--primary-ink); }
.check { display: flex; gap: .6rem; align-items: center; min-height: 44px; font-weight: 500; margin: .2rem 0; cursor: pointer; }
.check input { width: 22px; height: 22px; }

/* ---------- lain-lain ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; z-index: 99; font-weight: 600; max-width: 90vw; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
@media (min-width: 861px) { .toast { bottom: 24px; } }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.tip { background: var(--warn-soft); border-radius: 12px; padding: .8rem 1rem; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .col i { display: block; width: 100%; max-width: 38px; background: var(--primary); border-radius: 6px 6px 0 0; }
.chart .col i.pass { background: var(--ok); }
.chart .col span { font-size: .7rem; color: var(--muted); }
.line70 { position: relative; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); }
.heat i.l1 { background: #9ecae1; } .heat i.l2 { background: #4292c6; } .heat i.l3 { background: #08519c; }
.search-hit { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.search-hit:last-child { border-bottom: 0; }
.search-hit b { background: var(--hl); color: var(--hl-ink); }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 2rem 1.5rem; box-shadow: var(--shadow); }
.login-logo { font-size: 3rem; text-align: center; }
.login-card h1 { text-align: center; margin: .2rem 0 0; }
.login-card > p { text-align: center; margin-top: .2rem; }
.login-card .btn.big { margin-top: 1.2rem; }
.pw-row { display: flex; gap: .5rem; } .pw-row .btn { flex: none; width: 56px; }
.err { color: var(--bad); min-height: 1.4em; margin: .5rem 0 0; font-weight: 600; }

@media print {
  .sidenav, .bottomnav, .reader-tools, .selbar { display: none !important; }
  main { padding: 0; } .md { border: 0; }
}
