
:root {
  --page-w: min(42vw, 470px);
  --page-h: calc(var(--page-w) * 1.414);
  --book-open-w: calc(var(--page-w) * 2);
  --book-closed-w: var(--page-w);
  --paper: #fffaf0;
  --gold: #d8a84d;
  --gold-2: #f8dda0;
  --dark: #0d0803;
  --ink: #fff4dd;
  --turn-time: 650ms;
  --user-zoom: 1;
  --base-zoom: 1;
  --pan-x: 0px;
  --pan-y: 0px;
  --dock-h: 132px;
  --ui-blur: blur(16px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 26%, rgba(244, 184, 71, .28), transparent 23%),
    radial-gradient(circle at 12% 18%, rgba(42, 112, 82, .22), transparent 23%),
    radial-gradient(circle at 83% 82%, rgba(111, 54, 13, .52), transparent 31%),
    linear-gradient(145deg, #050302 0%, #150d07 48%, #030201 100%);
  overflow-x: hidden;
}
body.reader-mode { overflow: hidden; }
body.modal-open { overflow: hidden; }
button, input, select { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.grain { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: .12; mix-blend-mode: soft-light; background-image: repeating-radial-gradient(circle at 20% 30%, rgba(255,255,255,.08) 0 1px, transparent 1px 3px); }
.particles { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .70; }
[hidden] { display: none !important; }

/* Biblioteca */
.library-view { position: relative; z-index: 4; min-height: 100dvh; padding: max(18px, env(safe-area-inset-top)) 20px 48px; }
.library-header { width: min(1180px, 100%); margin: 0 auto 24px; display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.brand-lockup h1 { margin: 0; font-size: clamp(2rem, 5vw, 4.6rem); line-height: .95; text-shadow: 0 18px 45px rgba(0,0,0,.48); }
.eyebrow { margin: 0 0 6px; color: var(--gold-2); font-size: .76rem; letter-spacing: .22em; text-transform: uppercase; }
.library-subtitle { margin: 10px 0 0; max-width: 660px; color: rgba(255,244,221,.78); font-size: clamp(1rem, 2vw, 1.18rem); }
.ghost-btn, .primary { border: 1px solid rgba(255, 220, 150, .48); border-radius: 999px; padding: 11px 16px; cursor: pointer; color: #fff6dc; background: rgba(36,23,12,.72); box-shadow: 0 12px 28px rgba(0,0,0,.22); transition: transform .18s ease, background .18s ease; }
.ghost-btn:hover, .primary:hover { transform: translateY(-1px); background: rgba(81,52,25,.86); }
.primary { color: #1b1106; background: linear-gradient(135deg, #ffd98c, #d8a84d); border-color: #ffe8ad; font-weight: 700; }
.primary:disabled, .ghost-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.hero-library { width: min(1180px, 100%); margin: 0 auto 36px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .65fr); gap: 24px; align-items: stretch; }
.hero-copy, .hero-card, .catalog-toolbar, .library-roadmap article { border: 1px solid rgba(255,220,150,.24); border-radius: 28px; background: linear-gradient(145deg, rgba(39,24,12,.78), rgba(15,9,5,.58)); backdrop-filter: var(--ui-blur); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.hero-copy { padding: clamp(24px, 4vw, 48px); }
.badge { display: inline-flex; border: 1px solid rgba(255,220,150,.42); border-radius: 999px; padding: 8px 12px; color: #ffe6a8; background: rgba(0,0,0,.18); margin-bottom: 16px; }
.hero-copy h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.6rem); line-height: 1.02; }
.hero-copy p { color: rgba(255,244,221,.78); line-height: 1.65; max-width: 720px; }
.hero-card { padding: 24px; display: grid; place-content: center; text-align: center; min-height: 260px; }
.mini-shelf { display: flex; justify-content: center; gap: 8px; align-items: end; height: 160px; margin-bottom: 16px; }
.mini-shelf span { display: block; width: 34px; border-radius: 8px 8px 4px 4px; background: linear-gradient(160deg, #734719, #d8a84d); box-shadow: inset 8px 0 12px rgba(255,255,255,.16), 0 14px 30px rgba(0,0,0,.25); }
.mini-shelf span:nth-child(1) { height: 118px; transform: rotate(-4deg); }
.mini-shelf span:nth-child(2) { height: 146px; background: linear-gradient(160deg, #264b35, #f8dda0); }
.mini-shelf span:nth-child(3) { height: 132px; background: linear-gradient(160deg, #7a251c, #d8a84d); }
.mini-shelf span:nth-child(4) { height: 154px; background: linear-gradient(160deg, #1f345d, #f8dda0); }
.mini-shelf span:nth-child(5) { height: 124px; transform: rotate(3deg); }
.hero-card p { color: #f8dda0; margin: 0 0 8px; }
.hero-card strong { font-size: 1.2rem; }
.catalog-toolbar { width: min(1180px, 100%); margin: 0 auto 14px; padding: 18px; display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.section-kicker { margin: 0; color: var(--gold-2); letter-spacing: .16em; text-transform: uppercase; font-size: .72rem; }
.catalog-toolbar h2 { margin: 4px 0 0; font-size: clamp(1.4rem, 3vw, 2.2rem); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input, .filters select { border: 1px solid rgba(255,220,150,.35); border-radius: 999px; padding: 10px 13px; background: rgba(0,0,0,.26); color: #fff6dc; outline: none; max-width: 100%; }
.bookshelf-wrap { width: min(1180px, 100%); margin: 0 auto 32px; position: relative; padding: 28px 18px 42px; border-radius: 30px; background: linear-gradient(180deg, rgba(88,50,21,.55), rgba(33,18,8,.78)); box-shadow: inset 0 18px 40px rgba(255,255,255,.06), 0 30px 80px rgba(0,0,0,.35); }
.bookshelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px; align-items: stretch; }
.shelf-base { position: absolute; left: 18px; right: 18px; bottom: 20px; height: 16px; border-radius: 999px; background: linear-gradient(180deg, #9a6328, #3d210d); box-shadow: 0 12px 24px rgba(0,0,0,.35); }
.book-card { position: relative; z-index: 1; min-height: 390px; display: grid; grid-template-rows: 1fr auto; gap: 14px; padding: 14px; border-radius: 22px; background: rgba(14,9,5,.42); border: 1px solid rgba(255,220,150,.18); transition: transform .22s ease, box-shadow .22s ease; }
.book-card.available:hover { transform: translateY(-8px); box-shadow: 0 22px 48px rgba(0,0,0,.36); }
.book-cover-card { position: relative; min-height: 260px; border-radius: 18px; overflow: hidden; cursor: pointer; background: linear-gradient(135deg, #6b4218, #160e06); box-shadow: 0 18px 38px rgba(0,0,0,.36); }
.book-cover-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.25), transparent 18%, transparent 82%, rgba(255,255,255,.12)); pointer-events: none; }
.book-cover-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder-cover { display: grid; place-items: center; color: #f8dda0; text-align: center; }
.placeholder-title { font-size: 1.4rem; opacity: .82; }
.book-info-card h3 { margin: 8px 0 6px; font-size: 1.18rem; line-height: 1.15; }
.book-info-card p { margin: 0 0 10px; color: rgba(255,244,221,.70); font-size: .92rem; line-height: 1.45; }
.book-status { color: #f8dda0; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.book-card-tags, .modal-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.book-card-tags span, .modal-tags span { border: 1px solid rgba(255,220,150,.26); border-radius: 999px; padding: 5px 8px; color: #f8dda0; background: rgba(0,0,0,.18); font-size: .72rem; }
.book-open-btn { margin-top: 12px; width: 100%; }
.library-roadmap { width: min(1180px, 100%); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.library-roadmap article { padding: 20px; }
.library-roadmap span { color: #f8dda0; font-size: .84rem; letter-spacing: .14em; }
.library-roadmap h3 { margin: 8px 0; }
.library-roadmap p { margin: 0; color: rgba(255,244,221,.72); line-height: 1.55; }

/* Modal ficha */
.book-modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: 22px; }
.book-modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.68); backdrop-filter: blur(10px); }
.modal-card { position: relative; width: min(980px, 100%); max-height: min(88dvh, 780px); overflow: auto; display: grid; grid-template-columns: minmax(240px, .75fr) minmax(0, 1.25fr); gap: 22px; padding: 22px; border: 1px solid rgba(255,220,150,.34); border-radius: 30px; background: linear-gradient(145deg, rgba(37,22,10,.96), rgba(12,8,4,.94)); box-shadow: 0 40px 100px rgba(0,0,0,.55); }
.modal-close { position: absolute; right: 14px; top: 12px; z-index: 2; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,220,150,.42); color: #fff6dc; background: rgba(0,0,0,.28); cursor: pointer; font-size: 1.5rem; }
.modal-cover { min-height: 360px; border-radius: 22px; overflow: hidden; background: #1c1007; box-shadow: 0 24px 55px rgba(0,0,0,.44); }
.modal-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.modal-content { padding: 16px 8px 8px; }
.modal-content h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1; }
.modal-subtitle { color: #f8dda0; font-size: 1.06rem; line-height: 1.45; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.modal-meta span { border: 1px solid rgba(255,220,150,.24); border-radius: 999px; padding: 7px 10px; background: rgba(0,0,0,.18); font-size: .84rem; color: rgba(255,244,221,.82); }
#modalDescription { color: rgba(255,244,221,.78); line-height: 1.65; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* Reader V6 */
.reader-view { position: relative; z-index: 3; height: 100dvh; padding: max(14px, env(safe-area-inset-top)) 18px max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-rows: auto 1fr auto auto; gap: 10px; }
.topbar { width: min(1320px, 100%); margin: 0 auto; display: flex; justify-content: space-between; gap: 18px; align-items: end; transition: opacity .25s ease, transform .25s ease; }
.brand h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 2.25rem); line-height: 1.05; text-shadow: 0 2px 14px rgba(0,0,0,.45); }
.back-library { display: inline-flex; margin-bottom: 8px; border: 1px solid rgba(255,220,150,.38); color: #fff6dc; background: rgba(0,0,0,.22); border-radius: 999px; padding: 7px 10px; cursor: pointer; }
.status-card { min-width: 122px; border: 1px solid rgba(255, 216, 142, .45); background: rgba(24, 14, 6, .62); backdrop-filter: var(--ui-blur); border-radius: 18px; padding: 10px 12px; color: #fff6dd; font-size: .9rem; box-shadow: 0 8px 28px rgba(0,0,0,.25); }
.mini-progress { margin-top: 8px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.15); overflow: hidden; }
.mini-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f5d07b, #fff3bf); transition: width .25s ease; }
.stage { position: relative; width: min(1360px, 100%); margin: auto; min-height: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr) 58px; align-items: center; gap: 8px; }
.book-wrap { position: relative; min-width: 0; height: min(calc(var(--page-h) + 88px), 72dvh); display: flex; justify-content: center; align-items: center; perspective: 2600px; overflow: visible; touch-action: none; cursor: grab; }
.book-wrap.dragging { cursor: grabbing; }
.gesture-tip { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 12; color: rgba(255,246,220,.72); background: rgba(0,0,0,.22); border: 1px solid rgba(255,220,150,.22); border-radius: 999px; padding: 6px 11px; font-size: .78rem; opacity: .85; pointer-events: none; transition: opacity .25s ease; }
.zoomed .gesture-tip, .cinema .gesture-tip { opacity: 0; }
.ambient-glow { position: absolute; width: calc(var(--book-open-w) * 1.14); height: calc(var(--page-h) * .96); border-radius: 50%; background: radial-gradient(circle, rgba(245, 193, 82, .22), transparent 67%); filter: blur(7px); transform: translate(var(--pan-x), calc(var(--pan-y) + 8px)) scale(calc(var(--base-zoom) * var(--user-zoom))); pointer-events: none; }
.book-shadow { position: absolute; width: calc(var(--book-open-w) * 1.12); height: 68px; bottom: 1px; left: 50%; transform: translateX(-50%) translate(var(--pan-x), var(--pan-y)) scale(calc(var(--base-zoom) * var(--user-zoom))); background: radial-gradient(ellipse at center, rgba(0,0,0,.75), transparent 70%); filter: blur(11px); opacity: .96; }
.book { position: relative; width: var(--book-open-w); height: var(--page-h); transform-style: preserve-3d; transform: translate(var(--pan-x), var(--pan-y)) rotateX(5deg) scale(calc(var(--base-zoom) * var(--user-zoom))); transition: width .25s ease, transform .08s linear; filter: drop-shadow(0 30px 32px rgba(0,0,0,.54)); }
.book.closed { width: var(--book-closed-w); }
.spread-face { position: absolute; top: 0; width: var(--page-w); height: var(--page-h); overflow: hidden; background: var(--paper); border: 1px solid rgba(255, 232, 166, .62); box-shadow: inset 0 0 0 1px rgba(255,255,255,.24), 4px 8px 18px rgba(0,0,0,.24); }
.left-page { left: 0; border-radius: 12px 0 0 12px; }
.right-page { right: 0; border-radius: 0 12px 12px 0; }
.book.closed .left-page { display: none; }
.book.closed .right-page { left: 0; right: auto; border-radius: 12px; box-shadow: 0 22px 42px rgba(0,0,0,.38); }
.spread-face img, .turn-face img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; image-rendering: auto; }
.spread-face::before, .turn-face::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.left-page::before { background: linear-gradient(270deg, rgba(0,0,0,.20), transparent 13%, transparent 85%, rgba(255,255,255,.10)); }
.right-page::before { background: linear-gradient(90deg, rgba(0,0,0,.22), transparent 13%, transparent 84%, rgba(255,255,255,.10)); }
.spine { position: absolute; top: -1px; left: calc(50% - 5px); width: 10px; height: calc(100% + 2px); z-index: 8; border-radius: 999px; background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(255,245,206,.42), rgba(0,0,0,.48)); box-shadow: 0 0 20px rgba(0,0,0,.48), inset 0 0 10px rgba(255,255,255,.24); pointer-events: none; }
.book.closed .spine { display: none; }
.turn-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; transform-style: preserve-3d; }
.turn-sheet { position: absolute; top: 0; width: var(--page-w); height: var(--page-h); transform-style: preserve-3d; animation-duration: var(--turn-time); animation-timing-function: cubic-bezier(.22,.64,.18,1); animation-fill-mode: forwards; filter: drop-shadow(0 20px 24px rgba(0,0,0,.38)); }
.turn-sheet.next { right: 0; transform-origin: left center; animation-name: turnNext; }
.turn-sheet.cover-open { left: 0; transform-origin: left center; animation-name: turnCoverOpen; }
.turn-sheet.prev { left: 0; transform-origin: right center; animation-name: turnPrev; }
.turn-face { position: absolute; inset: 0; overflow: hidden; background: var(--paper); backface-visibility: hidden; border: 1px solid rgba(255, 232, 166, .62); }
.turn-front { transform: rotateY(0deg) translateZ(.9px); }
.turn-back { transform: rotateY(180deg) translateZ(.9px); }
.turn-sheet.next .turn-front, .turn-sheet.cover-open .turn-front { border-radius: 0 12px 12px 0; }
.turn-sheet.next .turn-back, .turn-sheet.cover-open .turn-back { border-radius: 12px 0 0 12px; }
.turn-sheet.prev .turn-front { border-radius: 12px 0 0 12px; }
.turn-sheet.prev .turn-back { border-radius: 0 12px 12px 0; }
@keyframes turnNext { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(-180deg); } }
@keyframes turnCoverOpen { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(-180deg); } }
@keyframes turnPrev { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(180deg); } }
.nav.side { width: 50px; height: 50px; border-radius: 50%; border: 1px solid rgba(255, 220, 150, .55); color: #fff7df; background: rgba(48, 30, 14, .76); font-size: 2rem; line-height: 1; cursor: pointer; transition: transform .18s ease, background .18s ease, opacity .18s ease; box-shadow: 0 10px 24px rgba(0,0,0,.28); z-index: 25; }
.nav.side:hover { transform: scale(1.08); background: rgba(91, 57, 22, .88); }
.nav.side:disabled, .control-dock button:disabled { opacity: .32; cursor: not-allowed; }
.control-dock { width: min(1320px, calc(100vw - 24px)); margin: 0 auto; display: grid; gap: 7px; padding: 9px; border: 1px solid rgba(255,220,150,.26); border-radius: 22px; background: rgba(18,11,5,.44); backdrop-filter: var(--ui-blur); box-shadow: 0 16px 38px rgba(0,0,0,.26); transition: opacity .25s ease, transform .25s ease; }
.dock-row { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.control-dock button, .speed, .zoom-control, .progress-wrap { border: 1px solid rgba(255, 220, 150, .45); color: #fff6dc; background: rgba(36, 23, 12, .72); border-radius: 999px; padding: 8px 12px; box-shadow: 0 8px 20px rgba(0,0,0,.20); font-size: .84rem; }
.control-dock button { cursor: pointer; transition: transform .18s ease, background .18s ease; }
.control-dock button:hover { transform: translateY(-1px); background: rgba(81, 52, 25, .82); }
.control-dock .primary { color: #1b1106; background: linear-gradient(135deg, #ffd98c, #d8a84d); border-color: #ffe8ad; font-weight: 700; }
.zoom-control { display: grid; grid-template-columns: auto 32px minmax(120px, 240px) 32px 56px 70px; align-items: center; gap: 7px; max-width: min(620px, 100%); }
.zoom-control button { width: 100%; height: 30px; padding: 0 8px; }
.zoom-control input { width: 100%; min-width: 0; accent-color: #f5c96d; }
.speed { display: flex; align-items: center; gap: 8px; }
.speed select { border: none; color: #fff6dc; background: rgba(0,0,0,.22); border-radius: 999px; padding: 4px 8px; }
.zoom-control span, .speed span { text-transform: uppercase; letter-spacing: .11em; font-size: .70rem; color: rgba(255, 245, 210, .78); }
.progress-wrap { display: grid; grid-template-columns: 42px minmax(120px, 220px); gap: 9px; align-items: center; }
.progress-bar { height: 7px; border-radius: 999px; background: rgba(255,255,255,.15); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f5d07b, #fff3bf); transition: width .25s ease; }
.hint { margin: -2px auto 0; width: min(920px, 100%); text-align: center; color: rgba(255, 246, 220, .66); font-size: .82rem; }
body.cinema .topbar { opacity: 0; transform: translateY(-18px); pointer-events: none; }
body.cinema .control-dock { opacity: .14; transform: translateY(10px); }
body.cinema .control-dock:hover { opacity: 1; transform: translateY(0); }
body.cinema .hint { opacity: 0; }
body.cinema { --base-zoom: 1.08; }

@media (max-width: 900px) {
  .library-header, .hero-library, .catalog-toolbar { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .hero-library { display: grid; grid-template-columns: 1fr; }
  .library-roadmap { grid-template-columns: 1fr; }
  .filters { width: 100%; }
  .filters input, .filters select { width: 100%; }
  .modal-card { grid-template-columns: 1fr; max-height: 90dvh; }
  .modal-cover { min-height: 280px; }
}

@media (max-width: 760px) {
  :root { --page-w: min(49vw, calc((100dvh - var(--dock-h) - 104px) / 1.414)); --base-zoom: 1; --dock-h: 154px; }
  body.reader-mode { overflow: hidden; }
  .reader-view { padding: max(8px, env(safe-area-inset-top)) 8px calc(var(--dock-h) + env(safe-area-inset-bottom) + 8px); grid-template-rows: auto 1fr auto; gap: 5px; }
  .topbar { align-items: start; gap: 8px; }
  .brand h1 { font-size: clamp(.98rem, 4.6vw, 1.34rem); max-width: 72vw; }
  .eyebrow { font-size: .54rem; letter-spacing: .16em; }
  .back-library { font-size: .68rem; padding: 6px 8px; margin-bottom: 4px; }
  .status-card { min-width: 84px; padding: 7px 9px; font-size: .66rem; }
  .stage { grid-template-columns: 1fr; width: 100%; }
  .book-wrap { height: calc(100dvh - var(--dock-h) - 108px); min-height: 330px; perspective: 2200px; }
  .gesture-tip { display: none; }
  .nav.side { position: fixed; top: 50%; transform: translateY(-50%); width: 43px; height: 43px; font-size: 1.62rem; background: rgba(48, 30, 14, .56); backdrop-filter: blur(8px); }
  .nav.side.left { left: 8px; }
  .nav.side.right { right: 8px; }
  .nav.side:hover { transform: translateY(-50%) scale(1.04); }
  .control-dock { position: fixed; left: 50%; bottom: calc(6px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; width: calc(100vw - 12px); max-height: 42dvh; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 7px; border-radius: 18px; }
  .main-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 5px; }
  .main-actions button:nth-child(5), .main-actions button:nth-child(6), .main-actions button:nth-child(7) { grid-column: span 1; }
  .fine-controls { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 6px; }
  .control-dock button, .speed, .zoom-control, .progress-wrap { width: 100%; min-width: 0; padding: 7px 5px; font-size: .62rem; text-align: center; }
  .zoom-control { grid-column: 1 / -1; grid-template-columns: auto 30px minmax(0, 1fr) 30px 48px 56px; padding-inline: 8px; }
  .zoom-control span, .speed span { font-size: .58rem; }
  .speed { justify-content: center; }
  .speed select { max-width: 76px; font-size: .62rem; }
  .progress-wrap { grid-template-columns: 36px minmax(0, 1fr); }
  .hint { display: none; }
  body.cinema { --base-zoom: 1.15; --dock-h: 74px; }
  body.cinema .topbar { display: none; }
  body.cinema .book-wrap { height: calc(100dvh - var(--dock-h) - 18px); }
  body.cinema .fine-controls { display: none; }
  body.cinema .control-dock { opacity: .14; max-height: 72px; }
  body.cinema .control-dock:hover { opacity: 1; }
}

@media (max-width: 430px) {
  :root { --dock-h: 166px; --page-w: min(49vw, calc((100dvh - var(--dock-h) - 104px) / 1.414)); }
  .library-view { padding-inline: 12px; }
  .brand-lockup h1 { font-size: 2.25rem; }
  .hero-copy { padding: 22px; }
  .bookshelf-wrap { padding-inline: 10px; }
  .book-card { min-height: 350px; }
  .book-cover-card { min-height: 230px; }
  .modal-card { padding: 14px; border-radius: 22px; }
  .modal-content h2 { font-size: 1.8rem; }
  .modal-actions { display: grid; grid-template-columns: 1fr; }
  .main-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .zoom-control { grid-template-columns: auto 28px minmax(0, 1fr) 28px; }
  .zoom-control button:nth-of-type(3), .zoom-control button:nth-of-type(4) { grid-column: span 2; }
  .speed span { display: none; }
}

@media (orientation: landscape) and (max-height: 620px) {
  :root { --page-w: min(38vw, calc((100dvh - 74px) / 1.414)); --dock-h: 62px; }
  .reader-view { padding-top: 6px; padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 6px); }
  .topbar, .hint { display: none; }
  .book-wrap { height: calc(100dvh - var(--dock-h) - 14px); }
  .fine-controls { display: none; }
  .control-dock { position: fixed; left: 50%; bottom: calc(5px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(720px, calc(100vw - 12px)); max-height: 58px; padding: 6px; opacity: .28; }
  .control-dock:hover { opacity: 1; }
  .main-actions { display: flex; flex-wrap: nowrap; }
}


/* V8 mobile/tablet interaction recovery */
.tools-toggle { display: none; }
.book-card { cursor: pointer; touch-action: manipulation; }
.book-card.locked .book-open-btn { opacity: 1; cursor: pointer; }
.book-card.locked { filter: none; }
.book-card.locked .book-cover-card { opacity: .92; }
.modal-actions .primary:disabled { opacity: .72; cursor: not-allowed; filter: grayscale(.15); }

@media (max-width: 760px) {
  .tools-toggle { display: inline-flex; justify-content: center; align-items: center; }
  .main-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }
  .main-actions button { min-height: 34px; }
  .control-dock {
    max-height: min(38dvh, 176px);
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .fine-controls { display: none; }
  .control-dock.tools-open .fine-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 6px;
  }
  .control-dock.tools-open .zoom-control {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: auto 30px minmax(0, 1fr) 30px 48px 56px;
  }
  body.cinema .fine-controls,
  body.cinema .tools-toggle { display: none !important; }
  body.cinema .main-actions {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .book-wrap { touch-action: none; }
  .gesture-tip { font-size: .64rem; max-width: calc(100vw - 24px); white-space: nowrap; }
}

@media (min-width: 761px) {
  .tools-toggle { display: none !important; }
}

@media (max-width: 430px) {
  .main-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main-actions button { padding-inline: 4px; font-size: .58rem; }
  .control-dock.tools-open { max-height: min(46dvh, 230px); }
  .control-dock.tools-open .zoom-control {
    grid-template-columns: auto 28px minmax(0, 1fr) 28px;
  }
  .control-dock.tools-open .zoom-control button:nth-of-type(3),
  .control-dock.tools-open .zoom-control button:nth-of-type(4) {
    grid-column: span 2;
  }
}
