:root {
  --forest: #173e2f;
  --forest-deep: #0d2b20;
  --leaf: #387b56;
  --sage: #9fb7a5;
  --cream: #f4efe3;
  --paper: #fffdf7;
  --ink: #1d2b24;
  --muted: #68766e;
  --wood: #6b4028;
  --gold: #c99c56;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: #102a20; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.mobile-shell { width: 100%; max-width: 480px; min-height: 100dvh; margin: 0 auto; overflow: hidden; position: relative; background: var(--cream); box-shadow: 0 0 80px #0007; }

/* Login */
.login-page { background: #2c211b; }
.login-scene {
  min-height: 100dvh; display: grid; place-items: center; padding: 48px 22px;
  position: relative; isolation: isolate; overflow: hidden;
  background:
    linear-gradient(#2b2018bb, #211712db),
    repeating-linear-gradient(89deg, #523a2c 0, #694a38 2px, #4e3529 4px, #4e3529 78px, #36241d 80px);
}
.login-scene::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .22; background: radial-gradient(circle at 20% 30%, #fff8 0 1px, transparent 2px), radial-gradient(circle at 72% 68%, #0008 0 1px, transparent 2px); background-size: 17px 19px, 23px 21px; }
.green-orb, .white-orb { position: absolute; border-radius: 50%; z-index: -1; }
.green-orb { width: 250px; height: 250px; background: linear-gradient(145deg, #65a878, #174c34 70%); top: -132px; left: -95px; box-shadow: inset -22px -18px 45px #0d3829aa, 0 22px 45px #0005; }
.green-orb::after { content: ""; position: absolute; width: 112px; height: 28px; left: 69px; bottom: 45px; border-radius: 50%; background: #fff2; transform: rotate(-20deg); filter: blur(8px); }
.white-orb { width: 225px; height: 225px; right: -117px; bottom: -114px; background: radial-gradient(circle at 35% 30%, #fff, #e7e3da 58%, #b7b2a8); box-shadow: inset -15px -20px 35px #9d988f66, 0 0 44px #0005; }
.login-paper { width: 100%; position: relative; padding: 42px 26px 28px; background: var(--paper); transform: rotate(-.7deg); box-shadow: 0 20px 50px #0c090866, 0 2px 2px #0003; clip-path: polygon(1% 1%, 99% 0, 100% 97%, 94% 99%, 85% 98%, 76% 100%, 65% 98.5%, 53% 100%, 43% 98%, 33% 100%, 21% 98.5%, 9% 100%, 0 98%); }
.login-paper::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .25; background-image: repeating-linear-gradient(0deg, transparent 0, transparent 5px, #b6aa8f11 6px); }
.paper-pin { position: absolute; width: 14px; height: 14px; left: 50%; top: 14px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d6c8a9, #756a59); box-shadow: 0 2px 3px #0006; }
.brand-mark { width: 54px; height: 44px; margin: 0 auto 9px; position: relative; }
.leaf { position: absolute; width: 26px; height: 37px; background: var(--forest); border-radius: 100% 0 100% 0; transform-origin: bottom center; }
.leaf-one { left: 6px; transform: rotate(-29deg); }
.leaf-two { right: 5px; transform: scaleX(-1) rotate(-29deg); background: var(--leaf); }
.brand-mark::after { content: ""; position: absolute; height: 31px; width: 2px; background: #173e2f; left: 27px; bottom: 0; }
.eyebrow { margin: 0; text-align: center; text-transform: uppercase; letter-spacing: .22em; color: var(--leaf); font-size: .68rem; font-weight: 700; }
.login-paper h1 { margin: 11px 0; text-align: center; font: 700 clamp(2rem, 9vw, 2.7rem)/.96 "Cormorant Garamond", serif; letter-spacing: -.035em; }
.login-copy { margin: 0 auto 25px; max-width: 310px; color: var(--muted); text-align: center; font-size: .82rem; line-height: 1.65; }
.login-form label { display: block; margin: 0 0 8px; color: #34463d; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.input-wrap { display: flex; align-items: center; border: 1px solid #c9d0c9; background: #fff; padding: 0 13px; transition: border .2s, box-shadow .2s; }
.input-wrap:focus-within { border-color: var(--leaf); box-shadow: 0 0 0 3px #387b561c; }
.input-wrap svg { width: 20px; height: 20px; fill: none; stroke: #698075; stroke-width: 1.7; }
.input-wrap input { min-width: 0; width: 100%; height: 52px; border: 0; outline: 0; padding: 0 10px; color: var(--ink); background: transparent; font-size: .9rem; text-transform: uppercase; }
.input-wrap input::placeholder { text-transform: none; color: #a0aaa4; }
.form-error { margin: 8px 0 0; color: #9e352e; font-size: .72rem; line-height: 1.4; }
.primary-button { display: inline-grid; place-items: center; width: 100%; min-height: 52px; margin-top: 14px; border: 0; background: var(--forest); color: white; text-decoration: none; font-weight: 700; font-size: .86rem; box-shadow: 0 8px 18px #173e2f35; transition: transform .15s, background .15s; }
.primary-button:active { transform: translateY(1px); background: var(--forest-deep); }
.login-help { margin: 18px 5px 0; text-align: center; color: #879189; font-size: .65rem; line-height: 1.45; }

/* Library */
.library-page { background: #193c2f; }
.library-scene { min-height: 100dvh; position: relative; padding: max(24px, env(safe-area-inset-top)) 22px 30px; background: linear-gradient(#173e2ff4, #0e2d22f8), repeating-linear-gradient(88deg, transparent 0 65px, #fff1 67px), #173e2f; }
.library-scene::before { content: ""; position: absolute; inset: 0; opacity: .12; pointer-events: none; background: radial-gradient(circle at 12% 20%, #fff 0 1px, transparent 1.5px); background-size: 21px 22px; }
.library-header { position: relative; display: flex; align-items: center; justify-content: space-between; color: white; }
.welcome { margin: 0 0 2px; color: #b8cbbf; font-size: .72rem; }
.library-header h1 { margin: 0; font: 700 1.9rem/1 "Cormorant Garamond", serif; }
.icon-button, .reader-action, .reader-back { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #ffffff35; border-radius: 50%; color: white; background: #ffffff10; }
.icon-button svg, .reader-action svg, .reader-back svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.library-intro { position: relative; margin: 38px 0 24px; color: white; }
.tiny-leaf { float: left; width: 12px; height: 17px; margin: 0 9px 0 2px; border-radius: 100% 0 100% 0; background: #88bd92; transform: rotate(-20deg); }
.library-intro p { margin: 0 0 5px; color: #adc8b7; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.library-intro h2 { margin: 0; font: 700 2rem/1.05 "Cormorant Garamond", serif; }
.bookshelf { position: relative; margin-inline: -22px; }
.shelf-row { position: relative; padding: 0 22px 34px; }
.book-spine { min-height: 92px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; padding: 10px 16px 10px 10px; color: #f8f1df; text-decoration: none; border-radius: 3px 6px 6px 2px; box-shadow: inset 8px 0 14px #0002, inset -2px 0 #fff2, 2px 7px 12px #0006; position: relative; overflow: hidden; }
.book-spine::after { content: ""; position: absolute; inset: 6px; border: 1px solid #e4c98545; pointer-events: none; }
.spine-0 { background: linear-gradient(100deg, #773d2e, #9c5542 55%, #683124); }
.spine-1 { background: linear-gradient(100deg, #265c4a, #3e8069 55%, #194637); }
.spine-2 { background: linear-gradient(100deg, #464d73, #626c9b 55%, #343959); }
.spine-3 { background: linear-gradient(100deg, #856126, #aa7e36 55%, #654817); }
.book-number { font: 600 .68rem/1 "Manrope"; color: #f6e3b6; transform: rotate(-90deg); }
.book-title { padding: 0 8px; font: 700 1.35rem/1.05 "Cormorant Garamond", serif; }
.open-book { border: 1px solid #fff5; border-radius: 20px; padding: 7px 10px; font-size: .57rem; text-transform: uppercase; letter-spacing: .08em; }
.book-progress { margin: 11px 5px 0; }
.progress-copy { display: flex; justify-content: space-between; color: #b8c9be; font-size: .63rem; }
.progress-copy strong { color: #f2dda8; }
.progress-track { height: 3px; margin-top: 6px; overflow: hidden; background: #ffffff24; }
.progress-track span { display: block; height: 100%; max-width: 100%; background: #dbb66b; }
.wood-shelf { position: absolute; z-index: 2; bottom: 18px; left: 0; right: 0; height: 13px; background: linear-gradient(#9b6a47, #583521 55%, #2f1b13); box-shadow: 0 8px 12px #0008, inset 0 1px #d49a6f; }
.wood-shelf::after { content: ""; position: absolute; left: 0; right: 0; top: 4px; border-top: 1px solid #cf966966; }
.library-footer { color: #8eab99; text-align: center; font: italic 600 .9rem "Cormorant Garamond", serif; }
.empty-shelf { padding: 55px 25px 70px; text-align: center; color: white; }
.empty-shelf span { font-size: 2.5rem; }
.empty-shelf h3 { margin-bottom: 5px; font-family: "Cormorant Garamond", serif; font-size: 1.6rem; }
.empty-shelf p { color: #a9c0b1; font-size: .78rem; }

/* Reader */
.reader-page { background: #111; overflow: hidden; }
.reader { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; height: 100dvh; background: #1c211f; color: white; }
.reader-header { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 14px 10px; background: #173e2f; }
.reader-back { text-decoration: none; }
.reader-header div { min-width: 0; text-align: center; }
.reader-header span { display: block; color: #95b3a1; font-size: .56rem; text-transform: uppercase; letter-spacing: .13em; }
.reader-header h1 { overflow: hidden; margin: 2px 0 0; text-overflow: ellipsis; white-space: nowrap; font: 700 1.04rem "Cormorant Garamond", serif; }
.reader-status { min-height: 22px; padding-top: 5px; color: #b7c5bd; background: #1c211f; text-align: center; font-size: .62rem; }
.pdf-viewport { overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; padding: 6px 12px; background: radial-gradient(circle at center, #3b403e, #202422 70%); }
.canvas-stage { min-height: 100%; display: flex; justify-content: center; align-items: flex-start; transform-origin: center top; transition: transform .08s; }
#pdf-canvas { display: block; max-width: none; background: white; box-shadow: 0 10px 25px #0009; }
.reader-error { max-width: 320px; margin: 80px auto 0; padding: 24px; text-align: center; color: #d4ded8; }
.reader-error strong { display: block; font-family: "Cormorant Garamond", serif; font-size: 1.6rem; }
.reader-error p { font-size: .75rem; line-height: 1.5; }
.reader-error a { color: #e5c587; font-size: .72rem; }
.reader-hint { padding: 6px; color: #7f8c85; text-align: center; background: #151917; font-size: .55rem; }
.reader-controls { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 9px 18px max(10px, env(safe-area-inset-bottom)); background: #101412; }
.reader-controls button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #ffffff25; border-radius: 50%; color: white; background: #ffffff0c; }
.reader-controls button:last-child { justify-self: end; }
.reader-controls button:disabled { opacity: .3; }
.reader-controls svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; }
.page-position { text-align: center; }
.page-position strong { font: 700 1.35rem "Cormorant Garamond", serif; }
.page-position span { color: #85928b; font-size: .7rem; }

.simple-page { min-height: 100dvh; display: grid; place-items: center; padding: 30px; text-align: center; color: white; background: var(--forest); }
.simple-page span { color: #d6b46e; font: 700 4rem "Cormorant Garamond", serif; }
.simple-page h1 { font-family: "Cormorant Garamond", serif; }
.simple-page p { color: #b0c4b7; font-size: .82rem; }
.simple-page .primary-button { padding: 0 20px; }

@media (min-width: 481px) {
  body::before { content: "Mobil elektron kutubxona"; position: fixed; left: 34px; bottom: 30px; color: #ffffff55; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
