/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
  --bg: #fbfaf8;
  --bg-elev: #ffffff;
  --bg-sunken: #f2f0ec;
  --fg: #1c1b19;
  --fg-muted: #5f5b55;
  --fg-subtle: #8a847c;
  --border: #e4e0d9;
  --border-strong: #cfc9c0;
  --accent: #b4451f;
  --accent-soft: #fbeee8;
  --ok: #2f6b46;
  --ok-soft: #e8f2ec;
  --warn: #8a6412;
  --warn-soft: #fbf2dd;
  --code-bg: #f5f3ef;
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 4px 16px rgba(28, 27, 25, .04);

  --syn-kw: #a4306a;
  --syn-str: #2f6b46;
  --syn-com: #8a847c;
  --syn-num: #9a5518;
  --syn-fn: #2a5ea8;
  --syn-dec: #8a6412;

  --radius: 10px;
  --sidebar-w: 286px;
  --content-w: 800px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --bg-elev: #1e1d23;
    --bg-sunken: #131217;
    --fg: #eceaf0;
    --fg-muted: #a6a2b0;
    --fg-subtle: #79757f;
    --border: #2d2b33;
    --border-strong: #413e49;
    --accent: #f0865c;
    --accent-soft: #2e1f19;
    --ok: #71c295;
    --ok-soft: #17251d;
    --warn: #d8b169;
    --warn-soft: #262015;
    --code-bg: #131217;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 20px rgba(0, 0, 0, .25);

    --syn-kw: #e590bd;
    --syn-str: #8fd0a8;
    --syn-com: #79757f;
    --syn-num: #e0a878;
    --syn-fn: #86b4ee;
    --syn-dec: #d8b169;
  }
}

:root[data-theme="light"] {
  --bg: #fbfaf8; --bg-elev: #ffffff; --bg-sunken: #f2f0ec;
  --fg: #1c1b19; --fg-muted: #5f5b55; --fg-subtle: #8a847c;
  --border: #e4e0d9; --border-strong: #cfc9c0;
  --accent: #b4451f; --accent-soft: #fbeee8;
  --ok: #2f6b46; --ok-soft: #e8f2ec;
  --warn: #8a6412; --warn-soft: #fbf2dd;
  --code-bg: #f5f3ef;
  --shadow: 0 1px 2px rgba(28,27,25,.05), 0 4px 16px rgba(28,27,25,.04);
  --syn-kw: #a4306a; --syn-str: #2f6b46; --syn-com: #8a847c;
  --syn-num: #9a5518; --syn-fn: #2a5ea8; --syn-dec: #8a6412;
}

:root[data-theme="dark"] {
  --bg: #16151a; --bg-elev: #1e1d23; --bg-sunken: #131217;
  --fg: #eceaf0; --fg-muted: #a6a2b0; --fg-subtle: #79757f;
  --border: #2d2b33; --border-strong: #413e49;
  --accent: #f0865c; --accent-soft: #2e1f19;
  --ok: #71c295; --ok-soft: #17251d;
  --warn: #d8b169; --warn-soft: #262015;
  --code-bg: #131217;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 20px rgba(0,0,0,.25);
  --syn-kw: #e590bd; --syn-str: #8fd0a8; --syn-com: #79757f;
  --syn-num: #e0a878; --syn-fn: #86b4ee; --syn-dec: #d8b169;
}

/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

code, pre, kbd { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.shell { display: flex; align-items: flex-start; gap: 0; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  background: var(--bg-sunken);
  padding: 1.75rem 1.25rem 2.5rem;
}

.main { flex: 1 1 auto; min-width: 0; padding: 0 2rem 6rem; }
.wrap { max-width: var(--content-w); margin: 0 auto; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.brand { display: block; text-decoration: none; color: inherit; margin-bottom: .35rem; }
.brand-title { font-size: 1.02rem; font-weight: 650; letter-spacing: -.01em; color: var(--fg); }
.brand-sub { font-size: .78rem; color: var(--fg-subtle); margin-top: .1rem; }

.progress-box { margin: 1.25rem 0 1rem; }
.progress-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .74rem; color: var(--fg-subtle); margin-bottom: .4rem;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.progress-track { height: 5px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0; transition: width .35s cubic-bezier(.4,0,.2,1); }

.nav { list-style: none; margin: 0; padding: 0; }
.nav li { margin: 0; }
.nav a {
  display: flex; gap: .6rem; align-items: baseline;
  padding: .42rem .6rem; margin: 1px 0;
  border-radius: 7px;
  text-decoration: none; color: var(--fg-muted);
  font-size: .875rem; line-height: 1.35;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--border); color: var(--fg); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .num {
  flex: 0 0 auto; font-size: .7rem; font-weight: 700;
  color: var(--fg-subtle); font-variant-numeric: tabular-nums;
  min-width: 1.1rem;
}
.nav a.active .num { color: var(--accent); }
.nav a.done .num::after { content: " ✓"; color: var(--ok); }

.side-foot { margin-top: 1.5rem; padding-top: 1.15rem; border-top: 1px solid var(--border); }

.theme-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--fg-muted); border-radius: 7px;
  padding: .38rem .7rem; font-size: .8rem; cursor: pointer;
  font-family: inherit; transition: border-color .12s, color .12s;
}
.theme-btn:hover { border-color: var(--border-strong); color: var(--fg); }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero { padding: 3.25rem 0 2.25rem; border-bottom: 1px solid var(--border); margin-bottom: 2.5rem; }
.eyebrow {
  display: inline-block; font-size: .73rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); padding: .25rem .6rem; border-radius: 5px;
  margin-bottom: 1rem;
}
h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); line-height: 1.15; letter-spacing: -.025em; margin: 0 0 .75rem; font-weight: 700; }
.lede { font-size: 1.075rem; color: var(--fg-muted); margin: 0 0 1.5rem; max-width: 62ch; }

.facts { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; padding: 0; margin: 0; list-style: none; }
.facts div { font-size: .82rem; }
.facts dt { color: var(--fg-subtle); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.facts dd { margin: .1rem 0 0; font-weight: 600; color: var(--fg); }

/* ── Sections ─────────────────────────────────────────────────────────── */
.phase { padding: 2.5rem 0 1rem; border-top: 1px solid var(--border); }
.phase:first-of-type { border-top: none; padding-top: .5rem; }

.phase-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: .5rem; }
.phase-num {
  flex: 0 0 auto; width: 2.35rem; height: 2.35rem; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums;
  margin-top: .1rem;
}
h2 { font-size: 1.5rem; line-height: 1.25; letter-spacing: -.02em; margin: 0; font-weight: 680; }
h3 { font-size: 1.05rem; margin: 2rem 0 .6rem; letter-spacing: -.01em; font-weight: 650; }
h4 { font-size: .9rem; margin: 1.25rem 0 .4rem; color: var(--fg-muted); font-weight: 650; }

.meta { display: flex; flex-wrap: wrap; gap: .4rem; margin: .55rem 0 1.1rem; }
.tag {
  font-size: .73rem; font-weight: 600; padding: .17rem .55rem;
  border-radius: 999px; border: 1px solid var(--border-strong); color: var(--fg-muted);
  white-space: nowrap;
}
.tag.time { background: var(--bg-sunken); }
.tag.key { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

p { margin: 0 0 1rem; }
.phase > p, .phase > ul, .phase > ol { max-width: 68ch; }

ul, ol { padding-left: 1.3rem; margin: 0 0 1rem; }
li { margin: .3rem 0; }
li > ul { margin-top: .3rem; }

strong { font-weight: 650; }

/* ── Goal callout ─────────────────────────────────────────────────────── */
.goal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: .9rem 1.1rem; margin: 0 0 1.5rem;
  font-size: .93rem;
}
.goal b { color: var(--accent); }
.goal p:last-child { margin-bottom: 0; }

/* ── Code ─────────────────────────────────────────────────────────────── */
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .95rem 1.05rem;
  overflow-x: auto; margin: 0 0 1.15rem;
  font-size: .84rem; line-height: 1.6; tab-size: 4;
}
pre code { background: none; padding: 0; border: none; font-size: inherit; color: var(--fg); }

:not(pre) > code {
  background: var(--code-bg); border: 1px solid var(--border);
  padding: .08em .38em; border-radius: 5px; font-size: .875em;
  color: var(--fg); white-space: nowrap;
}

.tok-kw { color: var(--syn-kw); }
.tok-str { color: var(--syn-str); }
.tok-com { color: var(--syn-com); font-style: italic; }
.tok-num { color: var(--syn-num); }
.tok-fn { color: var(--syn-fn); }
.tok-dec { color: var(--syn-dec); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-sunken); font-weight: 650; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }

/* ── Skip list ────────────────────────────────────────────────────────── */
.skip { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0 0 1.25rem; }
.skip h4 { margin-top: 0; }

/* ── Resources ────────────────────────────────────────────────────────── */
.res { display: grid; gap: .55rem; margin: 0 0 1.25rem; padding: 0; list-style: none; }
.res li { margin: 0; }
.res a {
  display: block; text-decoration: none; color: inherit;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem .9rem;
  transition: border-color .14s, transform .14s, box-shadow .14s;
}
.res a:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.res-top { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.res-title { font-weight: 620; font-size: .92rem; color: var(--accent); }
.res-kind {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .1rem .42rem; border-radius: 4px; white-space: nowrap;
  background: var(--bg-sunken); color: var(--fg-subtle); border: 1px solid var(--border);
}
.res-kind.official { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.res-desc { font-size: .82rem; color: var(--fg-muted); margin-top: .18rem; }
.res-host { font-size: .74rem; color: var(--fg-subtle); font-family: ui-monospace, monospace; }
.res-foot {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; margin-top: .35rem;
}
.res-go { font-size: .76rem; font-weight: 620; color: var(--accent); white-space: nowrap; opacity: .75; transition: opacity .14s; }
.res a:hover .res-go { opacity: 1; }

/* ── Halaman rangkuman materi ──────────────────────────────────────────── */
.doc-page { background: var(--bg); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .back {
  font-size: .85rem; font-weight: 600; text-decoration: none;
  color: var(--fg-muted); padding: .3rem .1rem;
}
.topbar .back:hover { color: var(--accent); }

.doc { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
.doc h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.2; margin: 0 0 .7rem; }
.doc h2 {
  font-size: 1.2rem; margin: 2.6rem 0 .7rem; padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.doc h3 { font-size: 1rem; margin: 1.8rem 0 .5rem; }
.doc h4 { font-size: .88rem; margin: 1.3rem 0 .4rem; }
.doc > article > p, .doc > article > ul, .doc > article > ol { max-width: 68ch; }

.crumb {
  display: inline-block; font-size: .72rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); padding: .25rem .6rem; border-radius: 5px;
  margin-bottom: .9rem;
}

.src {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  margin: 0 0 1.75rem;
}
.src a {
  display: inline-flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  text-decoration: none; color: inherit;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .5rem .8rem;
  transition: border-color .14s, box-shadow .14s;
}
.src a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.src-label { font-size: .85rem; font-weight: 620; color: var(--accent); }
.src-host { font-size: .76rem; color: var(--fg-subtle); font-family: ui-monospace, monospace; }
.src-time { font-size: .78rem; color: var(--fg-subtle); }

.tldr {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0 0 2rem;
}
.tldr h4 {
  margin: 0 0 .5rem; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--accent);
}
.tldr ul { margin: 0; padding-left: 1.15rem; font-size: .93rem; }
.tldr li { margin: .35rem 0; }

.doc .steps { counter-reset: s; list-style: none; padding: 0; }
.doc .steps > li { counter-increment: s; position: relative; padding-left: 2rem; margin: .7rem 0; }
.doc .steps > li::before {
  content: counter(s); position: absolute; left: 0; top: .1rem;
  width: 1.4rem; height: 1.4rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}

.closing {
  margin-top: 2.75rem; padding: .9rem 1.1rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .88rem; color: var(--fg-muted);
}
.closing p { margin: 0; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 2.5rem; }
.pager-item {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .75rem .9rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-elev);
  text-decoration: none; color: inherit; min-width: 0;
  transition: border-color .14s, box-shadow .14s;
}
.pager-item.empty { border: none; background: none; }
a.pager-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pager-item.next { text-align: right; }
.pager-dir { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--fg-subtle); }
.pager-title { font-size: .88rem; font-weight: 620; color: var(--accent); overflow-wrap: anywhere; }

/* ── Checkpoint ───────────────────────────────────────────────────────── */
.check {
  background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
  border-radius: var(--radius); padding: 1rem 1.15rem; margin: 1.5rem 0 0;
}
.check-head { display: flex; align-items: center; gap: .5rem; font-weight: 680; color: var(--ok); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .45rem; }
.check p { margin: 0 0 .75rem; font-size: .93rem; }
.check p:last-of-type { margin-bottom: .75rem; }
.check label { display: flex; gap: .5rem; align-items: center; font-size: .85rem; font-weight: 600; color: var(--ok); cursor: pointer; user-select: none; }
.check input { width: 1rem; height: 1rem; accent-color: var(--ok); cursor: pointer; margin: 0; }

.note {
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1.25rem; font-size: .89rem;
}
.note b { color: var(--warn); }
.note p:last-child { margin-bottom: 0; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--border); margin-top: 3rem; padding-top: 1.75rem; font-size: .84rem; color: var(--fg-subtle); }
.foot p { margin: 0 0 .4rem; }

.rules { counter-reset: r; list-style: none; padding: 0; }
.rules li { counter-increment: r; position: relative; padding-left: 2rem; margin: .55rem 0; }
.rules li::before {
  content: counter(r); position: absolute; left: 0; top: .12rem;
  width: 1.4rem; height: 1.4rem; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}

/* ── Mobile ───────────────────────────────────────────────────────────── */
.menu-btn { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: static; width: auto; height: auto; flex: none;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
  }
  .nav-collapse { display: none; }
  .sidebar.open .nav-collapse { display: block; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--bg-elev); border: 1px solid var(--border); color: var(--fg-muted);
    border-radius: 7px; padding: .38rem .7rem; font-size: .8rem; font-family: inherit; cursor: pointer;
  }
  .side-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
  .main { padding: 0 1.25rem 4rem; }
  .hero { padding: 2.25rem 0 1.75rem; }
  .facts { gap: .75rem 1.25rem; }

  .topbar { padding: .6rem 1.1rem; }
  .doc { padding: 1.75rem 1.1rem 4rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-item.empty { display: none; }
  .pager-item.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .sidebar, .theme-btn, .menu-btn, .topbar, .pager { display: none; }
  .main, .doc { padding: 0; }
  a { text-decoration: none; }
  .res a::after { content: " (" attr(href) ")"; font-size: .7rem; color: #666; }
}
