/* NigiBooks - a warm library look: wood brown, paper, gold */
:root { --bg: #f6f1e9; --bg2: #fffdf8; --card: #fff; --fg: #2b2118; --fg2: #7a6a58; --ac: #8b5a2b; --ac2: #c08a3e; --bd: #e6dccd; --sh: 0 6px 24px rgba(60, 40, 20, .12); --r: 14px; }
@media (prefers-color-scheme: dark) { :root { --bg: #17130f; --bg2: #1f1a15; --card: #26201a; --fg: #f1e7da; --fg2: #a8987f; --ac: #d79a52; --ac2: #e8b46a; --bd: #3a3027; --sh: 0 6px 24px rgba(0, 0, 0, .4); } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: 'Segoe UI', Heebo, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--bd); background: var(--card); border-radius: 10px; padding: 7px 12px; }
button:hover { border-color: var(--ac2); }
button.pri { background: var(--ac); border-color: var(--ac); color: #fff; } button.pri:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; }
button.danger { color: #b91c1c; }
input, select, textarea { background: var(--bg2); border: 1px solid var(--bd); border-radius: 10px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ac2); outline-offset: -1px; }
.muted { color: var(--fg2); } .small { font-size: 13px; } .hidden { display: none !important; } .grow { flex: 1; } .center { text-align: center; padding: 40px 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ltr { direction: ltr; text-align: start; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); background: linear-gradient(90deg, #3b2a1a, #5b3d22); color: #fbeedd; box-shadow: var(--sh); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; } .brand img { width: 34px; height: 34px; border-radius: 9px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tabs button { background: transparent; border: 0; color: #e9d5bc; white-space: nowrap; padding: 8px 12px; border-radius: 999px; }
.tabs button.on { background: rgba(255, 255, 255, .16); color: #fff; }
.top .ghost { color: #fbeedd; }
.avatar { width: 36px; height: 36px; border-radius: 50%; padding: 0; background: var(--ac2); color: #3b2a1a; border: 0; font-weight: 700; }
main { padding: 14px; padding-bottom: 120px; max-width: 1500px; margin: 0 auto; }

/* library */
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bar input[type=search] { flex: 1; min-width: 180px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.chip { white-space: nowrap; border-radius: 999px; padding: 6px 12px; background: var(--card); border: 1px solid var(--bd); cursor: pointer; }
.chip.on { background: var(--ac); color: #fff; border-color: var(--ac); } .chip small { opacity: .7; margin-inline-start: 4px; }
h2.sec { font-size: 17px; margin: 18px 4px 10px; }
.shelf { display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 14px; scroll-snap-type: x proximity; }
.shelf .bk { width: 128px; flex: none; scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; }
.bk { cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cv { position: relative; aspect-ratio: 2 / 3; border-radius: 6px 12px 12px 6px; overflow: hidden; background: linear-gradient(135deg, #8b5a2b, #c08a3e); box-shadow: var(--sh), inset 4px 0 0 rgba(0, 0, 0, .18); transition: transform .15s; }
.bk:hover .cv { transform: translateY(-3px); }
.cv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv .ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 12px; color: #fff8ec; font-weight: 700; font-size: 14px; gap: 6px; }
.cv .ph small { font-weight: 400; opacity: .85; }
.cv .fmt { position: absolute; top: 6px; inset-inline-start: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 6px; text-transform: uppercase; }
.cv .pr { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, .35); } .cv .pr i { display: block; height: 100%; background: #f5b342; }
.cv .done { position: absolute; bottom: 8px; inset-inline-end: 8px; background: #16a34a; color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11px; }
.bk b { font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk span { font-size: 12px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 50px 10px; color: var(--fg2); } .empty b { display: block; font-size: 18px; color: var(--fg); margin: 8px 0; }

/* the sheet (details, dialogs) */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(20, 12, 4, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet-in { background: var(--bg2); border-radius: 18px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 70px rgba(0, 0, 0, .5); padding: 18px; }
.det { display: grid; grid-template-columns: 190px 1fr; gap: 18px; }
.det .cv { width: 190px; }
.det h1 { margin: 0 0 4px; font-size: 22px; } .det .by { color: var(--fg2); margin-bottom: 10px; }
.det .desc { white-space: pre-wrap; line-height: 1.6; max-height: 240px; overflow: auto; font-size: 14.5px; margin: 10px 0; }
.det .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.det .facts { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; } .det .facts span { background: var(--card); border: 1px solid var(--bd); border-radius: 999px; padding: 2px 10px; }
.catsel { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.form { display: flex; flex-direction: column; gap: 10px; } .form label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--fg2); }
.sheet h3 { margin: 0 0 12px; }
.tracks { max-height: 260px; overflow: auto; border: 1px solid var(--bd); border-radius: 10px; margin-top: 10px; }
.tracks div { display: flex; gap: 8px; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--bd); font-size: 13.5px; } .tracks div:hover { background: var(--card); } .tracks div.on { color: var(--ac); font-weight: 700; }

/* search + download */
.res { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--bd); border-radius: var(--r); background: var(--card); margin-bottom: 10px; }
.res img, .res .noimg { width: 70px; height: 104px; border-radius: 6px; object-fit: cover; flex: none; background: linear-gradient(135deg, #8b5a2b, #c08a3e); }
.res .t { flex: 1; min-width: 0; } .res .t b { display: block; } .res .t p { margin: 4px 0; font-size: 13px; color: var(--fg2); max-height: 3.9em; overflow: hidden; }
.res .dl { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.jobs { border: 1px solid var(--bd); border-radius: var(--r); padding: 8px 12px; background: var(--card); margin-bottom: 12px; font-size: 13.5px; } .jobs div { padding: 3px 0; }
.card { background: var(--card); border: 1px solid var(--bd); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.drop { border: 2px dashed var(--ac2); border-radius: var(--r); padding: 26px; text-align: center; color: var(--fg2); }
.drop.over { background: rgba(192, 138, 62, .12); }

/* the audiobook player */
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: linear-gradient(90deg, #3b2a1a, #5b3d22); color: #fbeedd; box-shadow: 0 -6px 24px rgba(0, 0, 0, .25); }
.player img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: #8b5a2b; }
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; } .pinfo b, .pinfo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .pinfo span { font-size: 12px; opacity: .8; }
.pbar { display: flex; gap: 8px; align-items: center; font-size: 12px; direction: ltr; } .pbar input { flex: 1; accent-color: #f5b342; }
.pctl { display: flex; gap: 6px; align-items: center; direction: ltr; }
.pctl button, .pctl select { background: rgba(255, 255, 255, .12); border: 0; color: #fff; min-width: 38px; min-height: 38px; }
.pctl .big { width: 48px; height: 48px; border-radius: 50%; background: #f5b342; color: #3b2a1a; font-size: 18px; }

/* the reader */
.reader { position: fixed; inset: 0; z-index: 50; background: var(--rbg, #fbf6ec); color: var(--rfg, #2b2118); display: flex; flex-direction: column; }
.reader.th-sepia { --rbg: #f4ecd8; --rfg: #3b2f1e; } .reader.th-light { --rbg: #ffffff; --rfg: #1f1f1f; } .reader.th-dark { --rbg: #121212; --rfg: #d8d2c8; } .reader.th-night { --rbg: #000; --rfg: #b8b0a2; }
.rbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); background: rgba(0, 0, 0, .06); transition: opacity .2s, transform .2s; z-index: 3; }
.reader.th-dark .rbar, .reader.th-night .rbar { background: rgba(255, 255, 255, .06); }
.rbar button { background: transparent; border: 0; font-size: 18px; min-width: 42px; min-height: 42px; color: inherit; }
.rtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; opacity: .8; }
.rview { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.rview .page { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 2px; overflow: auto; touch-action: pan-y pinch-zoom; }
.rview .page img, .rview .page canvas { max-width: 100%; max-height: 100%; object-fit: contain; display: block; box-shadow: 0 2px 16px rgba(0, 0, 0, .2); background: #fff; }
.rview .page.fitw { align-items: flex-start; } .rview .page.fitw img, .rview .page.fitw canvas { max-height: none; width: 100%; }
.rview .page.two img { max-width: 50%; }
.rzone { position: absolute; top: 56px; bottom: 44px; z-index: 2; } .rzone.prev { inset-inline-start: 0; width: 26%; } .rzone.next { inset-inline-end: 0; width: 26%; } .rzone.mid { left: 26%; right: 26%; }
.rfoot { display: flex; align-items: center; gap: 10px; padding: 6px 14px; padding-bottom: max(6px, env(safe-area-inset-bottom)); font-size: 12px; opacity: .8; direction: ltr; z-index: 3; transition: opacity .2s; }
.rfoot input { flex: 1; accent-color: var(--ac2); }
.reader.immersive .rbar, .reader.immersive .rfoot { opacity: 0; pointer-events: none; }
.rpanel { position: absolute; top: 56px; inset-inline-end: 10px; z-index: 6; width: min(360px, calc(100% - 20px)); max-height: calc(100% - 120px); overflow: auto; background: var(--bg2); color: var(--fg); border: 1px solid var(--bd); border-radius: 14px; box-shadow: 0 16px 50px rgba(0, 0, 0, .35); padding: 12px; }
.rpanel .toc a { display: block; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; } .rpanel .toc a:hover { background: var(--card); } .rpanel .toc a.sub { padding-inline-start: 22px; font-size: 13px; }
.rpanel .opt { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; } .rpanel .opt > span { width: 90px; font-size: 13px; color: var(--fg2); }
.rpanel .sw { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--bd); } .rpanel .sw.on { border-color: var(--ac); }
.rtts { position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 8px; align-items: center; background: var(--bg2); color: var(--fg); border: 1px solid var(--bd); border-radius: 999px; padding: 6px 10px; box-shadow: var(--sh); max-width: calc(100% - 20px); }
.rtts span { max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.rtts button { border-radius: 50%; width: 36px; height: 36px; padding: 0; }
.rload { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; opacity: .8; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: #2b2118; color: #fff; padding: 10px 18px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 90; pointer-events: none; max-width: 90vw; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.login { max-width: 380px; margin: 8vh auto; background: var(--bg2); border-radius: 20px; padding: 26px; box-shadow: var(--sh); text-align: center; }
.login img { width: 80px; height: 80px; border-radius: 20px; } .login .form { text-align: start; margin-top: 14px; }
.menu { position: fixed; z-index: 70; background: var(--bg2); border: 1px solid var(--bd); border-radius: 12px; box-shadow: var(--sh); padding: 6px; min-width: 200px; }
.menu button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 9px 12px; } .menu button:hover { background: var(--card); }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: max-content; margin: 8px auto; }

@media (max-width: 760px) {
  .top { gap: 6px; padding: 6px 8px; } .brand b, .top .lbl, .tabs button span { display: none; } .tabs button { font-size: 20px; padding: 6px 10px; }
  main { padding: 10px; } .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 10px; }
  .shelf .bk { width: 104px; }
  .det { grid-template-columns: 1fr; } .det .cv { width: 150px; margin: 0 auto; }
  .sheet { padding: 0; align-items: flex-end; } .sheet-in { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .player { flex-wrap: wrap; gap: 8px; } .player img { width: 44px; height: 44px; } .pctl { width: 100%; justify-content: space-between; }
  .rzone.prev, .rzone.next { width: 30%; } .rzone.mid { left: 30%; right: 30%; }
}
