:root {
  --brand: #0b3a6e;
  --brand-ink: #ffffff;
  --accent: #e2a72e;
  --bg: #eef1f5;
  --stage: #1d2733;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5d6b7a;
  --line: #d7dde4;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink);
}
.topbar img.logo { height: 34px; width: auto; background: #fff; border-radius: 6px; padding: 3px; }
.topbar .title { font-weight: 600; font-size: 17px; line-height: 1.2; }
.topbar .sub { font-size: 12.5px; opacity: .8; }
.topbar .spacer { flex: 1; }
.topbar a.btn-light, .topbar button.btn-light {
  color: var(--brand-ink); text-decoration: none; border: 1px solid rgba(255,255,255,.45);
  background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13.5px;
}

/* ---------- Archive / bookshelf ---------- */
.shelf-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.latest {
  display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 28px; align-items: center;
  background: var(--panel); border-radius: 14px; padding: 22px; box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.latest img { width: 100%; border-radius: 6px; box-shadow: 0 8px 22px rgba(0,0,0,.22); display: block; }
.latest .tag { display: inline-block; background: var(--accent); color: #2b1d00; font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; letter-spacing: .03em; text-transform: uppercase; }
.latest h1 { margin: 10px 0 6px; font-size: 28px; }
.latest p { color: var(--muted); margin: 0 0 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); padding: 10px 20px; font-weight: 600; text-decoration: none; font-size: 15px;
}
.btn.secondary { background: #e4e9f0; color: var(--ink); }
.btn.small { padding: 6px 13px; font-size: 13.5px; }
.btn.danger { background: #b3261e; color: #fff; }
.year-head { margin: 36px 0 12px; font-size: 20px; border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px; }
.card { text-decoration: none; color: inherit; display: block; }
.card .cover { aspect-ratio: 210/297; background: #dde3ea; border-radius: 5px; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); transition: transform .15s, box-shadow .15s; }
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .cover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,.22); }
.card .name { font-weight: 600; margin-top: 9px; font-size: 14.5px; }
.card .date { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
@media (max-width: 640px) {
  .latest { grid-template-columns: 1fr; text-align: center; }
  .latest img { max-width: 220px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}

/* ---------- Reader ---------- */
body.reader { background: var(--stage); overflow: hidden; }
.reader-app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--stage); }
.reader-app .topbar { flex: 0 0 auto; }
.stage { position: relative; flex: 1 1 auto; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.book-holder { position: relative; }
.page { background: #fff; overflow: hidden; }
.page .pg { position: relative; width: 100%; height: 100%; }
.page img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.page .spin { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #aab; font-size: 13px; }
a.hot {
  position: absolute; display: block; z-index: 5; border-radius: 3px;
  background: rgba(226,167,46,.0); outline: 2px solid rgba(226,167,46,0); transition: background .2s, outline-color .2s;
}
a.hot.vid { display: flex; align-items: center; justify-content: center; }
a.hot .vbadge { width: 54px; height: 54px; max-width: 70%; max-height: 70%; aspect-ratio: 1; border-radius: 50%; background: rgba(10,14,24,.62); color: #fff; border: 2px solid rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.35); transition: transform .2s; }
a.hot .vbadge svg { width: 46%; height: 46%; margin-left: 8%; }
a.hot.vid:hover .vbadge { transform: scale(1.08); }
a.hot:hover, .show-links a.hot { background: rgba(226,167,46,.18); outline-color: rgba(226,167,46,.85); }
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 20;
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 22px;
}
.nav-arrow:hover { background: rgba(255,255,255,.25); }
.nav-arrow.prev { left: 12px; } .nav-arrow.next { right: 12px; }
.toolbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap;
  padding: 8px 10px; background: rgba(0,0,0,.35); color: #fff;
}
.toolbar button {
  background: transparent; border: 0; color: #fff; padding: 7px 10px; border-radius: 8px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; min-width: 52px;
}
.toolbar button svg { width: 21px; height: 21px; }
.toolbar button:hover, .toolbar button.on { background: rgba(255,255,255,.14); }
.toolbar .count { font-size: 13px; padding: 0 10px; opacity: .9; min-width: 80px; text-align: center; }
@media (max-width: 640px) {
  .toolbar { gap: 0; padding: 6px 4px; }
  .toolbar button { min-width: 34px; padding: 6px 5px; }
  .toolbar button span { display: none; }
  .toolbar button[data-act=first], .toolbar button[data-act=last] { display: none; }
  .toolbar .count { min-width: 60px; padding: 0 4px; }
  .nav-arrow { display: none; }
}

.panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); z-index: 40;
  background: var(--panel); color: var(--ink); box-shadow: 4px 0 20px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
}
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.panel header button { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); }
.panel .body { overflow: auto; padding: 14px 16px; flex: 1; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.thumbs button { border: 2px solid transparent; background: none; padding: 0; text-align: center; color: var(--muted); font-size: 12px; border-radius: 4px; }
.thumbs button img { width: 100%; display: block; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.thumbs button.cur { border-color: var(--accent); }
.toc a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.toc a span:last-child { color: var(--muted); }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.share-row input { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.qr-box { text-align: center; padding: 10px; }
.qr-box img { width: 200px; height: 200px; image-rendering: pixelated; }

.zoom-layer { position: absolute; inset: 0; z-index: 60; background: rgba(10,14,20,.96); overflow: hidden; touch-action: none; cursor: grab; }
.zoom-layer img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.zoom-ctl { position: absolute; z-index: 61; right: 14px; top: 14px; display: flex; gap: 8px; }
.zoom-ctl button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 20px; }

.notice { color: #dfe6ee; text-align: center; padding: 40px 20px; max-width: 460px; }
.notice h2 { margin-top: 0; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: #222; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; z-index: 100; }
body.embed .topbar { display: none; }
