/* ===== Token warna: terang (default), gelap mengikuti sistem atau pilihan pembaca ===== */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #6b655c;
  --line: #e6dfd3;
  --accent: #9a3b1f;
  --accent-ink: #ffffff;
  --accent-soft: #f4e6dc;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 16px rgba(40, 30, 20, .05);
  --fs: 19px;
  --read-width: 40rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16161a; --surface: #1f1f24; --text: #e6e1d8; --muted: #9c968c; --line: #2f2e35;
    --accent: #f0a27a; --accent-ink: #1a1210; --accent-soft: #2e231f;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16161a; --surface: #1f1f24; --text: #e6e1d8; --muted: #9c968c; --line: #2f2e35;
  --accent: #f0a27a; --accent-ink: #1a1210; --accent-soft: #2e231f;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

/* ===== Dasar ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--sans); min-height: 100vh; display: flex; flex-direction: column;
  transition: background-color .2s, color .2s;
}
main { flex: 1; padding-bottom: 3rem; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 68rem; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 44rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 8px; top: 8px; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 1rem; height: 56px; }
.brand { font: 700 1.15rem/1 var(--serif); color: var(--text); text-decoration: none; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-nav { display: flex; gap: 1rem; margin-right: auto; }
.main-nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.main-nav a:hover { color: var(--text); }
.tools { display: flex; gap: 4px; flex-shrink: 0; }
.tool {
  min-width: 40px; height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: 600 .9rem/1 var(--sans); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.tool:hover { border-color: var(--accent); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tool .i-moon { fill: currentColor; stroke: none; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
@media (max-width: 560px) { .main-nav { display: none; } .brand { margin-right: auto; } }

/* ===== Komponen ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: 600 .95rem/1.2 var(--sans);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); filter: none; }
.btn-sm { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; }
.is-disabled { opacity: .4; pointer-events: none; }
.section-title { font: 700 1.3rem/1.3 var(--serif); margin: 2.2rem 0 1rem; }
.meta { color: var(--muted); font-size: .9rem; margin: .2rem 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem; padding: 0; margin: 1rem 0; font-size: .85rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: .3rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* ===== Beranda ===== */
.hero { padding: 2.5rem 16px 1rem; }
.hero h1 { font: 700 clamp(1.8rem, 5vw, 2.6rem)/1.15 var(--serif); margin: 0 0 .4rem; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0; font-size: 1.05rem; }
.novel-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); }
.novel-card { display: flex; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; box-shadow: var(--shadow); }
.novel-card h3 { font: 700 1.2rem/1.3 var(--serif); margin: 0; }
.novel-card h3 a { color: var(--text); text-decoration: none; }
.novel-card-link { flex-shrink: 0; display: block; }
.novel-card .cover { width: 120px; }
.novel-card-body { min-width: 0; display: flex; flex-direction: column; }
.synopsis { margin: .4rem 0 .8rem; font-size: .95rem; color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: auto; }
.cover { width: 104px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; flex-shrink: 0; display: block; }
.cover-fallback {
  display: flex; align-items: center; justify-content: center; text-align: center; padding: .6rem;
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #000));
  color: #fff; font: 700 .85rem/1.25 var(--serif);
}
.latest { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.latest li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border-top: 1px solid var(--line); }
.latest li:first-child { border-top: 0; }
.latest a { text-decoration: none; color: var(--text); display: flex; flex-direction: column; min-width: 0; }
.latest a:hover .l-ch { color: var(--accent); }
.l-novel { font-size: .8rem; color: var(--muted); }
.l-ch { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest time { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* ===== Halaman novel ===== */
.novel-detail { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; margin-top: .5rem; }
.cover-lg { width: 180px; box-shadow: var(--shadow); }
.novel-info h1 { font: 700 clamp(1.6rem, 4.5vw, 2.3rem)/1.15 var(--serif); margin: 0 0 .3rem; letter-spacing: -.01em; }
.alt-title { color: var(--muted); margin: 0 0 .6rem; font-style: italic; }
.facts { display: grid; gap: .25rem; margin: .8rem 0 1.2rem; font-size: .95rem; }
.facts div { display: flex; gap: .5rem; }
.facts dt { color: var(--muted); min-width: 7.5rem; }
.facts dd { margin: 0; }
.synopsis-full { max-width: var(--read-width); font-family: var(--serif); font-size: calc(var(--fs) * .9); line-height: 1.75; }
@media (max-width: 560px) {
  .novel-detail { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .facts div { justify-content: center; } .facts dt { min-width: 0; }
  .card-actions { justify-content: center; }
  .cover-lg { width: 150px; }
}
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.chapter-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); gap: 0 1.5rem; }
.chapter-list a { display: flex; justify-content: space-between; gap: .8rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.chapter-list a:hover span { color: var(--accent); }
.chapter-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-list time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.chapter-list .is-read span { color: var(--muted); }
.pager { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.pager a, .pager span { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; text-decoration: none; }
.pager span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ===== Pembaca bab ===== */
.reader-wrap { max-width: calc(var(--read-width) + 32px); }
.ch-picker { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: .5rem; margin: .5rem 0 .75rem; }
.ch-picker select {
  width: 100%; min-height: 44px; padding: .5rem 2rem .5rem .75rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.8' fill='none'/%3E%3C/svg%3E") no-repeat right .75rem center;
  color: var(--text); font: 500 .95rem/1.2 var(--sans); appearance: none; -webkit-appearance: none; cursor: pointer; text-overflow: ellipsis;
}
.ch-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; margin: .75rem 0; }
.ch-nav .btn { padding-inline: .7rem; }
.ch-head { text-align: center; margin: 2rem 0 1.8rem; }
.ch-novel { margin: 0 0 .4rem; font-size: .9rem; }
.ch-novel a { color: var(--muted); text-decoration: none; }
.ch-head h1 { font: 700 clamp(1.5rem, 4.5vw, 2.1rem)/1.25 var(--serif); margin: 0 0 .3rem; }
.ch-title { display: block; font-weight: 500; font-size: .75em; margin-top: .25rem; }
.ch-body { font-family: var(--serif); font-size: var(--fs); line-height: 1.8; overflow-wrap: break-word; hyphens: auto; }
.ch-body p { margin: 0 0 1.1em; }
.ch-body hr.scene { border: 0; text-align: center; margin: 2em 0; }
.ch-body hr.scene::after { content: "* * *"; color: var(--muted); letter-spacing: .6em; }
.is-reader .ch-body, .is-reader .ch-head { user-select: text; }
.end-note { text-align: center; color: var(--muted); font-style: italic; margin-top: 1.5rem; }
.progress { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 30; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

/* ===== Halaman statis ===== */
.page { font-family: var(--serif); font-size: calc(var(--fs) * .9); line-height: 1.75; }
.page h1 { font: 700 clamp(1.6rem, 4.5vw, 2.2rem)/1.2 var(--serif); margin: .5rem 0 1.2rem; }
.page h2 { font: 700 1.25rem/1.3 var(--serif); margin: 2rem 0 .6rem; }
.notfound { text-align: center; padding-top: 4rem; }

/* ===== Iklan ===== */
.ad { margin: 1.5rem 0; min-height: 100px; text-align: center; overflow: hidden; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0 2rem; font-size: .9rem; color: var(--muted); }
.footer-nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: .6rem; }
.footer-nav a { color: var(--muted); }
.copy { margin: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .site-header, .site-footer, .ch-nav, .ch-picker, .ad, .progress, .crumbs { display: none !important; } }

/* ===== Kutipan ===== */
.page blockquote, .ch-body blockquote {
  margin: 2rem 0; padding: .4rem 0 .4rem 1.2rem; border-left: 3px solid var(--accent);
  font-style: italic; font-size: 1.08em; color: var(--text);
}
.page blockquote p, .ch-body blockquote p { margin: 0; }
