:root {
  color-scheme: light;
  --paper:#f7f1e5;
  --white:#fffcf6;
  --line:#ded3bf;
  --ink:#282820;
  --muted:#625c4f;
  --green:#29483d;
  --green-dark:#1b342b;
  --light-green:#e6ebde;
  --gold:#c59a50;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow:0 15px 45px #48391d0d;
}
* { box-sizing:border-box; }
body { margin:0; color:var(--ink); font:15px/1.55 var(--sans); background:var(--paper); }
a { color:var(--green); text-underline-offset:3px; }
button, input, textarea, select { font:inherit; }
button, select { cursor:pointer; }
img { max-width:100%; }
h1, h2, h3 { font-family:var(--serif); line-height:1.1; font-weight:600; }
h1 { margin:0 0 12px; font-size:clamp(2rem,5vw,3.6rem); letter-spacing:-.035em; }
h2 { margin:0 0 12px; font-size:1.65rem; }
p { margin:0 0 1em; }
:focus-visible { outline:3px solid #a36b29; outline-offset:4px; }
.topbar { background:var(--green-dark); min-height:70px; color:#fff8e5; padding:10px clamp(16px,4.4vw,72px); display:flex; align-items:center; justify-content:space-between; gap:14px; border-bottom:3px solid #a9834b; }
.brand { color:inherit; display:inline-flex; align-items:center; gap:13px; font:600 clamp(1.05rem,3vw,1.6rem)/1.1 var(--serif); text-decoration:none; overflow-wrap:anywhere; }
.brand-icon { display:flex; align-items:flex-end; gap:3px; flex:none; }
.brand-icon i { width:6px; height:22px; border:1px solid #ebc783; border-radius:1px; background:linear-gradient(transparent 18%,#ebc783 18% 23%,transparent 23% 75%,#ebc783 75% 81%,transparent 81%); }
.brand-icon i:nth-child(2) { height:19px; }
.brand-icon i:last-child { transform:rotate(-16deg); height:17px; margin-left:2px; }
.topbar nav { display:flex; align-items:center; gap:clamp(9px,2vw,26px); font-size:.87rem; }
.topbar a, .header-link { color:inherit; }
.header-link { border:0; background:none; font-size:inherit; padding:4px 0; text-decoration:underline; text-underline-offset:4px; }
.user-label { max-width:12ch; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; display:block; }
.notifications { max-width:1150px; margin:14px auto 0; padding:0 18px; }
.notifications p { background:#e7eddf; padding:9px 14px; color:#274035; margin:0; border-radius:6px; }
.library-layout { max-width:1600px; margin:auto; display:grid; grid-template-columns:215px minmax(0,1fr); gap:clamp(20px,4vw,62px); padding:clamp(18px,4vw,50px) clamp(16px,4.4vw,72px) 56px; }
.shelf-sidebar { padding:10px 0; }
.shelf-sidebar h2 { font-size:1.5rem; padding-left:12px; margin-bottom:16px; }
.shelf-menu { display:grid; gap:5px; }
.shelf-menu a { display:grid; grid-template-columns:21px 1fr minmax(12px,auto); align-items:center; gap:8px; padding:9px 12px; color:var(--muted); text-decoration:none; border-radius:7px; }
.shelf-menu a[aria-current] { background:#e2e8d8; color:var(--green-dark); font-weight:650; }
.shelf-menu a:hover { background:#ece6d8; }
.shelf-menu small { opacity:.9; text-align:right; font-variant-numeric:tabular-nums; }
.menu-icon { font-family:var(--sans); font-size:1.15rem; line-height:1; text-align:center; }
.menu-favorites { color:#825920; }
.sidebar-add { margin-top:19px; width:100%; }
.mobile-admin { display:none; }
.opds-help { font-size:.85rem; color:var(--muted); border-top:1px solid var(--line); margin-top:26px; padding:14px 2px 0; }
.opds-help summary { cursor:pointer; }
.opds-help p { margin:10px 0; }
.opds-help input { width:100%; }
.collection { min-width:0; }
.collection-intro { position:relative; isolation:isolate; overflow:hidden; min-height:176px; display:flex; align-items:center; padding:23px clamp(17px,4vw,43px); margin:0 0 22px; border-radius:13px; border:1px solid #d9c8aa; background:linear-gradient(113deg,#f3e7cc 0%,#ecdcba 59%,#ddc59b 100%); box-shadow:var(--shadow); }
.intro-copy { position:relative; z-index:2; }
.collection-intro h1 { color:#244338; }
.collection-intro p { color:#5e5441; margin:0; }
.collection-intro--stats { gap:18px; justify-content:space-between; }
.collection-intro--stats .intro-copy { min-width:0; }
.collection-intro .last-sync { display:grid; gap:3px; margin-top:7px; font-size:.875rem; }
.last-sync time { white-space:nowrap; }
.last-sync-result { display:flex; flex-wrap:wrap; align-items:center; gap:3px 10px; }
.last-sync-warning { padding:1px 7px; border-radius:5px; background:#f9e3d6; color:#773c2d; font-size:.82rem; }
.book-stack { display:flex; align-items:flex-end; justify-content:center; gap:7px; width:258px; height:135px; position:relative; direction:ltr; }
.collection-intro .book-stack { position:absolute; right:clamp(-80px,3vw,38px); bottom:0; z-index:0; }
.collection-intro--stats .book-stack { position:relative; right:auto; bottom:auto; flex:none; align-self:flex-end; margin-bottom:-23px; }
@media (max-width:1050px) {
  .collection-intro--stats .book-stack { display:none; }
}
.book-stack::after { content:""; position:absolute; height:9px; background:#704b27; border-radius:3px 3px 0 0; width:calc(100% + 12px); left:-6px; bottom:0; box-shadow:0 8px 15px #6543254a; }
.book-stack i { width:31px; height:108px; display:block; border-radius:3px 5px 1px 1px; transform-origin:bottom; border:1px solid #251e1b45; background:linear-gradient(90deg,#0004,#fff2 16%,transparent 37%,#0003),linear-gradient(0deg,transparent 12%,#e8c987 12% 14%,transparent 14% 21%,#e8c987 21% 22%,transparent 22% 72%,#e8c987 72% 73%,transparent 73% 81%,#e8c987 81% 83%,transparent 83%),var(--spine,#385447); }
.book-stack i:nth-child(2) { --spine:#a3543e; height:123px; width:24px; }
.book-stack i:nth-child(3) { --spine:#496071; height:101px; width:35px; }
.book-stack i:nth-child(4) { --spine:#ac783f; height:92px; width:24px; }
.book-stack i:nth-child(5) { --spine:#634347; height:117px; transform:rotate(-12deg); margin-left:13px; }
.book-stack i:nth-child(6) { --spine:#686238; height:98px; transform:rotate(14deg); }
.filters { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:24px; }
.filters input, .filters select, .opds-help input, .field-stack input:not([type=checkbox]), .field-stack textarea, .reader-tools select, .reader-tools input { color:var(--ink); background:var(--white); border:1px solid #cabea7; border-radius:6px; min-height:40px; padding:7px 10px; }
.filters select { min-width:132px; max-width:170px; }
.filters select[name="sort"] { min-width:158px; }
.search-box { flex:1 1 210px; display:flex; align-items:center; gap:6px; position:relative; }
.search-box span { position:absolute; left:11px; font-size:1.45rem; color:#60553e; pointer-events:none; }
.search-box input { width:100%; min-width:0; padding-left:34px; }
.button { display:inline-flex; min-height:40px; align-items:center; justify-content:center; gap:7px; padding:7px 14px; font-weight:650; text-decoration:none; text-align:center; border:1px solid transparent; border-radius:6px; line-height:1.3; white-space:normal; }
.button.primary { background:var(--green); color:#fffdf1; border-color:var(--green); }
.button.primary:hover { background:#3e6152; }
.button.outline { border-color:#a7a792; color:var(--green); background:var(--white); }
.button.outline:hover { background:var(--light-green); }
.button:disabled { cursor:progress; opacity:.7; }
.continue { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:-4px 0 25px; padding:13px 17px; border-radius:8px; background:#e8ecdf; border:1px solid #d2d8c6; }
.continue h2 { font-size:1.25rem; margin-bottom:4px; }
.continue p { margin:0; overflow-wrap:anywhere; }
.continue p span, .muted { color:var(--muted); }
.book-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(146px,1fr)); gap:25px 18px; }
.book-card { min-width:0; }
.poster { position:relative; aspect-ratio:2/2.82; display:grid; place-items:center; background:#e9dfca; border-radius:6px 9px 9px 6px; box-shadow:0 9px 15px #3f2c1c1c; overflow:hidden; text-decoration:none; }
.poster:hover { box-shadow:0 12px 20px #3f2c1c3f; }
.poster img { width:100%; height:100%; object-fit:contain; }
.format-chip { position:absolute; right:7px; bottom:7px; padding:2px 6px; background:#fff8e8; color:#3c372c; border-radius:3px; font-size:.68rem; font-weight:800; letter-spacing:.055em; }
.book-art { --book-color:#3e5749; background:linear-gradient(90deg,#17140750 0%,#fff2 5%,transparent 8%,#2221 10%,transparent 12%),linear-gradient(145deg,#fff1,#23150924),var(--book-color); color:#fff3cf; width:100%; height:100%; padding:12% 9% 14% 13%; box-shadow:inset 0 0 0 1px #d8c99d38; display:flex; align-items:stretch; }
.ink-rose { --book-color:#784752; }.ink-blue { --book-color:#405668; }.ink-umber { --book-color:#78563a; }.ink-slate { --book-color:#555470; }.ink-moss { --book-color:#59603d; }
.book-art-frame { border:1px solid #d6b678bd; outline:1px solid #d6b67854; outline-offset:4px; display:flex; flex:1; align-items:center; justify-content:center; min-width:0; flex-direction:column; gap:9px; text-align:center; padding:7px; }
.cover-mark { color:#dfc08b; font-size:1rem; }
.cover-name { font:600 clamp(.95rem,1.65vw,1.38rem)/1.2 var(--serif); overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:5; -webkit-box-orient:vertical; overflow:hidden; }
.cover-author { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; color:#f2e6bf; font-size:.68rem; line-height:1.2; overflow-wrap:anywhere; }
.book-card h2 { font-size:1.12rem; margin:10px 0 3px; overflow-wrap:anywhere; }
.book-card h2 a { color:var(--ink); text-decoration:none; }
.book-card h2 a:hover { text-decoration:underline; }
.book-card p { color:var(--muted); font-size:.85rem; margin:0; overflow-wrap:anywhere; }
.shelf-progress { margin-top:6px; }
progress { appearance:none; width:100%; display:block; height:5px; border:0; border-radius:6px; overflow:hidden; color:var(--green); background:#e0d6c0; }
progress::-webkit-progress-bar { background:#e0d6c0; }
progress::-webkit-progress-value { background:#55765a; }
progress::-moz-progress-bar { background:#55765a; }
.pagination, .reader-pagination { display:flex; justify-content:center; align-items:center; gap:13px; margin:30px 0 0; }
.empty { text-align:center; background:#fbf7ec; padding:35px 16px; border:1px dashed #c3b696; border-radius:12px; }
.empty-icon { color:#826333; font:2.4rem/1.1 var(--serif); margin-bottom:12px; }
.shell { max-width:1160px; margin:auto; padding:29px clamp(16px,4vw,50px) 64px; }
.narrow { max-width:750px; }
.back { display:inline-block; margin-bottom:20px; font-weight:650; }
.detail-layout { display:grid; grid-template-columns:minmax(130px,300px) minmax(0,1fr); gap:clamp(20px,6vw,75px); }
.detail-info h1 { margin:8px 0; overflow-wrap:anywhere; }
.detail-cover { width:100%; align-self:start; }
.detail-cover .cover-name { font-size:clamp(1.05rem,3.5vw,2.1rem); }
.detail-cover .cover-author { font-size:.95rem; }
.book-meta { display:flex; flex-wrap:wrap; gap:5px; }
.pill { display:inline-block; background:#e9e6d6; border-radius:16px; padding:3px 9px; font-size:.79rem; overflow-wrap:anywhere; color:#415344; }
.byline { font:1.28rem/1.4 var(--serif); color:var(--green); margin-bottom:8px; }
.action-row { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.detail-progress { display:flex; gap:10px; align-items:center; margin-top:16px; color:var(--muted); }
.detail-progress progress { max-width:230px; height:7px; }
.description { margin:23px 0 0; padding-top:18px; border-top:1px solid var(--line); overflow-wrap:anywhere; }
.secondary-actions { padding-top:12px; gap:14px; color:var(--green); font-size:.86rem; }
.secondary-actions form { display:flex; flex-wrap:wrap; gap:12px; }
.text-button { background:none; border:0; padding:3px 0; color:var(--green); text-decoration:underline; text-underline-offset:3px; }
.form-card { background:var(--white); border:1px solid var(--line); border-radius:12px; padding:clamp(16px,4.5vw,37px); box-shadow:var(--shadow); }
.form-card h1 { font-size:clamp(1.9rem,5vw,2.7rem); }
.field-stack p { display:flex; flex-direction:column; gap:4px; margin-bottom:14px; }
.field-stack .helptext { font-size:.85rem; color:var(--muted); }
.field-stack input[type=checkbox] { align-self:flex-start; }
.field-stack input[type=file] { max-width:100%; }
.field-stack textarea { resize:vertical; }
.dropzone { display:flex; flex-direction:column; align-items:center; gap:6px; background:#f5f2e7; border:1px dashed #b3a689; border-radius:8px; padding:16px 8px; margin-bottom:13px; text-align:center; }
.dropzone span { color:var(--muted); font-size:.89rem; }
.errorlist, .errornote { color:#8a2f28; }
.import-result { padding:12px; border:1px solid #cfdbc2; background:#edf0e3; margin:0 0 15px; border-radius:8px; overflow-wrap:anywhere; }
.import-result h2 { font-size:1.2rem; }
.login-wrap { max-width:850px; margin:clamp(24px,10vw,100px) auto; padding:0 17px; display:grid; grid-template-columns:minmax(0,.94fr) minmax(0,1fr); }
.login-art { display:flex; justify-content:center; align-items:center; min-height:210px; overflow:hidden; background:linear-gradient(145deg,#e9dabb,#c7a874); border-radius:13px 0 0 13px; }
.login-art .book-stack { transform:scale(1.15); }
.login-form { border-radius:0 13px 13px 0; }
.login-form input { width:100%; }
.reader-shell { max-width:990px; margin:auto; padding:18px clamp(10px,3vw,32px) 35px; }
.reader-header { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:14px; padding:8px 0 16px; }
.reader-header h1 { margin:0; font-size:clamp(1.15rem,3vw,1.8rem); text-align:center; overflow-wrap:anywhere; }
.reader-header a { margin:0; white-space:nowrap; }
.reader-tools { border-top:1px solid var(--line); border-bottom:1px solid var(--line); display:flex; align-items:center; flex-wrap:wrap; gap:10px 17px; padding:8px 0; }
.reader-tools label, .reader-font-control, .size-tools, .jump { display:inline-flex; align-items:center; gap:7px; }
.reader-tools label { max-width:100%; }
.reader-tools select { max-width:min(60vw,300px); }
.reader-tools input { width:78px; }
.size-tools button { min-width:40px; min-height:44px; color:var(--green); background:var(--white); border:1px solid var(--line); border-radius:4px; }
.size-tools button:disabled { opacity:.5; cursor:default; }
.size-tools output { min-width:2ch; text-align:center; font-variant-numeric:tabular-nums; }
.reader-content[data-font="times"] { --reading-family:"Times New Roman", "Liberation Serif", serif; }
.reader-content[data-font="sans"] { --reading-family:var(--sans); }
.reader-content[data-font="mono"] { --reading-family:ui-monospace, "Courier New", monospace; }
.reader-content { background:var(--white); max-width:100%; min-height:210px; margin-top:16px; padding:clamp(16px,5vw,54px); border:1px solid var(--line); border-radius:7px; font:var(--reading-size,21px)/1.72 var(--reading-family, var(--serif)); overflow-wrap:anywhere; }
.reader-content p { max-width:66ch; margin:0 auto 1em; white-space:pre-wrap; }
.reader-content h2 { max-width:62ch; margin:0 auto 20px; text-align:center; font-family:inherit; font-size:1.18em; line-height:1.25; }
.reader-content img { display:block; max-height:80vh; width:auto; height:auto; margin:9px auto; object-fit:contain; }
.reader-content.pdf-content { padding:9px; }
.pdf-content img { width:100%; max-height:none; object-fit:contain; margin:0 auto; }
.reading-page.dark-reader { color-scheme:dark; --paper:#202522; --white:#292f2a; --line:#4b574e; --ink:#f0e9d8; --muted:#d1ccba; --green:#b6d1b6; --light-green:#39453b; }
.dark-reader .button.primary { background:#375847; border-color:#4f755e; }
@media (max-width:860px) {
  .library-layout { grid-template-columns:173px minmax(0,1fr); gap:20px; }
  .collection-intro .book-stack { opacity:.62; right:-50px; }
  .book-grid { grid-template-columns:repeat(auto-fill,minmax(128px,1fr)); }
}
@media (max-width:640px) {
  .library-layout { display:block; }
  .shelf-sidebar { padding:0 0 15px; }
  .shelf-sidebar h2 { display:none; }
  .shelf-menu { display:flex; gap:4px; flex-wrap:wrap; }
  .shelf-menu a { display:flex; font-size:.8rem; padding:5px 7px; gap:4px; }
  .shelf-menu .menu-icon { font-size:.82rem; }
  .sidebar-tools { display:flex; align-items:center; flex-wrap:wrap; gap:9px 12px; margin-top:9px; }
  .sidebar-add { width:auto; margin:0; }
  .mobile-admin { display:inline; font-size:.86rem; }
  .opds-help { margin-top:10px; padding:6px 0 0; width:max-content; max-width:100%; }
  .collection-intro { min-height:128px; margin-bottom:13px; }
  .collection-intro .book-stack { right:-100px; transform:scale(.78); bottom:-13px; opacity:.3; }
  .book-grid { gap:16px 12px; grid-template-columns:repeat(auto-fill,minmax(114px,1fr)); }
  .filters { margin-bottom:15px; }
  .filters select, .filters select[name="sort"] { flex:1 1 auto; max-width:100%; min-width:0; font-size:.83rem; }
  .detail-layout { grid-template-columns:minmax(0,1fr); }
  .detail-cover { max-width:200px; }
  .login-wrap { grid-template-columns:1fr; }
  .login-art { min-height:155px; border-radius:12px 12px 0 0; }
  .login-art .book-stack { transform:none; }
  .login-form { border-radius:0 0 12px 12px; }
  .header-admin { display:none; }
  .reader-header { gap:8px; }
  .reader-header a { font-size:.8rem; }
  .reader-pagination { gap:7px; }
  .reader-pagination .button { padding:6px 9px; }
}

.folder-browser { margin:0 0 22px; padding:12px 16px; border:1px solid #d8cbb2; border-radius:8px; background:var(--white); }
.folder-trail { display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 8px; overflow-wrap:anywhere; }
.folder-trail [aria-current] { font-weight:650; }
.folder-scope { margin-top:7px; font-size:.88rem; }
.subfolder-list { list-style:none; margin:12px 0 0; padding:0; display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap:6px; }
.subfolder-list a { display:block; border:1px solid #d8cbb2; border-radius:5px; padding:6px 9px; overflow-wrap:anywhere; text-decoration:none; }
.subfolder-list a:hover { text-decoration:underline; }

.shelf-remove { margin-top:8px; }
.shelf-remove .text-button { font-size:.82rem; text-align:left; }
.reader-shell { max-width:1230px; }
.reader-content { position:relative; --book-page-height:clamp(235px, calc(100svh - 365px), 820px); }
.reader-content img { max-width:100%; }
.reader-columns { min-width:0; }
.reader-content.paginated { padding:clamp(16px,3vw,40px); }
.reader-content.paginated .reader-columns {
  height:var(--book-page-height); width:100%; overflow:hidden;
  column-fill:auto; column-count:1; column-gap:42px;
  scroll-behavior:auto; overscroll-behavior:none;
}
.reader-content.paginated .reader-columns img { max-height:calc(var(--book-page-height) - 30px); break-inside:avoid; }
.reader-columns p { widows:2; orphans:2; }
.reader-columns h2 { break-after:avoid; }
.reader-columns:focus-visible { outline:2px solid var(--green); }
.pdf-facing-page, .finish-spread { display:none !important; }
.reader-pagination [hidden] { display:none !important; }
.reader-blank-page { break-before:column; height:1px; }
@media (min-width:780px) {
  .reader-content.paginated, .reader-content.pdf-content {
    border-radius:12px 12px 22px 22px;
    background:linear-gradient(90deg, var(--white) 47%, var(--paper) 49.8%, var(--line) 50%, var(--paper) 50.2%, var(--white) 53%);
    box-shadow:0 4px 0 -1px var(--white), 0 5px 0 -1px var(--line), 0 10px 22px #211a171a;
  }
  .reader-content.paginated .reader-columns { column-count:2; }
  .reader-content.pdf-content { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; align-items:start; padding:14px; }
  .reader-content.pdf-content .pdf-facing-page, .pdf-content + .reader-pagination .finish-spread { display:block !important; }
  .pdf-content + .reader-pagination:has(.finish-spread) #next-part { display:none; }
}

.reader-fullscreen-bar { display:none; }
.reader-fullscreen-button { min-height:44px; }
.reader-fullscreen-button[hidden] { display:none; }
body.reader-expanded { overflow:hidden; }
.reader-expanded > .topbar, .reader-expanded > .notifications,
.reader-expanded .reader-header, .reader-expanded .reader-tools { display:none; }
.reader-expanded #reader {
  position:fixed;
  inset:0;
  z-index:10;
  width:100%;
  height:100%;
  height:100dvh;
  max-width:none;
  margin:0;
  padding:max(6px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right))
          max(6px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  gap:6px;
  background:var(--paper);
  color:var(--ink);
}
.reader-expanded #reader:fullscreen { height:100%; }
.reader-expanded .reader-fullscreen-bar { display:flex; justify-content:flex-end; }
.reader-expanded .reader-content { min-height:0; margin:0; }
.reader-expanded .reader-content.paginated { padding:clamp(12px,3vw,36px); }
.reader-expanded .reader-content.paginated .reader-columns { height:100%; }
.reader-expanded .reader-content.paginated .reader-columns img { max-height:85%; }
.reader-expanded .pdf-content { display:flex; justify-content:center; gap:12px; padding:4px; }
.reader-expanded .pdf-content img { width:auto; min-width:0; max-height:100%; object-fit:contain; }
.reader-expanded .reader-pagination { flex-wrap:wrap; margin:0; }
.reader-expanded .reader-pagination .button { min-height:44px; }
@media (min-width:780px) {
  .reader-expanded .pdf-content { display:grid; align-items:center; }
  .reader-expanded .pdf-content img { width:100%; height:100%; }
}
