/* Pustaka Saku — gaya bersama untuk katalog & pembaca ebook
   Konsep tata letak: rak buku digital — katalog berupa rak sampul,
   pembaca berupa halaman kertas tenang dengan daftar isi di samping. */
:root {
  --paper: #f6f8f7;
  --surface: #ffffff;
  --ink: #16211f;
  --muted: #586763;
  --line: #dbe2df;
  --accent: #0d6a61;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ee;
  --mark: #e9a325;
  --mark-soft: #fbedcd;
  --ok: #2c7a47;
  --ok-soft: #e1f2e6;
  --bad: #b2412d;
  --bad-soft: #f9e4df;

  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-read: "Literata", Georgia, "Times New Roman", serif;
  --f-num: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --r: 10px;
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101716; --surface: #172120; --ink: #e5ece9; --muted: #98a7a2; --line: #2a3634;
    --accent: #52c2b2; --accent-ink: #062320; --accent-soft: #173533;
    --mark: #f0b445; --mark-soft: #3a2e16;
    --ok: #6fc68b; --ok-soft: #173323; --bad: #ec8d78; --bad-soft: #3b1f19;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101716; --surface: #172120; --ink: #e5ece9; --muted: #98a7a2; --line: #2a3634;
  --accent: #52c2b2; --accent-ink: #062320; --accent-soft: #173533;
  --mark: #f0b445; --mark-soft: #3a2e16;
  --ok: #6fc68b; --ok-soft: #173323; --bad: #ec8d78; --bad-soft: #3b1f19;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-display);
  font-size: 16px;
  line-height: 1.5;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; line-height: 1.15; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button, input, textarea, select { font: inherit; color: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: var(--gut-l); padding-right: var(--gut-r); }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { padding: 8px; width: 40px; height: 40px; }
.btn svg { width: 18px; height: 18px; }

/* ---------- Header situs ---------- */
.site-head { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-head .wrap { display: flex; align-items: center; gap: 12px; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 19px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; bottom: 6px; width: 5px; background: var(--accent-ink); border-radius: 1px; }
.brand-mark::before { left: 8px; height: 16px; }
.brand-mark::after { left: 16px; height: 12px; transform: rotate(-14deg); transform-origin: bottom; background: var(--mark); }
.site-head .spacer { flex: 1; }

/* ---------- Katalog ---------- */
.intro { padding-block: 44px 28px; display: grid; gap: 12px; }
.intro h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 800; letter-spacing: -0.02em; max-width: 18ch; }
.intro p { margin: 0; color: var(--muted); font-size: 18px; max-width: 56ch; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-block: 8px 20px; }
.search { flex: 1 1 240px; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 13px; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 22px; padding-bottom: 56px; }
.book { display: grid; gap: 10px; text-decoration: none; color: var(--ink); align-content: start; }
.book:hover .cover { transform: translateY(-3px); box-shadow: 0 14px 28px -14px rgba(0,0,0,.45); }
.cover {
  aspect-ratio: 3 / 4; max-width: 100%; border-radius: 4px 10px 10px 4px; position: relative; overflow: hidden;
  background: var(--c1, #0d6a61); color: #fff; padding: 18px 18px 18px 26px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 8px 18px -12px rgba(0,0,0,.45); transition: transform .2s, box-shadow .2s;
}
.cover::before { /* punggung buku */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px;
  background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(0,0,0,.05));
}
.cover::after { /* pola koin */
  content: ""; position: absolute; right: -40px; bottom: -40px; width: 170px; height: 170px; border-radius: 50%;
  background: repeating-radial-gradient(circle, var(--c2, #e9a325) 0 9px, transparent 9px 18px); opacity: .9;
}
.cover .c-kat { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; font-weight: 600; position: relative; z-index: 1; }
.cover .c-judul { font-size: 24px; font-weight: 800; line-height: 1.08; letter-spacing: -0.01em; position: relative; z-index: 1; max-width: 9ch; }
.cover .c-penulis { font-size: 12px; opacity: .85; position: relative; z-index: 1; }
.book-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.book-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.book-sub { color: var(--muted); font-size: 14px; line-height: 1.4; }
.price { font-family: var(--f-num); font-size: 14px; font-weight: 600; white-space: nowrap; }
.price.free { color: var(--ok); }
.empty { color: var(--muted); padding: 40px 0; grid-column: 1 / -1; }
.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.site-foot .wrap { padding-block: 22px; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* ---------- Pembaca ebook ---------- */
.reader-top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
body.reader::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: var(--surface); }
.reader-top .wrap { display: flex; align-items: center; gap: 8px; padding-block: 8px; max-width: none; }
.reader-top .r-title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.progress { height: 3px; background: transparent; }
.progress > i { display: block; height: 100%; width: 0; background: var(--mark); transition: width .1s linear; }

.reader-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 48px; max-width: 1120px; margin: 0 auto; padding-left: var(--gut-l); padding-right: var(--gut-r); }
.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); align-self: start; padding-block: 32px; max-height: calc(100vh - 80px); overflow-y: auto; }
.toc ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
.toc a { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; align-items: baseline; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 15px; line-height: 1.35; }
.toc a:hover { background: var(--accent-soft); }
.toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc .t-no { font-family: var(--f-num); font-size: 13px; color: var(--muted); }
.toc .t-lock { width: 14px; height: 14px; color: var(--muted); }
.toc-close { display: none; }

article.book-body { padding-block: 36px 80px; min-width: 0; }
.book-head { display: grid; gap: 14px; padding-bottom: 32px; border-bottom: 1px solid var(--line); margin-bottom: 8px; max-width: 680px; }
.book-head h1 { font-size: clamp(32px, 5vw, 48px); font-weight: 800; letter-spacing: -0.02em; }
.book-head .lede { font-family: var(--f-read); font-size: 19px; color: var(--muted); margin: 0; }
.book-head .facts { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--muted); }
.book-head .facts b { color: var(--ink); font-weight: 600; }

.chapter { max-width: 680px; padding-block: 40px 16px; scroll-margin-top: 80px; }
.chapter + .chapter { border-top: 1px solid var(--line); }
.ch-label { font-family: var(--f-num); font-size: 13px; color: var(--accent); font-weight: 600; letter-spacing: .04em; }
.chapter h2 { font-size: clamp(26px, 3.6vw, 34px); font-weight: 800; letter-spacing: -0.015em; margin: 6px 0 20px; }
.chapter h3 { font-size: 20px; font-weight: 700; margin: 32px 0 10px; }
.prose { font-family: var(--f-read); font-size: 18px; line-height: 1.75; }
.prose p { margin: 0 0 1.1em; }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.3em; }
.prose li { margin-bottom: .4em; }
.prose strong { font-weight: 700; }
.prose mark { background: var(--mark-soft); color: inherit; padding: 0 3px; border-radius: 3px; }

.note-box { border-left: 3px solid var(--mark); background: var(--mark-soft); padding: 14px 18px; border-radius: 0 var(--r) var(--r) 0; margin: 24px 0; font-family: var(--f-display); font-size: 16px; line-height: 1.55; }
.note-box b { display: block; margin-bottom: 4px; }

table.tbl { border-collapse: collapse; width: 100%; font-family: var(--f-display); font-size: 15px; }
.tbl-wrap { overflow-x: auto; margin: 20px 0 24px; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tbl td.r, .tbl th.r { text-align: right; }

/* ---------- Widget interaktif ---------- */
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 28px 0; font-family: var(--f-display); font-size: 16px; display: grid; gap: 14px; }
.widget-head { display: flex; gap: 10px; align-items: center; }
.widget-tag { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
.widget-title { font-weight: 700; font-size: 17px; }
.widget p { margin: 0; color: var(--muted); font-size: 15px; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; line-height: 1.4; }
.checklist label:hover { background: var(--accent-soft); }
.checklist input { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.checklist input:checked + span { color: var(--muted); }
.check-sum { font-size: 15px; font-weight: 600; }

.quiz-q { display: grid; gap: 8px; }
.quiz-q + .quiz-q { border-top: 1px dashed var(--line); padding-top: 14px; }
.quiz-q .q { font-weight: 600; }
.quiz-opts { display: grid; gap: 6px; }
.quiz-opts button { text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 10px 14px; cursor: pointer; line-height: 1.4; }
.quiz-opts button:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opts button:disabled { cursor: default; }
.quiz-opts button.right { background: var(--ok-soft); border-color: var(--ok); }
.quiz-opts button.wrong { background: var(--bad-soft); border-color: var(--bad); }
.quiz-why { font-size: 15px; color: var(--muted); }
.quiz-score { font-weight: 700; }

.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; font-size: 14px; color: var(--muted); font-weight: 600; }
.field input, .field select { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 10px 12px; font-family: var(--f-num); font-size: 16px; color: var(--ink); width: 100%; min-width: 0; }
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.res { background: var(--paper); border-radius: 10px; padding: 12px 14px; display: grid; gap: 2px; }
.res .k { font-size: 13px; color: var(--muted); }
.res .v { font-family: var(--f-num); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.res.hi { background: var(--accent-soft); }
.res.hi .v { color: var(--accent); }
.bar503020 { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--line); }
.bar503020 i { display: block; height: 100%; }
.bar503020 i:nth-child(1) { background: var(--accent); }
.bar503020 i:nth-child(2) { background: var(--mark); }
.bar503020 i:nth-child(3) { background: var(--ok); }
textarea.journal { width: 100%; min-height: 110px; border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 12px; font-family: var(--f-read); font-size: 16px; line-height: 1.6; resize: vertical; }
.saved-hint { font-size: 13px; color: var(--muted); }

/* ---------- Kunci ---------- */
.lock-card { max-width: 680px; margin: 40px 0; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 26px; display: grid; gap: 16px; }
.lock-card h2 { font-size: 26px; font-weight: 800; }
.lock-card p { margin: 0; color: var(--muted); }
.lock-card ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.lock-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lock-price .num { font-size: 28px; font-weight: 600; }
.code-form { display: flex; flex-wrap: wrap; gap: 8px; }
.code-form input { flex: 1 1 200px; min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 10px 16px; font-family: var(--f-num); letter-spacing: .08em; text-transform: uppercase; }
.msg { font-size: 15px; padding: 10px 14px; border-radius: 9px; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.info { background: var(--accent-soft); color: var(--ink); }
.chapter.locked-stub { color: var(--muted); padding-block: 18px; }
.chapter.locked-stub h2 { font-size: 20px; margin: 4px 0 0; color: var(--muted); }

.pager { max-width: 680px; display: flex; justify-content: space-between; gap: 12px; padding-top: 30px; border-top: 1px solid var(--line); margin-top: 30px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .reader-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); max-height: none;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px) max(16px, env(safe-area-inset-left, 0px));
    transform: translateX(-105%); transition: transform .22s ease;
  }
  body.toc-open .toc { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .toc-close { display: inline-flex; float: right; }
  .prose { font-size: 17px; }
}
@media (min-width: 901px) { .toc-toggle { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

@media print {
  .reader-top, .toc, .lock-card, .locked-stub, .pager, .btn, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .reader-grid { display: block; padding: 0; }
  .chapter { break-before: page; max-width: none; }
  .widget { break-inside: avoid; border-color: #bbb; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Widget tambahan: penyusun teks, email, simulator ---------- */
.field textarea { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 10px 12px; font-family: var(--f-display); font-size: 15px; line-height: 1.5; color: var(--ink); width: 100%; min-width: 0; min-height: 70px; resize: vertical; }
.field input[type="text"], .field input:not([inputmode]) { font-family: var(--f-display); }
.field textarea:focus { border-color: var(--accent); outline: none; }
.field .hint { font-weight: 400; font-size: 13px; }
.stack { display: grid; gap: 12px; }
.draft { background: var(--paper); border: 1px dashed var(--line); border-radius: 10px; padding: 14px 16px; font-family: var(--f-read); font-size: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; font-size: 14px; color: var(--muted); }
.btn.small { padding: 6px 14px; font-size: 14px; }
details.qa { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 8px 0; font-family: var(--f-display); font-size: 16px; }
details.qa summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style-position: outside; }
details.qa[open] summary { border-bottom: 1px solid var(--line); }
details.qa .qa-body { padding: 12px 16px; display: grid; gap: 8px; line-height: 1.6; }
details.qa .qa-body p { margin: 0; }
details.qa .qa-body .tip { color: var(--muted); font-size: 15px; }
.sim-card { background: var(--paper); border-radius: 12px; padding: 22px; display: grid; gap: 12px; text-align: center; }
.sim-count { font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.sim-q { font-size: clamp(20px, 3vw, 26px); font-weight: 700; line-height: 1.3; text-wrap: balance; min-height: 2.6em; display: grid; place-items: center; }
.sim-time { font-family: var(--f-num); font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.sim-time.over { color: var(--bad); font-size: 22px; }
.sim-tip { font-size: 15px; color: var(--muted); text-align: left; background: var(--surface); border-radius: 9px; padding: 10px 14px; }
.sim-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sim-bank { display: none; }
@media print { .sim-card, details.qa summary::marker { display: none; } details.qa .qa-body { display: grid; } }
