:root {
  color-scheme: dark;
  --bg: #09090C;
  --bg-elevated: #131318;
  --bg-muted: #1B1B23;
  --bg-glass: rgba(11, 11, 15, 0.78);
  --text: #F2EFE9;
  --text-secondary: #ACA69C;
  --text-muted: #726C63;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #D6A456;
  --accent-soft: rgba(214, 164, 86, 0.14);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 32px 84px rgba(0, 0, 0, 0.78);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-book: cubic-bezier(0.25, 0.9, 0.25, 1);
}

html[data-site-theme="light"] {
  color-scheme: light;
  --bg: #F6F4EF;
  --bg-elevated: #FFFFFF;
  --bg-muted: #ECE8DF;
  --bg-glass: rgba(246, 244, 239, 0.84);
  --text: #161513;
  --text-secondary: #5D5850;
  --text-muted: #8B847B;
  --border: rgba(22, 21, 19, 0.09);
  --border-strong: rgba(22, 21, 19, 0.16);
  --accent: #9E4725;
  --accent-soft: rgba(158, 71, 37, 0.10);
  --shadow-sm: 0 2px 10px rgba(22, 21, 19, 0.06);
  --shadow-md: 0 14px 34px rgba(22, 21, 19, 0.10);
  --shadow-lg: 0 26px 64px rgba(22, 21, 19, 0.18);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

html[data-site-theme="light"] * {
  scrollbar-color: rgba(22, 21, 19, 0.22) transparent;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

html[data-site-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(22, 21, 19, 0.18);
}

html[data-site-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(22, 21, 19, 0.34);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 440px at 50% -120px, color-mix(in srgb, var(--accent) 11%, transparent), transparent 72%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.35s var(--ease-out), color 0.35s var(--ease-out);
}

[hidden] {
  display: none !important;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button, a, .book-card, .continue-card, .upload-ghost-card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ================= TOPBAR ================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 13px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  background: none;
  border: none;
  padding: 4px 8px;
  margin-left: -8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform 0.32s var(--ease-out);
}

.brand:hover {
  transform: translateY(-1px);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  color: var(--accent);
  transition: transform 0.4s var(--ease-out), border-color 0.3s ease, box-shadow 0.3s ease;
}

.brand:hover .brand-mark {
  transform: rotate(-5deg) scale(1.06);
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--accent-soft);
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.header-search-wrap {
  position: relative;
  flex: 1;
  max-width: 430px;
  margin-left: auto;
}

.header-search-wrap .search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.25s ease;
}

.header-search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

.header-search-wrap input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.header-search-wrap:focus-within .search-ico {
  color: var(--accent);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--bg-muted);
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* BOTOES */
.btn-primary, .btn-secondary, .btn-ghost, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.btn-primary {
  height: 40px;
  padding: 0 18px;
  background: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-secondary {
  height: 40px;
  padding: 0 18px;
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  height: 38px;
  padding: 0 14px;
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 12.5px;
}

.btn-danger {
  color: #E06C6C;
  border-color: rgba(224, 108, 108, 0.30);
}

.btn-danger:hover {
  background: rgba(224, 108, 108, 0.12);
  border-color: #E06C6C;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}

.icon-btn:hover {
  transform: translateY(-2px) rotate(6deg);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

html[data-site-theme="light"] .sun-ico { display: none; }
html[data-site-theme="dark"] .moon-ico { display: none; }

#site-sound-toggle .sound-off-ico { display: none; }
#site-sound-toggle.is-muted .sound-on-ico { display: none; }
#site-sound-toggle.is-muted .sound-off-ico { display: block; opacity: 0.65; }

/* ================= HERO EDITORIAL CLEAN ================= */
.library-view {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 28px 86px;
}

.hero-section {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 4.3vw, 54px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  max-width: 780px;
}

.hero-subtitle {
  margin: 0;
  max-width: 640px;
  color: var(--text-secondary);
  font-size: 15.5px;
  line-height: 1.6;
}

/* ================= CONTINUAR LENDO ================= */
.continue-section {
  margin-top: 28px;
}

.section-head {
  margin-bottom: 12px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.continue-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.42s var(--ease-out), box-shadow 0.42s var(--ease-out), border-color 0.35s ease;
}

.continue-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, color-mix(in srgb, var(--card-accent, #D6A456) 16%, transparent), transparent 58%);
  opacity: 0.35;
  transition: opacity 0.4s var(--ease-out);
  pointer-events: none;
}

.continue-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--card-accent, #D6A456) 55%, var(--border));
  box-shadow: 0 20px 44px -12px color-mix(in srgb, var(--card-accent, #D6A456) 24%, rgba(0,0,0,0.65));
}

.continue-card:hover::before {
  opacity: 1;
}

.continue-thumb {
  width: 56px;
  height: 84px;
  position: relative;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
  transition: transform 0.5s var(--ease-out);
}

.continue-card:hover .continue-thumb {
  transform: perspective(700px) rotateY(-18deg) scale(1.06);
}

.continue-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.continue-info {
  flex: 1;
  min-width: 0;
  position: relative;
}

.continue-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--card-accent, var(--accent));
}

.continue-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  margin: 2px 0 3px;
}

.continue-chapter {
  font-size: 13.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.35s var(--ease-out);
}

.continue-card:hover .continue-cta {
  background: var(--card-accent, var(--accent));
  border-color: transparent;
  color: #FFFFFF;
}

.continue-cta svg {
  transition: transform 0.35s var(--ease-out);
}

.continue-card:hover .continue-cta svg {
  transform: translateX(4px);
}

/* ================= CONTROLES DA ESTANTE ================= */
.shelf-controls {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.28s var(--ease-out), background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.filter-pill:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--text);
}

.filter-pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.shelf-right-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-select {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.25s ease;
}

.sort-select:hover {
  border-color: var(--border-strong);
}

.view-switcher {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.view-btn {
  width: 30px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.view-btn:hover {
  color: var(--text);
}

.view-btn.active {
  background: var(--bg-muted);
  color: var(--text);
}

.mobile-only-view-btn {
  display: none;
}

.view-switcher[data-mode="grid"] #view-toggle-grid,
.view-switcher[data-mode="list"] #view-toggle-list {
  background: var(--bg-muted);
  color: var(--text);
}

/* ================= ESTANTE & LIVROS 3D INTERATIVOS ================= */
.shelf-stage {
  margin-top: 28px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 38px 30px;
  align-items: start;
}

.book-grid.is-list {
  grid-template-columns: 1fr;
  gap: 14px;
}

.book-card {
  --card-accent: #D6A456;
  --stagger-idx: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border-radius: var(--radius-md);
  outline: none;
  contain: layout style;
  animation: cardReveal 0.48s var(--ease-out) backwards;
  animation-delay: calc(var(--stagger-idx) * 55ms);
}

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 0) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

.book-stage {
  position: relative;
  perspective: 1400px;
  padding: 6px 10px 12px 4px;
}

/* Halo luminoso ambiental atras do livro (gradiente puro sem filter:blur para 120fps) */
.book-halo {
  position: absolute;
  inset: -6px -4px -8px -8px;
  border-radius: 26px;
  background: radial-gradient(ellipse 68% 64% at 50% 52%, color-mix(in srgb, var(--card-accent) 42%, transparent) 0%, color-mix(in srgb, var(--card-accent) 14%, transparent) 45%, transparent 74%);
  opacity: 0;
  transform: scale(0.92);
  will-change: opacity, transform;
  transition: opacity 0.4s var(--ease-out), transform 0.48s var(--ease-out);
  pointer-events: none;
  z-index: 0;
}

.book-object {
  position: relative;
  z-index: 1;
  aspect-ratio: 2 / 3;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.45s var(--ease-out);
}

/* Bloco interno de paginas que aparece quando a capa abre no hover */
.book-interior {
  position: absolute;
  inset: 4px 0 4px 4px;
  border-radius: 3px 10px 10px 3px;
  background: linear-gradient(135deg, #27221B 0%, #171410 100%);
  border: 1px solid rgba(235, 215, 175, 0.28);
  box-shadow:
    inset 14px 0 22px rgba(0, 0, 0, 0.58),
    0 16px 32px rgba(0, 0, 0, 0.58);
  transform: translateZ(-6px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 18px 20px 26px;
}

/* Filete lateral das paginas empilhadas */
.book-pages-stack {
  position: absolute;
  top: 2px;
  bottom: 2px;
  right: 0;
  width: 15px;
  background: repeating-linear-gradient(
    to right,
    #E4DBC9 0px,
    #E4DBC9 1.5px,
    #B6AB96 1.5px,
    #B6AB96 3px
  );
  opacity: 0.94;
  box-shadow: -3px 0 8px rgba(0, 0, 0, 0.35);
}

.book-interior-sheet {
  position: relative;
  z-index: 1;
  margin-right: 13px;
  height: 100%;
  border: 1px solid rgba(214, 164, 86, 0.32);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #E7DFD0;
}

.book-interior-kicker {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #D6A456;
}

.book-interior-title {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.15;
  color: #FAF6EE;
}

.book-interior-cta {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #D6A456;
}

/* Capa dura frontal articulada na lombada esquerda (nitida em repouso, 3D apenas no hover) */
.book-front-leaf {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px 11px 11px 4px;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.52s var(--ease-book), box-shadow 0.45s var(--ease-out);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.44);
}

.book-front-face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px 11px 11px 4px;
  overflow: hidden;
  backface-visibility: hidden;
  background: #141316;
}

.book-front-face .book-bitmap-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* CAPA VETORIAL PADRONIZADA (MESMA GRADE DO PDF E EPUB) */
.book-edition-cover {
  container-type: size;
  position: relative;
  width: 100%;
  height: 100%;
  color: #F6F2E8;
  overflow: hidden;
  font-family: var(--font-serif);
  user-select: none;
}

.bec-border {
  position: absolute;
  top: 3.4cqh;
  bottom: 3.4cqh;
  left: 5cqw;
  right: 5cqw;
  border: 1.4px solid var(--cov-gold, #D4A55A);
  opacity: 0.78;
  pointer-events: none;
  z-index: 2;
}

.bec-border-inner {
  position: absolute;
  top: 4.5cqh;
  bottom: 4.5cqh;
  left: 6.6cqw;
  right: 6.6cqw;
  border: 0.75px solid var(--cov-gold, #D4A55A);
  opacity: 0.38;
  pointer-events: none;
  z-index: 2;
}

.bec-grid {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 6.8cqh 8cqw 5.4cqh 8cqw;
  display: grid;
  grid-template-rows: 26% 54% 20%;
  align-items: center;
  justify-items: center;
}

.bec-top {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr 4.2cqh;
  align-items: center;
  justify-items: center;
  text-align: center;
  padding-top: 0.5cqh;
}

.bec-kicker {
  font-family: var(--font-sans);
  font-size: 1.15cqh;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--cov-gold, #D4A55A);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bec-title {
  font-family: var(--font-display);
  font-size: 4.75cqh;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.04;
  color: #FAF4E8;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
}

.book-edition-cover.is-two-lines .bec-title {
  font-size: 4.15cqh;
}

.bec-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.48cqh;
  line-height: 1.28;
  color: #DECDB4;
  max-width: 98%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bec-mid {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bec-art-frame {
  height: 89%;
  aspect-ratio: 3 / 4;
  border: 1.4px solid var(--cov-gold, #D4A55A);
  overflow: hidden;
  background: #0F0D0E;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.58);
}

.bec-art-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--cov-art-pos, center 45%);
  display: block;
}

.bec-bottom {
  width: 92%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  align-items: center;
  text-align: center;
  padding-top: 5.4cqh;
  padding-bottom: 0.4cqh;
}

.bec-bottom-line {
  width: 100%;
  height: 100%;
  border-top: 1px solid color-mix(in srgb, var(--cov-gold, #D4A55A) 44%, transparent);
  padding-top: 1.2cqh;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
}

.bec-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.45cqh;
  line-height: 1.32;
  color: #D4C3AA;
  margin-bottom: 0.5cqh;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bec-edition {
  font-family: var(--font-sans);
  font-size: 1.05cqh;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cov-gold, #D4A55A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Miniaturas muito pequenas (Continuar lendo e Modo Lista) */
.book-edition-cover.is-mini .bec-border-inner,
.book-edition-cover.is-mini .bec-kicker,
.book-edition-cover.is-mini .bec-subtitle,
.book-edition-cover.is-mini .bec-bottom,
.book-grid.is-list .bec-border-inner,
.book-grid.is-list .bec-kicker,
.book-grid.is-list .bec-subtitle,
.book-grid.is-list .bec-bottom {
  display: none;
}

.book-edition-cover.is-mini .bec-border,
.book-grid.is-list .bec-border {
  top: 4cqh;
  bottom: 4cqh;
  left: 5.5cqw;
  right: 5.5cqw;
  border-width: 1px;
}

.book-edition-cover.is-mini .bec-grid,
.book-grid.is-list .bec-grid {
  padding: 10cqh 12cqw;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 5cqh;
  align-items: center;
  justify-items: center;
}

.book-edition-cover.is-mini .bec-top,
.book-grid.is-list .bec-top {
  display: block;
  height: auto;
  padding-top: 0;
}

.book-edition-cover.is-mini .bec-title,
.book-grid.is-list .bec-title {
  font-size: 6.4cqh;
  line-height: 1.06;
  letter-spacing: 0.03em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-edition-cover.is-mini.is-two-lines .bec-title,
.book-grid.is-list .book-edition-cover.is-two-lines .bec-title {
  font-size: 5.6cqh;
}

.book-edition-cover.is-mini .bec-mid,
.book-grid.is-list .bec-mid {
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.book-edition-cover.is-mini .bec-art-frame,
.book-grid.is-list .bec-art-frame {
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  width: auto;
  aspect-ratio: 3 / 4;
  border-width: 1px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

.book-spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 16px;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.56) 0%,
    rgba(255, 255, 255, 0.18) 34%,
    rgba(0, 0, 0, 0.28) 64%,
    rgba(0, 0, 0, 0) 100%
  );
  pointer-events: none;
  z-index: 3;
}

.book-sheen {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 220px at 50% 50%,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0.03) 44%,
    transparent 72%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 3;
}

/* Fallback tipografico elegante */
.book-generated-cover {
  width: 100%;
  height: 100%;
  padding: 24px 20px 20px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #FAF6EE;
  background: radial-gradient(circle at 28% 20%, color-mix(in srgb, var(--card-accent) 62%, #111), #0F0E12 85%);
  position: relative;
}

.book-generated-cover::after {
  content: "";
  position: absolute;
  inset: 12px 12px 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.gen-cover-kicker {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.78;
}

.gen-cover-title {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.1;
}

.gen-cover-foot {
  font-size: 11px;
  opacity: 0.72;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 8px;
}

/* Barra frosted-glass de acoes no hover */
.book-quick-actions {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  gap: 8px;
  padding: 7px;
  border-radius: 12px;
  background: rgba(12, 12, 16, 0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transition: opacity 0.34s var(--ease-out), transform 0.4s var(--ease-out);
}

.quick-btn {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.22s var(--ease-out), color 0.2s ease;
}

.quick-btn.read {
  background: #F4F0E8;
  color: #111114;
}

.quick-btn.read:hover {
  background: #FFFFFF;
  transform: translateY(-1px);
}

.quick-btn.info {
  background: rgba(255, 255, 255, 0.12);
  color: #F4F0E8;
}

.quick-btn.info:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* HOVER PRINCIPAL: LEVITA + INCLINA + CAPA ABRE NA LOMBADA */
.book-card:hover .book-halo,
.book-card:focus-visible .book-halo {
  opacity: 0.95;
  transform: scale(1.04) translateY(-6px);
}

.book-card:hover .book-object,
.book-card:focus-visible .book-object {
  transform: translate3d(0, -14px, 0) scale(1.03);
}

.book-card:hover .book-front-leaf,
.book-card:focus-visible .book-front-leaf {
  transform: rotateY(-24deg);
  box-shadow: 12px 22px 34px -8px rgba(0, 0, 0, 0.68);
}

.book-card:hover .book-sheen {
  opacity: 1;
}

.book-card:hover .book-quick-actions,
.book-card:focus-within .book-quick-actions {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Metadados minimalistas abaixo da capa (sem indicadores) */
.book-meta {
  padding: 12px 4px 4px;
}

.book-universe {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--card-accent);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-title {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.12;
  margin: 0 0 5px;
  transition: color 0.28s ease, transform 0.35s var(--ease-out);
}

.book-card:hover .book-title {
  color: color-mix(in srgb, var(--card-accent) 70%, #FFFFFF);
}

.book-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* MODO LISTA */
.book-grid.is-list .book-card {
  flex-direction: row;
  align-items: center;
  gap: 22px;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.3s ease;
}

.book-grid.is-list .book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--card-accent) 55%, var(--border));
}

.book-grid.is-list .book-stage {
  width: 80px;
  flex-shrink: 0;
  padding: 0;
}

.book-grid.is-list .book-halo,
.book-grid.is-list .book-interior,
.book-grid.is-list .book-quick-actions {
  display: none;
}

.book-grid.is-list .book-card:hover .book-object {
  transform: translateY(-2px);
}

.book-grid.is-list .book-card:hover .book-front-leaf {
  transform: rotateY(-14deg);
}

.book-grid.is-list .book-meta {
  flex: 1;
  padding: 0;
}

/* CARD FANTASMA DE UPLOAD NA ESTANTE */
.upload-ghost-card {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  cursor: pointer;
  transition: transform 0.45s var(--ease-out), border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.45s var(--ease-out);
}

.upload-ghost-card:hover {
  transform: translateY(-10px);
  border-style: solid;
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.55);
}

.ghost-icon-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  transition: transform 0.42s var(--ease-out), background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.upload-ghost-card:hover .ghost-icon-circle {
  transform: scale(1.12) rotate(90deg);
  background: var(--accent);
  border-color: transparent;
  color: #111114;
}

.upload-ghost-card strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.upload-ghost-card span {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 210px;
}

.book-grid.is-list .upload-ghost-card {
  aspect-ratio: auto;
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  gap: 18px;
  padding: 18px 22px;
}

.book-grid.is-list .ghost-icon-circle {
  margin-bottom: 0;
  width: 46px;
  height: 46px;
}

.library-empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ================= PALCO 3D DE ABERTURA DO LIVRO ================= */
.book-open-overlay {
  --open-accent: #D6A456;
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.book-open-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--open-accent) 16%, #0B0B0E) 0%, #050507 76%);
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.24s ease;
}

.book-open-overlay.is-opening .book-open-scrim {
  opacity: 1;
}

.book-stage-3d {
  position: relative;
  z-index: 2;
  perspective: 2000px;
  width: min(340px, 72vw);
  aspect-ratio: 2 / 3;
}

.book-3d-assembly {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  transform: translate3d(0, 22px, 0) scale(0.80) rotateY(6deg);
  opacity: 0;
}

.book-open-overlay.is-opening .book-3d-assembly {
  animation: bookRiseIn 0.76s var(--ease-book) forwards;
}

.book-open-overlay.is-entering .book-3d-assembly {
  animation: bookZoomIntoReader 0.26s var(--ease-out) forwards;
}

.book-open-overlay.is-entering .book-open-scrim {
  opacity: 0;
  transition: opacity 0.24s ease;
}

@keyframes bookRiseIn {
  0% {
    opacity: 0;
    transform: translate3d(0, 22px, 0) scale(0.80) rotateY(6deg);
  }
  30% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(0.98) rotateY(2deg);
  }
  100% {
    opacity: 1;
    transform: translate3d(20%, 0, 0) scale(1.04) rotateY(-4deg);
  }
}

@keyframes bookZoomIntoReader {
  from {
    opacity: 1;
    transform: translate3d(20%, 0, 0) scale(1.04) rotateY(-4deg);
  }
  to {
    opacity: 0;
    transform: translate3d(12%, 0, 0) scale(1.24) rotateY(0deg);
  }
}

.book-3d-back {
  position: absolute;
  inset: 0;
  border-radius: 4px 12px 12px 4px;
  background: #101014;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateZ(-10px);
}

.book-3d-pages {
  position: absolute;
  inset: 4px 4px 4px 2px;
  border-radius: 2px 9px 9px 2px;
  background: linear-gradient(to right, #131217 0%, #1B1920 22%, #17161B 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  transform: translateZ(-2px);
  display: flex;
  padding: 28px 22px 26px 32px;
}

.book-3d-inner-page {
  width: 100%;
  height: 100%;
  border: 1px solid color-mix(in srgb, var(--open-accent) 34%, transparent);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  color: #F2EFE9;
}

.open-book-kicker {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--open-accent);
  margin-bottom: 10px;
}

.open-book-title {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  margin: 0;
}

.open-book-rule {
  width: 44px;
  height: 1.5px;
  background: var(--open-accent);
  margin: 14px 0;
  opacity: 0.8;
}

.open-book-chapter {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13.5px;
  color: #B4AEA3;
}

/* Folhas animadas folheando (otimizadas para GPU) */
.book-3d-flip-sheet {
  position: absolute;
  inset: 5px 6px 5px 2px;
  border-radius: 2px 9px 9px 2px;
  background: linear-gradient(to right, #23201B 0%, #19171B 24%, #141318 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform-origin: left center;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.book-open-overlay.is-opening .sheet-1 {
  animation: sheetFlip 0.56s var(--ease-book) 0.12s forwards;
}

.book-open-overlay.is-opening .sheet-2 {
  animation: sheetFlip 0.56s var(--ease-book) 0.24s forwards;
}

@keyframes sheetFlip {
  0% {
    transform: rotateY(0deg);
    opacity: 0.95;
  }
  65% {
    opacity: 0.95;
  }
  100% {
    transform: rotateY(-158deg);
    opacity: 0.25;
  }
}

/* Capa frontal 3D com frente e verso */
.book-3d-front-cover {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}

.book-open-overlay.is-opening .book-3d-front-cover {
  animation: coverSwingOpen 0.70s var(--ease-book) 0.04s forwards;
}

@keyframes coverSwingOpen {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(-165deg);
  }
}

.book-3d-cover-front,
.book-3d-cover-inside {
  position: absolute;
  inset: 0;
  border-radius: 4px 12px 12px 4px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.book-3d-cover-front {
  background: #141317;
}

.book-3d-cover-front .book-bitmap-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-3d-cover-inside {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #16151A 0%, #0E0E12 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-inside-frame {
  width: 100%;
  height: 100%;
  border: 1px solid color-mix(in srgb, var(--open-accent) 42%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  gap: 8px;
  color: #DFD8CB;
}

.cover-inside-frame span {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--open-accent);
}

.cover-inside-frame strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}

/* ================= MODAIS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.22s ease;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.72);
  backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(90vh, 880px);
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalRise 0.34s var(--ease-out);
}

.modal-panel-lg {
  max-width: 860px;
}

.modal-panel-upload {
  max-width: 820px;
  padding: 28px 30px;
}

.modal-panel-search {
  max-width: 680px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.28s var(--ease-out), background-color 0.2s ease, border-color 0.2s ease;
}

.modal-close-btn:hover {
  transform: rotate(90deg);
  background: var(--bg-muted);
  border-color: var(--accent);
}

/* Dossie limpo */
.dossier-hero {
  position: relative;
  height: 195px;
  background: #0D0D11;
  overflow: hidden;
}

.dossier-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.65;
}

.dossier-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg-elevated) 2%, rgba(0, 0, 0, 0.22) 100%);
}

.dossier-body {
  padding: 0 30px 30px;
  margin-top: -68px;
  position: relative;
  z-index: 2;
}

.dossier-top {
  display: flex;
  gap: 24px;
  align-items: flex-end;
}

.dossier-cover {
  width: 136px;
  aspect-ratio: 2 / 3;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--bg-elevated);
  background: #141317;
}

.dossier-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dossier-heading {
  flex: 1;
  padding-bottom: 6px;
}

.dossier-heading h2 {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.08;
  margin: 4px 0 6px;
}

.dossier-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14.5px;
}

.dossier-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.dossier-epigraph {
  margin: 22px 0 0;
  padding: 14px 18px;
  border-left: 3px solid var(--card-accent, var(--accent));
  background: var(--bg-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-secondary);
}

.dossier-toc-wrap {
  margin-top: 26px;
}

.dossier-toc-wrap h3 {
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.dossier-toc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 4px;
}

.dossier-toc-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: transform 0.28s var(--ease-out), border-color 0.2s ease, background-color 0.2s ease;
}

.dossier-toc-item:hover {
  transform: translateX(4px);
  border-color: var(--card-accent, var(--accent));
  background: var(--bg-muted);
}

.dossier-toc-item small {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dossier-toc-item span {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.32;
  margin-top: 2px;
}

/* ================= UPLOAD MODAL ================= */
.upload-header h2 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 4px 0 6px;
}

.upload-header p {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.upload-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 36px 24px;
  text-align: center;
  background: var(--bg);
  transition: border-color 0.28s ease, background-color 0.28s ease;
}

.upload-dropzone.is-dragover,
.upload-dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-glyph {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transition: transform 0.35s var(--ease-out);
}

.upload-dropzone:hover .dropzone-glyph {
  transform: translateY(-4px) scale(1.06);
}

.dropzone-title {
  font-size: 16.5px;
  font-weight: 600;
  margin-bottom: 5px;
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.dropzone-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.upload-parse-status {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  font-size: 13.5px;
  color: var(--text-secondary);
}

.upload-editor {
  margin-top: 18px;
}

.upload-editor-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
}

.upload-preview-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #141317;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}

.upload-preview-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-preview-stats {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-row input,
.field-row select,
.field-row textarea {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.accent-swatch-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.accent-swatch-btn:hover {
  transform: scale(1.12);
}

.accent-swatch-btn.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg-elevated) inset;
}

.upload-progress-wrap {
  margin-top: 14px;
}

.upload-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
  margin-bottom: 6px;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.upload-progress-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ================= GLOBAL DROP & TOAST ================= */
.global-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(6, 6, 8, 0.80);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.global-drop-card {
  border: 2px dashed rgba(214, 164, 86, 0.55);
  border-radius: var(--radius-lg);
  padding: 46px 56px;
  text-align: center;
  color: #F2EFE9;
  background: rgba(255, 255, 255, 0.04);
}

.global-drop-card h3 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 12px 0 6px;
}

.global-drop-card p {
  margin: 0;
  opacity: 0.8;
}

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: modalRise 0.28s var(--ease-out);
}

.toast.is-error {
  background: #8B2222;
  color: #FFFFFF;
  border-color: transparent;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalRise {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (hover: none), (pointer: coarse) {
  .brand:hover,
  .btn-primary:hover,
  .btn-secondary:hover,
  .icon-btn:hover,
  .filter-pill:hover,
  .continue-card:hover,
  .upload-ghost-card:hover,
  .book-card:hover .book-object,
  .book-card:focus-visible .book-object,
  .book-grid.is-list .book-card:hover,
  .book-grid.is-list .book-card:hover .book-object {
    transform: none;
  }

  .book-card:hover .book-front-leaf,
  .book-card:focus-visible .book-front-leaf,
  .book-grid.is-list .book-card:hover .book-front-leaf {
    transform: none;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.44);
  }

  .book-card:hover .book-halo,
  .book-card:focus-visible .book-halo,
  .book-card:hover .book-sheen {
    opacity: 0;
  }

  .continue-card:hover .continue-thumb {
    transform: none;
  }

  .continue-card:hover {
    box-shadow: none;
    border-color: var(--border);
  }

  .continue-card:hover::before {
    opacity: 0.35;
  }

  .book-quick-actions {
    display: none;
  }

  .book-card:active .book-object,
  .continue-card:active {
    transform: scale(0.985);
  }
}

@keyframes bookRiseInMobile {
  0% {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.84) rotateY(6deg);
  }
  28% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(0.98) rotateY(2deg);
  }
  100% {
    opacity: 1;
    transform: translate3d(47%, 0, 0) scale(1) rotateY(-3deg);
  }
}

@keyframes bookZoomIntoReaderMobile {
  from {
    opacity: 1;
    transform: translate3d(47%, 0, 0) scale(1) rotateY(-3deg);
  }
  to {
    opacity: 0;
    transform: translate3d(28%, 0, 0) scale(1.16) rotateY(0deg);
  }
}

@media (max-width: 900px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px 12px;
    padding: 10px 18px;
  }
  .brand {
    order: 1;
  }
  .header-actions {
    order: 2;
    margin-left: auto;
    gap: 8px;
  }
  .header-search-wrap {
    order: 3;
    flex: 0 0 100%;
    max-width: none;
    width: 100%;
    margin-left: 0;
  }
  .upload-editor-grid {
    grid-template-columns: 1fr;
  }
  .upload-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .upload-preview-cover {
    max-width: 170px;
    margin: 0 auto 10px;
  }
  .dossier-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
}

@media (max-width: 720px) {
  .book-stage-3d {
    width: min(172px, 41vw);
    perspective: 1400px;
  }
  .book-open-overlay.is-opening .book-3d-assembly {
    animation: bookRiseInMobile 0.76s var(--ease-book) forwards;
  }
  .book-open-overlay.is-entering .book-3d-assembly {
    animation: bookZoomIntoReaderMobile 0.26s var(--ease-out) forwards;
  }
  .book-3d-pages {
    padding: 14px 10px 14px 14px;
  }
  .book-3d-inner-page {
    padding: 12px 10px;
  }
  .open-book-kicker {
    font-size: 7.5px;
    letter-spacing: 0.12em;
    margin-bottom: 6px;
  }
  .open-book-title {
    font-size: 15.5px;
    line-height: 1.12;
  }
  .open-book-rule {
    width: 28px;
    margin: 9px 0;
  }
  .open-book-chapter {
    font-size: 10.5px;
    line-height: 1.3;
  }
  .book-3d-cover-inside {
    padding: 10px;
  }
  .cover-inside-frame {
    padding: 10px;
    gap: 5px;
  }
  .cover-inside-frame span {
    font-size: 8px;
    letter-spacing: 0.16em;
  }
  .cover-inside-frame strong {
    font-size: 13px;
    line-height: 1.15;
  }
}

@media (max-width: 680px) {
  .header-inner {
    padding: 10px 14px;
    gap: 9px 10px;
  }
  .brand {
    gap: 8px;
    padding: 2px 4px;
    margin-left: -4px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .brand-text strong {
    font-size: 20px;
  }
  .header-actions {
    gap: 6px;
  }
  .header-actions .icon-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }
  .header-actions .btn-primary {
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .header-search-wrap input {
    height: 38px;
    font-size: 15px;
    padding: 0 36px 0 38px;
  }

  .library-view {
    padding: 22px 16px 64px;
  }
  .hero-section {
    padding-bottom: 20px;
  }
  .hero-eyebrow {
    font-size: 10.5px;
    margin-bottom: 8px;
  }
  .hero-title {
    font-size: clamp(28px, 8vw, 38px);
    line-height: 1.08;
    margin-bottom: 10px;
  }
  .hero-subtitle {
    font-size: 14px;
    line-height: 1.55;
  }

  .continue-section {
    margin-top: 22px;
  }
  .continue-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    gap: 14px 15px;
    padding: 15px 16px;
    border-radius: 16px;
  }
  .continue-thumb {
    width: 58px;
    height: 87px;
    grid-column: 1;
    grid-row: 1;
  }
  .continue-info {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .continue-kicker {
    font-size: 10.5px;
    letter-spacing: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .continue-title {
    font-size: 21px;
    line-height: 1.16;
    margin: 3px 0 4px;
  }
  .continue-chapter {
    font-size: 13px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .continue-cta {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 13px;
    background: color-mix(in srgb, var(--card-accent, var(--accent)) 16%, var(--bg-muted));
    border-color: color-mix(in srgb, var(--card-accent, var(--accent)) 34%, var(--border));
    color: var(--text);
  }

  .shelf-controls {
    margin-top: 22px;
    flex-direction: column;
    align-items: stretch;
    gap: 11px;
  }
  .filter-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 7px;
    margin: 0 -16px;
    padding: 0 16px 2px;
  }
  .filter-pills::-webkit-scrollbar {
    display: none;
  }
  .filter-pill {
    flex: 0 0 auto;
    white-space: nowrap;
    height: 34px;
    padding: 0 14px;
    font-size: 12.5px;
  }
  .shelf-right-controls {
    width: 100%;
    justify-content: space-between;
  }
  .sort-select {
    flex: 1;
    max-width: 210px;
  }

  .mobile-only-view-btn {
    display: inline-flex;
  }
  .view-switcher[data-mode="grid"][data-mobile-cols="1"] #view-toggle-grid {
    background: transparent;
    color: var(--text-muted);
  }
  .view-switcher[data-mode="grid"][data-mobile-cols="1"] #view-toggle-single {
    background: var(--bg-muted);
    color: var(--text);
  }
  .view-switcher[data-mode="grid"][data-mobile-cols="2"] #view-toggle-grid {
    background: var(--bg-muted);
    color: var(--text);
  }
  .view-switcher[data-mode="list"] #view-toggle-list {
    background: var(--bg-muted);
    color: var(--text);
  }

  .shelf-stage {
    margin-top: 20px;
  }
  .book-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .book-card {
    width: 100%;
    max-width: 296px;
    margin: 0 auto;
  }
  .book-stage {
    padding: 4px 6px 10px 4px;
  }
  .book-meta {
    padding: 10px 4px 2px;
  }
  .book-universe {
    font-size: 11px;
    letter-spacing: 0.10em;
    margin-bottom: 4px;
  }
  .book-title {
    font-size: 24px;
    line-height: 1.14;
    margin: 0 0 5px;
  }
  .book-subtitle {
    font-size: 13px;
    line-height: 1.48;
  }

  .book-grid.is-mobile-2col:not(.is-list) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 14px;
  }
  .book-grid.is-mobile-2col:not(.is-list) .book-card {
    max-width: none;
    margin: 0;
  }
  .book-grid.is-mobile-2col:not(.is-list) .book-stage {
    padding: 2px 2px 6px 2px;
  }
  .book-grid.is-mobile-2col:not(.is-list) .book-meta {
    padding: 8px 2px 2px;
  }
  .book-grid.is-mobile-2col:not(.is-list) .book-universe {
    font-size: 9.5px;
    letter-spacing: 0.08em;
    margin-bottom: 3px;
  }
  .book-grid.is-mobile-2col:not(.is-list) .book-title {
    font-size: 18px;
    line-height: 1.14;
    margin: 0 0 4px;
  }
  .book-grid.is-mobile-2col:not(.is-list) .book-subtitle {
    font-size: 11.5px;
    line-height: 1.4;
  }
  .upload-ghost-card {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    gap: 14px;
    padding: 16px 18px;
  }
  .upload-ghost-card .ghost-icon-circle {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    margin-bottom: 0;
  }
  .upload-ghost-card strong {
    font-size: 19px;
    margin-bottom: 2px;
    display: block;
  }
  .upload-ghost-card span {
    font-size: 12px;
    max-width: none;
    display: block;
  }
  .book-grid.is-list {
    grid-template-columns: 1fr;
    gap: 11px;
  }
  .book-grid.is-list .book-card {
    max-width: none;
    margin: 0;
    gap: 14px;
    padding: 12px 14px;
  }
  .book-grid.is-list .book-stage {
    width: 60px;
  }
  .book-grid.is-list .book-title {
    font-size: 19px;
  }

  .modal-backdrop {
    padding: 12px;
  }
  .modal-panel {
    max-height: calc(100dvh - 24px);
    border-radius: 16px;
  }
  .modal-panel-upload {
    padding: 20px 16px;
  }
  .modal-close-btn {
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    font-size: 18px;
  }
  .upload-header h2 {
    font-size: 24px;
    padding-right: 34px;
  }
  .upload-dropzone {
    padding: 24px 14px;
  }
  .dropzone-buttons {
    flex-direction: column;
  }
  .dropzone-buttons .btn-primary,
  .dropzone-buttons .btn-secondary {
    width: 100%;
  }
  .field-row-2 {
    grid-template-columns: 1fr;
  }
  .field-row input,
  .field-row select,
  .field-row textarea {
    font-size: 16px;
  }
  .upload-footer {
    flex-direction: column-reverse;
  }
  .upload-footer button {
    width: 100%;
  }
  .dossier-hero {
    height: 140px;
  }
  .dossier-body {
    padding: 0 18px 22px;
    margin-top: -54px;
  }
  .dossier-cover {
    width: 106px;
  }
  .dossier-heading h2 {
    font-size: 26px;
  }
  .dossier-subtitle {
    font-size: 13.5px;
  }
  .dossier-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
  }
  .dossier-actions .btn-primary {
    grid-column: 1 / -1;
    width: 100%;
  }
  .dossier-actions .btn-secondary,
  .dossier-actions .btn-ghost {
    width: 100%;
  }
  .dossier-toc-list {
    grid-template-columns: 1fr;
    max-height: 240px;
  }
  .toast-root {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}

@media (max-width: 380px) {
  .brand-text strong {
    font-size: 19px;
  }
  .header-actions .btn-primary {
    padding: 0 10px;
    font-size: 11.5px;
  }
}
