html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: #f3f2ef;
  color: #252525;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.library {
  background: #f3f2ef;
}

.shelf {
  max-width: 1100px;
  margin: 0 auto;
  padding: 50px 20px;
  font-size: 0;
}

.shelf-with-back {
  padding-top: 75px;
}

.book {
  display: inline-block;
  width: 25%;
  padding: 25px 12px;
  color: #252525;
  font-size: 16px;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  vertical-align: top;
}

.score-cover {
  display: block;
  width: 150px;
  height: 200px;
  margin: 0 auto 13px;
  border: 1px solid #c8c4bc;
  background: #ddd9d1;
  object-fit: cover;
  -webkit-transition: -webkit-transform 120ms ease;
  transition: transform 120ms ease;
}

.catalog-cover {
  border: 2px solid #b9aa87;
}

.catalog-icon {
  position: relative;
  display: block;
  width: 150px;
  height: 200px;
  margin: 0 auto 13px;
}

.folder-shape {
  position: absolute;
  top: 54px;
  left: 50%;
  display: block;
  width: 136px;
  height: 98px;
  margin-left: -68px;
  border: 1px solid #b9aa87;
  border-radius: 5px;
  background: #d4c49d;
}

.folder-tab {
  position: absolute;
  top: -18px;
  left: 10px;
  display: block;
  width: 56px;
  height: 19px;
  border: 1px solid #b9aa87;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #d4c49d;
}

.catalog-back {
  position: fixed;
  z-index: 4;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: rgba(35, 35, 35, 0.68);
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 32px;
  line-height: 37px;
  text-align: center;
  text-decoration: none;
}

.catalog-back:focus {
  outline: 2px solid #56524c;
  outline-offset: 2px;
}

.cover-fallback {
  position: relative;
}

.cover-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  fill: none;
  stroke: #817c73;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.book:hover .score-cover {
  -webkit-transform: translateY(-2px);
  transform: translateY(-2px);
}

.book:focus {
  outline: 2px solid #56524c;
  outline-offset: 4px;
}

.book span {
  display: block;
  max-width: 100%;
  word-wrap: break-word;
}

.viewer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #d8d8d5;
  -webkit-user-select: none;
  user-select: none;
}

.score {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  opacity: 0;
  -webkit-transition: opacity 120ms ease;
  transition: opacity 120ms ease;
}

.score.ready {
  opacity: 1;
}

.back {
  position: fixed;
  z-index: 4;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: rgba(35, 35, 35, 0.68);
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 32px;
  line-height: 37px;
  text-align: center;
  text-decoration: none;
}

.back:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.turn {
  position: fixed;
  z-index: 3;
  top: 0;
  bottom: 0;
  width: 38%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.turn-left {
  left: 0;
}

.turn-right {
  right: 0;
}

.turn:focus {
  outline: none;
}

.empty {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 0;
  display: none;
  width: 100%;
  margin-top: -20px;
  padding: 0 24px;
  color: #555;
  text-align: center;
}

@media (max-width: 800px) {
  .book {
    width: 33.3333%;
  }
}

@media (max-width: 520px) {
  .shelf {
    padding: 25px 10px;
  }

  .book {
    width: 50%;
    padding: 20px 8px;
  }

  .score-cover {
    width: 135px;
    height: 180px;
  }

  .catalog-icon {
    width: 135px;
    height: 180px;
  }

  .folder-shape {
    top: 44px;
  }
}

.upload-fab {
  position: fixed; z-index: 8; right: 18px; bottom: 18px;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(35,35,35,.78); color: #fff; text-decoration: none;
  font: 32px/45px Arial,sans-serif; text-align: center; box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.admin-page { min-height: 100vh; padding: 28px 14px; background: #eceae5; }
.admin-card { width: min(680px, 100%); margin: 0 auto; padding: 28px; border-radius: 18px; background: #fff; box-shadow: 0 10px 35px rgba(0,0,0,.08); }
.admin-login-card { max-width: 430px; margin-top: 8vh; }
.admin-card h1 { margin: 10px 0 22px; font-size: 28px; }
.admin-muted { color: #777; margin: -12px 0 22px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.admin-home, .admin-link-button { color: #555; text-decoration: none; font: inherit; }
.admin-link-button { border: 0; background: none; cursor: pointer; padding: 0; }
.admin-form { display: grid; gap: 18px; }
.admin-form label { display: grid; gap: 7px; font-weight: 600; }
.admin-form input[type="text"], .admin-form input[type="password"], .admin-form select {
  width: 100%; border: 1px solid #cfcac0; border-radius: 10px; background: #fff; padding: 12px 13px; font: inherit;
}
.mode-switch { display: flex; gap: 18px; flex-wrap: wrap; padding: 4px 0; }
.mode-switch label { display: flex; grid-gap: 7px; align-items: center; font-weight: 500; }
.dropzone { border: 2px dashed #bdb7aa; border-radius: 14px; padding: 24px; text-align: center; cursor: pointer; background: #faf9f6; }
.dropzone.dragging { border-color: #56524c; background: #f0eee8; }
.dropzone span { color: #777; font-weight: 400; line-height: 1.5; }
.dropzone input { margin: 8px auto; max-width: 100%; }
.dropzone strong { font-size: 14px; color: #4b4945; }
.admin-primary { border: 0; border-radius: 11px; padding: 13px 18px; background: #34322f; color: #fff; font: 600 16px/1.2 inherit; cursor: pointer; }
.admin-alert { border-radius: 10px; padding: 11px 13px; margin-bottom: 18px; }
.admin-alert.success { background: #e7f4e9; color: #285a31; }
.admin-alert.error { background: #fae8e6; color: #7c3028; }
.admin-form small { font-weight: 400; color: #777; }
@media (max-width: 520px) { .admin-card { padding: 20px 16px; border-radius: 14px; } .mode-switch { display: grid; gap: 10px; } }

.text-reader {
  background: #e9e5dc;
  color: #24211d;
}
.reader-paper {
  width: min(760px, calc(100% - 32px));
  margin: 40px auto 80px;
  padding: 54px 62px 72px;
  background: #fffdf8;
  box-shadow: 0 8px 40px rgba(35, 28, 20, .10);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.72;
}
.reader-paper h1 { margin: 0 0 8px; font-size: 36px; line-height: 1.18; }
.reader-paper p { margin: 0 0 1.05em; }
.reader-source { margin-bottom: 40px; color: #8b8378; font: 13px/1.4 Arial, sans-serif; }
.reader-back { position: fixed; z-index: 5; top: 12px; left: 12px; width: 40px; height: 40px; border-radius: 20px; background: rgba(35,35,35,.68); color: #fff; font: 32px/37px Arial,sans-serif; text-align: center; text-decoration: none; }
@media (max-width: 620px) {
  .reader-paper { width: 100%; margin: 0; padding: 70px 22px 60px; box-shadow: none; font-size: 18px; line-height: 1.65; }
  .reader-paper h1 { font-size: 30px; }
}


/* Beautiful library v1 */
.library-beautiful { background: radial-gradient(circle at 20% 0,#f8f1e5 0,#efe5d6 36%,#e6dac8 100%); min-height:100vh; }
.library-header { max-width:1180px; margin:0 auto; padding:54px 28px 22px; display:flex; align-items:flex-end; justify-content:space-between; gap:28px; }
.library-header h1 { margin:2px 0 6px; font:700 44px/1.05 Georgia,serif; color:#30281f; letter-spacing:-.03em; }
.library-header p { margin:0; color:#7a6b5a; font-size:16px; }.eyebrow{font:700 11px/1 Arial,sans-serif; letter-spacing:.28em;color:#a47c4f}
.header-add { padding:12px 17px; border-radius:999px; background:#382f27; color:#fff; text-decoration:none; font-weight:700; white-space:nowrap; box-shadow:0 8px 24px rgba(46,34,24,.16); }
.library-tools { max-width:1180px; margin:0 auto; padding:18px 28px 10px; display:flex; gap:12px; }
.search-box { flex:1; display:flex; align-items:center; gap:9px; background:rgba(255,255,255,.76); border:1px solid rgba(100,75,50,.14); border-radius:14px; padding:0 14px; box-shadow:0 5px 20px rgba(70,48,30,.05); }
.search-box input { flex:1; border:0; outline:0; background:transparent; padding:13px 0; font:inherit; color:#3d342c; }
#book-sort { border:1px solid rgba(100,75,50,.14); border-radius:14px; padding:0 14px; background:rgba(255,255,255,.76); color:#56483b; }
.library-tabs { max-width:1180px; margin:0 auto; padding:8px 28px 22px; display:flex; gap:8px; overflow:auto; }
.library-tabs button { border:0; border-radius:999px; padding:9px 14px; background:rgba(255,255,255,.48); color:#796957; cursor:pointer; font:600 14px/1 inherit; }
.library-tabs button.active { background:#a97947; color:#fff; }
.continue-section { max-width:1180px; margin:0 auto; padding:5px 28px 17px; }.continue-section h2{font:700 21px/1.2 Georgia,serif;color:#3f3429}
.continue-row { display:flex; gap:10px; overflow:auto; padding-bottom:4px; }.continue-card{min-width:190px;padding:13px 15px;border-radius:14px;background:rgba(255,255,255,.62);color:#493b30;text-decoration:none;display:flex;justify-content:space-between;gap:14px;box-shadow:0 5px 20px rgba(62,43,28,.05)}
.book-grid { max-width:1180px; margin:0 auto; padding:14px 28px 70px; display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:34px 24px; }
.library-card { min-width:0; position:relative; }.cover-link{display:block;text-decoration:none;position:relative}.library-cover{width:100%;aspect-ratio:2/3;display:flex;object-fit:cover;border-radius:8px 12px 12px 8px;box-shadow:-5px 5px 0 #c5af91,0 18px 34px rgba(57,39,25,.20);transition:.18s transform,.18s box-shadow;background:#d8c2a5}.library-card:hover .library-cover{transform:translateY(-5px) rotate(.3deg);box-shadow:-6px 7px 0 #c5af91,0 25px 42px rgba(57,39,25,.25)}
.generated-cover{align-items:center;justify-content:center;flex-direction:column;color:#fff;background:linear-gradient(145deg,#795a3e,#b78959)}.generated-letter{font:700 72px/1 Georgia,serif}.generated-cover small{margin-top:20px;letter-spacing:.16em;font-size:9px}.folder-cover{align-items:center;justify-content:center;font-size:54px;background:linear-gradient(145deg,#b79870,#d9c19b);color:#796247}.progress-track{position:absolute;left:8px;right:8px;bottom:8px;height:4px;border-radius:99px;background:rgba(255,255,255,.52);overflow:hidden}.progress-track i{display:block;height:100%;width:0;background:#f4d39c;border-radius:99px}
.card-meta{padding:13px 2px 0;position:relative}.book-title{display:block;padding-right:28px;color:#382e26;text-decoration:none;font:700 16px/1.28 Georgia,serif}.format-badge{display:inline-block;margin-top:7px;color:#8d7965;font-size:11px;text-transform:uppercase;letter-spacing:.08em}.favorite-button{position:absolute;right:0;top:9px;border:0;background:none;color:#9a7652;font-size:24px;cursor:pointer;padding:0}.favorite-button.active{color:#a64b42}.empty-library-state{padding:60px 24px;text-align:center;color:#806f60}

.reader-toolbar{position:fixed;z-index:20;top:0;left:0;right:0;height:58px;display:flex;align-items:center;gap:12px;padding:8px 14px;background:rgba(35,30,26,.88);backdrop-filter:blur(12px);color:#fff}.reader-round{width:40px;height:40px;border-radius:50%;background:rgba(255,255,255,.12);color:#fff;text-decoration:none;font:30px/36px Arial;text-align:center}.reader-title-mini{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}.reader-actions{display:flex;gap:6px}.reader-actions button,.viewer-bookmark{border:0;border-radius:10px;background:rgba(255,255,255,.12);color:#fff;padding:8px 9px;cursor:pointer}.reader-progress{position:fixed;z-index:21;top:58px;left:0;right:0;height:3px;background:rgba(0,0,0,.12)}.reader-progress i{display:block;height:100%;width:0;background:#c99761}.text-reader[data-theme="sepia"]{background:#d8c6aa}.text-reader[data-theme="sepia"] .reader-paper{background:#f0e0c2;color:#46392d}.text-reader[data-theme="dark"]{background:#171513;color:#ddd}.text-reader[data-theme="dark"] .reader-paper{background:#211e1b;color:#e2ddd6;box-shadow:none}.bookmark-drawer{position:fixed;z-index:30;right:14px;top:70px;width:min(360px,calc(100% - 28px));max-height:70vh;overflow:auto;padding:16px;border-radius:16px;background:#fffdf8;box-shadow:0 18px 50px rgba(0,0,0,.24);color:#302922}.drawer-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.drawer-head button{border:0;background:none;font-size:25px;cursor:pointer}.bookmark-row{display:grid;width:100%;text-align:left;gap:3px;padding:11px;border:0;border-bottom:1px solid #eee3d4;background:transparent;cursor:pointer;color:inherit}.bookmark-row small,.drawer-empty{color:#8d8072}.book-page-viewer{background:#2d2b29}.page-counter{position:fixed;z-index:5;left:50%;top:13px;transform:translateX(-50%);padding:8px 13px;border-radius:999px;background:rgba(20,20,20,.62);color:#fff;font:13px/1 Arial}.viewer-bookmark{position:fixed;z-index:5;right:12px;top:12px;font-size:17px}
@media(max-width:700px){.library-header{padding:34px 18px 14px;align-items:flex-start}.library-header h1{font-size:36px}.library-header p{font-size:14px}.header-add{font-size:0;width:44px;height:44px;padding:0;text-align:center}.header-add:after{content:'＋';font-size:24px;line-height:44px}.library-tools{padding:14px 18px 8px;display:grid}.library-tabs{padding:6px 18px 18px}.book-grid{padding:10px 18px 60px;grid-template-columns:repeat(2,minmax(0,1fr));gap:28px 16px}.continue-section{padding-left:18px;padding-right:18px}.reader-toolbar{gap:7px}.reader-title-mini{display:none}.reader-actions{margin-left:auto}.reader-actions button{padding:8px}.reader-paper{padding-top:90px}}

/* Book reader v2 */
.library-login-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at top,#4b3a2b 0,#241b16 44%,#17110e 100%)}
.library-login-card{width:min(420px,100%);padding:34px;border-radius:24px;background:#f8f2e7;box-shadow:0 30px 80px rgba(0,0,0,.38)}
.library-login-card h1{font-family:Georgia,serif;font-size:34px;margin:8px 0}.library-login-card p{color:#766b61;margin:0 0 24px}
.book-reader{min-height:100vh;overflow:hidden;background:#2a211b;color:#2a211b}.reader-toolbar{height:58px;display:flex;align-items:center;gap:14px;padding:0 18px;background:#1c1713;color:#f6eee3}
.reader-icon{color:inherit;text-decoration:none;font-size:34px}.reader-title{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:Georgia,serif}.reader-actions{display:flex;gap:6px}.reader-actions button,.reader-footer button{border:0;border-radius:8px;background:#3b3129;color:#f8f1e7;padding:8px 10px;cursor:pointer}
.book-stage{position:relative;height:calc(100vh - 96px);display:grid;place-items:center;padding:22px 52px}.book-spread{position:relative;display:grid;grid-template-columns:1fr 1fr;width:min(1120px,92vw);height:min(760px,calc(100vh - 140px));filter:drop-shadow(0 18px 28px rgba(0,0,0,.33));perspective:1800px;transform-origin:center}
.paper-page{overflow:hidden;padding:54px 48px 48px;background:#fffdf6;font-family:Georgia,"Times New Roman",serif;font-size:20px;line-height:1.58}.paper-page p{margin:0 0 1em;text-align:justify;text-indent:1.4em}.paper-page p:first-child{text-indent:0}.left-page{border-radius:6px 0 0 6px;box-shadow:inset -20px 0 28px -28px rgba(0,0,0,.65)}.right-page{border-radius:0 6px 6px 0;box-shadow:inset 20px 0 28px -28px rgba(0,0,0,.65)}.book-gutter{position:absolute;left:50%;top:0;bottom:0;width:28px;transform:translateX(-50%);background:linear-gradient(90deg,transparent,rgba(0,0,0,.12),transparent);pointer-events:none}.measure-page{position:fixed!important;visibility:hidden;pointer-events:none;left:-10000px;top:0;width:min(560px,46vw);height:min(760px,calc(100vh - 140px))}
.page-hit{position:absolute;z-index:5;top:0;bottom:0;width:18%;border:0;background:transparent;cursor:pointer}.page-hit.left{left:0}.page-hit.right{right:0}.page-flip{animation:pageFlip .28s ease}@keyframes pageFlip{0%{transform:rotateY(0)}50%{transform:rotateY(-2deg) scale(.997)}100%{transform:rotateY(0)}}
.reader-footer{height:38px;display:flex;align-items:center;justify-content:center;gap:18px;background:#1c1713;color:#d9cec1;font:13px Arial}.bookmark-panel{position:fixed;z-index:20;right:18px;top:72px;width:min(340px,calc(100vw - 36px));max-height:65vh;overflow:auto;padding:16px;border-radius:14px;background:#fffaf0;box-shadow:0 20px 60px rgba(0,0,0,.35)}.bookmark-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.bookmark-head button{border:0;background:none;font-size:26px}.bookmark-item{display:block;width:100%;padding:10px 12px;margin:6px 0;border:0;border-radius:9px;background:#eee4d5;text-align:left;cursor:pointer}.bookmark-empty{color:#8c8175}
.book-reader[data-theme="light"] .paper-page{background:#fff;color:#222}.book-reader[data-theme="sepia"] .paper-page{background:#f5ecd9;color:#352b23}.book-reader[data-theme="dark"]{background:#111}.book-reader[data-theme="dark"] .paper-page{background:#242424;color:#ddd}.book-reader[data-theme="dark"] .book-gutter{background:linear-gradient(90deg,transparent,rgba(255,255,255,.05),transparent)}
@media(max-width:759px){.reader-title{font-size:14px}.reader-actions button{padding:7px 8px}.book-stage{padding:0;height:calc(100vh - 96px)}.book-spread{display:block;width:100%;height:100%;filter:none}.paper-page{width:100%;height:100%;padding:42px 24px 34px;border-radius:0!important;box-shadow:none!important;line-height:1.62}.right-page,.book-gutter{display:none!important}.page-hit{width:28%}.measure-page{width:100%;height:calc(100vh - 96px);padding:42px 24px 34px}.reader-footer{height:38px}}
