:root {
  --primary: #5900B2;
  --primary-dark: #35006f;
  --gold: #E4C48B;
  --bg: #f7f2ea;
  --card: #ffffff;
  --text: #241b2f;
  --muted: #756b7f;
  --shadow: 0 18px 45px rgba(36, 27, 47, .13);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(228,196,139,.35), transparent 35%),
    linear-gradient(180deg, #fffaf2 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  padding: 34px 22px 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  box-shadow: var(--shadow);
}

.topbar h1 { margin: 8px 0 6px; font-size: 30px; }
.topbar p { margin: 0; opacity: .9; line-height: 1.4; }

.app-label {
  background: var(--gold);
  color: var(--primary-dark);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

main { max-width: 1100px; margin: 0 auto; padding: 28px 18px 50px; }
.view { display: none; }
.view.active { display: block; }

.section-title {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.section-title h2 { margin: 0; font-size: 24px; }

#searchInput {
  width: min(380px, 100%);
  border: 1px solid rgba(89,0,178,.18);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 15px;
  outline: none;
  background: white;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

.book-card {
  background: var(--card);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  border: 1px solid rgba(89,0,178,.08);
}

.book-card:hover { transform: translateY(-5px); box-shadow: 0 22px 55px rgba(36, 27, 47, .18); }

.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 18px;
  background: #ddd;
  margin-bottom: 14px;
}

.book-card h3 { margin: 0 0 7px; font-size: 19px; }
.book-author { color: var(--primary); font-weight: 700; margin: 0 0 8px; font-size: 14px; }
.book-desc { color: var(--muted); margin: 0 0 14px; line-height: 1.4; font-size: 14px; }

.read-button {
  display: inline-block;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
}

.back-btn {
  border: none;
  background: var(--primary);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 18px;
}

.reader-card {
  background: white;
  border-radius: 26px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.reader-header {
  display: flex;
  gap: 18px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(89,0,178,.12);
  margin-bottom: 18px;
}

.reader-header img {
  width: 105px;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 12px 25px rgba(0,0,0,.16);
}

.reader-label { color: var(--primary); font-weight: 700; font-size: 12px; text-transform: uppercase; }
.reader-header h2 { margin: 8px 0 6px; font-size: 26px; }
.reader-header p { margin: 0; color: var(--muted); }

.paragraph {
  padding: 16px 0;
  border-bottom: 1px solid rgba(36, 27, 47, .08);
  line-height: 1.65;
  font-size: 18px;
}

.paragraph-number {
  color: var(--primary);
  font-weight: 800;
  margin-right: 8px;
}

@media (max-width: 650px) {
  .section-title { flex-direction: column; align-items: stretch; }
  .reader-header { align-items: flex-start; }
  .reader-header img { width: 82px; height: 110px; }
  .topbar h1 { font-size: 25px; }
}

.loading-livro{
  min-height:220px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:14px;
  color:#6500C8;
  font-weight:600;
}

.spinner{
  width:46px;
  height:46px;
  border:5px solid #eadbff;
  border-top-color:#6500C8;
  border-radius:50%;
  animation:girar .8s linear infinite;
}

@keyframes girar{
  to{ transform:rotate(360deg); }
}

.paragraphs-list {
  display: block !important;
  margin-top: 30px;
}

.paragraph-item {
  display: flex !important;
  align-items: flex-start;
  gap: 18px;
  padding: 24px 0;
  border-bottom: 1px solid #eee;
  color: #160022;
}

.paragraph-number {
  display: inline-flex !important;
  min-width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #6500C8;
  color: #fff !important;
  font-weight: 700;
  flex-shrink: 0;
}

.paragraph-text {
  flex: 1;
}

.paragraph-text p,
.paragraph-item p {
  display: block !important;
  color: #160022 !important;
  font-size: 18px;
  line-height: 1.75;
  margin: 0;
}

.paragraph-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.action-btn {
  border: none;
  background: #f4edff;
  color: #6500c8;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: .2s ease;
}

.action-btn:hover {
  background: #6500c8;
  color: #fff;
  transform: translateY(-2px);
}
.books-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(150px, 1fr));
  gap:34px 28px;
  align-items:start;
}

.book-card{
  background:transparent;
  border:none;
  box-shadow:none;
  cursor:pointer;
  text-align:center;
  transition:.25s ease;
}

.book-card:hover{
  transform:translateY(-8px);
}

.book-cover{
  width:145px;
  height:215px;
  object-fit:cover;
  border-radius:8px 14px 14px 8px;
  box-shadow:
    10px 14px 28px rgba(35, 0, 70, .22),
    inset 8px 0 10px rgba(255,255,255,.28);
  background:#eee;
  transition:.25s ease;
}

.book-card:hover .book-cover{
  transform:rotateY(-8deg) scale(1.04);
  box-shadow:14px 20px 34px rgba(35, 0, 70, .30);
}

.book-card h3{
  margin:14px auto 4px;
  max-width:160px;
  font-size:16px;
  line-height:1.2;
}

.book-card p{
  margin:0;
  font-size:13px;
  opacity:.7;
}

.books-grid::after{
  content:"";
  grid-column:1 / -1;
  height:14px;
  margin-top:-18px;
  border-radius:999px;
  background:linear-gradient(90deg, transparent, rgba(80,40,0,.18), transparent);
}

.reader-tools {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-book-btn {
  border: none;
  background: #6500c8;
  color: white;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(101, 0, 200, .18);
}

.search-book-btn:hover {
  transform: translateY(-2px);
}

.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 0, 40, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 70px 18px 18px;
  z-index: 9999;
}

.search-modal.active {
  display: flex;
}

.search-modal-content {
  width: 100%;
  max-width: 680px;
  max-height: 82vh;
  overflow: auto;
  background: #fff;
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 25px 70px rgba(0,0,0,.25);
}

.search-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.search-modal-header h3 {
  margin: 0;
}

#closeSearchModal {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #f1e5ff;
  color: #6500c8;
  font-size: 26px;
  cursor: pointer;
}

#modalSearchInput {
  width: 100%;
  padding: 15px 18px;
  border-radius: 999px;
  border: 1px solid #e2d2f7;
  font-size: 16px;
  outline: none;
}

.modal-search-results {
  margin-top: 18px;
}

.search-result-item {
  padding: 15px 0;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.search-result-item strong {
  color: #6500c8;
}

.search-result-item p {
  margin: 6px 0 0;
  line-height: 1.5;
  color: #333;
}

.search-result-item:hover {
  background: #faf6ff;
}

.search-hint {
  text-align: center;
  color: #777;
  padding: 24px;
}

.paragraph-highlight {
  animation: destacarParagrafo 2.2s ease;
}

@keyframes destacarParagrafo {
  0% {
    background: #fff2b8;
    transform: scale(1.01);
  }
  100% {
    background: transparent;
    transform: scale(1);
  }
}

.menu-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--gold);
  color: var(--primary-dark);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  z-index: 1001;
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,0,40,.45);
  opacity: 0;
  visibility: hidden;
  transition: .25s ease;
  z-index: 1099;
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(330px, 88vw);
  height: 100vh;
  background: #fff;
  transform: translateX(100%);
  transition: transform .28s ease;
  z-index: 1100;
  box-shadow: -20px 0 45px rgba(0,0,0,.2);
  padding: 22px;
}

.side-menu.active {
  transform: translateX(0);
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid #eee;
}

.close-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #f1e5ff;
  color: var(--primary);
  font-size: 26px;
  cursor: pointer;
}

.side-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
}

.menu-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 14px 16px;
  border-radius: 14px;
  text-align: left;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.menu-item:hover {
  background: #f7efff;
  color: var(--primary);
}

.info-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20,0,40,.55);
  padding: 18px;
  z-index: 1200;
}

.info-modal.active {
  display: flex;
}

.info-modal-content {
  width: min(560px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: #fff;
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 25px 70px rgba(0,0,0,.25);
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.info-modal-header h3 {
  margin: 0;
  color: var(--primary);
}

#closeInfoModal {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #f1e5ff;
  color: var(--primary);
  font-size: 26px;
  cursor: pointer;
}

#infoModalBody {
  color: var(--text);
  line-height: 1.7;
}

.favorite-btn {
  background: #fff7dd;
  color: #7b5900;
}

.favorite-btn:hover,
.favorite-btn.favoritado {
  background: #e4c48b;
  color: #35006f;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.favorite-item {
  position: relative;
  padding: 16px;
  border: 1px solid rgba(89, 0, 178, .12);
  border-radius: 18px;
  background: #fff;
  transition: .2s ease;
}

.favorite-item:hover {
  border-color: rgba(89, 0, 178, .35);
  box-shadow: 0 12px 28px rgba(36, 27, 47, .10);
}

.favorite-open {
  display: block;
  width: 100%;
  padding: 0 0 42px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.favorite-reference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.favorite-reference strong {
  color: var(--primary);
  font-size: 16px;
}

.favorite-reference span {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f1e5ff;
  color: var(--primary);
  font-weight: 800;
}

.favorite-open small {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.favorite-open p {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

.favorite-remove {
  position: absolute;
  left: 16px;
  bottom: 14px;
  border: none;
  background: transparent;
  color: #9b1c1c;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.favorite-remove:hover {
  text-decoration: underline;
}

.favoritos-vazio {
  padding: 35px 15px;
  text-align: center;
  color: var(--muted);
}

.favoritos-vazio-icone {
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 52px;
}

.random-book-btn {
  border: 1px solid rgba(89, 0, 178, .18);
  background: #f4edff;
  color: var(--primary);
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: .2s ease;
}

.random-book-btn:hover {
  background: var(--gold);
  color: var(--primary-dark);
  transform: translateY(-2px);
}

.random-point-card {
  text-align: left;
}

.random-point-reference {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.random-point-reference span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  height: 42px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.random-point-reference small {
  color: var(--muted);
  font-weight: 700;
}

.random-point-card p {
  margin: 0 0 22px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
}

.open-random-point-btn,
.new-random-point-btn {
  border: none;
  border-radius: 999px;
  padding: 11px 17px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: .2s ease;
}

.open-random-point-btn {
  background: var(--primary);
  color: #fff;
  margin-right: 8px;
}

.new-random-point-btn {
  background: #f1e5ff;
  color: var(--primary);
}

.open-random-point-btn:hover,
.new-random-point-btn:hover {
  transform: translateY(-2px);
}

@media (max-width: 520px) {
  .reader-tools {
    justify-content: stretch;
  }

  .random-book-btn,
  .search-book-btn {
    flex: 1;
    padding-left: 12px;
    padding-right: 12px;
  }

  .open-random-point-btn,
  .new-random-point-btn {
    width: 100%;
    margin: 0 0 9px;
  }
}