:root {
  --bg: #f8f5ed;
  --bg-card: #ffffff;
  --border: #e6ddce;
  --text: #19261e;
  --text-muted: #5e6d63;
  --brand: #0d2b1d;
  --brand-dark: #071910;
  --gold: #c99e46;
  --gold-light: #f5dfa6;
  --gold-dark: #916e25;
  --navy: #152d44;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(13, 43, 29, 0.08);
}

[data-theme="dark"] {
  --bg: #09140e;
  --bg-card: #102117;
  --border: #1d3829;
  --text: #f0ede4;
  --text-muted: #9ab0a2;
  --brand: #143e2b;
  --brand-dark: #06110a;
  --gold: #e2ba64;
  --gold-light: #382c13;
  --gold-dark: #f0cf87;
  --shadow: 0 4px 22px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* SHELL LAYOUT */
.shell {
  display: flex;
  width: 100%;
  height: 100%;
}

.col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  position: relative;
}

/* SIDEBAR (DESKTOP) */
.side {
  width: 260px;
  background: var(--brand-dark);
  color: #fff;
  border-right: 1px solid rgba(212, 175, 55, 0.25);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
}

.side .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 18px;
}

.side .brand img {
  border-radius: 50%;
  border: 1.5px solid var(--gold);
}

.side .brand span {
  display: flex;
  flex-direction: column;
}

.side .brand b {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  color: #fff;
  letter-spacing: 0.05em;
}

.side .brand small {
  font-size: 11px;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #d1ded6;
  transition: all 0.2s;
}

.side-nav a:hover, .side-nav a.active {
  background: rgba(212, 175, 55, 0.15);
  color: #fff;
}

.side-nav a.active {
  color: var(--gold);
  border-left: 3px solid var(--gold);
}

.side-nav a svg {
  color: var(--gold);
}

.side-progress {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.sp-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #c4d4ca;
  margin-bottom: 6px;
}

.bar-track {
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.3s;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-install {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--gold) 0%, #aa802e 100%);
  color: #071910;
  font-weight: 800;
  font-size: 12.5px;
  padding: 10px;
  border-radius: 8px;
}

.side-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #a4baa9;
  font-size: 12px;
  padding: 6px;
}

/* TOP HEADER */
.top {
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.top-brand {
  display: none;
  align-items: center;
  gap: 8px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 15px;
}

.top-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ib {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text);
}

.ib:hover {
  background: rgba(0,0,0,0.06);
}

.pgbtn {
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 4px 12px;
  font-weight: 800;
  font-size: 13px;
  color: var(--brand);
}

.top-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  color: #0d2b1d;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 20px;
}

.read-prog {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: transparent;
}

.read-prog i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
}

/* MAIN APP CONTAINER */
main#app {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* VIEWS */
.view {
  padding: 24px 20px 80px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.view[hidden] {
  display: none !important;
}

/* HERO SECTION (INICIO) */
.hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}

.hero-art .cover {
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  border: 1.5px solid var(--border);
}

.hero-txt {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-kicker {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--gold);
  margin-bottom: 6px;
}

.hero h1 {
  font-family: 'Lora', Georgia, serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero p.lead {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(13, 43, 29, 0.3);
}

.btn-gold {
  background: linear-gradient(135deg, #d4af37 0%, #aa802e 100%);
  color: #071910;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
}

.btn-secondary {
  background: rgba(0,0,0,0.06);
  color: var(--text);
}

.hero-stats {
  display: flex;
  gap: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.stat-card b {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 24px;
  color: var(--gold-dark);
}

.stat-card span {
  font-size: 12px;
  color: var(--text-muted);
}

/* ERAS GRID */
.section-head {
  margin-bottom: 18px;
}

.section-head h2 {
  font-family: 'Lora', Georgia, serif;
  font-size: 24px;
  color: var(--brand);
  margin-bottom: 4px;
}

.section-head p {
  font-size: 14px;
  color: var(--text-muted);
}

.eras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.era-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}

.era-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
}

.era-badge {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.era-card h3 {
  font-family: 'Lora', serif;
  font-size: 17px;
  color: var(--brand);
  margin-bottom: 8px;
  line-height: 1.25;
}

.era-card p {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  margin-bottom: 14px;
}

.era-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-dark);
}

/* VIEW HEADERS */
.view-header {
  margin-bottom: 22px;
}

.view-header h2 {
  font-family: 'Lora', Georgia, serif;
  font-size: 26px;
  color: var(--brand);
  margin-bottom: 4px;
}

.view-header p {
  font-size: 14px;
  color: var(--text-muted);
}

.badge-maps {
  display: inline-block;
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--gold-dark);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

/* COUNTRY FILTERS */
.country-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 6px 0;
  scrollbar-width: none;
}

.country-filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.2s;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* PLACES GRID (GOOGLE MAPS) */
.places-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.place-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.place-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.place-country {
  font-size: 11px;
  font-weight: 800;
  background: rgba(13, 43, 29, 0.1);
  color: var(--brand);
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.place-page-badge {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.place-card h3 {
  font-family: 'Lora', serif;
  font-size: 16px;
  color: var(--brand);
  margin-bottom: 2px;
}

.place-now {
  font-size: 13px;
  color: #9c2727;
  font-weight: 600;
  margin-bottom: 14px;
}

.place-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.btn-open-map {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #1a73e8;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(26,115,232,0.3);
}

.btn-atlas-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--gold);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
}

/* SEARCH VIEW */
.search-box {
  margin-bottom: 24px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
}

.search-bar:focus-within {
  border-color: var(--gold);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 16px;
  color: var(--text);
}

.search-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.tag {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.tag:hover {
  border-color: var(--gold);
  color: var(--gold-dark);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s;
}

.result-item:hover {
  border-color: var(--gold);
}

/* INDEX CHAPTER ACCORDION */
.chapter-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chapter-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: var(--bg-card);
  border-bottom: 1px solid transparent;
}

.chapter-box.open .chapter-header {
  border-bottom-color: var(--border);
}

.chapter-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chapter-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 14px;
}

.chapter-info h3 {
  font-family: 'Lora', serif;
  font-size: 16px;
  color: var(--brand);
}

.chapter-info p {
  font-size: 12.5px;
  color: var(--text-muted);
}

.sections-list {
  display: flex;
  flex-direction: column;
}

.section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  transition: background 0.15s;
}

.section-row:last-child {
  border-bottom: none;
}

.section-row:hover {
  background: rgba(212, 175, 55, 0.08);
}

.sec-page {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-dark);
  background: rgba(212,175,55,0.15);
  padding: 2px 8px;
  border-radius: 12px;
}

/* MAP READER VIEW */
#v-lector {
  padding: 0 !important;
  max-width: 100% !important;
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  background: #141816;
}

.map-viewport-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-viewport {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-x pan-y;
}

.map-stage {
  display: inline-block;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
}

.map-image {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  display: block;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  border-radius: 4px;
}

.map-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.2);
  z-index: 10;
}

.map-nav-btn.prev { left: 14px; }
.map-nav-btn.next { right: 14px; }

/* BOTTOM SHEET FOR "EL AHORA" IN READER */
.now-sheet {
  background: #0d2b1d;
  color: #fff;
  border-top: 2px solid var(--gold);
  box-shadow: 0 -6px 20px rgba(0,0,0,0.4);
  max-height: 240px;
  display: flex;
  flex-direction: column;
  z-index: 15;
}

.now-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
}

.now-badge {
  background: var(--gold);
  color: #0d2b1d;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.08em;
  margin-right: 8px;
}

.now-sheet-title strong {
  font-size: 13px;
  font-weight: 600;
  color: #f7eed8;
}

.now-sheet-toggle {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold);
}

.now-sheet-body {
  overflow-y: auto;
  padding: 4px 16px 14px 16px;
  display: none;
}

.now-sheet.open .now-sheet-body {
  display: block;
}

.now-places-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.now-place-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(212,175,55,0.5);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
}

.now-place-pill strong {
  color: #fff;
}

.now-place-pill span {
  color: #f3d594;
}

.btn-mini-maps {
  background: #1a73e8;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  margin-left: 4px;
}

/* JUMP DIALOG */
.jump-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  background: var(--bg-card);
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  margin: auto;
  max-width: 320px;
  width: 90%;
}

.jump-dialog::backdrop {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}

.jump-box {
  padding: 22px;
}

.jump-box h3 {
  font-family: 'Lora', serif;
  font-size: 18px;
  color: var(--brand);
  margin-bottom: 14px;
  text-align: center;
}

.jump-input-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.jump-input-wrap input {
  width: 80px;
  height: 44px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  border: 2px solid var(--gold);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.jump-box input[type="range"] {
  width: 100%;
  margin-bottom: 20px;
}

.jump-btns {
  display: flex;
  gap: 10px;
}

.jump-btns .btn {
  flex: 1;
  justify-content: center;
}

/* BOTTOM NAVIGATION (MOBILE) */
.bot-nav {
  display: none;
  height: 60px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 30;
  justify-content: space-around;
  align-items: center;
}

.bot-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.bot-nav a.active {
  color: var(--gold-dark);
}

.bot-nav a.active svg {
  color: var(--gold-dark);
}

/* RESPONSIVE */
@media (max-width: 860px) {
  .now-sheet {
    margin-bottom: 60px;
  }
  .side {
    display: none;
  }
  .top-brand {
    display: inline-flex;
  }
  .bot-nav {
    display: flex;
  }
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 20px;
  }
  .hero-art {
    max-width: 240px;
    margin: 0 auto;
  }
  .hero-actions {
    justify-content: center;
  }
  .hero-stats {
    justify-content: center;
  }
}
