:root {
  --bg: #080807;
  --bg-2: #11100d;
  --surface: rgba(24, 21, 17, 0.86);
  --surface-2: rgba(34, 29, 23, 0.9);
  --paper: #efe0bf;
  --ink: #f6eddc;
  --muted: #b8ad98;
  --soft: #8b806d;
  --gold: #d9b56c;
  --gold-2: #f2d79a;
  --bronze: #8f6d38;
  --wine: #68312c;
  --sage: #59604b;
  --line: rgba(231, 196, 123, 0.16);
  --line-2: rgba(231, 196, 123, 0.34);
  --shadow-soft: 0 18px 50px rgba(0, 0, 0, 0.34);
  --shadow-deep: 0 32px 90px rgba(0, 0, 0, 0.58);
  --radius: 8px;
  --topbar: 64px;
  --nav: 78px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(8, 8, 7, 0.94) 0%, rgba(18, 15, 12, 0.96) 48%, rgba(6, 6, 5, 1) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(0deg, rgba(217, 181, 108, 0.02) 0 1px, transparent 1px 9px),
    var(--bg);
  letter-spacing: 0;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
}

body::before {
  opacity: 0.72;
  background:
    linear-gradient(110deg, rgba(217, 181, 108, 0.08), transparent 22%, transparent 72%, rgba(104, 49, 44, 0.08)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 36%, rgba(0, 0, 0, 0.32));
}

body::after {
  opacity: 0.18;
  background:
    repeating-linear-gradient(24deg, transparent 0 18px, rgba(239, 224, 191, 0.08) 18px 19px, transparent 19px 40px),
    repeating-linear-gradient(112deg, transparent 0 34px, rgba(217, 181, 108, 0.08) 34px 35px, transparent 35px 70px);
  mix-blend-mode: soft-light;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-2), var(--gold));
  box-shadow: 0 0 14px rgba(242, 215, 154, 0.5);
  transition: width 140ms ease;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 7, 0.78);
  backdrop-filter: blur(20px);
}

.brand-button,
.top-install,
.btn,
.icon-btn,
.chip,
.search-shell,
.chapter-link {
  min-height: 44px;
  border-radius: var(--radius);
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 5px 8px 5px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand-mark {
  display: inline-grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--gold-2);
  background: linear-gradient(145deg, #14110d, #060605);
  box-shadow: inset 0 0 16px rgba(217, 181, 108, 0.08);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.brand-text {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-action {
  display: none;
}

body.can-install .install-action {
  display: inline-flex;
}

.top-install {
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  color: var(--gold-2);
  background: linear-gradient(180deg, rgba(217, 181, 108, 0.14), rgba(217, 181, 108, 0.04));
  cursor: pointer;
}

.app-view {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 16px calc(var(--nav) + 30px + env(safe-area-inset-bottom));
}

.screen,
.home-shell,
.story-reader,
.editorial-reader {
  animation: reveal 300ms ease both;
}

.home-shell {
  display: grid;
  gap: 24px;
}

.book-stage {
  position: relative;
  display: grid;
  min-height: 278px;
  place-items: center;
  perspective: 1200px;
  isolation: isolate;
}

.book-stage::before {
  position: absolute;
  inset: 11% 6% 3%;
  z-index: -2;
  content: "";
  background:
    linear-gradient(160deg, rgba(217, 181, 108, 0.18), transparent 42%),
    linear-gradient(25deg, rgba(89, 96, 75, 0.16), transparent 58%);
  filter: blur(26px);
  opacity: 0.78;
  transform: skewY(-3deg);
}

.book-stage::after {
  position: absolute;
  right: 8%;
  bottom: 1%;
  left: 14%;
  z-index: -1;
  height: 26px;
  content: "";
  background: rgba(0, 0, 0, 0.58);
  filter: blur(18px);
  transform: skewX(-18deg);
}

.book-mockup {
  position: relative;
  width: min(52vw, 212px);
  transform: rotateY(-12deg) rotateX(2deg);
  transform-style: preserve-3d;
}

.book-mockup::before {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: -13px;
  width: 26px;
  content: "";
  border-radius: 7px 0 0 7px;
  background:
    linear-gradient(90deg, #050505, #241b11 35%, #816139 70%, #1b130c),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 9px);
  box-shadow: inset -6px 0 14px rgba(0, 0, 0, 0.45);
  transform: translateZ(-18px);
}

.book-mockup::after {
  position: absolute;
  top: 8px;
  right: -12px;
  bottom: 8px;
  width: 18px;
  content: "";
  border-radius: 0 6px 6px 0;
  background:
    linear-gradient(90deg, rgba(239, 224, 191, 0.35), rgba(239, 224, 191, 0.08)),
    repeating-linear-gradient(0deg, rgba(80, 60, 32, 0.4) 0 1px, transparent 1px 7px);
  transform: rotateY(34deg);
  transform-origin: left;
}

.book-cover {
  position: relative;
  z-index: 2;
  width: 100%;
  border-radius: 7px;
  box-shadow: var(--shadow-deep), 0 0 0 1px rgba(242, 215, 154, 0.18);
}

.home-copy {
  display: grid;
  gap: 16px;
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 820;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.15rem, 10vw, 4.8rem);
  line-height: 0.98;
}

h2 {
  font-size: clamp(1.8rem, 8vw, 3.2rem);
  line-height: 1.04;
}

h3 {
  font-size: 1.16rem;
  line-height: 1.18;
}

.subtitle,
.lead,
.section-lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.62;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.home-actions .wide-action {
  grid-column: 1 / -1;
}

.btn,
.icon-btn,
.chip,
.chapter-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.btn {
  min-height: 46px;
  padding: 0 18px;
  font-weight: 780;
}

.btn:hover,
.icon-btn:hover,
.chip:hover,
.chapter-link:hover,
.bottom-nav button:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #15110b;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  box-shadow: 0 14px 30px rgba(217, 181, 108, 0.22);
}

.btn.secondary {
  border-color: var(--line-2);
  color: var(--gold-2);
  background: linear-gradient(180deg, rgba(217, 181, 108, 0.12), rgba(217, 181, 108, 0.035));
}

.btn.ghost {
  border-color: var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.035);
}

.chapter-strip {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.chapter-link {
  justify-content: flex-start;
  min-height: 72px;
  padding: 12px 14px;
  border-color: var(--line);
  background:
    linear-gradient(180deg, rgba(34, 29, 23, 0.82), rgba(18, 16, 13, 0.82)),
    repeating-linear-gradient(90deg, rgba(239, 224, 191, 0.035) 0 1px, transparent 1px 8px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  text-align: left;
}

.chapter-link span {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--gold-2);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.chapter-link strong {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
}

.chapter-link small {
  display: block;
  margin-top: 2px;
  color: var(--soft);
  font-size: 0.82rem;
}

.screen-heading {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.search-shell svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: var(--gold);
}

.search-shell input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-shell input::placeholder {
  color: var(--soft);
}

.chip-row {
  display: flex;
  gap: 8px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border-color: var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  white-space: nowrap;
}

.chip.is-active {
  border-color: rgba(242, 215, 154, 0.72);
  color: #15110b;
  background: var(--gold);
}

.result-count {
  margin: 4px 0 14px;
  color: var(--soft);
  font-size: 0.9rem;
}

.stories-grid {
  display: grid;
  gap: 14px;
}

.story-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(35, 30, 24, 0.94), rgba(15, 14, 12, 0.96)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 8px);
  box-shadow: var(--shadow-soft);
}

.story-card::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.035);
  border-radius: var(--radius);
}

.card-image-wrap {
  position: relative;
  height: 190px;
  overflow: hidden;
  background: #0d0c0a;
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease;
}

.story-card:hover .card-image-wrap img {
  transform: scale(1.035);
}

.card-image-wrap::after {
  position: absolute;
  inset: auto 0 0;
  height: 62%;
  content: "";
  background: linear-gradient(180deg, transparent, rgba(8, 8, 7, 0.82));
}

.story-card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.story-number {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.story-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.52;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(217, 181, 108, 0.24);
  border-radius: 999px;
  color: var(--gold-2);
  background: rgba(217, 181, 108, 0.08);
  font-size: 0.74rem;
  font-weight: 760;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

.card-actions .btn {
  width: 100%;
}

.story-reader,
.editorial-reader {
  width: min(860px, 100%);
  margin: 0 auto;
}

.reader-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon-btn {
  width: 46px;
  min-width: 46px;
  height: 46px;
  border-color: var(--line);
  color: var(--gold-2);
  background: rgba(255, 255, 255, 0.035);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.story-hero,
.editorial-hero {
  position: relative;
  display: grid;
  min-height: 430px;
  align-items: end;
  margin: 0 -16px 22px;
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: #0a0908;
}

.story-hero img,
.editorial-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.04);
}

.story-hero::before,
.editorial-hero::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(8, 8, 7, 0.08) 0%, rgba(8, 8, 7, 0.42) 45%, rgba(8, 8, 7, 0.96) 100%),
    linear-gradient(90deg, rgba(8, 8, 7, 0.68), transparent 52%);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  padding: 118px 16px 24px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.story-hero h1,
.editorial-hero h1 {
  max-width: 13ch;
  text-shadow: 0 14px 38px rgba(0, 0, 0, 0.58);
}

.reader-surface {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(28, 24, 19, 0.78), rgba(12, 11, 10, 0.64)),
    repeating-linear-gradient(0deg, rgba(239, 224, 191, 0.026) 0 1px, transparent 1px 9px);
  box-shadow: var(--shadow-soft);
}

.reader-quote {
  margin: 0;
  padding: 18px 18px 18px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--gold-2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.58;
}

.reader-body {
  padding: 20px 18px 6px;
  font-size: clamp(1.05rem, 4.3vw, 1.18rem);
  line-height: 1.82;
}

.reader-body p {
  margin: 0 0 1.16em;
  color: #f1e8d8;
}

.editorial-reader .reader-body p {
  color: #f4ead8;
}

.editorial-reader.is-dedicatoria .reader-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.18rem, 5.2vw, 1.42rem);
  line-height: 1.76;
}

.reader-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.empty-state {
  display: grid;
  min-height: 44svh;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.empty-state p {
  max-width: 30rem;
  margin: 10px auto 0;
  color: var(--muted);
  line-height: 1.58;
}

.about-panel {
  display: grid;
  gap: 22px;
  padding-top: 8px;
}

.download-panel {
  display: grid;
  gap: 26px;
  align-items: center;
}

.download-art {
  position: relative;
  display: grid;
  min-height: 310px;
  place-items: center;
  perspective: 1200px;
}

.download-art::before {
  position: absolute;
  inset: 14% 10% 8%;
  z-index: -1;
  content: "";
  background: linear-gradient(135deg, rgba(217, 181, 108, 0.18), rgba(104, 49, 44, 0.12), transparent);
  filter: blur(28px);
}

.download-copy {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(34, 29, 23, 0.86), rgba(12, 11, 10, 0.7)),
    repeating-linear-gradient(0deg, rgba(239, 224, 191, 0.026) 0 1px, transparent 1px 9px);
  box-shadow: var(--shadow-soft);
}

.about-logo {
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
  background: #050505;
  box-shadow: var(--shadow-soft);
}

.about-copy {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.72;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: min(620px, calc(100% - 18px));
  min-height: calc(var(--nav) + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background:
    linear-gradient(180deg, rgba(20, 17, 14, 0.96), rgba(7, 7, 6, 0.97)),
    repeating-linear-gradient(90deg, rgba(239, 224, 191, 0.035) 0 1px, transparent 1px 7px);
  box-shadow: 0 -16px 44px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(20px);
}

.bottom-nav button {
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 170ms ease, background 170ms ease, transform 170ms ease;
}

.bottom-nav button.is-active {
  color: var(--gold-2);
  background: rgba(217, 181, 108, 0.1);
}

.bottom-nav svg {
  width: 23px;
  height: 23px;
  fill: currentColor;
}

.bottom-nav span {
  overflow: hidden;
  max-width: 100%;
  font-size: 0.74rem;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.noscript {
  padding: 20px;
  color: var(--gold-2);
  text-align: center;
}

@media (min-width: 560px) {
  .chapter-strip,
  .reader-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reader-nav .btn:nth-child(2) {
    grid-column: auto;
  }
}

@media (min-width: 740px) {
  .app-view {
    padding: 34px 24px calc(var(--nav) + 34px + env(safe-area-inset-bottom));
  }

  .home-shell {
    grid-template-columns: 0.92fr 1.08fr;
    align-items: center;
    min-height: calc(100svh - var(--topbar) - var(--nav) - 46px);
    gap: 40px;
  }

  .book-stage {
    min-height: 520px;
  }

  .book-mockup {
    width: min(34vw, 360px);
  }

  .home-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chapter-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-image-wrap {
    height: 220px;
  }

  .story-hero,
  .editorial-hero {
    min-height: 500px;
    margin-inline: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .hero-content {
    padding: 150px 34px 34px;
  }

  .reader-body {
    padding: 28px 34px 10px;
  }

  .reader-quote {
    padding: 24px 34px;
    font-size: 1.18rem;
  }

  .reader-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .about-panel {
    grid-template-columns: 124px minmax(0, 1fr);
    align-items: start;
  }

  .download-panel {
    grid-template-columns: 0.86fr 1.14fr;
    min-height: calc(100svh - var(--topbar) - var(--nav) - 78px);
  }

  .download-art {
    min-height: 460px;
  }

  .download-copy {
    padding: 30px;
  }
}

@media (min-width: 1080px) {
  .stories-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
