/* =========================================================
   LAIF — Your life is a story.
   Folha de estilos única do aplicativo.
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  /* Papel e tinta */
  --paper: #F3ECDF;
  --paper-deep: #EAE0CE;
  --card: #FBF7EF;
  --white: #FFFDF8;
  --ink: #241C16;
  --ink-2: #5A4D42;
  --ink-3: #6B6157; /* contraste 5,1:1 no papel (mínimo recomendado para texto pequeno: 4,5:1) */
  --line: rgba(36, 28, 22, 0.11);
  --line-strong: rgba(36, 28, 22, 0.2);

  /* Cores de destaque */
  --wine: #6B1E2C;
  --forest: #2E4A3B;
  --navy: #1D2D4A;
  --gold: #B08A4A;
  --danger: #8E2A2A;

  /* Madeira da estante */
  --wood-1: #9C7451;
  --wood-2: #7E5A3B;
  --wood-3: #5F412A;

  /* Tipografia */
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Forma */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(36, 28, 22, 0.05), 0 10px 28px -16px rgba(36, 28, 22, 0.35);
  --shadow-2: 0 2px 4px rgba(36, 28, 22, 0.06), 0 24px 48px -24px rgba(36, 28, 22, 0.45);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Contexto do livro (redefinido por página) */
  --book: #6B1E2C;
  --book-ink: #F6EFE2;
  --accent: #6B1E2C;

  --gutter: clamp(16px, 4vw, 44px);
  --topbar-h: 64px;
}

/* ---------- 2. Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 50% -200px, rgba(255, 252, 244, 0.9), transparent 70%),
    radial-gradient(900px 500px at 100% 100%, rgba(214, 196, 166, 0.25), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body:has(dialog[open]) { overflow: hidden; }

img, video { max-width: 100%; display: block; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.i {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.eyebrow {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.display {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.5rem, 6vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
}

/* ---------- 3. Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 236, 223, 0.82);
  backdrop-filter: saturate(1.2) blur(14px);
  -webkit-backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: none;
}

.brand-mark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: 0.22em;
  line-height: 1;
  color: var(--ink);
}

.brand-tag {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-3);
}

.crumbs {
  margin-left: auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

.crumb-trail {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.crumb-trail li {
  display: flex;
  align-items: center;
  min-width: 0;
  white-space: nowrap;
}

.crumb-trail li + li::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--line-strong);
  margin: 0 12px;
  flex: none;
}

.crumb-trail a,
.crumb-trail [aria-current] {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.crumb-trail a { transition: color 0.2s; }
.crumb-trail a:hover { color: var(--ink); }
.crumb-trail [aria-current] { color: var(--ink); font-weight: 500; }

.crumb-back { display: none; }

/* ---------- 4. Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.25s var(--ease), transform 0.25s var(--ease), border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px) scale(0.99); }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 8px 20px -10px rgba(36, 28, 22, 0.6);
}
.btn-primary:hover { background: #3a2e25; box-shadow: 0 12px 26px -12px rgba(36, 28, 22, 0.7); }

.btn-ghost {
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: rgba(36, 28, 22, 0.05); }

.btn-soft {
  background: var(--paper-deep);
  color: var(--ink);
}
.btn-soft:hover { background: #E2D6C0; }

.btn-text {
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink-2);
}
.btn-text:hover { color: var(--ink); background: rgba(36, 28, 22, 0.05); }
.btn-text.danger { color: var(--danger); }
.btn-text.danger:hover { background: rgba(142, 42, 42, 0.07); }

.btn-danger {
  background: var(--danger);
  color: #FFF8F2;
}
.btn-danger:hover { background: #7A2121; }

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

/* Botões sobre fundos escuros (capas) */
.on-cover .btn-primary {
  background: var(--book-ink);
  color: var(--book);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.5);
}
.on-cover .btn-primary:hover { filter: brightness(1.05); }
.on-cover .btn-ghost {
  border-color: color-mix(in srgb, var(--book-ink) 40%, transparent);
  color: var(--book-ink);
}
.on-cover .btn-ghost:hover { background: color-mix(in srgb, var(--book-ink) 12%, transparent); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex: none;
}
.icon-btn:hover { background: rgba(36, 28, 22, 0.07); color: var(--ink); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm .i { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); background: rgba(142, 42, 42, 0.08); }

/* ---------- 5. Vistas ---------- */
.app { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

.view.enter { animation: view-in 0.55s var(--ease) both; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.state-message {
  max-width: 520px;
  margin: 18vh auto 0;
  padding: 0 var(--gutter);
  text-align: center;
  color: var(--ink-2);
}
.state-message h1 { font-family: var(--serif); font-weight: 500; font-size: 2rem; color: var(--ink); margin-bottom: 10px; }

/* ---------- 6. Capa de livro (componente) ---------- */
.cover {
  --foil: #E2C994;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  container-type: inline-size;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  color: var(--ink);
  background-color: var(--cover);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 1px 1px rgba(30, 18, 8, 0.18),
    0 24px 32px -20px rgba(30, 18, 8, 0.7);
}

/* Dobra da lombada e brilho do tecido, sempre por cima da arte da capa */
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.30) 0,
      rgba(0, 0, 0, 0.10) 4.5%,
      rgba(255, 255, 255, 0.14) 6%,
      rgba(255, 255, 255, 0) 9.5%,
      rgba(255, 255, 255, 0) 92%,
      rgba(0, 0, 0, 0.10) 100%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.10), rgba(0, 0, 0, 0.16));
}

/* Capa personalizada: elementos posicionados em % da capa e tamanhos em cqi */
.cover-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.cel {
  position: absolute;
  display: block;
  box-sizing: border-box;
  transform-origin: 50% 50%;
}

.cel-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.cel-shape svg,
.cel-drawing img,
.cel-drawing canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cel-image .cel-clip {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

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

.cel-image[data-border="print"] { background: #FFFDF8; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28); }
.cel-image[data-border="shadow"] .cel-clip { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); }
.cel-image[data-fshape="rounded"],
.cel-image[data-fshape="rounded"] .cel-clip { border-radius: 9%; }
.cel-image[data-fshape="circle"],
.cel-image[data-fshape="circle"] .cel-clip { border-radius: 50%; }
.cel-image[data-fshape="arch"],
.cel-image[data-fshape="arch"] .cel-clip { border-radius: 999px 999px 4px 4px; }

.cover-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5cqi;
  padding: 16cqi 11cqi 18cqi 15cqi;
  text-align: center;
}

.cover-frame {
  position: absolute;
  inset: 6cqi 6cqi 6cqi 10cqi;
  border: 1px solid color-mix(in srgb, var(--foil) 55%, transparent);
  border-radius: 2px;
  pointer-events: none;
}

.cover-rule {
  display: flex;
  align-items: center;
  gap: 3cqi;
  color: var(--foil);
}
.cover-rule::before,
.cover-rule::after {
  content: "";
  width: 12cqi;
  height: 1px;
  background: currentColor;
  opacity: 0.8;
}
.cover-rule span {
  width: 2.4cqi; height: 2.4cqi;
  transform: rotate(45deg);
  border: 1px solid currentColor;
}

.cover-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 12.5cqi;
  line-height: 1.02;
  letter-spacing: -0.005em;
  color: var(--ink);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-sub {
  font-family: var(--sans);
  font-size: 4.4cqi;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.78;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-mark {
  position: absolute;
  left: 4cqi; right: 0;
  bottom: 9cqi;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 4.6cqi;
  letter-spacing: 0.42em;
  color: var(--foil);
  text-align: center;
}

.cover.has-plate .cover-inner {
  justify-content: flex-start;
  padding-top: 13cqi;
  gap: 4.5cqi;
}

.cover.has-plate .cover-title { font-size: 10.5cqi; -webkit-line-clamp: 3; }
.cover.has-plate .cover-sub { -webkit-line-clamp: 2; }

.cover-plate {
  width: 68cqi;
  aspect-ratio: 1 / 1;
  padding: 2cqi;
  border: 1px solid color-mix(in srgb, var(--foil) 70%, transparent);
  background: color-mix(in srgb, var(--cover) 80%, black);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  flex: none;
}

.cover-plate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- 7. Biblioteca ---------- */
.lib-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(40px, 7vw, 88px) 0 clamp(36px, 5vw, 64px);
}

.lib-head .eyebrow { margin-bottom: 14px; }

.lede {
  margin-top: 16px;
  max-width: 460px;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.45;
  color: var(--ink-2);
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 17vw, 196px), 1fr));
  column-gap: 0;
  row-gap: clamp(34px, 5vw, 60px);
}

.slot {
  display: grid;
  grid-template-rows: 1fr auto auto;
  min-width: 0;
}

.slot .book {
  align-self: end;
  justify-self: center;
  width: calc(var(--s, 1) * (100% - 2 * clamp(14px, 2.2vw, 26px)));
}

.book {
  position: relative;
  display: block;
  isolation: isolate;
  transform-origin: 50% 100%;
  transition: transform 0.45s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

/* Páginas aparentes do lado direito */
.book::before {
  content: "";
  position: absolute;
  top: 2.2%;
  bottom: 1.5%;
  right: -5px;
  width: 10px;
  z-index: -1;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(90deg, #F5EEDF 0 1px, #DCD0B9 1px 2px);
  box-shadow: 2px 8px 12px -8px rgba(30, 18, 8, 0.5);
}

.book:hover,
.book:focus-visible { transform: translateY(-8px) rotate(-1.2deg); }
.book:hover .cover,
.book:focus-visible .cover {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 2px 2px rgba(30, 18, 8, 0.15),
    0 36px 40px -22px rgba(30, 18, 8, 0.75);
}
.book .cover { transition: box-shadow 0.45s var(--ease); }

.plank {
  position: relative;
  height: 15px;
  margin-top: -1px;
  background: linear-gradient(180deg, var(--wood-1) 0, var(--wood-2) 35%, var(--wood-3) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 220, 0.28),
    0 16px 18px -12px rgba(60, 35, 15, 0.55);
}

.plank::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 7px;
  background: linear-gradient(180deg, rgba(60, 35, 15, 0.16), transparent);
}

.slot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 46px;
  padding: 14px clamp(12px, 2vw, 22px) 0;
}

.slot-count {
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-actions {
  display: flex;
  gap: 2px;
  opacity: 0.0;
  transition: opacity 0.25s;
}

.slot:hover .slot-actions,
.slot:focus-within .slot-actions { opacity: 1; }

/* Espaço para um novo livro */
.book-new {
  width: 100%;
}

.new-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  aspect-ratio: 2 / 3;
  border-radius: 3px 8px 8px 3px;
  border: 1.5px dashed rgba(36, 28, 22, 0.25);
  color: var(--ink-3);
  background: rgba(255, 252, 244, 0.45);
  transition: border-color 0.3s, color 0.3s, background-color 0.3s;
}

.book-new::before { display: none; }
.book-new:hover .new-cover { border-color: var(--ink-2); color: var(--ink); background: rgba(255, 252, 244, 0.8); }

.new-plus {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid currentColor;
}
.new-plus .i { width: 20px; height: 20px; }

.new-label {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-style: italic;
}

.colophon {
  margin-top: clamp(56px, 8vw, 96px);
  text-align: center;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* ---------- 8. Página do livro ---------- */
.book-hero {
  position: relative;
  color: var(--book-ink);
  background-color: var(--book);
  background-image:
    radial-gradient(800px 420px at 20% 0%, rgba(255, 255, 255, 0.10), transparent 60%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.18));
  overflow: hidden;
}

.book-hero-inner {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-items: center;
  gap: clamp(32px, 6vw, 80px);
  padding-block: clamp(40px, 7vw, 84px);
}

.hero-book {
  display: block;
  width: 100%;
  cursor: pointer;
}

.hero-cover-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 14, 10, 0.72);
  color: #FBF6EC;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.3s, transform 0.3s var(--ease);
  backdrop-filter: blur(6px);
}
.hero-cover-hint .i { width: 15px; height: 15px; }
.hero-book:hover .hero-cover-hint,
.hero-book:focus-visible .hero-cover-hint { opacity: 1; transform: translate(-50%, 0); }
.hero-cover .cover {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 2px 2px rgba(0, 0, 0, 0.2),
    0 40px 50px -24px rgba(0, 0, 0, 0.6);
}

.hero-text .eyebrow { color: color-mix(in srgb, var(--book-ink) 65%, transparent); margin-bottom: 14px; }

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.4rem, 5.6vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.hero-sub {
  margin-top: 14px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  color: color-mix(in srgb, var(--book-ink) 82%, transparent);
}

.hero-meta {
  margin-top: 22px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--book-ink) 65%, transparent);
}

.hero-actions {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Sumário */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(40px, 6vw, 72px) 0 22px;
  border-bottom: 1px solid var(--line-strong);
}

.section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  line-height: 1;
}

.section-note {
  font-size: 13px;
  color: var(--ink-3);
}

.toc-item {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: clamp(14px, 3vw, 36px);
  padding: 26px 8px;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.toc-item:hover { background: rgba(255, 252, 244, 0.6); }

.toc-num {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.4s var(--ease);
}
.toc-item:hover .toc-num { transform: translateX(6px); }

.toc-body { min-width: 0; }

.toc-title {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.4rem, 2.4vw, 1.8rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.toc-desc {
  display: -webkit-box;
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink-2);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 620px;
}

.toc-meta {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.toc-thumb {
  width: clamp(84px, 13vw, 148px);
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: color-mix(in srgb, var(--book) 18%, var(--paper-deep));
  box-shadow: var(--shadow-1);
}
.toc-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.toc-item:hover .toc-thumb img { transform: scale(1.04); }

.toc-thumb.empty {
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.6rem;
  color: color-mix(in srgb, var(--accent) 60%, transparent);
}

.empty-block {
  padding: clamp(40px, 7vw, 72px) 0;
  text-align: center;
  color: var(--ink-2);
}

.empty-block h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty-block p { max-width: 420px; margin: 0 auto 22px; }

/* ---------- 9. Página do capítulo ---------- */
.chapter-hero {
  position: relative;
  color: var(--book-ink);
  background-color: var(--book);
  background-size: cover;
  background-position: center;
  isolation: isolate;
  overflow: hidden;
}

.chapter-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px 380px at 15% 0%, rgba(255, 255, 255, 0.10), transparent 60%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.22));
}

.chapter-hero.has-image { color: #FBF6EC; --book-ink: #FBF6EC; }
.chapter-hero.has-image::before {
  background: linear-gradient(180deg, rgba(20, 14, 10, 0.25) 0%, rgba(20, 14, 10, 0.35) 45%, rgba(20, 14, 10, 0.82) 100%);
}

.chapter-hero-inner {
  min-height: clamp(320px, 46vh, 480px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-block: clamp(40px, 6vw, 64px);
}

.chapter-num {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  margin-bottom: 8px;
  opacity: 0.85;
}

.chapter-desc {
  margin-top: 16px;
  max-width: 640px;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  line-height: 1.45;
  opacity: 0.9;
}

/* ---------- 11. Janelas modais ---------- */
.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 40px 90px -30px rgba(20, 12, 6, 0.55), 0 0 0 1px rgba(36, 28, 22, 0.05);
  overflow: hidden;
}

.modal-wide { width: min(780px, calc(100vw - 32px)); }
.modal-small { width: min(460px, calc(100vw - 32px)); }

.modal[open] { animation: modal-in 0.35s var(--ease); }

.modal::backdrop {
  background: rgba(30, 20, 12, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.3s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 26px 6px 30px;
}

.modal-head .eyebrow { margin-bottom: 6px; }

.modal-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1.05;
}

.modal-body {
  padding: 18px 30px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 26px 24px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.fields { display: flex; flex-direction: column; gap: 22px; }

.field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }

.field-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0;
}
.field-label em {
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink-3);
  margin-left: 4px;
}

.field input[type="text"],
.field input[type="date"],
.field textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input[type="date"] { min-height: 50px; }

.field textarea { resize: vertical; min-height: 92px; line-height: 1.5; }

.field textarea.writing {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.6;
  min-height: 180px;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(176, 138, 74, 0.16);
}

.field.invalid input { border-color: var(--danger); }

.field-date { max-width: 260px; }

.field-error {
  min-height: 0;
  font-size: 13px;
  color: var(--danger);
}
.field-error:empty { display: none; }

.file-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--gold); outline-offset: 3px; }

/* Formulário do livro */
.book-form {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 34px;
  align-items: start;
}

.book-preview-wrap {
  position: sticky;
  top: 0;
  padding: 4px 6px 0 0;
}

.book-preview .book { pointer-events: none; }

.preview-note {
  margin-top: 16px;
  font-size: 12px;
  text-align: center;
  color: var(--ink-3);
}

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

.swatch { position: relative; }

.swatch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.swatch-dot {
  display: block;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
  pointer-events: none;
}

.swatch input:checked + .swatch-dot {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 0 3px var(--card), 0 0 0 5px var(--ink);
}
.swatch input:focus-visible + .swatch-dot { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--gold); }
.swatch:hover .swatch-dot { transform: scale(1.08); }

.swatch-custom .swatch-dot {
  background: conic-gradient(from 200deg, #6B1E2C, #A4502F, #B5862E, #2E4A3B, #1D2D4A, #4B2A44, #6B1E2C);
  display: grid;
  place-items: center;
}
.swatch-custom .swatch-dot::after {
  content: "";
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c, transparent);
  box-shadow: 0 0 0 2px var(--white);
}
.swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}

/* Capa do capítulo no formulário */
.chapter-cover-preview {
  position: relative;
  aspect-ratio: 16 / 7;
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-deep);
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
}
.chapter-cover-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Mídias no formulário de registro */
.draft-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 6px;
}
.draft-media:empty { display: none; }

.draft-item {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.draft-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--paper-deep);
}
.draft-thumb img,
.draft-thumb video { width: 100%; height: 100%; object-fit: cover; }

.draft-kind {
  position: absolute;
  left: 8px; top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(20, 14, 10, 0.6);
  backdrop-filter: blur(4px);
}
.draft-kind .i { width: 13px; height: 13px; }

.draft-remove {
  position: absolute;
  right: 6px; top: 6px;
  width: 32px; height: 32px;
  background: rgba(255, 252, 245, 0.92);
  color: var(--ink);
}
.draft-remove:hover { color: var(--danger); background: #fff; }
.draft-remove .i { width: 15px; height: 15px; }

.draft-caption {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
}
.draft-caption:focus { outline: none; background: rgba(176, 138, 74, 0.07); }

.form-error { margin: 0; }

/* Confirmação */
.confirm-body { padding-top: 30px; }
.confirm-body .modal-title { font-size: 1.75rem; overflow-wrap: anywhere; }
.confirm-message { margin-top: 12px; color: var(--ink-2); font-size: 15px; }

/* Visualização de foto */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(18, 12, 8, 0.94);
  color: #F5EEE2;
}
.lightbox[open] { display: grid; place-items: center; animation: fade-in 0.3s ease; }
.lightbox::backdrop { background: transparent; }

.lightbox-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  color: #F5EEE2;
  background: rgba(255, 255, 255, 0.08);
  z-index: 1;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

.lightbox-figure {
  margin: 0;
  padding: 64px 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 100%;
}
.lightbox-figure img {
  max-width: min(92vw, 1400px);
  max-height: calc(100dvh - 180px);
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
.lightbox-figure figcaption {
  max-width: 640px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  text-align: center;
  color: rgba(245, 238, 226, 0.85);
}
.lightbox-figure figcaption:empty { display: none; }

/* Aviso */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 100;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.35s var(--ease);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 12. Responsividade ---------- */
@media (hover: none) {
  .slot-actions { opacity: 1; }
  .book:hover { transform: none; }
}

@media (max-width: 900px) {
  .book-hero-inner { grid-template-columns: minmax(150px, 210px) 1fr; }
}

@media (max-width: 720px) {
  :root { --topbar-h: 58px; }
  body { font-size: 15px; }

  .brand-tag { display: none; }
  .brand-mark { font-size: 22px; }

  .crumb-trail { display: none; }
  .crumb-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 58vw;
    min-height: 40px;
    padding: 0 14px 0 8px;
    border-radius: 999px;
    background: rgba(36, 28, 22, 0.06);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
  }
  .crumb-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Biblioteca */
  .lib-head { flex-direction: column; align-items: flex-start; gap: 22px; padding-top: 36px; }
  .lib-head .btn { width: 100%; }

  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 34px; }
  .slot .book { width: calc(var(--s, 1) * (100% - 36px)); }
  .slot-meta { padding: 10px 12px 0; }
  .new-label { font-size: 1.1rem; }

  /* Livro */
  .book-hero-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 28px;
    padding-block: 36px 40px;
  }
  .hero-cover { width: min(48vw, 190px); }
  .hero-actions { justify-content: center; }
  .hero-actions .btn-primary { flex: 1 1 100%; }
  .hero-actions .btn-ghost { flex: 1 1 0; }

  .section-head { flex-direction: column; align-items: flex-start; gap: 6px; }

  .toc-item {
    grid-template-columns: 40px 1fr auto;
    gap: 14px;
    padding: 20px 2px;
  }
  .toc-num { font-size: 1.6rem; }
  .toc-thumb { width: 76px; }
  .toc-desc { font-size: 13.5px; }

  /* Capítulo */
  .chapter-hero-inner { min-height: 300px; padding-block: 32px; }
  .chapter-hero .hero-actions .btn-primary { flex: 1 1 100%; }
  .chapter-hero .hero-actions .btn-ghost { flex: 1 1 0; }

  /* Modais como folhas inferiores */
  .modal,
  .modal-wide,
  .modal-small {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    max-height: 94dvh;
  }
  .modal[open] { animation: sheet-in 0.4s var(--ease); }
  .modal-form { max-height: 94dvh; }
  .modal-head { padding: 22px 18px 4px 22px; }
  .modal-title { font-size: 1.7rem; }
  .modal-body { padding: 16px 22px 8px; }
  .modal-foot { padding: 14px 18px calc(16px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }

  .book-form { grid-template-columns: 1fr; gap: 24px; }
  .book-preview-wrap { position: static; width: 150px; margin: 0 auto; padding: 0; }
  .preview-note { display: none; }
  .field-date { max-width: none; }

  .draft-media { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@media (max-width: 380px) {
  .shelf { column-gap: 0; }
  .slot .book { width: calc(var(--s, 1) * (100% - 26px)); }
  .draft-media { grid-template-columns: 1fr; }
}

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


/* =========================================================
   13. Biblioteca imersiva
   ========================================================= */
.library { position: relative; }

.lib-glow {
  position: absolute;
  inset: 0 0 auto 0;
  height: 820px;
  pointer-events: none;
  background:
    radial-gradient(640px 420px at 78% 140px, rgba(255, 234, 196, 0.55), transparent 70%),
    radial-gradient(560px 380px at 8% 0, rgba(255, 251, 242, 0.75), transparent 70%);
}

.library .wrap { position: relative; }

.lib-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  margin-top: 20px;
  font-size: 13px;
  color: var(--ink-3);
}
.lib-stats span { display: inline-flex; align-items: center; }
.lib-stats span + span::before {
  content: "";
  width: 3px; height: 3px;
  margin: 0 12px;
  border-radius: 50%;
  background: var(--ink-3);
  opacity: 0.6;
}

.lib-feature {
  position: relative;
  display: grid;
  grid-template-columns: minmax(190px, 290px) 1fr;
  align-items: center;
  gap: clamp(32px, 6vw, 88px);
  margin-bottom: clamp(44px, 6vw, 80px);
  padding: clamp(28px, 4vw, 52px) clamp(24px, 5vw, 64px);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 252, 245, 0.92), rgba(238, 228, 209, 0.75));
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.feature-stage {
  position: relative;
  padding: 8px 9% 30px;
}
.feature-stage::after {
  content: "";
  position: absolute;
  left: 14%; right: 2%; bottom: 6px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 24, 10, 0.38), transparent);
  filter: blur(3px);
  z-index: -1;
}

.feature-title {
  margin-top: 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 4.6vw, 3.7rem);
  line-height: 1;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.feature-sub {
  margin-top: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--ink-2);
}
.feature-meta {
  margin-top: 16px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

/* Estante de madeira */
.bookcase {
  position: relative;
  padding: clamp(22px, 3vw, 36px) 0 clamp(16px, 2vw, 24px);
  border-radius: 26px;
  background: linear-gradient(180deg, #E7DCC7 0%, #DED0B6 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 60px 90px -70px rgba(70, 45, 20, 0.45),
    inset 0 -40px 60px -60px rgba(70, 45, 20, 0.35),
    0 34px 60px -46px rgba(60, 40, 20, 0.5);
  overflow: hidden;
}
.bookcase::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 45% at 50% 0, rgba(255, 242, 214, 0.6), transparent 72%);
}

.case-head {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(18px, 3vw, 36px) clamp(20px, 2.6vw, 30px);
}
.case-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
}
.case-note { font-size: 12.5px; color: var(--ink-3); }

.bookcase .shelf { position: relative; }

.bookcase .plank {
  height: 20px;
  background: linear-gradient(180deg, #C89F75 0, #A97D55 20%, #8C6543 24%, #7A5638 62%, #5D3F28 100%);
  box-shadow: inset 0 1px 0 rgba(255, 240, 220, 0.45), 0 18px 22px -14px rgba(50, 30, 12, 0.7);
}

/* Livro em 3D: capa, lombada e páginas */
.book3d { perspective: 1300px; }
.book3d::before { display: none; }
.book3d:hover,
.book3d:focus-visible { transform: none; }

.b3-body {
  position: relative;
  display: block;
  container-type: inline-size;
  transform-style: preserve-3d;
  transform: rotateY(-6deg);
  transition: transform 0.65s var(--ease);
}

.b3-front {
  position: relative;
  display: block;
  transform: translateZ(calc(var(--tk) * 0.5cqi));
}

.b3-spine,
.b3-pages {
  position: absolute;
  top: 0;
  height: 100%;
  width: calc(var(--tk) * 1cqi);
}

.b3-spine {
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 9cqi 0 7cqi;
  overflow: hidden;
  border-radius: 3px 0 0 3px;
  transform-origin: 0 50%;
  transform: translateZ(calc(var(--tk) * -0.5cqi)) rotateY(-90deg);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.10) 45%, rgba(0, 0, 0, 0.28)),
    var(--cover);
}
.b3-spine-title {
  writing-mode: vertical-rl;
  max-height: 72%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--serif);
  font-weight: 600;
  font-size: calc(var(--tk) * 0.5cqi);
  color: var(--ink);
}
.b3-spine-mark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: calc(var(--tk) * 0.42cqi);
  color: var(--foil);
}

.b3-pages {
  right: 0;
  top: 1.6%;
  height: 96.8%;
  transform-origin: 100% 50%;
  transform: translateZ(calc(var(--tk) * -0.5cqi)) rotateY(90deg);
  background: repeating-linear-gradient(90deg, #F6EFE0 0 1px, #DCCFB6 1px 2px);
}

.book3d:hover .b3-body,
.book3d:focus-visible .b3-body { transform: translateY(-12px) rotateY(26deg); }

.feature-book .b3-body { transform: rotateY(20deg) rotateX(2deg); }
.feature-book:hover .b3-body,
.feature-book:focus-visible .b3-body { transform: translateY(-6px) rotateY(8deg); }

/* Transição da capa ao abrir um livro */
::view-transition-group(laif-cover) {
  animation-duration: 0.6s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.4s; }

/* Formulário do livro */
.design-note {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--paper-deep);
  font-size: 13px;
  color: var(--ink-2);
}
.modal-foot .foot-left { margin-right: auto; }


/* =========================================================
   14. Editor de capa
   ========================================================= */
.editor {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #1E1814;
  color: #F1E9DB;
  overflow: hidden;
}
.editor[open] { animation: fade-in 0.25s ease; }
.editor::backdrop { background: #1E1814; }

.ed-shell {
  display: grid;
  height: 100%;
  grid-template-columns: 86px minmax(0, 1fr) 330px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "tools stage panel";
}

.ed-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #19130F;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.editor .ed-top .icon-btn { color: #E8DFCF; }
.editor .ed-top .icon-btn:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.icon-btn:disabled { opacity: 0.3; pointer-events: none; }

.ed-heading {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.ed-heading .eyebrow { color: #9C8E7C; font-size: 10.5px; }
.ed-heading strong {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-top-actions { display: flex; align-items: center; gap: 6px; }
.ed-top .btn-ghost { color: #F1E9DB; border-color: rgba(255, 255, 255, 0.22); }
.ed-top .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.ed-top .btn-primary { background: #F1E9DB; color: #1E1814; }
.ed-top .btn-primary:hover { background: #fff; }

.ed-tools {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 8px;
  overflow-y: auto;
  background: #19130F;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.ed-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: 12px;
  color: #BFB2A0;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.ed-tool .i { width: 21px; height: 21px; }
.ed-tool:hover { background: rgba(255, 255, 255, 0.07); color: #F1E9DB; }
.ed-tool.active { background: #F1E9DB; color: #1E1814; }
.ed-tool:focus-within { outline: 2px solid var(--gold); outline-offset: -2px; }

.ed-stage {
  grid-area: stage;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #3B2F26 0%, #241C16 62%, #1E1814 100%);
}

.ed-board {
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.6s var(--ease);
}

.ed-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  box-shadow: 0 46px 90px -34px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.ed-cover .cel img { pointer-events: none; -webkit-user-drag: none; }
.editor.drawing .ed-board { cursor: crosshair; }

.ed-sel {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  border: 1.5px solid #E2C994;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.ed-sel.framing { border-style: dashed; border-color: #fff; }
.ed-sel::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -30px;
  width: 1.5px;
  height: 30px;
  background: #E2C994;
}

.ed-sel .h {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #B08A4A;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  touch-action: none;
}
.ed-sel .h::after { content: ""; position: absolute; inset: -10px; }
.ed-sel .h-nw { left: 0; top: 0; cursor: nwse-resize; }
.ed-sel .h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.ed-sel .h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.ed-sel .h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.ed-sel .h-n { left: 50%; top: 0; width: 22px; height: 8px; margin: -4px 0 0 -11px; border-radius: 4px; cursor: ns-resize; }
.ed-sel .h-s { left: 50%; top: 100%; width: 22px; height: 8px; margin: -4px 0 0 -11px; border-radius: 4px; cursor: ns-resize; }
.ed-sel .h-e { left: 100%; top: 50%; width: 8px; height: 22px; margin: -11px 0 0 -4px; border-radius: 4px; cursor: ew-resize; }
.ed-sel .h-w { left: 0; top: 50%; width: 8px; height: 22px; margin: -11px 0 0 -4px; border-radius: 4px; cursor: ew-resize; }
.ed-sel .h-rot { left: 50%; top: -38px; width: 18px; height: 18px; margin: -9px 0 0 -9px; background: #E2C994; border-color: #fff; cursor: grab; }
.ed-sel[data-type="text"] .h-n,
.ed-sel[data-type="text"] .h-s { display: none; }
.ed-sel.framing .h:not(.h-rot) { opacity: 0.35; }

.ed-guide {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  background: #E2C994;
  opacity: 0;
  transition: opacity 0.15s;
}
.ed-guide.v { top: 0; bottom: 0; left: 50%; width: 1px; }
.ed-guide.h { left: 0; right: 0; top: 50%; height: 1px; }
.ed-guide.on { opacity: 0.9; }

/* Visualização: a capa como um livro de verdade */
.editor.previewing .ed-tools,
.editor.previewing .ed-panel { display: none; }
.editor.previewing .ed-shell { grid-template-columns: 1fr; grid-template-areas: "top" "stage"; }
.editor.previewing .ed-board { transform: perspective(1800px) rotateY(-16deg) scale(0.92); }
.editor.previewing .ed-board::after {
  content: "";
  position: absolute;
  top: 1.6%;
  bottom: 1.6%;
  right: -11px;
  width: 13px;
  z-index: -1;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(90deg, #F5EEDF 0 1px, #DCD0B9 1px 2px);
}

/* Painel de propriedades */
.ed-panel {
  grid-area: panel;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 22px 36px;
  background: #F7F1E6;
  color: var(--ink);
  border-left: 1px solid rgba(0, 0, 0, 0.3);
}

.ep-head { margin-bottom: 14px; }
.ep-head h2 { font-family: var(--serif); font-weight: 500; font-size: 1.65rem; line-height: 1.1; }
.ep-head p { margin-top: 4px; font-size: 13px; color: var(--ink-3); }

.ep-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 10px; }
.ep-actions .icon-btn { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }

.ep-sec { padding: 16px 0; border-top: 1px solid var(--line); }
.ep-sec:first-of-type { border-top: 0; padding-top: 4px; }
.ep-title {
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.ep-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.4;
  resize: vertical;
}
.ep-textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176, 138, 74, 0.18); }

.ep-fonts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ep-font {
  padding: 10px 4px;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ep-font.on { box-shadow: inset 0 0 0 2px var(--ink); }

.ep-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }

.ep-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}
.ep-seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.ep-seg button .i { width: 16px; height: 16px; }
.ep-seg button.on { background: var(--ink); color: var(--paper); }
.ep-seg-wide { display: flex; }
.ep-seg-wide button { flex: 1; }

.ep-range { display: block; margin-top: 12px; }
.ep-label { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12.5px; color: var(--ink-2); }
.ep-label output { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ep-range input { width: 100%; accent-color: var(--ink); }

.ep-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.ep-color {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
  cursor: pointer;
}
.ep-color.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16), 0 0 0 2px #F7F1E6, 0 0 0 4px var(--ink); }
.ep-colors-lg .ep-color { width: 38px; height: 38px; }
.ep-color-custom { background: conic-gradient(from 200deg, #6B1E2C, #A04B2C, #B5862E, #2E4A3B, #1D2D4A, #4B2A44, #6B1E2C); }
.ep-color-custom::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px #fff;
}
.ep-color-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

.ep-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ep-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13px;
  font-weight: 500;
}
.ep-chip.on { background: var(--ink); color: var(--paper); }

.ep-wide { width: 100%; }
.ep-note { margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }

.ep-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ep-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 8px;
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}
.ep-quick-btn:hover { box-shadow: inset 0 0 0 1px var(--ink-3), var(--shadow-1); transform: translateY(-1px); }
.ep-quick-btn .i { width: 22px; height: 22px; }
.ep-quick-btn:focus-within { outline: 2px solid var(--gold); }

.ep-tips { display: grid; gap: 6px; padding-left: 18px; list-style: disc; font-size: 13px; color: var(--ink-2); }

.ep-shapes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ep-shape {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px 8px;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 10.5px;
  transition: box-shadow 0.2s;
}
.ep-shape:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.ep-shape svg { width: 36px; height: 36px; }

.ep-templates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.ep-template { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; text-align: center; }
.ep-template .cover { transition: transform 0.35s var(--ease), box-shadow 0.35s; }
.ep-template:hover .cover { transform: translateY(-4px); }

.ep-layers { display: grid; gap: 4px; }
.ep-layer {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13.5px;
  text-align: left;
}
.ep-layer.on { box-shadow: inset 0 0 0 2px var(--ink); }
.ep-layer-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ep-layer-type { font-size: 11px; color: var(--ink-3); }

.ep-brush-preview {
  display: grid;
  place-items: center;
  height: 46px;
  margin-top: 10px;
  border-radius: 10px;
  background: repeating-conic-gradient(#EFE8DA 0 25%, #fff 0 50%) 0 0 / 12px 12px;
}
.ep-brush-preview span { border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }


/* =========================================================
   15. Leitura imersiva
   ========================================================= */
body.reading { overflow: hidden; }
body.reading .topbar { display: none; }

.reader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: #EFE6D6;
  background: radial-gradient(120% 85% at 50% 32%, #4B3B2E 0%, #2C221B 56%, #181210 100%);
}
.reader.view.enter { animation: fade-in 0.5s ease both; }

.rd-top {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) clamp(10px, 3vw, 24px) 6px;
}

.rd-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #EFE6D6;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.rd-btn:hover { background: rgba(255, 255, 255, 0.15); }
.rd-btn .i { width: 17px; height: 17px; }

.rd-heading { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.rd-book-title,
.rd-chapter { max-width: 46vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rd-book-title { font-family: var(--serif); font-size: 1.15rem; }
.rd-chapter { min-height: 1.4em; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(239, 230, 214, 0.55); }

.rd-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.rd-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: rgba(239, 230, 214, 0.7);
  pointer-events: none;
  transition: opacity 0.4s;
}
.reader.ready .rd-loading { opacity: 0; }

.rd-book {
  position: relative;
  display: flex;
  width: calc(var(--pw) * 2);
  height: var(--ph);
  perspective: 2600px;
  opacity: 0;
  transition: transform 0.85s var(--ease), opacity 0.2s ease;
}
.reader.ready .rd-book { opacity: 1; }
.reader.ready .rd-book.is-jumping { opacity: 0; }
.is-single .rd-book { width: var(--pw); }
.is-single .rd-left { display: none; }
.is-spread .rd-book.closed-front { transform: translateX(calc(var(--pw) * -0.5)); }
.is-spread .rd-book.closed-back { transform: translateX(calc(var(--pw) * 0.5)); }

.rd-side { position: relative; flex: none; width: var(--pw); height: var(--ph); }
.rd-side::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: var(--sh, 0);
}
.rd-right::after { background: linear-gradient(to right, rgba(20, 12, 6, 0.5), rgba(20, 12, 6, 0) 55%); }
.rd-left::after { background: linear-gradient(to left, rgba(20, 12, 6, 0.5), rgba(20, 12, 6, 0) 55%); }
.is-single .rd-right::after { background: linear-gradient(to right, rgba(20, 12, 6, 0.32), rgba(20, 12, 6, 0) 75%); }

.rd-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: calc(var(--ph) * 0.055) calc(var(--pw) * 0.1) calc(var(--ph) * 0.04);
  font-size: var(--fs);
  color: #2A2019;
  background-color: #FBF7EE;
}
.rd-page.right {
  padding-left: calc(var(--pw) * 0.115);
  border-radius: 2px 7px 7px 2px;
  background-image: linear-gradient(to right, rgba(90, 60, 30, 0.2), rgba(90, 60, 30, 0) 8%);
  box-shadow: 1px 0 0 #E7DDC9, 2px 0 0 #FAF5EA, 3px 0 0 #E2D7C2, 4px 0 0 #F7F1E4, 5px 0 0 #D9CCB4, 0 30px 50px -28px rgba(0, 0, 0, 0.75);
}
.rd-page.left {
  padding-right: calc(var(--pw) * 0.115);
  border-radius: 7px 2px 2px 7px;
  background-image: linear-gradient(to left, rgba(90, 60, 30, 0.2), rgba(90, 60, 30, 0) 8%);
  box-shadow: -1px 0 0 #E7DDC9, -2px 0 0 #FAF5EA, -3px 0 0 #E2D7C2, -4px 0 0 #F7F1E4, -5px 0 0 #D9CCB4, 0 30px 50px -28px rgba(0, 0, 0, 0.75);
}
.is-single .rd-page.right { background-image: linear-gradient(to right, rgba(90, 60, 30, 0.16), rgba(90, 60, 30, 0) 6%); }
.rd-page.is-empty { background: none; box-shadow: none; }

.rd-page.kind-cover { padding: 0; background: none; box-shadow: 0 34px 60px -26px rgba(0, 0, 0, 0.8); border-radius: 3px 8px 8px 3px; }
.rd-page.kind-cover .cover { width: 100%; height: 100%; aspect-ratio: auto; }
.rd-page.kind-back { padding: 0; background: var(--book); box-shadow: 0 34px 60px -26px rgba(0, 0, 0, 0.8); border-radius: 8px 3px 3px 8px; }
.rd-backcover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-bottom: 12%;
  color: var(--book-ink);
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.3) 0, rgba(0, 0, 0, 0.08) 5%, transparent 10%), linear-gradient(170deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.18));
}
.rd-back-mark { font-family: var(--serif); font-weight: 600; letter-spacing: 0.42em; font-size: calc(var(--pw) * 0.045); }
.rd-back-tag { font-family: var(--serif); font-style: italic; font-size: calc(var(--pw) * 0.035); opacity: 0.75; }

.pg-head {
  flex: none;
  height: calc(var(--fs) * 1.9);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  font-family: var(--sans);
  font-size: calc(var(--fs) * 0.55);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #A39380;
}

.pg-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.5;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.pg-body > :first-child { margin-top: 0; }

.pg-folio {
  flex: none;
  height: calc(var(--fs) * 1.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: calc(var(--fs) * 0.8);
  color: #6B6157;
}

.pg-body p { margin: 0; text-indent: 1.4em; text-align: justify; }
.pg-orn { display: flex; align-items: center; justify-content: center; gap: 0.7em; margin: 1.1em 0; color: #B5A68F; }
.pg-orn::before,
.pg-orn::after { content: ""; width: 2.2em; height: 1px; background: currentColor; }
.pg-orn span { width: 0.4em; height: 0.4em; transform: rotate(45deg); border: 1px solid currentColor; }

.pg-titlepage,
.pg-opener,
.pg-endpage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pg-titlepage { gap: 0.6em; }
.pg-kicker { font-family: var(--sans); font-size: 0.6em; font-weight: 600; letter-spacing: 0.42em; color: var(--accent); }
.pg-titlepage h1 { font-size: 2.3em; font-weight: 500; line-height: 1.05; overflow-wrap: anywhere; }
.pg-sub { font-style: italic; font-size: 1.12em; color: #5A4D42; }
.pg-colophon { font-style: italic; font-size: 0.85em; color: #6B6157; }

.pg-toc-title { margin-bottom: 0.9em; font-size: 1.9em; font-weight: 500; text-align: center; }
.pg-toc ol { display: grid; gap: 0.15em; }
.pg-toc-row {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  width: 100%;
  padding: 0.35em 0;
  font-family: var(--serif);
  font-size: 1em;
  text-align: left;
  color: inherit;
}
.pg-toc-row .n { min-width: 1.8em; font-style: italic; color: var(--accent); }
.pg-toc-row .t { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.pg-toc-row .d { flex: 1; min-width: 1em; border-bottom: 1px dotted #C2B196; transform: translateY(-0.3em); }
.pg-toc-row:hover .t { color: var(--accent); }
.pg-note { text-align: center; font-style: italic; color: #6B6157; }

.pg-opener { gap: 0.5em; }
.pg-op-num { font-style: italic; font-size: 1.05em; color: var(--accent); }
.pg-op-title { font-size: 2.1em; font-weight: 500; line-height: 1.05; overflow-wrap: anywhere; }
.pg-op-desc {
  display: -webkit-box;
  max-width: 92%;
  overflow: hidden;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  font-size: 0.98em;
  color: #5A4D42;
}
.pg-op-img {
  display: block;
  flex: none;
  width: 78%;
  height: 34%;
  margin-top: 0.8em;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: 0 12px 20px -14px rgba(0, 0, 0, 0.55);
}
.pg-op-img img { width: 100%; height: 100%; object-fit: cover; }
.pg-op-empty { font-style: italic; font-size: 0.92em; color: #6B6157; }
.pg-endpage { gap: 0.5em; font-style: italic; font-size: 1.4em; color: #5A4D42; }

/* A folha que vira */
.rd-leaf {
  position: absolute;
  top: 0;
  z-index: 6;
  width: var(--pw);
  height: var(--ph);
  transform-style: preserve-3d;
  pointer-events: none;
  will-change: transform;
}
.rd-leaf.fwd { left: 50%; transform-origin: 0 50%; }
.rd-leaf.bwd { left: 0; transform-origin: 100% 50%; }
.rd-leaf.single { left: 0; transform-origin: 0 50%; }

.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 0 calc(var(--k, 0) * 40px) rgba(0, 0, 0, calc(var(--k, 0) * 0.35));
}
.leaf-face.back { transform: rotateY(180deg); }
.leaf-face .rd-page { box-shadow: none; }

.leaf-shade { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.rd-leaf.fwd .front .leaf-shade,
.rd-leaf.bwd .back .leaf-shade,
.rd-leaf.single .front .leaf-shade {
  background: linear-gradient(to right,
    rgba(0, 0, 0, calc(0.05 + var(--k, 0) * 0.16)) 0%,
    rgba(0, 0, 0, 0) 16%,
    rgba(255, 255, 255, calc(var(--k, 0) * 0.22)) 58%,
    rgba(0, 0, 0, calc(var(--a, 0) * 0.3)) 100%);
}
.rd-leaf.fwd .back .leaf-shade,
.rd-leaf.bwd .front .leaf-shade,
.rd-leaf.single .back .leaf-shade {
  background: linear-gradient(to left,
    rgba(0, 0, 0, calc(0.05 + var(--k, 0) * 0.16)) 0%,
    rgba(0, 0, 0, 0) 16%,
    rgba(255, 255, 255, calc(var(--k, 0) * 0.22)) 58%,
    rgba(0, 0, 0, calc((1 - var(--a, 0)) * 0.3)) 100%);
}

/* Barra inferior */
.rd-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 28px);
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
}
.rd-nav {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #EFE6D6;
  transition: background-color 0.2s, opacity 0.2s;
}
.rd-nav:hover { background: rgba(255, 255, 255, 0.16); }
.rd-nav:disabled { opacity: 0.28; pointer-events: none; }
.rd-progress { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: min(220px, 48vw); }
.rd-label { font-size: 12px; letter-spacing: 0.06em; color: rgba(239, 230, 214, 0.78); font-variant-numeric: tabular-nums; }
.rd-track { width: 100%; height: 2px; overflow: hidden; border-radius: 2px; background: rgba(255, 255, 255, 0.14); }
.rd-fill { display: block; width: 0; height: 100%; background: #E2C994; transition: width 0.5s var(--ease); }

/* Sumário lateral */
.rd-toc {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(400px, 92vw);
  color: var(--ink);
  background: #FBF7EE;
  box-shadow: -30px 0 60px -20px rgba(0, 0, 0, 0.6);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.45s var(--ease), visibility 0s linear 0.45s;
}
.reader.toc-open .rd-toc { transform: none; visibility: visible; transition: transform 0.45s var(--ease), visibility 0s; }
.rd-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 14px 12px 24px;
  border-bottom: 1px solid var(--line);
}
.rd-toc-head h2 { font-family: var(--serif); font-weight: 500; font-size: 1.75rem; }
.rd-toc-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px calc(24px + env(safe-area-inset-bottom)); }
.rd-toc-chapter {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  text-align: left;
  font-family: var(--serif);
  font-size: 1.15rem;
}
.rd-toc-chapter:hover,
.rd-toc-day:hover { background: rgba(36, 28, 22, 0.06); }
.rd-toc-chapter .n { min-width: 1.8em; font-style: italic; color: var(--accent); }
.rd-toc-chapter .t { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.rd-toc-chapter .pg,
.rd-toc-day .pg { font-family: var(--sans); font-size: 12px; color: var(--ink-3); }
.rd-toc-list { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.rd-toc-days { display: grid; gap: 1px; margin-bottom: 6px; padding-left: 2.6em; }
.rd-toc-day {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
}

/* Área invisível usada para diagramar as páginas */
.rd-measure {
  position: absolute;
  top: 0;
  left: -10000px;
  width: var(--pw);
  height: var(--ph);
  visibility: hidden;
  pointer-events: none;
}
.rd-measure .rd-page { box-shadow: none; }


/* =========================================================
   16. Responsividade das novas áreas
   ========================================================= */
@media (hover: none) {
  .book3d:hover .b3-body { transform: rotateY(-6deg); }
  .book3d:active .b3-body { transform: translateY(-6px) rotateY(18deg) scale(0.98); }
  .feature-book:hover .b3-body { transform: rotateY(20deg) rotateX(2deg); }
  .hero-cover-hint { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 1100px) {
  .ed-shell { grid-template-columns: 76px minmax(0, 1fr) 290px; }
}

@media (max-width: 720px) {
  /* Biblioteca */
  .lib-feature {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 16px;
    padding: 26px 18px 24px;
    border-radius: 22px;
    text-align: center;
  }
  .feature-stage { width: min(54vw, 210px); padding: 4px 4% 24px; }
  .feature-sub { font-size: 1.15rem; }
  .feature-actions { justify-content: center; width: 100%; }
  .feature-actions .btn-primary { flex: 1 1 100%; }
  .feature-actions .btn-ghost { flex: 1 1 0; }
  .lib-stats { gap: 4px 14px; font-size: 12.5px; }
  .lib-stats span + span::before { display: none; }
  .bookcase { margin-inline: calc(var(--gutter) * -0.5); border-radius: 20px; }
  .case-head { padding: 0 16px 16px; }
  .slot-meta { flex-direction: column; justify-content: flex-start; gap: 2px; min-height: 72px; padding: 10px 4px 0; }
  .slot-actions { gap: 4px; }
  .slot-actions .icon-btn.sm { width: 34px; height: 34px; }

  .book-hero .hero-actions .btn-ghost { flex: 1 1 40%; }
  .hero-cover-hint { font-size: 11px; padding: 6px 10px; bottom: 10px; }

  .modal-foot { flex-wrap: wrap; }
  .modal-foot .foot-left { flex: 1 1 100%; order: -1; margin: 0; }

  /* Editor */
  .ed-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "stage" "panel" "tools";
  }
  .ed-top { gap: 2px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
  .ed-heading .eyebrow { display: none; }
  .ed-heading strong { font-size: 1.05rem; padding-left: 4px; }
  .ed-preview-btn span { display: none; }
  .ed-preview-btn { padding: 0 11px; }
  .ed-top .btn.sm { padding: 0 12px; }

  .ed-tools {
    flex-direction: row;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto;
    border-right: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    scrollbar-width: none;
  }
  .ed-tools::-webkit-scrollbar { display: none; }
  .ed-tool { flex: 1 0 62px; padding: 7px 2px; font-size: 10.5px; }

  .ed-panel {
    max-height: 38dvh;
    padding: 14px 16px 18px;
    border-left: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.3);
  }
  .ep-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
  .ep-head h2 { font-size: 1.3rem; }
  .ep-head p { flex: 1 1 100%; margin: 0; }
  .ep-actions { margin-top: 0; }
  .ep-templates { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
  .ep-quick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ep-quick-btn { padding: 12px 4px; font-size: 11.5px; }

  .ed-sel .h { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
  .ed-sel .h-n, .ed-sel .h-s { width: 28px; height: 10px; margin: -5px 0 0 -14px; }
  .ed-sel .h-e, .ed-sel .h-w { width: 10px; height: 28px; margin: -14px 0 0 -5px; }
  .ed-sel .h-rot { width: 22px; height: 22px; margin: -11px 0 0 -11px; }

  .editor.previewing .ed-shell { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top" "stage"; }

  /* Leitura */
  .rd-btn { padding: 0 12px; }
  .rd-btn span { display: none; }
  .rd-book-title { font-size: 1.02rem; max-width: 58vw; }
  .rd-chapter { max-width: 58vw; }
  .rd-nav { width: 42px; height: 42px; }
}

/* =========================================================
   17. Páginas, momentos soltos e criação rápida
   ========================================================= */
[hidden] { display: none !important; }

/* ---- Folha de página: papel, cabeçalho, número. Tudo escala com a largura (cqi). ---- */
.pg-sheet {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  container-type: inline-size;
  overflow: hidden;
  border-radius: 2px 6px 6px 2px;
  color: var(--paper-ink, #2A2019);
  background-color: var(--paper-c, #FBF7EE);
  font-family: var(--serif);
}
/* Dobra junto à lombada (página da direita, por padrão) */
.pg-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(to right, rgba(90, 60, 30, 0.17), rgba(90, 60, 30, 0) 7%);
}
.rd-page.left .pg-sheet::after { background: linear-gradient(to left, rgba(90, 60, 30, 0.17), rgba(90, 60, 30, 0) 7%); }

/* Texturas do papel (em % da folha, acompanham qualquer tamanho) */
.pg-sheet[data-pattern="lines"] {
  background-image: linear-gradient(to bottom, transparent calc(100% - 1px), rgba(120, 96, 70, 0.2) 0);
  background-size: 100% 4.6%;
  background-position: 0 8.5%;
}
.pg-sheet[data-pattern="dots"] {
  background-image: radial-gradient(circle, rgba(120, 96, 70, 0.32) 0 0.7px, transparent 1.2px);
  background-size: 5% 3.3334%;
}
.pg-sheet[data-pattern="grid"] {
  background-image:
    linear-gradient(to bottom, transparent calc(100% - 1px), rgba(120, 96, 70, 0.14) 0),
    linear-gradient(to right, transparent calc(100% - 1px), rgba(120, 96, 70, 0.14) 0);
  background-size: 5% 3.3334%;
}

.pg-sheet .cover-art { z-index: 1; }

.pg-sheet-head {
  position: absolute;
  z-index: 2;
  top: 3.4%;
  left: 12%;
  right: 12%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  font-family: var(--sans);
  font-size: 2.2cqi;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-ink, #2A2019);
  opacity: 0.45;
  pointer-events: none;
}
.pg-sheet-head:empty { display: none; }

.pg-sheet-folio {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 2.4%;
  text-align: center;
  font-style: italic;
  font-size: 3cqi;
  color: var(--paper-ink, #2A2019);
  opacity: 0.55;
  pointer-events: none;
}

/* Vídeos na composição (mesmos formatos e molduras das fotografias) */
.cel-video .cel-clip {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #15100C;
}
.cel-video video { display: block; width: 100%; height: 100%; object-fit: cover; }
.cel-video[data-border="print"] { background: #FFFDF8; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28); }
.cel-video[data-border="shadow"] .cel-clip { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); }
.cel-video[data-fshape="rounded"],
.cel-video[data-fshape="rounded"] .cel-clip { border-radius: 9%; }
.cel-video[data-fshape="circle"],
.cel-video[data-fshape="circle"] .cel-clip { border-radius: 50%; }
.cel-video[data-fshape="arch"],
.cel-video[data-fshape="arch"] .cel-clip { border-radius: 999px 999px 4px 4px; }
.cel-play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 13cqi;
  height: 13cqi;
  max-width: 54px;
  max-height: 54px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  color: #fff;
  background: rgba(20, 12, 6, 0.45);
  pointer-events: none;
}
.cel-play .i { width: 52%; height: 52%; }
.cel-text { hyphens: auto; -webkit-hyphens: auto; }

/* ---- Páginas na leitura ---- */
.rd-page.kind-record { padding: 0; }
.rd-page .pg-sheet {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: inherit;
}
.rd-page .cel-image[data-zoom] { cursor: zoom-in; }
.rd-measure-sheet {
  position: absolute;
  top: 0;
  left: -10000px;
  width: 600px;
  visibility: hidden;
  pointer-events: none;
}
.rd-top-actions { display: flex; align-items: center; gap: 8px; }
.rd-toc-day { gap: 12px; text-align: left; }
.rd-toc-entry { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rd-toc-entry b { font-weight: 600; color: var(--ink); }

/* ---- Editor no modo página ---- */
.ed-cover.pg-sheet {
  position: absolute;
  aspect-ratio: auto;
  border-radius: 2px 6px 6px 2px;
}
.cover .pg-sheet-head { display: none; }
.ed-cover .cel video { pointer-events: none; }
.ed-date { display: block; min-width: 0; }
.ed-date input {
  width: 100%;
  max-width: 11em;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #F1E9DB;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  color-scheme: dark;
}
.ed-date input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
.ed-overflow {
  position: absolute;
  left: -6px;
  right: -6px;
  z-index: 4;
  height: 0;
  border-top: 1.5px dashed rgba(226, 201, 148, 0.95);
  pointer-events: none;
}
.ed-overflow span {
  position: absolute;
  right: 6px;
  top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #B08A4A;
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.editor[data-kind="page"].previewing .ed-board { transform: scale(0.96); }
.editor[data-kind="page"].previewing .ed-board::after { display: none; }
.editor[data-kind="page"].previewing .ed-overflow { display: none; }

.ep-papers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ep-paper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px 8px;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 11.5px;
  font-weight: 600;
}
.ep-paper span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 46px;
  border-radius: 2px 4px 4px 2px;
  background: var(--c);
  color: var(--i);
  font-family: var(--serif);
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}
.ep-paper.on { box-shadow: inset 0 0 0 2px var(--ink); }
.ep-page-template .pg-sheet { box-shadow: var(--shadow-1); transition: transform 0.35s var(--ease); }
.ep-page-template:hover .pg-sheet { transform: translateY(-4px); }

/* ---- Capítulo: as páginas ---- */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(132px, 17vw, 188px), 1fr));
  gap: clamp(24px, 3vw, 38px) clamp(16px, 2.4vw, 28px);
  padding-bottom: 110px;
}
.page-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.page-thumb {
  display: block;
  border-radius: 2px 6px 6px 2px;
  box-shadow: 0 1px 2px rgba(36, 28, 22, 0.08), 0 18px 30px -18px rgba(36, 28, 22, 0.55);
  transition: transform 0.35s var(--ease), box-shadow 0.35s;
  -webkit-tap-highlight-color: transparent;
}
.page-thumb:hover { transform: translateY(-4px) rotate(-0.5deg); }
.page-thumb .pg-sheet { pointer-events: none; }
.page-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 36px; }
.page-card-date { min-width: 0; font-family: var(--serif); font-size: 1.05rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-card-actions { display: flex; gap: 2px; flex: none; }
.page-new {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 2 / 3;
  border: 1.5px dashed var(--line-strong);
  background: rgba(255, 253, 248, 0.55);
  box-shadow: none;
  color: var(--ink-2);
}
.page-new:hover { background: var(--white); color: var(--ink); }
.page-new-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.page-new-inner .i { width: 26px; height: 26px; }
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 2px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 11.5px;
  font-weight: 700;
}

/* ---- Atalho de criação rápida ---- */
.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 22px 0 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 16px 32px -14px rgba(36, 28, 22, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.25s var(--ease), box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: scale(0.97); }
.fab .i { width: 22px; height: 22px; }

.lib-head-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- Momentos soltos ---- */
.moments { margin-bottom: clamp(44px, 6vw, 76px); }
.moments-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.moments-head .case-note { margin-top: 4px; }
.moment-list {
  display: flex;
  gap: 20px;
  margin: 0 calc(var(--gutter) * -1);
  padding: 14px var(--gutter) 18px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: thin;
}
.moment {
  display: flex;
  flex: 0 0 clamp(224px, 25vw, 268px);
  flex-direction: column;
  gap: 12px;
  scroll-snap-align: start;
}
.moment-paper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 188px;
  padding: 20px 18px;
  border-radius: 3px;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(36, 28, 22, 0.08), 0 16px 26px -18px rgba(36, 28, 22, 0.5);
  transform: rotate(var(--tilt, -0.7deg));
}
.moment:nth-child(even) .moment-paper { --tilt: 0.8deg; }
/* Fita adesiva */
.moment-paper::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 66px;
  height: 20px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(214, 186, 128, 0.5);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}
.moment-date { font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.moment-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.moment-thumbs.n-1 { grid-template-columns: 1fr; }
.moment-thumbs.n-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.moment-thumb { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 2px; background: var(--paper-deep); }
.moment-thumbs.n-1 .moment-thumb { aspect-ratio: 16 / 10; }
.moment-thumb img,
.moment-thumb video { width: 100%; height: 100%; object-fit: cover; }
.moment-thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, 0.22); }
.moment-thumb .play .i { width: 20px; height: 20px; }
.moment-more { position: absolute; right: 22px; top: 18px; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.moment-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.4;
  white-space: pre-line;
}
.moment-actions { display: flex; align-items: center; gap: 4px; }
.moment-actions .btn { flex: 1; }

/* ---- Colocar num livro / trazer momentos ---- */
.select {
  width: 100%;
  min-height: 50px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  font-size: 16px;
}
.select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(176, 138, 74, 0.16); }
.field-help { font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.place-books { display: flex; gap: 16px; overflow-x: auto; padding: 8px 4px 10px; }
.place-book {
  display: flex;
  flex: 0 0 92px;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
}
.place-cover { display: block; border-radius: 3px 8px 8px 3px; transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.place-book[aria-pressed="true"] { color: var(--ink); }
.place-book[aria-pressed="true"] .place-cover { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.place-book-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.place-empty { font-family: var(--serif); font-size: 1.15rem; color: var(--ink-2); }

.bring-list { display: grid; gap: 8px; max-height: 52vh; margin-top: 14px; overflow-y: auto; }
.bring-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.bring-item:has(input:checked) { box-shadow: inset 0 0 0 2px var(--ink); }
.bring-item input { flex: none; width: 18px; height: 18px; accent-color: var(--ink); }
.bring-thumb { display: grid; flex: none; place-items: center; width: 54px; height: 54px; overflow: hidden; border-radius: 6px; background: var(--paper-deep); color: var(--ink-3); }
.bring-thumb img,
.bring-thumb video { width: 100%; height: 100%; object-fit: cover; }
.bring-body { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; color: var(--ink-2); }
.bring-body b { font-weight: 600; color: var(--ink); }
.bring-body span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

@media (max-width: 720px) {
  .fab { width: 58px; height: 58px; padding: 0; justify-content: center; }
  .fab span { display: none; }
  .lib-head-actions { width: 100%; }
  .lib-head-actions .btn { flex: 1 1 0; width: auto; }
  .moments-head .btn { display: none; }
  .page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* No celular, tocar na data já abre o seletor nativo: o ícone extra só ocuparia espaço. */
  .ed-date input { font-size: 1rem; }
  .editor[data-kind="page"] .ed-top-actions { gap: 0; }
  .ed-date input::-webkit-calendar-picker-indicator { display: none; }
  .ep-papers { grid-template-columns: repeat(7, minmax(52px, 1fr)); overflow-x: auto; }
  .rd-book-title,
  .rd-chapter { max-width: 44vw; }
  .rd-top-actions { gap: 6px; }
}


/* =========================================================
   18. Vídeo: escolher o trecho (até 30 s)
   ========================================================= */
.trimmer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #17110D;
  color: #F1E9DB;
}
.trimmer[open] { animation: fade-in 0.25s ease; }
.trimmer::backdrop { background: #17110D; }

.tr-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.tr-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.trimmer .tr-top .icon-btn { color: #E8DFCF; }
.trimmer .tr-top .icon-btn:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.tr-heading { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.tr-heading .eyebrow { color: #9C8E7C; font-size: 10.5px; }
.tr-heading strong { overflow: hidden; font-family: var(--serif); font-size: 1.3rem; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.tr-top .btn-primary { background: #F1E9DB; color: #1E1814; }
.tr-top .btn-primary:hover { background: #fff; }

.tr-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 8px 16px;
}
.tr-stage video {
  position: absolute;
  inset: 8px 16px;
  width: calc(100% - 32px);
  height: calc(100% - 16px);
  object-fit: contain;
  border-radius: 6px;
  background: #0E0A08;
}
.tr-play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(20, 12, 6, 0.55);
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.tr-play .i { width: 28px; height: 28px; }
.tr-play .i-play { fill: currentColor; margin-left: 3px; }
.tr-play .i-pause { display: none; stroke-width: 2.6; }
.tr-play.playing { opacity: 0; }
.tr-play.playing:hover,
.tr-play.playing:focus-visible { opacity: 1; }
.tr-play.playing .i-play { display: none; }
.tr-play.playing .i-pause { display: block; }
.tr-msg {
  position: absolute;
  left: 50%;
  bottom: 18px;
  max-width: min(440px, 86%);
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(20, 12, 6, 0.78);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.tr-controls { padding: 6px 20px calc(18px + env(safe-area-inset-bottom)); }
.tr-times {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: #BFB2A0;
}
.tr-len { font-family: var(--serif); font-size: 1.1rem; color: #F1E9DB; }

.tr-strip {
  position: relative;
  height: 58px;
  border-radius: 10px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.tr-frames {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(90deg, #3B2F26, #2A211B);
}
.tr-frames canvas { flex: 1 1 0; min-width: 0; height: 100%; object-fit: cover; }
.tr-shade {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(14, 9, 6, 0.66);
  pointer-events: none;
}
.tr-shade.l { left: 0; border-radius: 10px 0 0 10px; }
.tr-shade.r { right: 0; border-radius: 0 10px 10px 0; }
.tr-window {
  position: absolute;
  top: -3px;
  bottom: -3px;
  border: 3px solid #E2C994;
  border-left-width: 16px;
  border-right-width: 16px;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  cursor: grab;
  transform: translateX(-16px);
  box-sizing: content-box;
}
.tr-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30px;
  cursor: ew-resize;
  outline: none;
}
.tr-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 2px;
  background: #3B2A17;
}
.tr-handle.s { left: -23px; }
.tr-handle.e { right: -23px; }
.tr-handle:focus-visible::after { background: #fff; box-shadow: 0 0 0 3px #3B2A17; }
.tr-head {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.tr-hint { margin-top: 12px; font-size: 12.5px; text-align: center; color: #9C8E7C; }
.trimmer.locked .tr-strip { cursor: default; }
.trimmer.locked .tr-handle { display: none; }
.trimmer.locked .tr-hint { visibility: hidden; }

.tr-result-title { font-family: var(--serif); font-size: 1.4rem; text-align: center; }
.tr-result-info { margin-top: 2px; font-size: 13px; text-align: center; color: #BFB2A0; }
.tr-result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.tr-result-actions .btn-ghost { color: #F1E9DB; border-color: rgba(255, 255, 255, 0.22); }
.tr-result-actions .btn-primary { background: #F1E9DB; color: #1E1814; }

.trimmer[data-mode="trim"] .tr-only-result,
.trimmer[data-mode="result"] .tr-only-trim { display: none; }

.tr-busy {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(14, 9, 6, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.tr-busy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(320px, 84vw);
  padding: 24px;
  border-radius: 18px;
  background: #241C16;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9);
  text-align: center;
}
.tr-busy-card p { font-family: var(--serif); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.tr-bar { display: block; width: 100%; height: 3px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.tr-bar span { display: block; width: 0; height: 100%; background: #E2C994; transition: width 0.2s linear; }
.tr-busy-card .btn-ghost { color: #F1E9DB; border-color: rgba(255, 255, 255, 0.22); }

@media (max-width: 720px) {
  .tr-top { padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
  .tr-heading strong { font-size: 1.08rem; }
  .tr-stage video { inset: 4px 8px; width: calc(100% - 16px); height: calc(100% - 8px); }
  .tr-controls { padding: 6px 16px calc(14px + env(safe-area-inset-bottom)); }
  .tr-result-actions .btn { flex: 1 1 0; }
}


/* =========================================================
   19. Planos
   ========================================================= */
.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.7);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background-color 0.2s, box-shadow 0.2s;
}
.plan-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.plan-chip:hover { background: var(--white); box-shadow: inset 0 0 0 1px var(--ink-3); }
.plan-chip.is-premium { background: var(--ink); color: var(--paper); box-shadow: none; }

.usage-note { color: var(--ink-3); font-size: 12px; }
.link-btn {
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); text-decoration-color: currentColor; }
.section-note .usage-note { display: inline-block; margin-top: 4px; }
.form-error .link-btn { color: var(--ink); font-weight: 600; }

.plan-reason {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(176, 138, 74, 0.12);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.4;
  color: var(--ink);
}
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 20px 20px;
  border-radius: 18px;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line);
}
.plan-card.is-current { box-shadow: inset 0 0 0 2px var(--ink); }
.plan-card-premium {
  color: #F6EFE2;
  background:
    radial-gradient(420px 220px at 100% 0, rgba(226, 201, 148, 0.22), transparent 70%),
    linear-gradient(160deg, #3A1A22, #241014);
  box-shadow: 0 24px 40px -28px rgba(36, 16, 20, 0.9);
}
.plan-card-premium.is-current { box-shadow: 0 0 0 2px #E2C994, 0 24px 40px -28px rgba(36, 16, 20, 0.9); }
.plan-badge {
  display: none;
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.plan-card.is-current .plan-badge { display: inline-block; }
.plan-card-premium .plan-badge { background: #E2C994; color: #2A1A12; }
.plan-name { font-family: var(--serif); font-size: 1.7rem; font-weight: 500; line-height: 1.1; }
.plan-desc { font-size: 13.5px; line-height: 1.5; opacity: 0.8; }
.plan-usage { display: grid; gap: 12px; margin-top: 8px; }
.plan-meter { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13px; }
.plan-meter b { font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-track { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: 4px; background: var(--paper-deep); }
.plan-track span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.plan-meter-note { color: var(--ink-2); }
.plan-list { display: grid; gap: 10px; margin-top: 8px; font-size: 13.5px; line-height: 1.4; }
.plan-list li { display: flex; align-items: flex-start; gap: 10px; }
.plan-list .i { flex: none; width: 17px; height: 17px; margin-top: 1px; color: #E2C994; stroke-width: 2.2; }
.plan-soon-tag {
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.plan-cta:empty { display: none; }
.plan-cta { margin-top: 16px; }
.plan-note { font-size: 13.5px; line-height: 1.55; color: var(--ink-2); text-align: center; }

@media (max-width: 720px) {
  .plan-grid { grid-template-columns: 1fr; }
  .plan-name { font-size: 1.45rem; }
}


/* =========================================================
   20. Conta e assinatura
   ========================================================= */
.field input[type="email"] {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input[type="email"]:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(176, 138, 74, 0.16); }
.field input.code-input {
  font-family: var(--serif);
  font-size: 1.9rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.account-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--ink-2); }
.account-who { font-family: var(--serif); font-size: 1.2rem; overflow-wrap: anywhere; }
.link-btn.danger { color: var(--danger); }

.plan-account { margin-top: 14px; font-size: 13px; text-align: center; color: var(--ink-3); overflow-wrap: anywhere; }
.plan-account:empty { display: none; }
.plan-buy { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.plan-buy-btn { min-width: min(320px, 100%); min-height: 52px; font-size: 15px; }

/* =========================================================
   21. Perfil e livros na nuvem
   ========================================================= */
.profile-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.profile-heading { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; }
.profile-photo-row { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar .i { width: 30px; height: 30px; }
.input-prefix {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-prefix > span { padding-left: 15px; color: var(--ink-3); font-size: 16px; }
.field .input-prefix input[type="text"] { border: 0; background: transparent; padding-left: 4px; box-shadow: none; }
.input-prefix:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(176, 138, 74, 0.16); }
.profile-save { align-self: flex-start; }

.cloud-status {
  margin-top: 8px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--book-ink) 72%, transparent);
}
.cloud-status:empty { display: none; }
.cloud-status[data-tone="ok"]::before { content: "✓ "; }
.cloud-status[data-tone="warn"] { color: var(--book-ink); font-weight: 600; }

/* ---------- Amigos ---------- */
.friends-view .lib-head { margin-bottom: 18px; }
.friends-note { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); }
.friends-section { margin-top: clamp(24px, 4vw, 40px); }
.friends-search { max-width: 520px; }
.friends-empty { margin-top: 10px; font-size: 14px; color: var(--ink-3); }
.friends-empty:empty { display: none; }
.people { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.person {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.person-avatar {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  color: var(--ink-3);
}
.person-avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-avatar .i { width: 24px; height: 24px; }
.person-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.person-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; overflow-wrap: anywhere; }
.person-user { font-size: 13px; color: var(--ink-3); }
.person-bio { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-actions { flex: none; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.person-note { font-size: 13px; color: var(--ink-3); }
.btn.btn-compact { min-height: 38px; padding: 8px 14px; font-size: 13px; }
@media (max-width: 560px) {
  .person { flex-wrap: wrap; }
  .person-actions { width: 100%; justify-content: flex-start; padding-left: 62px; }
}

/* ---------- Publicar e livros dos amigos ---------- */
.publish-options { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; }
.publish-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.publish-option:has(input:checked) { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(107, 30, 44, 0.12); }
.publish-option input { margin-top: 4px; accent-color: var(--wine); width: 18px; height: 18px; flex: none; }
.publish-text { display: flex; flex-direction: column; gap: 2px; }
.publish-text b { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.publish-text span { font-size: 13.5px; color: var(--ink-2); }

.shared-books {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 22px 18px;
}
.shared-link { display: flex; flex-direction: column; gap: 10px; color: inherit; text-decoration: none; }
.shared-cover {
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
  box-shadow: var(--shadow-2);
  container-type: inline-size;
  transition: transform 0.3s var(--ease);
}
.shared-cover .cover { width: 100%; height: 100%; }
.shared-link:hover .shared-cover, .shared-link:focus-visible .shared-cover { transform: translateY(-4px); }
.shared-body { display: flex; flex-direction: column; gap: 2px; }
.shared-body b { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.shared-body span { font-size: 13px; color: var(--ink-3); }
.rd-byline { font-style: italic; font-weight: 400; opacity: 0.75; }

/* ---------- Livros colaborativos ---------- */
.invite-heading { margin: 20px 0 0; font-family: var(--serif); font-size: 1.3rem; font-weight: 500; }
#inviteBody .people { margin-top: 10px; }
#inviteBody .person { box-shadow: none; }
.invite-mark { background: var(--book); color: var(--book-ink); }
.ed-presence {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: #E2C994;
  font-weight: 600;
}
.ed-presence[hidden] { display: none; }
.legal-links { margin-top: 12px; font-size: 12.5px; text-align: center; color: var(--ink-3); }
.legal-links a { color: inherit; }

/* =========================================================
   22. Rede: cartão de perfil e estante
   ========================================================= */
.social-layout {
  display: grid;
  /* O perfil é a parte principal; a busca e as listas ficam numa coluna mais estreita. */
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  gap: clamp(24px, 4vw, 52px);
  align-items: start;
}
.social-side { min-width: 0; }
.social-main > .friends-section:first-of-type { margin-top: 18px; }
@media (max-width: 900px) {
  .social-layout { grid-template-columns: minmax(0, 1fr); }
}

.person { padding: 10px 14px 10px 10px; }
.person-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}
a.person-link:hover .person-name,
a.person-link:focus-visible .person-name { color: var(--wine); }
@media (max-width: 560px) { .person-actions { padding-left: 66px; } }

.profile-card {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}
/* Capa: o tecido do livro em destaque, com moldura dourada como nas capas do LAIF */
.pc-banner {
  position: relative;
  height: 112px;
  background:
    radial-gradient(120% 160% at 12% -20%, rgba(255, 255, 255, 0.18), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, color-mix(in srgb, var(--book) 82%, #fff 8%), color-mix(in srgb, var(--book) 88%, #000 22%));
}
.pc-frame {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(226, 201, 148, 0.5);
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px rgba(226, 201, 148, 0.12);
}
.pc-motto {
  position: absolute;
  right: 24px;
  top: 20px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(226, 201, 148, 0.85);
}
.pc-head {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-top: -44px;
  padding: 0 22px;
}
.pc-avatar {
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  color: var(--ink-3);
  border: 4px solid var(--card);
  box-shadow: 0 10px 24px -12px rgba(36, 28, 22, 0.55);
}
.pc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pc-avatar .i { width: 40px; height: 40px; }
.pc-names { min-width: 0; padding-bottom: 6px; }
.pc-name { font-family: var(--serif); font-weight: 600; font-size: 1.65rem; line-height: 1.1; overflow-wrap: anywhere; }
.pc-user { margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.pc-bio { padding: 12px 22px 0; font-family: var(--serif); font-style: italic; font-size: 1.1rem; line-height: 1.45; color: var(--ink-2); }
.pc-stats {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px 22px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.pc-stats li + li { border-left: 1px solid var(--line); }
.pc-stats b { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.55rem; line-height: 1.1; color: var(--ink); }
.pc-stats span { display: block; font-size: 12px; letter-spacing: 0.01em; color: var(--ink-3); white-space: nowrap; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 22px 0; }
.pc-actions:empty { display: none; }

/* Estante do perfil: madeira e livros em 3D, como a biblioteca */
.pc-books {
  margin-top: 18px;
  padding: 16px 0 20px;
  background: linear-gradient(180deg, #E7DCC7 0%, #DED0B6 100%);
  box-shadow: inset 0 40px 60px -50px rgba(70, 45, 20, 0.45);
}
.pc-books-title { padding: 0 22px 14px; font-family: var(--serif); font-weight: 500; font-size: 1.3rem; }
/* As tábuas são desenhadas no fundo da lista: uma por fileira, de ponta a ponta. */
.pc-shelf {
  --bw: 104px;                                   /* largura de cada lugar na estante */
  --bh: calc((var(--bw) - 18px) * 1.5);          /* altura do livro (capa 2:3) */
  --gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--bw));
  grid-auto-rows: calc(var(--bh) + 12px);
  row-gap: var(--gap);
  background:
    linear-gradient(180deg, transparent var(--bh), #C89F75 var(--bh), #A97D55 calc(var(--bh) + 2px),
      #7A5638 calc(var(--bh) + 8px), #5D3F28 calc(var(--bh) + 12px), rgba(60, 35, 15, 0.18) calc(var(--bh) + 12px),
      transparent calc(var(--bh) + 19px))
    0 0 / 100% calc(var(--bh) + 12px + var(--gap)) repeat-y;
}
.pc-slot { min-width: 0; height: var(--bh); display: flex; align-items: flex-end; justify-content: center; }
.pc-slot .book { width: calc(var(--bw) - 18px); }
.pc-empty { padding: 0 22px; font-size: 13.5px; color: var(--ink-2); }

/* Página de perfil: versão larga */
.profile-view .wrap { max-width: 980px; padding-top: clamp(20px, 4vw, 40px); padding-bottom: clamp(40px, 6vw, 72px); }
.profile-card.is-wide .pc-banner { height: clamp(150px, 24vw, 230px); }
.profile-card.is-wide .pc-frame { inset: 16px; }
.profile-card.is-wide .pc-motto { top: auto; bottom: 22px; right: 28px; font-size: 15px; }
.profile-card.is-wide .pc-head { margin-top: -64px; padding: 0 clamp(20px, 4vw, 40px); gap: 18px; }
.profile-card.is-wide .pc-avatar { width: 132px; height: 132px; border-width: 5px; }
.profile-card.is-wide .pc-name { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.profile-card.is-wide .pc-bio,
.profile-card.is-wide .pc-actions { padding-left: clamp(20px, 4vw, 40px); padding-right: clamp(20px, 4vw, 40px); }
.profile-card.is-wide .pc-stats { max-width: 520px; margin-left: clamp(20px, 4vw, 40px); }
.profile-card.is-wide .pc-books { margin-top: 26px; padding: 26px 0 30px; }
.profile-card.is-wide .pc-books-title { padding: 0 clamp(20px, 4vw, 40px) 20px; font-size: 1.6rem; }
.profile-card.is-wide .pc-shelf { --bw: 150px; --gap: 34px; padding: 0 clamp(14px, 3vw, 32px); }
@media (max-width: 560px) {
  .profile-card.is-wide .pc-avatar { width: 104px; height: 104px; }
  .profile-card.is-wide .pc-head { margin-top: -52px; }
  .profile-card.is-wide .pc-shelf { --bw: 120px; }
}

/* Cartão ao lado das listas: maior, com a estante em destaque */
.social-side .pc-banner { height: clamp(140px, 16vw, 180px); }
.social-side .pc-head { margin-top: -56px; }
.social-side .pc-avatar { width: 116px; height: 116px; border-width: 5px; }
.social-side .pc-avatar .i { width: 48px; height: 48px; }
.social-side .pc-name { font-size: clamp(1.7rem, 2.6vw, 2.1rem); }
.social-side .pc-stats b { font-size: 1.75rem; }
.social-side .pc-books { padding: 22px 0 26px; }
.social-side .pc-books-title { font-size: 1.5rem; padding-bottom: 18px; }
.social-side .pc-shelf { --bw: 132px; --gap: 30px; padding: 0 18px; }
@media (max-width: 560px) { .social-side .pc-shelf { --bw: 104px; } }

/* Foto de capa do perfil */
.pc-banner.has-photo { background-size: cover; background-position: center; }
.pc-banner.has-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 14, 10, 0.05) 40%, rgba(20, 14, 10, 0.4));
  pointer-events: none;
}
.pc-banner > * { z-index: 1; }
.pc-banner-btn {
  position: absolute;
  top: 22px;
  left: 24px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(20, 14, 10, 0.5);
  color: #FBF6EC;
  font-size: 12.5px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: background 0.2s;
}
.pc-banner-btn:hover, .pc-banner-btn:focus-visible { background: rgba(20, 14, 10, 0.72); }
.pc-banner-btn .i { width: 15px; height: 15px; }
