/* Rienai Baca — tema dasar */
:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6862;
  --line: #e4e1da;
  --accent: #b4532a;
  --accent-soft: #f6e6de;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 27, 25, .06), 0 8px 24px rgba(28, 27, 25, .06);
  --reader-font: 19px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #14140f;
  --surface: #1c1c17;
  --text: #e9e5da;
  --muted: #9c978a;
  --line: #2c2c25;
  --accent: #e08b5f;
  --accent-soft: #2a2018;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

html[data-theme="sepia"] {
  --bg: #f4ecd8;
  --surface: #fbf5e6;
  --text: #3b3222;
  --muted: #7d6f55;
  --line: #e2d6bb;
  --accent: #9a5b23;
  --accent-soft: #efe0c4;
  --shadow: 0 1px 2px rgba(59, 50, 34, .08), 0 8px 24px rgba(59, 50, 34, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.wrap { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; gap: 1.25rem; height: 64px; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-mark { font-size: 1.25rem; }
.search { margin-left: auto; display: flex; gap: .4rem; }
.search input {
  width: clamp(150px, 30vw, 280px);
  padding: .55rem .8rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search button {
  padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer;
}
.search button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- hero ---------- */
.hero { padding: 3.25rem 0 1.5rem; max-width: 640px; }
.hero h1 { font-family: var(--serif); font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; margin: 0 0 .6rem; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0; font-size: 1.02rem; }

.section-title { font-size: 1.05rem; font-weight: 650; margin: 2.25rem 0 1rem; letter-spacing: -.01em; }
.muted { color: var(--muted); font-weight: 400; }
.empty { color: var(--muted); padding: 2rem 0 3rem; }

/* ---------- cover ---------- */
.cover {
  aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden;
  background: var(--accent-soft); box-shadow: var(--shadow); flex: none;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-gen {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 20% 10%, hsl(var(--h) 45% 62%), transparent 60%),
    linear-gradient(160deg, hsl(var(--h) 40% 38%), hsl(calc(var(--h) + 40) 35% 22%));
}
.cover-gen span {
  font-family: var(--serif); font-size: 2.6rem; color: rgba(255, 255, 255, .92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}

/* ---------- grid of novels ---------- */
.grid {
  display: grid; gap: 1.1rem; padding-bottom: 3rem;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .16s ease, box-shadow .16s ease; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-link { display: block; padding: .8rem; }
.card .cover { width: 100%; margin-bottom: .75rem; }
.card-body h3 { margin: 0 0 .2rem; font-size: .98rem; line-height: 1.3; letter-spacing: -.01em; }
.card-body .meta { margin: 0 0 .45rem; color: var(--muted); font-size: .8rem; }
.excerpt { margin: 0 0 .6rem; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.badges { display: flex; gap: .35rem; flex-wrap: wrap; margin: 0; }
.badge {
  font-size: .7rem; padding: .18rem .5rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; letter-spacing: .01em;
}
.badge-done { background: var(--line); color: var(--muted); }

/* ---------- novel page ---------- */
.crumbs { padding: 1.25rem 0 0; font-size: .82rem; color: var(--muted); display: flex; gap: .45rem; }
.novel-head { display: grid; grid-template-columns: 200px 1fr; gap: 2rem; padding: 1.5rem 0 2rem; align-items: start; }
.cover-lg { width: 200px; }
.novel-info h1 { font-family: var(--serif); font-size: clamp(1.7rem, 4vw, 2.5rem); margin: 0 0 .5rem; letter-spacing: -.02em; line-height: 1.15; }
.novel-info .meta { color: var(--muted); margin: 0 0 .7rem; font-size: .88rem; }
.synopsis { color: var(--text); opacity: .92; max-width: 62ch; margin: .9rem 0 1.25rem; font-size: .95rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.05rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: .9rem; font-weight: 550;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); color: #fff; }
.btn-disabled { opacity: .45; cursor: default; }
.btn-disabled:hover { border-color: var(--line); color: var(--text); }

.chapters { padding-bottom: 3.5rem; }
.chapter-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.chapter-list li + li { border-top: 1px solid var(--line); }
.chapter-list a { display: flex; align-items: baseline; gap: .9rem; padding: .8rem 1rem; }
.chapter-list a:hover { background: var(--accent-soft); }
.chapter-list .num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; min-width: 2.2ch; }
.chapter-list .ttl { flex: 1; font-size: .94rem; }
.chapter-list .len { color: var(--muted); font-size: .75rem; }

/* ---------- reader ---------- */
.reader-bar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.reader-bar-inner { width: min(900px, 100% - 2rem); margin-inline: auto; display: flex; align-items: center; gap: 1rem; height: 56px; }
.reader-back { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-back:hover { color: var(--accent); }
.reader-tools { margin-left: auto; display: flex; gap: .5rem; }
.tool-group { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.tool-group button {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: .82rem;
  padding: .4rem .6rem; cursor: pointer; line-height: 1;
}
.tool-group button + button { border-left: 1px solid var(--line); }
.tool-group button:hover { background: var(--accent-soft); color: var(--accent); }
.progress { height: 2px; background: transparent; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

.reader { width: min(720px, 100% - 2.5rem); margin-inline: auto; padding: 3rem 0 5rem; }
.reader-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; color: var(--muted); margin: 0 0 .5rem; font-weight: 600; }
.reader-title { font-family: var(--serif); font-size: clamp(1.5rem, 3.6vw, 2.1rem); line-height: 1.2; margin: 0 0 2rem; letter-spacing: -.015em; }
.reader-body { font-family: var(--serif); font-size: var(--reader-font); line-height: 1.78; }
.reader-body p { margin: 0 0 1.25em; }
.reader-body p:first-of-type::first-letter {
  font-size: 3.1em; float: left; line-height: .82; padding: .06em .08em 0 0; color: var(--accent);
}
.reader-nav { display: flex; align-items: center; gap: .6rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chapter-select {
  flex: 1; min-width: 160px; padding: .55rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem;
}
.reader-end { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 2rem; }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--line); padding: 1.6rem 0 2.4rem; color: var(--muted); font-size: .82rem; }

/* ---------- 404 ---------- */
.notfound { padding: 4rem 0 6rem; max-width: 34rem; }
.notfound .nf-code {
  font-family: var(--serif); font-size: clamp(3.5rem, 12vw, 6rem); line-height: 1;
  margin: 0 0 .5rem; color: var(--accent); opacity: .35; letter-spacing: -.03em;
}
.notfound h1 { font-family: var(--serif); font-size: clamp(1.2rem, 3.4vw, 1.7rem); margin: 0 0 1.5rem; line-height: 1.3; }

/* ---------- admin ---------- */
.admin-wrap { width: min(900px, 100% - 2.5rem); margin: 2.5rem auto 5rem; }
.admin-wrap h1 { font-family: var(--serif); font-size: 1.8rem; margin: 0 0 1.25rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .3rem; color: var(--muted); }
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=url], .field select, .field textarea {
  width: 100%; padding: .6rem .75rem; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: .92rem;
}
.field textarea { min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; line-height: 1.6; }
.field .hint { color: var(--muted); font-size: .75rem; margin-top: .25rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.flash { padding: .7rem 1rem; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: .88rem; margin-bottom: 1rem; }
.flash-error { background: #fde8e6; color: #a12a1b; }

@media (max-width: 640px) {
  .novel-head { grid-template-columns: 120px 1fr; gap: 1.1rem; }
  .cover-lg { width: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .reader { padding-top: 2rem; }
  .reader-back span { display: none; }
}
