:root {
  --navy: #0b3067;
  --blue: #124783;
  --red: #e73349;
  --muted: #667894;
  --line: #e6ebf3;
  --canvas: #f4f7fb;
  --topbar-h: 76px;
  --toolbar-h: 94px;
  --sheet-ratio: 0.7075788062;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: #19365a; background: var(--canvas); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, img, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, .catalog-viewport:focus-visible { outline: 3px solid #4d8ff1; outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .28; box-shadow: none !important; }
.catalog-app { display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr) var(--toolbar-h); min-height: 320px; height: 100vh; height: 100dvh; width: 100%; overflow: hidden; isolation: isolate; position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 clamp(16px,3.2vw,48px); background: #fff; border-bottom: 1px solid var(--line); z-index: 12; }
.header-identity { min-width: 0; display: flex; align-items: center; gap: 20px; }
.brand-mark { color: #07366f; font-size: 23px; font-weight: 900; line-height: 1; letter-spacing: -.075em; border: 2.5px solid #164988; border-radius: 7px; padding: 7px 10px 8px 8px; white-space: nowrap; }
.brand-red { color: var(--red); }
.brand-divider { width: 1px; height: 31px; background: #e1e7f0; }
.header-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.header-title strong { font-weight: 760; font-size: 15px; color: #1a3150; letter-spacing: -.025em; }
.header-title small { font-size: 12px; color: #8190a6; white-space: nowrap; }
.top-actions, .toolbar-group { display: flex; align-items: center; gap: 8px; }
.top-count { border-radius: 100px; background: #f2f5fa; color: #7386a1; padding: 8px 13px; font-size: 11px; font-weight: 750; margin-right: 8px; white-space: nowrap; }
.icon-btn, .tool-btn, .nav-arrow, .close-thumbs { border: 1px solid var(--line); background: #fff; color: #375778; display: grid; place-items: center; transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease; }
.icon-btn:hover:not(:disabled), .tool-btn:hover:not(:disabled), .nav-arrow:hover:not(:disabled), .close-thumbs:hover:not(:disabled) { color: #0b4184; background: #f0f5fd; box-shadow: 0 3px 12px #173d7410; }
.icon-btn:active:not(:disabled), .tool-btn:active:not(:disabled), .nav-arrow:active:not(:disabled) { transform: scale(.95); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; }
.icon-btn svg, .tool-btn svg, .nav-arrow svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.viewer-shell { min-height: 0; position: relative; overflow: hidden; background: radial-gradient(ellipse at 48% 40%, #fff 0%, #f5f7fb 60%, #ecf1f8 100%); }
.ambient-circle { position: absolute; pointer-events: none; width: 350px; height: 350px; border: 1px solid #d9e3f1; border-radius: 50%; opacity: .7; }
.ambient-circle:before { content: ''; position: absolute; inset: 60px; border: 1px solid #d9e3f1; border-radius: 50%; }
.ambient-circle-left { left: -270px; top: 19%; }
.ambient-circle-right { right: -265px; bottom: -190px; }
.viewer-kicker { position: absolute; top: 24px; left: clamp(18px,3.2vw,48px); z-index: 2; display: flex; gap: 9px; align-items: center; font-size: 10px; letter-spacing: .18em; font-weight: 790; color: #8494ac; pointer-events: none; }
.kicker-dot { background: var(--red); width: 6px; height: 6px; border-radius: 50%; }
.viewer-hint { display: none; }
.catalog-viewport { position: absolute; inset: 0; display: flex; overflow: auto; padding: 52px 84px 35px; scrollbar-width: thin; scrollbar-color: #c5d1e2 transparent; overscroll-behavior: contain; }
.zoom-layer { flex: 0 0 auto; display: grid; place-items: center; margin: auto; }
.book-stage { display: block; width: 900px; aspect-ratio: 2110 / 1491; perspective: 2800px; position: relative; filter: drop-shadow(0 18px 26px rgba(21,45,78,.15)); touch-action: none; user-select: none; }
.book { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.22,.72,.22,1); }
.book.position-start { transform: translateX(-25%); }
.book.position-middle { transform: translateX(0); }
.book.position-end { transform: translateX(25%); }
.sheet { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d; transform: rotateY(0deg); transition: transform .76s cubic-bezier(.2,.74,.24,1); }
.sheet.dragging { transition: none !important; }
.sheet.flipped { transform: rotateY(-180deg); }
.page { position: absolute; inset: 0; overflow: hidden; background: #fff; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.page.back { transform: rotateY(180deg); }
.page img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; user-select: none; }
.mobile-viewer { display: none; }
.nav-arrow { position: absolute; top: 50%; width: 48px; height: 48px; z-index: 3; border-radius: 50%; transform: translateY(-50%); box-shadow: 0 9px 26px rgba(22,51,91,.11); }
.nav-arrow:active:not(:disabled) { transform: translateY(-50%) scale(.94); }
.nav-prev { left: clamp(15px,2.7vw,44px); }
.nav-next { right: clamp(15px,2.7vw,44px); }
.nav-arrow svg { width: 23px; height: 23px; }
.toolbar { display: grid; grid-template-columns: minmax(105px, 1fr) minmax(250px, 500px) minmax(300px, 1fr); align-items: center; gap: 16px; padding: 0 clamp(16px,3.2vw,48px); background: #fff; border-top: 1px solid var(--line); z-index: 11; box-shadow: 0 -4px 28px #102e5010; }
.toolbar-left { justify-content: flex-start; }
.toolbar-center { justify-content: center; gap: 18px; min-width: 0; }
.toolbar-right { justify-content: flex-end; }
.tool-btn { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; font-size: 24px; line-height: 1; padding: 0; }
.tool-btn.primary-nav { color: #fff; background: var(--blue); border-color: var(--blue); }
.tool-btn.primary-nav:hover:not(:disabled) { color: #fff; background: #073a75; border-color: #073a75; }
.tool-separator { height: 24px; width: 1px; background: #e4eaf2; margin: 0 5px; }
.page-indicator { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; flex-shrink: 0; min-width: 80px; }
.page-indicator small { font-size: 9px; letter-spacing: .16em; color: #95a1b4; font-weight: 800; }
.page-status { font-size: 13px; color: var(--navy); font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.page-range { --fill: 0%; flex: 1 1 auto; min-width: 56px; height: 28px; appearance: none; background: transparent; margin: 0; cursor: pointer; }
.page-range::-webkit-slider-runnable-track { height: 5px; background: linear-gradient(to right, var(--blue) var(--fill), #e5ebf3 var(--fill)); border-radius: 99px; }
.page-range::-webkit-slider-thumb { appearance: none; background: #fff; border: 3px solid var(--blue); width: 17px; height: 17px; border-radius: 50%; margin-top: -6px; box-shadow: 0 1px 5px #0b306725; }
.page-range::-moz-range-track { height: 5px; background: #e5ebf3; border-radius: 99px; }
.page-range::-moz-range-progress { height: 5px; background: var(--blue); border-radius: 99px; }
.page-range::-moz-range-thumb { width: 13px; height: 13px; background: #fff; border: 3px solid var(--blue); border-radius: 50%; }
.zoom-label { flex: 0 0 43px; font-size: 12px; font-weight: 750; color: #7e8da4; text-align: center; font-variant-numeric: tabular-nums; }
.tool-btn .sound-on { display: none; }
.tool-btn.sound-enabled .sound-on { display: block; }
.tool-btn.sound-enabled .sound-off { display: none; }
.panel-backdrop { position: absolute; inset: 0; z-index: 18; background: rgba(18, 35, 62, .17); opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s; }
.panel-backdrop.open { opacity: 1; visibility: visible; }
.thumb-panel { display: flex; flex-direction: column; position: absolute; top: 14px; bottom: 14px; left: 16px; z-index: 19; width: 290px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 15px 60px #1b38512b; transform: translateX(calc(-100% - 34px)); visibility: hidden; transition: transform .24s ease, visibility .24s; overflow: hidden; }
.thumb-panel.open { transform: translateX(0); visibility: visible; }
.thumb-panel-head { padding: 20px 17px 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.thumb-panel-head div { display: flex; flex-direction: column; gap: 6px; }
.thumb-panel-head small { font-size: 9px; letter-spacing: .18em; color: #92a2b6; font-weight: 800; }
.thumb-panel-head strong { color: #173c73; font-size: 16px; }
.close-thumbs { font-size: 23px; width: 34px; height: 34px; border-radius: 10px; line-height: 1; }
.thumb-list { flex: 1; min-height: 0; overflow: auto; padding: 17px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); align-content: start; gap: 16px 12px; }
.thumb { border: 2px solid transparent; padding: 4px; border-radius: 10px; background: #f4f6fa; cursor: pointer; display: block; min-width: 0; transition: border-color .18s, background .18s; }
.thumb img { display: block; width: 100%; aspect-ratio: 1055/1491; object-fit: cover; box-shadow: 0 2px 10px #34455b10; }
.thumb span { display: block; color: #7587a0; font-size: 10px; margin: 7px 0 3px; font-weight: 700; }
.thumb.active { border-color: #2371ce; background: #f0f6ff; }
.thumb.active span { color: var(--blue); }
.thumb:hover { background: #eaf1fc; }
.thumb-panel-bottom { flex: none; border-top: 1px solid var(--line); padding: 13px; color: #91a0b2; font-size: 11px; text-align: center; }
.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(var(--toolbar-h) + 12px); transform: translate(-50%, 14px); border-radius: 12px; background: #123e72; box-shadow: 0 10px 25px #0e315344; color: #fff; font-size: 12px; font-weight: 650; padding: 12px 17px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap; max-width: calc(100vw - 30px); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1120px) and (min-width: 861px) {
  .toolbar { grid-template-columns: auto minmax(190px,1fr) auto; gap: 12px; }
  .toolbar-center { gap: 11px; }
  .header-identity { gap: 14px; }
  .top-count { display: none; }
  .catalog-viewport { padding-left: 64px; padding-right: 64px; }
}
@media (max-width: 860px) {
  :root { --topbar-h: 65px; --toolbar-h: 117px; }
  .topbar { padding-left: 16px; padding-right: 16px; }
  .brand-mark { font-size: 19px; border-width: 2px; padding: 6px 8px 7px 7px; }
  .brand-divider { height: 28px; }
  .header-identity { gap: 13px; }
  .header-title strong { font-size: 13px; }
  .header-title small { font-size: 10px; }
  .top-count { display: none; }
  .icon-btn { width: 37px; height: 37px; border-radius: 10px; }
  .top-actions { gap: 5px; }
  .viewer-kicker { top: 10px; left: 15px; font-size: 9px; }
  .viewer-hint { display: block; position: absolute; left: 0; right: 0; bottom: 9px; text-align: center; font-size: 10px; color: #8396ac; font-weight: 550; pointer-events: none; }
  .viewer-hint.hidden { display: none; }
  .catalog-viewport { padding: 28px 12px 25px; }
  .book-stage { display: none; }
  .mobile-viewer { display: block; width: max-content; height: max-content; }
  /* Dobra de papel realista no celular — página única, sombras e curvatura suave. */
  .mobile-page-frame { width: 280px; aspect-ratio: 1055 / 1491; position: relative; isolation: isolate; background: #fff; box-shadow: 0 20px 46px #1a30494d, 3px 4px 0 #dce1e8, 6px 7px 0 #e9edf2; overflow: hidden; border-radius: 2px 4px 4px 2px; cursor: grab; }
  .mobile-page-frame:active:not(.zoomed) { cursor: grabbing; }
  .mobile-page-layer { position: absolute; display: block; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; pointer-events: none; -webkit-user-drag: none; }
  .mobile-page-curl { position: absolute; display: none; z-index: 4; inset: 0; width: 100%; height: 100%; pointer-events: none; }
  .mobile-page-frame.turning .mobile-page-curl { display: block; }
  .mobile-paper-edge { position: absolute; right: 0; top: 0; bottom: 0; width: 5px; z-index: 5; background: linear-gradient(90deg, transparent, rgba(15,48,85,.10)); pointer-events: none; }
  .mobile-book-spine { position: absolute; z-index: 5; top: 0; left: 0; bottom: 0; width: 9px; pointer-events: none; background: linear-gradient(90deg, rgba(8,35,72,.19), rgba(8,35,72,.045) 55%, transparent); opacity: .72; }
  .mobile-page-frame.turning .mobile-book-spine, .mobile-page-frame.turning .mobile-paper-edge { opacity: .2; }
  .mobile-corner-cue { position: absolute; right: 0; bottom: 0; z-index: 3; width: 32px; height: 32px; pointer-events: none; clip-path: polygon(100% 0%, 0% 100%, 100% 100%); background: linear-gradient(135deg, rgba(255,255,255,0) 36%, #f4f6f9 40%, #c3cdd9 100%); filter: drop-shadow(-3px -3px 5px #10294a35); opacity: .75; transition: opacity .18s ease; }
  .mobile-page-frame.turning .mobile-corner-cue, .mobile-page-frame.zoomed .mobile-corner-cue { opacity: 0; }
  .mobile-page-frame:not(.zoomed) { touch-action: pan-y; }
  .mobile-page-frame.zoomed { cursor: auto; touch-action: pan-x pan-y; }
  .nav-arrow { display: none; }
  .toolbar { height: var(--toolbar-h); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 42px 42px; grid-template-areas: "center center" "left right"; gap: 6px; padding: 8px 15px calc(8px + env(safe-area-inset-bottom, 0px)); align-content: center; }
  .toolbar-left { grid-area: left; }
  .toolbar-center { grid-area: center; gap: 12px; }
  .toolbar-right { grid-area: right; }
  .page-indicator { min-width: 65px; }
  .page-indicator small { font-size: 8px; }
  .page-status { font-size: 12px; }
  .tool-btn { flex-basis: 37px; width: 37px; height: 37px; border-radius: 10px; }
  .tool-separator { display: none; }
  .toolbar-group { gap: 6px; }
  .zoom-label { flex-basis: 37px; font-size: 11px; }
  .thumb-panel { top: 10px; bottom: 10px; left: 10px; }
  .toast { bottom: calc(var(--toolbar-h) + 12px); }
}
@media (max-width: 520px) {
  .header-title small { display: none; }
  .header-title strong { font-size: 12px; }
  .topbar { padding: 0 12px; }
  .header-identity { gap: 10px; }
  .brand-divider { height: 22px; }
  .viewer-hint { font-size: 9px; }
  .toolbar { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 380px) {
  .header-title { display: none; }
  .brand-divider { display: none; }
  .minor-control { display: none; }
  .toolbar-right { gap: 6px; }
  .toolbar-left { gap: 6px; }
}
@media (max-height: 550px) and (min-width: 861px) {
  :root { --topbar-h: 60px; --toolbar-h: 70px; }
  .viewer-kicker { top: 9px; }
  .catalog-viewport { padding-top: 25px; padding-bottom: 12px; }
}
@media (max-width: 860px) and (max-height: 620px) {
  :root { --topbar-h: 54px; --toolbar-h: 94px; }
  .toolbar { grid-template-rows: 29px 32px; row-gap: 4px; padding-top: 4px; padding-bottom: 4px; }
  .topbar { min-height: 0; }
  .catalog-viewport { padding-top: 17px; padding-bottom: 12px; }
  .viewer-hint { display: none; }
  .viewer-kicker { display: none; }
  .tool-btn { width: 32px; height: 32px; flex-basis: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Visor no estilo de um leitor digital, com controles compactos no celular. */
@media (max-width: 860px) {
  :root { --topbar-h: 58px; --toolbar-h: 69px; }
  .topbar { border-bottom-color: #e8edf2; }
  .viewer-shell { background: radial-gradient(ellipse at 50% 40%, #f7f9fb 0%, #e9eef4 100%); }
  .ambient-circle { opacity: .24; }
  .viewer-kicker { font-size: 9px; top: 12px; }
  .catalog-viewport { padding: 28px 12px 38px; }
  .viewer-hint { bottom: 10px; }
  .toolbar { display: flex; flex-wrap: nowrap; height: var(--toolbar-h); justify-content: center; gap: clamp(6px, 2.3vw, 14px); align-content: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .toolbar-group { gap: clamp(5px, 1.2vw, 10px); }
  .toolbar-left, .toolbar-right { flex: 0 0 auto; }
  .toolbar-center { flex: 0 0 auto; min-width: 0; }
  .page-indicator { align-items: center; min-width: 68px; }
  .page-indicator small { display: none; }
  .page-status { font-size: 13px; }
  .page-range, .zoom-label, .minor-control, .sound-disabled, .sound-enabled { display: none; }
  .tool-btn { width: 39px; height: 39px; flex-basis: 39px; border-radius: 11px; }
  .brand-mark { font-size: 17px; }
  .top-actions .icon-btn { width: 36px; height: 36px; }
}
@media (max-width: 380px) {
  .toolbar { gap: 7px; }
  .tool-btn { width: 36px; height: 36px; flex-basis: 36px; }
  .header-title { display: none; }
  .brand-divider { display: none; }
}
@media (max-width: 860px) and (max-height: 620px) {
  :root { --topbar-h: 49px; --toolbar-h: 58px; }
  .topbar { padding-top: 1px; padding-bottom: 1px; }
  .viewer-kicker, .viewer-hint { display: none; }
  .catalog-viewport { padding-top: 13px; padding-bottom: 15px; }
  .toolbar { padding: 5px 10px; }
  .tool-btn { width: 33px; height: 33px; flex-basis: 33px; }
}
