/* ============================================================
   NOVELKU — Stylesheet utama
   Struktur:
     1. Variabel tema (light / dark / sepia)
     2. Reset & tipografi
     3. Komponen umum (tombol, kartu, form, badge)
     4. Header & footer
     5. Halaman: beranda, jelajah, detail, profil
     6. READER (halaman baca + panel kustomisasi)
     7. Creator Studio
     8. Responsive
   ============================================================ */

/* ---------- 1. VARIABEL TEMA ---------- */
:root {
  --brand:        #6c4df6;
  --brand-dark:   #573ce0;
  --brand-soft:   #efeaff;

  --bg:           #f6f7fb;
  --bg-elev:      #ffffff;
  --bg-sunken:    #eef0f6;
  --text:         #1a1c25;
  --text-soft:    #5a6072;
  --text-faint:   #8b90a3;
  --border:       #e3e6ef;

  --success:      #16a34a;
  --danger:       #dc2626;
  --warning:      #d97706;
  --star:         #f5a623;

  --radius:       14px;
  --radius-sm:    9px;
  --shadow:       0 1px 2px rgba(16,20,40,.05), 0 8px 24px rgba(16,20,40,.06);
  --shadow-lg:    0 12px 40px rgba(16,20,40,.14);
  --container:    1180px;
  --font-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif:   'Lora', Georgia, 'Times New Roman', serif;
}

[data-theme="dark"] {
  --bg:         #0f1117;
  --bg-elev:    #171a23;
  --bg-sunken:  #1e2230;
  --text:       #e8eaf2;
  --text-soft:  #a2a8bd;
  --text-faint: #6f7590;
  --border:     #262b3a;
  --brand-soft: #232043;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.5);
}

[data-theme="sepia"] {
  --bg:         #f3e9d8;
  --bg-elev:    #fbf3e4;
  --bg-sunken:  #ece0c9;
  --text:       #3b2f20;
  --text-soft:  #6d5c44;
  --text-faint: #94825f;
  --border:     #ddcdae;
  --brand:      #9a6b32;
  --brand-dark: #7f572a;
  --brand-soft: #eadcc0;
}

/* ---------- 2. RESET & DASAR ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  transition: background .2s ease, color .2s ease;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.25; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
h3 { font-size: 1.12rem; }
p  { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted  { color: var(--text-soft); }
.faint  { color: var(--text-faint); font-size: .875rem; }
.center { text-align: center; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 18px; }
.section   { padding: 34px 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.section-head h2 { margin: 0; }
.section-head a  { font-size: .9rem; font-weight: 600; }

/* ---------- 3. KOMPONEN ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font: 600 .93rem/1 var(--font-ui); cursor: pointer;
  transition: .15s ease; text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.btn:active { transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost   { background: transparent; }
.btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm  { padding: 7px 13px; font-size: .84rem; }
.btn-lg  { padding: 13px 26px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-soft);
  font-size: .75rem; font-weight: 600; text-decoration: none;
}
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-ok    { background: rgba(22,163,74,.13);  color: var(--success); }
.badge-warn  { background: rgba(217,119,6,.13);  color: var(--warning); }
.badge-dang  { background: rgba(220,38,38,.13);  color: var(--danger); }

/* Form */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.input, input[type=text], input[type=email], input[type=password], input[type=search],
input[type=url], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font: 400 .95rem/1.5 var(--font-ui); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
textarea { resize: vertical; min-height: 110px; }
.field-error { color: var(--danger); font-size: .82rem; margin-top: 5px; }
.field-hint  { color: var(--text-faint); font-size: .8rem; margin-top: 5px; }
.checkbox { display: flex; align-items: center; gap: 9px; font-size: .9rem; }
.checkbox input { width: auto; }

/* Flash */
.flash-wrap { position: fixed; top: 74px; right: 18px; z-index: 200; display: grid; gap: 9px; max-width: 340px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border-left: 4px solid var(--brand);
  box-shadow: var(--shadow-lg); font-size: .9rem;
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } }
.flash-success { border-left-color: var(--success); }
.flash-error   { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warning); }
.flash-x { background: none; border: 0; font-size: 1.15rem; cursor: pointer; color: var(--text-faint); line-height: 1; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin: 28px 0; flex-wrap: wrap; }
.pagination a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); font-size: .88rem; font-weight: 600; text-decoration: none;
}
.pagination a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Breadcrumb */
.breadcrumb { font-size: .84rem; color: var(--text-soft); margin-bottom: 14px; }
.breadcrumb .sep { margin: 0 7px; opacity: .5; }

/* Empty state */
.empty { text-align: center; padding: 56px 20px; color: var(--text-soft); }
.empty .emoji { font-size: 2.6rem; display: block; margin-bottom: 10px; }

/* ---------- 4. HEADER & FOOTER ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.12rem; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.32rem; }

.search-box { flex: 1; max-width: 420px; position: relative; display: flex; }
.search-box input { padding-right: 42px; background: var(--bg-sunken); border-radius: 999px; }
.search-box button {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; padding: 7px 10px; cursor: pointer; font-size: .95rem;
}

.main-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.main-nav > a { padding: 8px 11px; border-radius: var(--radius-sm); color: var(--text-soft); font-weight: 600; font-size: .9rem; }
.main-nav > a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.main-nav > a.btn { color: #fff; }

.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 21px; height: 2px; background: var(--text); border-radius: 2px; }

.dropdown { position: relative; }
.dropdown-btn {
  background: none; border: 0; cursor: pointer; padding: 8px 11px;
  font: 600 .9rem var(--font-ui); color: var(--text-soft); border-radius: var(--radius-sm);
}
.dropdown-btn:hover { background: var(--bg-sunken); color: var(--text); }
.dropdown-menu {
  position: absolute; top: calc(100% + 7px); left: 0; min-width: 210px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 7px; display: none; z-index: 120;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu.align-right { left: auto; right: 0; }
.dropdown-menu a {
  display: block; padding: 8px 11px; border-radius: var(--radius-sm);
  color: var(--text); font-size: .89rem; text-decoration: none;
}
.dropdown-menu a:hover { background: var(--bg-sunken); }
.dropdown-menu a.danger { color: var(--danger); }
.dd-head { padding: 9px 11px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.dd-head small { display: block; color: var(--text-faint); }
.genre-menu { display: grid; grid-template-columns: 1fr 1fr; min-width: 300px; }

.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.avatar-lg {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 2rem;
}
.theme-toggle { background: none; border: 0; cursor: pointer; font-size: 1.1rem; padding: 7px; border-radius: 50%; }
.theme-toggle:hover { background: var(--bg-sunken); }

.site-footer { border-top: 1px solid var(--border); background: var(--bg-elev); margin-top: 56px; padding: 40px 0 22px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 28px; }
.footer-grid h4 { font-size: .87rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.footer-grid a { display: block; color: var(--text-soft); font-size: .9rem; padding: 3px 0; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 26px; padding-top: 18px; font-size: .83rem; color: var(--text-faint); }

/* ---------- 5. KARTU NOVEL & GRID ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, #9b5cf6 55%, #e05fa8 100%);
  color: #fff; padding: 52px 0; margin-bottom: 8px;
}
.hero h1 { color: #fff; margin-bottom: 10px; }
.hero p  { opacity: .93; max-width: 560px; margin-bottom: 20px; }
.hero .btn { background: #fff; color: var(--brand); border-color: #fff; }
.hero .btn-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.4); }

.novel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 20px; }
.novel-card { display: block; color: inherit; text-decoration: none; }
.novel-card:hover { text-decoration: none; }
.novel-card .cover {
  position: relative; aspect-ratio: 2/3; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-sunken); box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.novel-card:hover .cover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.novel-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.novel-card .cover .rank {
  position: absolute; top: 8px; left: 8px; width: 26px; height: 26px;
  border-radius: 8px; background: rgba(0,0,0,.62); color: #fff;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}
.novel-card .cover .chip {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,.62); color: #fff; padding: 3px 8px;
  border-radius: 6px; font-size: .7rem; font-weight: 600;
}
.novel-card .title {
  font-weight: 700; font-size: .93rem; margin: 10px 0 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.35;
}
.novel-card .meta { font-size: .78rem; color: var(--text-faint); display: flex; gap: 9px; flex-wrap: wrap; }

/* Baris horizontal (scrollable di mobile) */
.rail { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.rail > * { flex: 0 0 158px; scroll-snap-align: start; }
.rail::-webkit-scrollbar { height: 6px; }
.rail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Daftar horizontal (list view) */
.novel-list { display: grid; gap: 14px; }
.novel-row { display: flex; gap: 15px; padding: 15px; }
.novel-row .cover { width: 84px; flex: 0 0 84px; aspect-ratio: 2/3; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-sunken); }
.novel-row .cover img { width: 100%; height: 100%; object-fit: cover; }
.novel-row h3 { margin: 0 0 5px; font-size: 1rem; }
.novel-row .syn {
  font-size: .87rem; color: var(--text-soft); margin: 6px 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.stat-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--text-faint); }
.stars { color: var(--star); letter-spacing: 1px; }

/* Chip filter genre */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-row a, .chip-row label {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev); font-size: .85rem; font-weight: 600;
  color: var(--text-soft); cursor: pointer; text-decoration: none;
}
.chip-row a.active, .chip-row input:checked + span {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.chip-row label input { display: none; }
.chip-row label span { display: inline-block; }

/* Layout dua kolom */
.two-col { display: grid; grid-template-columns: 260px 1fr; gap: 26px; align-items: start; }
.sticky { position: sticky; top: 78px; }

/* Detail novel */
.novel-hero { display: grid; grid-template-columns: 210px 1fr; gap: 28px; margin-bottom: 26px; }
.novel-hero .cover-big { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 2/3; background: var(--bg-sunken); }
.novel-hero .cover-big img { width: 100%; height: 100%; object-fit: cover; }
.novel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-box { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-box b { display: block; font-size: 1.15rem; }
.stat-box span { font-size: .76rem; color: var(--text-faint); }

/* Rating widget */
.rate-stars { display: inline-flex; flex-direction: row-reverse; gap: 3px; }
.rate-stars input { display: none; }
.rate-stars label { font-size: 1.6rem; color: var(--border); cursor: pointer; line-height: 1; transition: color .12s; }
.rate-stars input:checked ~ label,
.rate-stars label:hover, .rate-stars label:hover ~ label { color: var(--star); }
.rating-bar { display: flex; align-items: center; gap: 8px; font-size: .8rem; margin-bottom: 5px; }
.rating-bar .track { flex: 1; height: 7px; background: var(--bg-sunken); border-radius: 4px; overflow: hidden; }
.rating-bar .fill  { height: 100%; background: var(--star); }

/* Daftar isi */
.toc-list { display: grid; gap: 2px; max-height: 520px; overflow-y: auto; }
.toc-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
}
.toc-item:hover { background: var(--bg-sunken); text-decoration: none; }
.toc-item.current { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.toc-item .no { color: var(--text-faint); font-size: .8rem; min-width: 46px; }
.toc-item .when { font-size: .76rem; color: var(--text-faint); white-space: nowrap; }

/* Komentar */
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: 0; }
.comment .body { flex: 1; min-width: 0; }
.comment .who { font-weight: 600; font-size: .9rem; }
.comment .when { font-size: .76rem; color: var(--text-faint); margin-left: 7px; }
.comment p { margin: 5px 0 6px; font-size: .93rem; white-space: pre-wrap; word-wrap: break-word; }
.comment .acts { display: flex; gap: 12px; font-size: .78rem; }
.comment .acts button { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: .78rem; padding: 0; }
.comment .acts button:hover { color: var(--brand); }
.replies { margin-left: 46px; border-left: 2px solid var(--border); padding-left: 14px; }

/* ---------- 6. READER ---------- */
.reader-page .site-header { position: static; }

.reader-wrap { max-width: var(--reader-width, 760px); margin: 0 auto; padding: 26px 20px 90px; }
.reader-head { text-align: center; margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.reader-head .novel-name { font-size: .88rem; color: var(--text-soft); }
.reader-head h1 { font-size: clamp(1.3rem, 3.5vw, 1.85rem); margin: 8px 0 10px; }
.reader-head .info { font-size: .8rem; color: var(--text-faint); display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* Area teks — dikendalikan variabel yang diubah oleh reader.js */
#chapterContent {
  font-family: var(--reader-font, var(--font-serif));
  font-size:   var(--reader-size, 19px);
  line-height: var(--reader-lh, 1.85);
  letter-spacing: var(--reader-ls, 0);
  text-align:  var(--reader-align, left);
  color: var(--text);
  word-wrap: break-word;
}
#chapterContent p  { margin: 0 0 1.15em; }
#chapterContent h2, #chapterContent h3 { margin: 1.7em 0 .7em; }
#chapterContent img { margin: 1.4em auto; border-radius: var(--radius-sm); }
#chapterContent blockquote {
  margin: 1.4em 0; padding: .6em 1.2em; border-left: 3px solid var(--brand);
  color: var(--text-soft); font-style: italic;
}
#chapterContent hr { margin: 2em auto; width: 40%; }

/* Bar alat bawah */
.reader-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; z-index: 90;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px; box-shadow: var(--shadow-lg);
  transition: transform .25s ease, opacity .25s ease;
}
.reader-bar.hidden { transform: translate(-50%, 130%); opacity: 0; pointer-events: none; }
.reader-bar button, .reader-bar a {
  background: none; border: 0; cursor: pointer; padding: 9px 13px;
  border-radius: 999px; color: var(--text-soft); font: 600 .85rem var(--font-ui);
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.reader-bar button:hover, .reader-bar a:hover { background: var(--bg-sunken); color: var(--text); }
.reader-bar button:disabled { opacity: .35; cursor: default; }
.reader-bar .sep { width: 1px; height: 22px; background: var(--border); }

/* Panel pengaturan & TOC */
.panel-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 140; display: none; }
.panel-backdrop.open { display: block; }
.panel {
  position: fixed; z-index: 150; background: var(--bg-elev);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  left: 50%; bottom: 0; transform: translate(-50%, 100%);
  width: min(520px, 100%); max-height: 82vh; overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0; padding: 22px;
  transition: transform .25s cubic-bezier(.32,.72,0,1);
}
.panel.open { transform: translate(-50%, 0); }
.panel h3 { display: flex; justify-content: space-between; align-items: center; }
.panel .close { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--text-faint); }
.setting-row { margin-bottom: 20px; }
.setting-row > label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-soft); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 62px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text-soft);
  cursor: pointer; font: 600 .85rem var(--font-ui);
}
.seg button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.theme-swatch { width: 100%; height: 42px; border-radius: var(--radius-sm); border: 2px solid var(--border); cursor: pointer; }
.theme-swatch.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.sw-light { background: #fff; color: #111; }
.sw-dark  { background: #14161f; color: #eee; }
.sw-sepia { background: #f3e9d8; color: #3b2f20; }
input[type=range] { width: 100%; accent-color: var(--brand); }

/* Progress baca di atas layar */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--brand); z-index: 130; width: 0; transition: width .1s linear; }

/* Navigasi bawah bab */
.chapter-nav { display: flex; gap: 12px; margin: 34px 0; }
.chapter-nav a { flex: 1; padding: 15px; text-align: center; }

/* ---------- 7. CREATOR STUDIO ---------- */
.studio { display: grid; grid-template-columns: 232px 1fr; gap: 26px; align-items: start; padding: 26px 0; }
.studio-side { position: sticky; top: 78px; }
.studio-side a {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px;
  border-radius: var(--radius-sm); color: var(--text-soft); font-size: .9rem; font-weight: 600; text-decoration: none;
}
.studio-side a:hover { background: var(--bg-sunken); color: var(--text); }
.studio-side a.active { background: var(--brand-soft); color: var(--brand); }
.studio-side .side-head { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); padding: 14px 13px 6px; }

.studio-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 16px; margin-bottom: 26px; }
.kpi { padding: 18px; }
.kpi .label { font-size: .78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 1.85rem; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.kpi .delta { font-size: .78rem; color: var(--success); }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; padding: 11px 13px; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); border-bottom: 1px solid var(--border); }
.table td { padding: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--bg-sunken); }
.table-wrap { overflow-x: auto; }

/* Editor */
.editor-shell { display: grid; grid-template-columns: 1fr 268px; gap: 22px; align-items: start; }
.editor-main .ql-toolbar { border-radius: var(--radius) var(--radius) 0 0 !important; border-color: var(--border) !important; background: var(--bg-elev); }
.editor-main .ql-container { border-radius: 0 0 var(--radius) var(--radius) !important; border-color: var(--border) !important; background: var(--bg-elev); min-height: 480px; font-family: var(--font-serif); font-size: 1.05rem; }
.editor-main .ql-editor { min-height: 480px; line-height: 1.8; color: var(--text); }
.editor-main .ql-editor.ql-blank::before { color: var(--text-faint); font-style: normal; }
[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text-soft); }
[data-theme="dark"] .ql-snow .ql-fill   { fill: var(--text-soft); }
[data-theme="dark"] .ql-snow .ql-picker-label { color: var(--text-soft); }
[data-theme="dark"] .ql-snow .ql-picker-options { background: var(--bg-elev); }

.title-input { font-size: 1.3rem !important; font-weight: 700 !important; border: 0 !important; background: transparent !important; padding-left: 0 !important; }
.title-input:focus { box-shadow: none !important; }

.save-state { font-size: .82rem; color: var(--text-faint); display: inline-flex; align-items: center; gap: 6px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.save-state.saving .dot { background: var(--warning); animation: pulse 1s infinite; }
.save-state.saved  .dot { background: var(--success); }
.save-state.error  .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* Grafik batang sederhana (tanpa library) */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 132px; }
.bars .bar { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .82; position: relative; }
.bars .bar:hover { opacity: 1; }
.bars .bar span {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: .7rem; padding: 2px 6px;
  border-radius: 4px; white-space: nowrap; display: none;
}
.bars .bar:hover span { display: block; }

/* Auth */
.auth-wrap { max-width: 430px; margin: 52px auto; }
.auth-wrap .card { padding: 30px; }
.auth-wrap h1 { font-size: 1.5rem; margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: .8rem; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Profil */
.profile-head { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin-bottom: 26px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px; }
.user-row .info { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button, .tabs a {
  background: none; border: 0; padding: 11px 15px; cursor: pointer;
  font: 600 .9rem var(--font-ui); color: var(--text-soft);
  border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none;
}
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- 8. RESPONSIVE ---------- */
@media (max-width: 900px) {
  .two-col, .studio, .editor-shell { grid-template-columns: 1fr; }
  .studio-side, .sticky { position: static; }
  .studio-side { display: flex; gap: 6px; overflow-x: auto; }
  .novel-hero { grid-template-columns: 132px 1fr; gap: 18px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; order: 3; margin-left: auto; }
  .search-box { order: 4; max-width: 100%; flex: 1 0 100%; margin-bottom: 10px; }
  .header-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .main-nav {
    display: none; flex-direction: column; align-items: stretch;
    width: 100%; order: 5; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border);
  }
  .main-nav.open { display: flex; }
  .dropdown-menu { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; }
  .genre-menu { min-width: 0; }
  .novel-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px; }
  .flash-wrap { left: 12px; right: 12px; max-width: none; top: 12px; }
  .reader-wrap { padding: 18px 16px 96px; }
  .reader-bar { left: 12px; right: 12px; transform: none; justify-content: space-around; }
  .reader-bar.hidden { transform: translateY(130%); }
  .reader-bar button span.txt { display: none; }
  .footer-grid { grid-template-columns: 1fr; }
  .replies { margin-left: 16px; }
}

/* Cetak / print: hanya isi bab */
@media print {
  .site-header, .site-footer, .reader-bar, .chapter-nav, .panel, .panel-backdrop, .read-progress { display: none !important; }
  body { background: #fff; color: #000; }
  #chapterContent { font-size: 12pt; }
}

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