:root {
  /* Defaults only - config.json overrides these at runtime via assets/site.js.
   * The values here mirror the qoranetheone design so the page looks right even
   * before config.json loads, rather than flashing an unrelated palette. */
  --bg: #161826;
  --bg-elev: #232532;
  --bg-hover: #3f424d;
  --border: #3f424d;
  --text: #e9e9ed;
  --text-dim: #9397ab;
  --accent: #9184d9;
  --radius: 8px;
  --header-h: 56px;

  /* Tonal ramps from the design. Not in config.json: these are derived steps on
   * one shared lightness scale, so the same step of any role matches the others
   * in visual value. Changing --accent alone does not regenerate them. */
  --neutral-100: #f3f5fe;
  --neutral-200: #e4e7f5;
  --neutral-300: #cfd3e5;
  --neutral-400: #b2b6ca;
  --neutral-500: #9397ab;
  --neutral-600: #75798c;
  --neutral-700: #595d6c;
  --neutral-800: #3f424d;
  --neutral-900: #292b31;

  --accent-100: #f5f4ff;
  --accent-200: #e7e5fe;
  --accent-300: #d2cefd;
  --accent-400: #b5abfc;
  --accent-500: #968ae0;
  --accent-600: #796cbf;
  --accent-700: #5d5294;
  --accent-800: #423a6a;
  --accent-900: #2b2741;

  --divider: color-mix(in srgb, var(--text) 16%, transparent);

  /* Elevation: a hairline edge plus ambient darkness, as the design defines it */
  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0, 0, 0, .55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0, 0, 0, .65);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-heading-weight: 500;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .card-title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
}

a { color: inherit; text-decoration: none; }

/* ---------- header ---------- */
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot { color: var(--accent); }
.topbar .spacer { flex: 1; }

.search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  width: 260px;
  max-width: 40vw;
  font: inherit;
}
.search:focus { outline: none; border-color: var(--accent-2, #6b59cc); }

/* ---------- library ---------- */
main { padding: 0 20px 60px; max-width: 1360px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
}

.card { display: block; }
.card .thumb {
  aspect-ratio: 2 / 3;
  background: var(--bg-elev) center/cover no-repeat;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover .thumb { transform: translateY(-2px); border-color: var(--accent); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0,0,0,.75);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  color: #fff;
}
.card h3 {
  margin: 8px 0 2px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
}
.card .sub { color: var(--text-dim); font-size: 11.5px; }

/* ---------- series detail ---------- */
.series-head { display: flex; gap: 28px; margin-bottom: 32px; flex-wrap: wrap; }
.series-head .cover {
  width: 200px;
  flex: none;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--bg-elev);
}
.series-head .meta { flex: 1; min-width: 260px; }
.series-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.series-head .orig { color: var(--text-dim); margin: 0 0 14px; }
.series-head dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0 0 18px;
  font-size: 14px;
}
.series-head dt { color: var(--text-dim); }
.series-head dd { margin: 0; }

.btn {
  display: inline-block;
  /* accent is a light lavender - white text on it is unreadable, so the solid
     button uses the deeper purple instead */
  background: var(--accent-2, #6b59cc);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:hover { filter: brightness(1.1); }

.chapters { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chapters a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.chapters a:last-child { border-bottom: none; }
.chapters a:hover { background: var(--bg-hover); }
.chapters .name { flex: 1; font-weight: 500; }
.chapters .count { color: var(--text-dim); font-size: 13px; }
.chapters .read { color: var(--accent); font-size: 12px; }

h2.section { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em;
             color: var(--text-dim); margin: 0 0 12px; }

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 28px;
  color: var(--text-dim);
  line-height: 1.7;
}
.empty code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
}

/* ---------- reader ---------- */
body.reading { background: #000; overflow: hidden; }
body.reading.strip { overflow: auto; }

.reader-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgba(23,25,34,.96);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: transform .2s ease;
}
.reader-bar.hidden { transform: translateY(-100%); }
.reader-bar select, .reader-bar button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.reader-bar button:hover, .reader-bar select:hover { background: var(--bg-hover); }
.reader-bar .title { font-weight: 600; font-size: 14px; }
.reader-bar .title small { color: var(--text-dim); font-weight: 400; }
.reader-bar .spacer { flex: 1; }
.reader-bar .pageno { color: var(--text-dim); font-size: 13px; min-width: 70px; text-align: right; }

#stage {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding-top: var(--header-h);
}
#stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#stage.fit-width img { max-width: 100%; max-height: none; width: auto; }
#stage.fit-height img { max-height: calc(100vh - var(--header-h)); }
#stage.fit-original img { max-width: none; max-height: none; }
#stage.double img { max-width: 50%; }

/* long-strip / webtoon */
#strip { padding-top: var(--header-h); text-align: center; }
#strip img { display: block; margin: 0 auto; max-width: min(100%, var(--strip-max, 900px)); }

.zone {
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  width: var(--zone-w, 28%);
  z-index: 60;
  cursor: pointer;
}
.zone.left { left: 0; }
.zone.right { right: 0; }
.zone.center { left: var(--zone-w, 28%); right: var(--zone-w, 28%); width: auto; cursor: default; }

.progress {
  position: fixed;
  bottom: 0; left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 110;
  transition: width .15s ease;
}

.hint {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.8);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  z-index: 110;
  pointer-events: none;
  transition: opacity .4s ease;
}
.hint.gone { opacity: 0; }

/* ---------- global nav (injected by site.js) ---------- */
.topbar .tabs { display: flex; gap: 2px; margin-left: 6px; }
.topbar .tabs a {
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.topbar .tabs a:hover { background: var(--bg-hover); color: var(--text); }
.topbar .tabs a.on { background: var(--bg-hover); color: var(--accent); font-weight: 600; }

/* ---------- auth widget ---------- */
.authslot { display: flex; align-items: center; gap: 8px; }
.who { display: flex; align-items: center; gap: 8px; max-width: 190px; }
.who img, .who .av {
  width: 28px; height: 28px; border-radius: 50%;
  flex: none; object-fit: cover;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.who .nm {
  font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.66);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 28px 26px;
  width: 100%; max-width: 380px;
  position: relative;
  text-align: center;
}
.modal h3 { margin: 0 0 8px; font-size: 19px; letter-spacing: -0.02em; }
.modal-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; line-height: 1.6; }
.modal .gbtn { display: flex; justify-content: center; min-height: 4px; margin-bottom: 12px; }
.modal-note {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 14px;
  text-align: left;
}
.modal-note code {
  background: var(--bg-elev); padding: 1px 5px; border-radius: 4px; color: var(--text);
}
.modal-x {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none;
  color: var(--text-dim); font-size: 15px; cursor: pointer;
  padding: 5px 8px; border-radius: 6px;
}
.modal-x:hover { background: var(--bg-hover); color: var(--text); }
.btn.wide { width: 100%; }

@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .who .nm { display: none; }
  .topbar .tabs a { padding: 6px 9px; font-size: 13px; }
}

@media (max-width: 640px) {
  .series-head .cover { width: 130px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
  .reader-bar .title { display: none; }
  .search { width: 130px; }
  .brand { font-size: 15px; }
}

/* ---------- discovery: filter bar, chips, progress ---------- */

.disco {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 22px 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.disco-sp { flex: 1; min-width: 8px; }
.disco-n { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.disco-sort {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
}
.disco-sort select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
}
.disco-sort select:focus { outline: none; border-color: var(--accent); }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip.on {
  background: var(--accent-deep, var(--bg-hover));
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.chip.clear { color: var(--accent); border-style: dashed; }

/* Progress rail. Sits under a cover in the grids, under the title in a feed row. */
.pbar {
  display: block;
  height: 3px;
  margin: 6px 0 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.pbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2, var(--accent)), var(--accent));
}
.pbar.done i { opacity: .45; }
.series-head .pbar { max-width: 320px; margin: 10px 0 4px; }

.card .badge.done, .bk-card .badge.done {
  right: auto;
  left: 8px;
  background: var(--accent-deep, rgba(0,0,0,.78));
  font-weight: 700;
}

.cross {
  display: inline-block;
  margin-top: 26px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 13px;
}
.cross:hover { background: var(--bg-hover); border-style: solid; }

.taglist, .tagcloud { display: flex; gap: 5px; flex-wrap: wrap; margin: 12px 0; }

.chapters .when { color: var(--text-dim); font-size: 12px; }
.row-pct {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 30px;
  text-align: right;
}
