/* ===== Fontes ===== */
@font-face { font-family: Figtree; src: url("../fonts/figtree-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Figtree; src: url("../fonts/figtree-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Figtree; src: url("../fonts/figtree-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Figtree; src: url("../fonts/figtree-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: Bricolage; src: url("../fonts/bricolage-grotesque-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Bricolage; src: url("../fonts/bricolage-grotesque-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }

/* ===== Cores e medidas ===== */
:root {
  --bg: #0b0b0d;
  --panel: #151519;
  --card: #1a1a20;
  --raised: #1b1b21;
  --line: #2c2a31;
  --line-soft: rgba(255, 255, 255, 0.08);
  --muted: #9a98a2;
  --soft: #c9c7cd;
  --ink: #f5f4f0;
  --red: #d6232b;
  --red-2: #ef656b;
  --red-deep: #a71927;
  --wine: #471d28;
  --green: #72d99a;
  --radius: 18px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --gutter: 16px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --title: Bricolage, system-ui, sans-serif;
  --body: Figtree, system-ui, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 85% -10%, rgba(214, 35, 43, 0.18), transparent 28rem), var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
button, a, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
a { text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--title); font-weight: 800; line-height: 1.05; letter-spacing: -0.025em; }
:focus-visible { outline: 2px solid var(--red-2); outline-offset: 3px; border-radius: 6px; }
.ic { width: 22px; height: 22px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Estrutura ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: content-box;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0.92), rgba(11, 11, 13, 0.7));
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transition: transform 0.25s ease;
}
.topbar.is-hidden { transform: translateY(-110%); }
.brand { font: 800 18px/1 var(--title); letter-spacing: 0.07em; white-space: nowrap; }
.brand span { color: var(--red); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--soft); }
.icon-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(145deg, #8c3844, #301821); border: 1px solid #b85d63;
  color: #ffe9e6; font-weight: 700; font-size: 15px;
}
.app-layout { max-width: 1440px; margin: 0 auto; }
.sidebar { display: none; }
main { min-width: 0; padding: 8px var(--gutter) calc(var(--nav-h) + var(--safe-b) + 32px); outline: none; }
.screen { max-width: 1080px; margin: 0 auto; animation: fade-in 0.3s ease both; }

.bottom-nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  border-top: 1px solid #25232a;
  background: rgba(13, 13, 16, 0.96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.bottom-nav a { position: relative; display: grid; place-content: center; justify-items: center; gap: 3px; color: #85828c; font-size: 11px; font-weight: 600; }
.bottom-nav a.is-active { color: var(--ink); }
.bottom-nav a.is-active .ic { color: var(--red-2); }
.bottom-nav .lock-badge { position: absolute; top: 9px; right: calc(50% - 20px); }

body.is-immersive .topbar, body.is-immersive .bottom-nav, body.is-immersive .sidebar { display: none; }
body.is-immersive main { padding-bottom: 40px; }
body.hide-topbar .topbar { display: none; }

@media (min-width: 900px) {
  :root { --gutter: 40px; }
  .topbar { height: 72px; }
  .brand { font-size: 20px; }
  .app-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar {
    display: block; position: sticky; top: 72px; align-self: start;
    min-height: calc(100vh - 72px); padding: 32px 20px;
    border-right: 1px solid var(--line-soft);
  }
  .sidebar nav { display: grid; gap: 4px; }
  .sidebar a {
    display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 11px;
    color: var(--muted); font-weight: 500; transition: background 0.2s, color 0.2s;
  }
  .sidebar a:hover, .sidebar a.is-active { background: rgba(214, 35, 43, 0.13); color: var(--ink); }
  .sidebar a.is-active .ic { color: var(--red-2); }
  .sidebar .lock-badge { margin-left: auto; }
  .sidebar-kicker { color: #6e6b74; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; margin: 0 12px 12px; }
  .sidebar-sep { height: 1px; background: var(--line-soft); margin: 14px 12px; }
  .bottom-nav { display: none; }
  main { padding: 24px var(--gutter) 80px; }
  body.hide-topbar .topbar { display: flex; }
}

/* ===== Textos ===== */
.kicker { display: block; color: var(--red-2); font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 6px; }
.muted { color: var(--muted); }
.page-title { font-size: clamp(28px, 7vw, 44px); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 32px 0 14px; }
.section-head h2 { font-size: 21px; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--red-2); font-size: 14px; font-weight: 600; white-space: nowrap; }
.attribution { margin: 36px auto 0; max-width: 720px; color: #77737e; font-size: 12px; line-height: 1.55; text-align: center; }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 50px; padding: 0 20px; border-radius: 12px;
  font-weight: 700; font-size: 16px; white-space: nowrap; transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 8px 23px rgba(214, 35, 43, 0.25); }
.btn-primary:hover { background: #e8333b; }
.btn-light { background: var(--ink); color: #121214; }
.btn-secondary { border: 1px solid var(--line); background: var(--raised); color: var(--soft); }
.btn-secondary:hover { border-color: #77424b; color: #fff; }
.btn-ghost { color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 99px; background: #15151a; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.is-active { border-color: #9b4049; background: rgba(214, 35, 43, 0.16); color: #fff; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.chip-row::-webkit-scrollbar { display: none; }

.lock-badge { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(11, 11, 13, 0.75); color: #e8c38c; border: 1px solid rgba(232, 195, 140, 0.35); }
.lock-badge .ic { width: 11px; height: 11px; stroke-width: 2.6; }

/* ===== Progresso ===== */
.progress-line { height: 4px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.2); }
.progress-line span { display: block; height: 100%; border-radius: inherit; background: var(--red-2); }

/* ===== Capas e cards ===== */
.cover { position: relative; width: 100%; height: 100%; overflow: hidden; background: #241f27; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 14px 12px 44px;
  background:
    radial-gradient(circle at 75% 18%, rgba(255, 255, 255, 0.16), transparent 42%),
    radial-gradient(circle at 20% 90%, rgba(214, 35, 43, 0.28), transparent 50%),
    linear-gradient(160deg, var(--c1), var(--c2));
}
.cover-fallback::before {
  content: ""; position: absolute; top: 14%; left: 50%; width: 56%; aspect-ratio: 1; transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 50%;
  box-shadow: 0 0 0 14px rgba(255, 255, 255, 0.03), 0 0 0 30px rgba(255, 255, 255, 0.02);
}
.cover-initial {
  position: absolute; top: 8%; left: 0; right: 0; text-align: center;
  font: 800 clamp(64px, 22vw, 120px)/1 var(--title); color: rgba(255, 255, 255, 0.13); letter-spacing: -0.04em;
}
.book-card .cover-initial { top: 14%; }
.cover-fallback strong { position: relative; font: 800 clamp(18px, 4.6vw, 26px)/1 var(--title); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.cover-group { position: relative; font-size: 9px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6); margin-bottom: 6px; }
.cover-brand { position: absolute; top: 12px; left: 12px; font: 800 8px/1 var(--title); letter-spacing: 0.16em; color: rgba(255, 255, 255, 0.45); }
.book-card .cover-fallback strong, .book-card .cover-group { display: none; }

.book-card {
  position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden;
  background: #29242d; box-shadow: 0 12px 25px rgba(0, 0, 0, 0.25); transition: transform 0.2s, filter 0.2s;
}
.book-card:hover { transform: translateY(-4px); filter: brightness(1.08); }
.book-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 42%, rgba(9, 8, 11, 0.92) 100%); pointer-events: none; }
.book-card-copy { position: absolute; z-index: 1; left: 11px; right: 11px; bottom: 11px; }
.book-card-copy strong { display: block; font: 800 19px/1.05 var(--title); overflow-wrap: anywhere; }
.book-card-copy small { display: block; margin-top: 4px; color: #ddd9dc; font-size: 12px; }
.book-card-copy .progress-line { margin-top: 8px; height: 3px; }

.shelf {
  display: grid; grid-auto-flow: column; grid-auto-columns: 38%; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter)); padding: 4px var(--gutter) 10px; scroll-padding: 0 var(--gutter);
}
.shelf::-webkit-scrollbar { display: none; }
.shelf > * { scroll-snap-align: start; }
@media (min-width: 600px) { .shelf { grid-auto-columns: 24%; } }
@media (min-width: 900px) { .shelf { grid-auto-columns: 172px; gap: 16px; } }

.grid-books { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-books .book-card-copy strong { font-size: 15px; }
.grid-books .book-card-copy small { font-size: 11px; }
@media (min-width: 600px) { .grid-books { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } .grid-books .book-card-copy strong { font-size: 18px; } }
@media (min-width: 1100px) { .grid-books { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* ===== Painéis ===== */
.panel { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(24, 24, 29, 0.8); }
.list-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft); text-align: left;
}
.list-row:last-child { border-bottom: 0; }
.list-row .row-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: rgba(214, 35, 43, 0.13); color: var(--red-2); flex: none; }
.list-row .row-main { flex: 1; min-width: 0; }
.list-row .row-main strong { display: block; font-size: 16px; }
.list-row .row-main small { display: block; color: var(--muted); font-size: 13px; }
.list-row .row-end { color: var(--muted); display: flex; align-items: center; gap: 8px; }

.empty-state { padding: 40px 20px; border: 1px dashed #3c3841; border-radius: 16px; color: var(--muted); text-align: center; }
.empty-state .ic { width: 34px; height: 34px; color: var(--red-2); margin-bottom: 12px; }
.empty-state h3 { color: var(--ink); font-size: 20px; margin-bottom: 6px; }
.empty-state p { max-width: 340px; margin: 0 auto; font-size: 15px; }
.empty-state .btn { margin-top: 18px; }

.field {
  width: 100%; min-height: 50px; padding: 12px 16px; border: 1px solid #3b3740; border-radius: 12px;
  background: #19191f; color: var(--ink); font-size: 16px; outline: none;
}
.field:focus { border-color: #9b4049; }
textarea.field { min-height: 120px; resize: vertical; line-height: 1.5; }

/* ===== Modal / folha inferior ===== */
.modal-backdrop {
  position: fixed; z-index: 60; inset: 0; display: grid; place-items: end center;
  background: rgba(5, 5, 7, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fade-in 0.2s ease;
}
.modal {
  position: relative; width: 100%; max-height: 88vh; overflow: auto;
  padding: 28px 20px calc(24px + var(--safe-b)); border: 1px solid #3d2a31; border-bottom: 0;
  border-radius: 22px 22px 0 0; background: linear-gradient(160deg, #1f171c, #131318);
  box-shadow: var(--shadow); animation: sheet-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 640px) {
  .modal-backdrop { place-items: center; padding: 20px; }
  .modal { width: min(480px, 100%); border-bottom: 1px solid #3d2a31; border-radius: 22px; padding-bottom: 28px; animation: fade-in 0.2s ease; }
}
.modal-close { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--muted); }
.modal h2 { font-size: 26px; padding-right: 36px; }
.modal p { color: var(--soft); margin-top: 10px; }
.modal .btn-block { margin-top: 12px; }
.lock-modal { text-align: center; padding-top: 8px; }
.lock-modal h2 { padding: 0; margin-bottom: 4px; }
.lock-modal p { margin-bottom: 18px; }
.lock-icon { display: grid; place-items: center; width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 18px; border: 1px solid rgba(232, 195, 140, 0.4); background: rgba(232, 195, 140, 0.1); color: #e8c38c; }
.lock-icon .ic { width: 28px; height: 28px; }
.sheet-actions { display: grid; gap: 4px; margin-top: 16px; }
.sheet-actions button, .sheet-actions a { display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 8px; border-radius: 12px; font-weight: 600; text-align: left; }
.sheet-actions button:hover, .sheet-actions a:hover { background: rgba(255, 255, 255, 0.05); }
.sheet-actions .ic { color: var(--red-2); }

/* ===== Toast ===== */
.toast {
  position: fixed; z-index: 70; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; width: max-content; max-width: calc(100% - 32px); padding: 12px 16px;
  border: 1px solid #5f343a; border-radius: 14px; background: #21171c; box-shadow: var(--shadow); color: #f4e7e7;
  animation: toast-in 0.3s ease;
}
.toast-icon { color: var(--green); }
.toast small { display: block; color: #aaa1a5; font-size: 13px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.skeleton { border-radius: 14px; background: linear-gradient(90deg, #17171c 0%, #222228 50%, #17171c 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }

@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
