/* OpenShelf - a warm, paper-like library. Themes: light (default), sepia, dark, black.
   The reader's theme choice (theme.js) also applies to the rest of the site. */

:root {
  --paper: #fbf8f2;
  --paper-2: #f3ede1;
  --card: #fffdf9;
  --ink: #2b2620;
  --ink-2: #6b6256;
  --line: #e4dccd;
  --accent: #8a4b2a;
  --accent-ink: #fff;
  --accent-soft: #f3e3d6;
  --ok: #2f6b45;
  --ok-soft: #e3f1e7;
  --bad: #a3322a;
  --bad-soft: #f8e1de;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, Cambria, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  color-scheme: light;
}

:root[data-theme="sepia"] {
  --paper: #f4ecd8; --paper-2: #ebe0c6; --card: #f8f1e0; --ink: #3b2f20; --ink-2: #6e5d45; --line: #dccdab;
  --accent-soft: #ead6bf;
}

:root[data-theme="dark"], :root[data-theme="black"] {
  --paper: #1b1916; --paper-2: #24211d; --card: #23201c; --ink: #e9e2d6; --ink-2: #a89f91; --line: #3a352e;
  --accent: #d79a6b; --accent-ink: #1b1916; --accent-soft: #3a2b20; --ok: #8fd0a4; --ok-soft: #1f3326;
  --bad: #f19a90; --bad-soft: #3d2220; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

:root[data-theme="black"] { --paper: #000; --paper-2: #0d0d0d; --card: #111; --line: #2a2a2a; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: #1b1916; --paper-2: #24211d; --card: #23201c; --ink: #e9e2d6; --ink-2: #a89f91; --line: #3a352e;
    --accent: #d79a6b; --accent-ink: #1b1916; --accent-soft: #3a2b20; --ok: #8fd0a4; --ok-soft: #1f3326;
    --bad: #f19a90; --bad-soft: #3d2220; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: .2em 0 .5em; }
h2 { font-size: 1.35rem; margin: 0 0 .7em; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* header & footer */
header.site {
  display: flex; align-items: center; gap: 1rem; padding: .7rem max(16px, calc((100% - 1180px) / 2));
  border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none;
  font: 600 1.35rem var(--serif); }
.logo { width: 30px; height: 30px; color: var(--accent); }
header.site nav { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
header.site nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
header.site nav a:hover { color: var(--accent); }
header.site nav .who { color: var(--ink-2); max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; font-size: 1.2rem; padding: .2rem .6rem; cursor: pointer; }
footer.site { margin-top: auto; padding: 2rem 16px; text-align: center; color: var(--ink-2); font-size: .9rem;
  border-top: 1px solid var(--line); }
main.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.5rem 16px 3rem; }

@media (max-width: 760px) {
  .menu-toggle { display: block; }
  header.site { flex-wrap: wrap; }
  header.site nav { display: none; width: 100%; flex-direction: column; align-items: flex-start; gap: .8rem;
    padding: .5rem 0; }
  header.site nav.open { display: flex; }
}

/* buttons, forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); padding: .6rem 1.15rem; border-radius: 999px;
  font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: .35rem .8rem; font-size: .85rem; }
.btn[disabled], .btn.busy { opacity: .6; cursor: progress; }
button.link { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; }
button.link:hover { color: var(--accent); }
button.link.small { font-size: .85rem; color: var(--ink-2); text-decoration: underline; }
button.icon { background: none; border: 0; color: var(--ink-2); cursor: pointer; font-size: 1rem; padding: .3rem .5rem;
  border-radius: 6px; }
button.icon:hover { background: var(--paper-2); color: var(--bad); }
form.inline { display: inline; margin: 0; }

.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .92rem; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form .row { grid-template-columns: 1fr; } }
input, textarea, select {
  font: 400 1rem var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem .75rem; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="radio"], input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="file"] { padding: .5rem; background: var(--paper-2); }
input.tiny { width: 7rem; display: inline-block; padding: .25rem .4rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .4rem; font-size: .92rem; }
.form label.choice { flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 400; margin-top: .5rem; }
.form label.choice input { margin-top: .3rem; }
.hint { color: var(--ink-2); font-size: .85rem; font-weight: 400; }
.lead { color: var(--ink-2); font-size: 1.05rem; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; background: var(--paper); }
.drop-title { font-family: var(--serif); font-size: 1.1rem; }
.switch { text-align: center; margin-top: 1.2rem; }
.small { font-size: .88rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem;
  box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.card h2:first-child { margin-top: 0; }
.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.auth { max-width: 440px; margin-top: 2rem; }
.notice { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.error { background: var(--bad-soft); color: var(--bad); }
.empty { color: var(--ink-2); padding: 1.5rem 0; }
.meta { color: var(--ink-2); font-size: .88rem; }
.tag { display: inline-block; font-size: .75rem; background: var(--accent-soft); color: var(--accent);
  padding: .1rem .5rem; border-radius: 999px; font-weight: 600; }
.count { font: 400 .95rem var(--sans); color: var(--ink-2); margin-left: .3rem; }
.crumbs { margin: 0 0 .3rem; }
.crumbs a { text-decoration: none; }

/* home */
.hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--paper-2)); border-radius: 18px;
  padding: clamp(1.5rem, 5vw, 3rem); margin-bottom: 2rem; border: 1px solid var(--line);
}
.hero h1 { margin-top: 0; max-width: 18ch; }
.hero p { max-width: 60ch; color: var(--ink-2); font-size: 1.05rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin: 1.5rem 0 1rem; }
.section-head h2 { margin: 0; }
.search { display: flex; gap: .5rem; flex: 0 1 34rem; }
.search input { flex: 1; min-width: 0; }
.search select { width: auto; flex: none; }
.search .btn { flex: none; }
@media (max-width: 600px) { .search { flex-basis: 100%; flex-wrap: wrap; } .search input { flex-basis: 100%; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.8rem 1.3rem; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 1.4rem 1rem; } }
.shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 1.3rem; overflow-x: auto;
  padding-bottom: .8rem; scroll-snap-type: x mandatory; }
.shelf-row > * { scroll-snap-align: start; }
.book-card { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: var(--ink); min-width: 0; }
.book-card:hover .cover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(60, 40, 20, .25); }
.book-card .bt { font: 600 .98rem/1.25 var(--serif); margin-top: .35rem; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card .ba { color: var(--ink-2); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf-item { display: flex; flex-direction: column; gap: .2rem; }

.cover {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 3px 8px 8px 3px; display: block;
  box-shadow: 0 2px 4px rgba(60, 40, 20, .2), inset 4px 0 6px -3px rgba(0, 0, 0, .35); background: var(--paper-2);
  transition: transform .2s, box-shadow .2s;
}
.cover.generated {
  display: flex; flex-direction: column; justify-content: space-between; padding: 14% 10%; color: #fdf6e8;
  font-family: var(--serif); text-align: center; overflow: hidden; position: relative;
  border-left: 6px solid rgba(0, 0, 0, .25);
}
.cover.generated::after { content: ""; position: absolute; inset: 8% 8%; border: 1px solid rgba(255, 255, 255, .35); }
.cover .ct { font-size: 1.05rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.cover .ca { font-size: .8rem; opacity: .85; }
.cover.large .ct { font-size: 1.6rem; }
.cover.large .ca { font-size: 1rem; }
.c0 { background: linear-gradient(160deg, #7b2f2a, #4e1c19); }
.c1 { background: linear-gradient(160deg, #24515e, #12303a); }
.c2 { background: linear-gradient(160deg, #4f5e2a, #2e3a16); }
.c3 { background: linear-gradient(160deg, #5b3b70, #352045); }
.c4 { background: linear-gradient(160deg, #9a6a23, #5e3f11); }
.c5 { background: linear-gradient(160deg, #2f3f6e, #1a2444); }
.c6 { background: linear-gradient(160deg, #6e4a3a, #3f2a20); }
.c7 { background: linear-gradient(160deg, #1f5b47, #0f3428); }

.bar { display: block; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: .2rem; }
.bar .fill { display: block; height: 100%; background: var(--accent); }
.w0{width:0}.w1{width:5%}.w2{width:10%}.w3{width:15%}.w4{width:20%}.w5{width:25%}.w6{width:30%}.w7{width:35%}
.w8{width:40%}.w9{width:45%}.w10{width:50%}.w11{width:55%}.w12{width:60%}.w13{width:65%}.w14{width:70%}.w15{width:75%}
.w16{width:80%}.w17{width:85%}.w18{width:90%}.w19{width:95%}.w20{width:100%}

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 2.5rem; color: var(--ink-2); }

/* book page */
.book-detail { display: grid; grid-template-columns: 240px 1fr; gap: 2.5rem; margin: 1rem 0 2rem; }
.book-detail h1 { margin-bottom: .1em; }
.book-detail .author { font: italic 1.2rem var(--serif); color: var(--ink-2); margin: 0 0 1rem; }
.book-detail .actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0; }
.description { font-family: var(--serif); font-size: 1.05rem; max-width: 65ch; }
@media (max-width: 680px) {
  .book-detail { grid-template-columns: 1fr; gap: 1.2rem; }
  .book-cover { max-width: 190px; }
}
.toc { list-style: none; padding: 0; margin: 0; columns: 2 340px; column-gap: 2rem; }
.toc li { break-inside: avoid; }
.toc a { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .5rem; padding: .55rem .4rem;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); align-items: baseline; }
.toc a:hover { background: var(--paper-2); }
.toc .n { color: var(--ink-2); font-size: .85rem; text-align: right; }
.toc .t { font-family: var(--serif); }
.toc .w { color: var(--ink-2); font-size: .8rem; white-space: nowrap; }
.toc li.current a { background: var(--accent-soft); }
.toc li.current .t::after { content: "  ← you are here"; color: var(--accent); font: 600 .78rem var(--sans); }

.bookmarks { list-style: none; padding: 0; margin: 0; }
.bookmark { display: flex; align-items: flex-start; gap: .5rem; border-bottom: 1px solid var(--line); }
.bookmark > a { flex: 1; display: flex; flex-direction: column; padding: .6rem 0; text-decoration: none; color: var(--ink); min-width: 0; }
.bookmark form { margin: .5rem 0 0; }
.bm-book { font-weight: 600; }
.bm-ch { color: var(--accent); font-size: .85rem; font-weight: 600; }
.bm-ex { font-family: var(--serif); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-note { font-size: .9rem; }

/* manage */
.chapter-rows { list-style: none; padding: 0; margin: 0; }
.chapter-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem 0;
  border-bottom: 1px solid var(--line); }
.chapter-row form { margin: 0; }
.chapter-row .n { width: 2.2rem; color: var(--ink-2); text-align: right; }
.chapter-row .rename { display: flex; gap: .4rem; flex: 1 1 280px; }
.chapter-row .rename input { padding: .35rem .6rem; font-family: var(--serif); }
.chapter-row .w { color: var(--ink-2); font-size: .82rem; width: 7.5rem; }
.cover-row { grid-template-columns: 110px 1fr; align-items: end; }
.cover-row .cover { width: 110px; }
.danger-zone { border-color: var(--bad-soft); }
