:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1f2a44;
  --muted: #5d6679;
  --line: #e4ddd2;
  --accent: #d0643b;
  --accent-ink: #ffffff;
  --ok: #2f7d5b;
  --bad: #b3413a;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(31, 42, 68, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --surface: #1d232d;
    --ink: #eef1f6;
    --muted: #a3acbb;
    --line: #2d3542;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.loading, .error { padding: 40px 16px; text-align: center; color: var(--muted); }
/* layar awal dengan logo (dipakai kalau brand/logo.png ada) */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--accent); color: #fff; text-align: center; padding: 24px; z-index: 50; transition: opacity .35s ease; }
.splash img { width: min(44vw, 200px); height: auto; }
.splash .splash-title { font-size: 20px; font-weight: 700; line-height: 1.3; max-width: 320px; }
.splash .splash-sub { font-size: 14px; opacity: .85; }
.splash.hide { opacity: 0; pointer-events: none; }

/* ---------- shell ---------- */
.shell {
  max-width: 560px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
}
.topbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.topbar .book-title { font-size: 14px; font-weight: 600; color: var(--muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 13px;
}
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }

/* ---------- card ---------- */
.stage { flex: 1; display: flex; }
.card {
  flex: 1; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
  animation: in .25s ease;
}
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kicker { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.card h1 { font-size: 24px; line-height: 1.25; margin: 0; }
.card h2 { font-size: 21px; line-height: 1.3; margin: 0; }
.card p { margin: 0; color: var(--muted); }
.media { width: 100%; border-radius: 14px; background: #000; display: block; }
img.media { background: var(--line); object-fit: cover; aspect-ratio: 1 / 1; height: auto; }
video.media { max-height: 56vh; }
.card.cover { padding: 0; gap: 0; overflow: hidden; }
.card.cover .cover-img { flex: 1; width: 100%; height: 100%; min-height: 0; object-fit: cover; display: block; background: var(--line); }
.points { margin: 0; padding-left: 20px; color: var(--ink); }
.points li { margin: 4px 0; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--line); }
.gallery figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* audio */
.audio-box { display: flex; align-items: center; gap: 14px; background: var(--bg); border-radius: 14px; padding: 14px; }
.play {
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 20px; flex: none;
}
.audio-meta { flex: 1; min-width: 0; }
.audio-meta .bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.audio-meta .bar > span { display: block; height: 100%; width: 0; background: var(--accent); }
.transcript { font-size: 14px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; white-space: pre-line; }

/* interaktif */
.options { display: grid; gap: 10px; }
.opt {
  text-align: left; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 14px 16px; font-size: 16px;
}
.opt:active { transform: scale(.99); }
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.opt[disabled] { cursor: default; }
.feedback { font-size: 14px; padding: 12px 14px; border-radius: 12px; background: var(--bg); }
.score { font-size: 40px; font-weight: 800; color: var(--accent); }
.review-list { display: grid; gap: 8px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; text-align: left; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin-top: 2px; }
.check small { display: block; color: var(--muted); }

.cta {
  display: block; text-align: center; text-decoration: none; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  padding: 15px 18px; border-radius: 14px; width: 100%;
}
.cta.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line); font-weight: 600; }
.ask-link { display: block; text-align: center; padding: 10px 8px 4px; font-size: 15px; font-weight: 600; color: var(--accent); text-decoration: none; }
.ask-link:hover { text-decoration: underline; }

/* nav */
.nav { display: flex; gap: 10px; padding-top: 14px; }
.nav button { flex: 1; padding: 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; }
.nav button.next { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.nav button[disabled] { opacity: .35; cursor: default; }

/* toc & pin */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet-inner { background: var(--surface); width: 100%; max-width: 560px; max-height: 80dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px 28px; }
.toc-item { display: flex; gap: 10px; width: 100%; text-align: left; background: none; border: 0; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.toc-item .t { color: var(--muted); font-size: 12px; min-width: 64px; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.pin-box { max-width: 320px; margin: 18vh auto 0; text-align: center; display: grid; gap: 14px; padding: 0 16px; }
.pin-box input { font-size: 28px; letter-spacing: .4em; text-align: center; padding: 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; }

/* Sumber dan rujukan (refs) */
.refs { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.refs summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.refs ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.refs a { color: var(--accent); word-break: break-word; }
