:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --ink: #32353a;
  --ink-strong: #191b20;
  --muted: #858a96;
  --muted-dark: #636974;
  --line: #eceef2;
  --primary: #9875fb;
  --primary-deep: #7652e6;
  --primary-soft: #f1edff;
  --coral: #ee8172;
  --gold: #e3a933;
  --shadow: 0 4px 16px rgba(52, 56, 70, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #fff; scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF UI Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
body.modal-open { overflow: hidden; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.home-app {
  position: relative;
  width: min(750px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  overflow: visible;
  background: var(--bg);
}

/* The reference keeps search and channels directly over the artwork. */
.home-header {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 20;
  width: 100%;
  color: #fff;
  transform: translateX(-50%);
  transition: background .2s ease, box-shadow .2s ease;
}
.home-header.scrolled {
  position: fixed;
  width: min(750px, 100%);
  color: var(--ink);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 1px 0 rgba(218, 220, 226, .9);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
}
.search-row { padding: max(10px, env(safe-area-inset-top)) 16px 7px; }
.search-box {
  width: 100%;
  height: 39px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px 0 13px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 22px;
  color: rgba(255, 255, 255, .88);
  background: rgba(255, 255, 255, .17);
}
.search-box:focus-within { border-color: rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .23); }
.search-box > svg { width: 17px; height: 17px; flex: 0 0 auto; color: rgba(255, 255, 255, .72); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; color: #fff; background: transparent; font-size: 14px; }
.search-box input::placeholder { color: rgba(255, 255, 255, .82); }
.search-submit, .search-clear { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: transparent; }
.search-submit svg { width: 16px; height: 16px; }
.search-clear svg { width: 14px; height: 14px; }
.search-submit:hover, .search-clear:hover { background: rgba(255, 255, 255, .16); }
.home-header.scrolled .search-box { border-color: transparent; color: var(--muted); background: #f5f6f8; }
.home-header.scrolled .search-box > svg { color: #9ca2ad; }
.home-header.scrolled .search-box input { color: var(--ink); }
.home-header.scrolled .search-box input::placeholder { color: #a0a5ae; }
.home-header.scrolled .search-submit, .home-header.scrolled .search-clear { color: var(--muted-dark); }

.channel-row {
  display: flex;
  align-items: center;
  gap: clamp(27px, 8vw, 60px);
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.channel-row::-webkit-scrollbar { display: none; }
.channel-tab {
  position: relative;
  flex: 0 0 auto;
  padding: 0 0 9px;
  color: rgba(255, 255, 255, .9);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}
.channel-tab::after { content: ""; position: absolute; right: 0; bottom: 1px; left: 0; height: 4px; border-radius: 4px; background: transparent; }
.channel-tab:hover, .channel-tab.active { color: var(--primary); }
.channel-tab.active::after { background: var(--primary); }
.home-header.scrolled .channel-tab { color: var(--muted-dark); }
.home-header.scrolled .channel-tab.active, .home-header.scrolled .channel-tab:hover { color: var(--primary-deep); }

.hero-section {
  position: relative;
  width: 100%;
  height: clamp(400px, 55vw, 430px);
  overflow: hidden;
  border-radius: 0 0 10px 10px;
  background: #707782 center / cover no-repeat;
}
.hero-art { position: absolute; inset: -22px; z-index: 0; background: center / cover no-repeat; filter: blur(17px); opacity: .78; transform: scale(1.06); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 20, 27, .26), rgba(14, 20, 27, .02) 35%, rgba(14, 20, 27, .12) 67%, rgba(14, 20, 27, .35)); pointer-events: none; }
.hero-hit-area { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; background: transparent; }
.hero-arrow { position: absolute; top: 52%; z-index: 4; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(24, 27, 34, .25); opacity: 0; transition: opacity .2s ease, background .2s ease; }
.hero-section:hover .hero-arrow, .hero-arrow:focus-visible { opacity: 1; }
.hero-arrow:hover { background: rgba(24, 27, 34, .48); }
.hero-arrow svg { width: 18px; height: 18px; }
.hero-arrow-prev { left: 13px; }
.hero-arrow-next { right: 13px; }
.hero-dots { position: absolute; right: 0; bottom: 11px; left: 0; z-index: 4; display: flex; justify-content: center; gap: 5px; pointer-events: auto; }
.hero-dot { width: 5px; height: 5px; padding: 0; border-radius: 5px; background: rgba(255, 255, 255, .58); }
.hero-dot.active { width: 17px; background: var(--primary); }

.section { scroll-margin-top: 74px; }
.editorial-card, .content-card, .search-results {
  position: relative;
  z-index: 5;
  width: calc(100% - 30px);
  margin: 16px auto 0;
  padding: 17px 15px 16px;
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.editorial-card { margin-top: -22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compact-heading h1, .compact-heading h2 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 750; line-height: 1.25; }
.see-all { display: inline-flex; align-items: center; gap: 2px; padding: 3px 0; color: #858a96; background: transparent; font-size: 13px; font-weight: 500; white-space: nowrap; }
.see-all svg { width: 14px; height: 14px; }
.see-all:hover { color: var(--primary-deep); }

.coverflow { position: relative; height: 178px; margin: 9px -15px 0; overflow: hidden; }
.editor-cover { position: absolute; top: 10px; left: 50%; width: 118px; height: 158px; padding: 0; border-radius: 7px; background: transparent; box-shadow: 0 9px 18px rgba(38, 38, 50, .18); transform: translateX(-50%); transition: transform .28s ease, opacity .28s ease, filter .28s ease; }
.editor-cover .cover-shell { width: 100%; height: 100%; box-shadow: none; }
.editor-cover.center { z-index: 5; transform: translateX(-50%); }
.editor-cover.left, .editor-cover.right { z-index: 3; opacity: .94; }
.editor-cover.left { transform: translateX(calc(-50% - 130px)) scale(.78); }
.editor-cover.right { transform: translateX(calc(-50% + 130px)) scale(.78); }
.editor-cover.left-far, .editor-cover.right-far { z-index: 1; opacity: .64; filter: brightness(.82); }
.editor-cover.left-far { transform: translateX(calc(-50% - 219px)) scale(.63); }
.editor-cover.right-far { transform: translateX(calc(-50% + 219px)) scale(.63); }
.editor-cover:hover { filter: brightness(1.05); }
.cover-shell { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 7px; background: #e8e9ee; }
.cover-shell img { width: 100%; height: 100%; display: block; object-fit: cover; }
.cover-art { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 11px 9px; color: #fff; background: var(--cover-bg, linear-gradient(145deg, #4e447e, #a777c8)); }
.cover-art::before { content: ""; position: absolute; top: -35px; right: -28px; width: 105px; height: 105px; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.cover-art span, .cover-art strong { position: relative; z-index: 1; }
.cover-art span { margin-bottom: 5px; color: rgba(255, 255, 255, .7); font-size: 7px; letter-spacing: .08em; text-transform: uppercase; }
.cover-art strong { max-height: 50px; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: 14px; line-height: 1.05; }
.cover-violet { --cover-bg: linear-gradient(155deg, #3f347c, #8f6ae5 55%, #d7a1bd); }
.cover-coral { --cover-bg: linear-gradient(150deg, #8f3e58, #ec876d 58%, #f7c79b); }
.cover-teal { --cover-bg: linear-gradient(150deg, #1d5967, #54a9a7 56%, #c3e0c6); }
.cover-midnight { --cover-bg: linear-gradient(150deg, #1b2548, #43589a 56%, #a18ed0); }
.cover-amber { --cover-bg: linear-gradient(150deg, #6a3e2d, #cb8650 58%, #f3d18d); }
.cover-rose { --cover-bg: linear-gradient(150deg, #653c65, #b5689d 56%, #efb39d); }
.editor-copy { min-width: 0; }
.editor-title-button { width: 100%; display: flex; align-items: center; gap: 4px; padding: 0; overflow: hidden; color: var(--ink); background: transparent; text-align: left; font-size: 17px; font-weight: 550; line-height: 1.3; }
.editor-title-button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-title-button svg { width: 15px; height: 15px; flex: 0 0 auto; color: #adb1bb; }
.editor-tags { display: flex; gap: 5px; margin-top: 9px; overflow: hidden; }
.editor-tags span { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; color: #8c92a0; background: #f2f3f6; font-size: 10px; line-height: 1; }
.editor-tags .more-tag { padding-inline: 9px; }
.editor-copy p { display: -webkit-box; margin: 10px 0 0; overflow: hidden; color: #858b99; font-size: 13px; line-height: 1.48; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.coin-promo { width: calc(100% - 30px); min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px auto 0; padding: 10px 13px; border-radius: 8px; background: linear-gradient(108deg, #c6e0ff 0%, #d8d7ff 47%, #c7b9ff 100%); }
.coin-promo-copy { min-width: 0; display: flex; align-items: center; gap: 9px; }
.coin-promo-icon { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #fff; background: rgba(118, 82, 230, .72); }
.coin-promo-icon svg { width: 17px; height: 17px; }
.coin-promo-copy > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.coin-promo strong { color: #7655dc; font-size: 15px; font-weight: 750; line-height: 1.15; }
.coin-promo small { margin-top: 3px; color: #777e9c; font-size: 10px; }
.coin-promo > button { min-width: 106px; min-height: 33px; display: inline-flex; align-items: center; justify-content: center; gap: 3px; flex: 0 0 auto; padding: 0 10px; border-radius: 18px; color: #fff; background: #7652e6; font-size: 11px; font-weight: 800; box-shadow: 0 5px 12px rgba(95, 72, 196, .2); }
.coin-promo > button svg { width: 14px; height: 14px; }

.trending-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; margin-top: 14px; }
.trending-lead { min-width: 0; display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 10px; cursor: pointer; }
.trending-lead .cover-shell { width: 88px; border-radius: 7px; }
.trending-lead h3 { display: -webkit-box; margin: 1px 0 5px; overflow: hidden; color: var(--ink); font-size: 13px; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.trending-lead p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.trending-lead div > span { display: inline-flex; align-items: center; gap: 3px; margin-top: 8px; color: var(--coral); font-size: 9px; font-weight: 750; }
.trending-lead div > span svg { width: 12px; height: 12px; }
.trending-list { min-width: 0; display: grid; gap: 7px; }
.small-story { min-width: 0; display: grid; grid-template-columns: 18px 37px minmax(0, 1fr); align-items: center; gap: 6px; padding-bottom: 7px; border-bottom: 1px solid var(--line); cursor: pointer; }
.small-story:last-child { padding-bottom: 0; border-bottom: 0; }
.small-story-number { color: #a4a9b2; font-size: 9px; font-weight: 800; }
.small-story .cover-shell { width: 37px; border-radius: 4px; box-shadow: none; }
.small-story-copy { min-width: 0; display: flex; flex-direction: column; }
.small-story-copy strong { display: -webkit-box; overflow: hidden; color: var(--ink); font-size: 10px; line-height: 1.24; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.small-story-copy small { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.small-story-copy i, .popular-meta i, .explore-story-copy i { margin: 0 3px; font-style: normal; color: #b5b9c2; }

.popular-list { margin-top: 8px; }
.popular-row { min-width: 0; display: grid; grid-template-columns: 20px 47px minmax(0, 1fr) 25px; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.popular-row:last-child { border-bottom: 0; }
.popular-rank { color: #a5aab4; font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-weight: 700; text-align: center; }
.popular-row:nth-child(-n+3) .popular-rank { color: var(--primary); }
.popular-row .cover-shell { width: 47px; border-radius: 5px; box-shadow: none; }
.popular-copy { min-width: 0; display: flex; flex-direction: column; }
.popular-copy strong { display: -webkit-box; overflow: hidden; color: var(--ink); font-size: 12px; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.popular-copy small { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.popular-meta { display: inline-flex; align-items: center; margin-top: 4px; color: #a2a7b2; font-size: 9px; }
.popular-meta svg { width: 11px; height: 11px; margin-right: 3px; color: var(--gold); fill: currentColor; }
.favorite-button { width: 25px; height: 25px; display: grid; place-items: center; padding: 0; border-radius: 50%; color: #b6bbc4; background: transparent; }
.favorite-button svg { width: 15px; height: 15px; }
.favorite-button:hover, .favorite-button.saved { color: var(--primary-deep); background: var(--primary-soft); }
.favorite-button.saved svg { fill: currentColor; }

.saved-rail, .library-rail { display: flex; gap: 10px; padding: 14px 1px 2px; overflow-x: auto; scrollbar-width: none; }
.saved-rail::-webkit-scrollbar, .library-rail::-webkit-scrollbar { display: none; }
.book-tile { position: relative; width: 85px; flex: 0 0 85px; min-width: 0; cursor: pointer; }
.book-tile .cover-shell { border-radius: 7px; box-shadow: none; }
.book-tile-title { min-width: 0; display: block; margin-top: 8px; }
.book-tile-title h3 { display: -webkit-box; margin: 0; overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 500; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.book-tile-title .favorite-button { position: absolute; top: 4px; right: 4px; color: rgba(255, 255, 255, .94); background: rgba(28, 32, 39, .25); }
.book-tile-title .favorite-button.saved { color: var(--primary-deep); background: rgba(255, 255, 255, .9); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.tag-chip { min-height: 30px; padding: 0 11px; border: 1px solid #e7e9ef; border-radius: 16px; color: #777d89; background: #fafbfc; font-size: 11px; }
.tag-chip.active, .tag-chip:hover { border-color: #d5caff; color: var(--primary-deep); background: var(--primary-soft); }
.tag-books { display: grid; gap: 0; margin-top: 13px; }
.tag-book { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.tag-book:last-child { border-bottom: 0; }
.tag-book strong { min-width: 0; overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tag-book small { flex: 0 0 auto; color: var(--muted); font-size: 9px; }

.explore-list { display: grid; gap: 0; margin-top: 8px; }
.explore-story { position: relative; min-width: 0; display: grid; grid-template-columns: 67px minmax(0, 1fr) 25px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.explore-story:last-child { border-bottom: 0; }
.explore-story .cover-shell { width: 67px; border-radius: 6px; box-shadow: none; }
.explore-story-copy { min-width: 0; }
.explore-story-copy h3 { display: -webkit-box; margin: 0; overflow: hidden; color: var(--ink); font-size: 12px; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.explore-story-copy p { display: -webkit-box; margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.explore-story-copy > span { display: block; margin-top: 5px; color: var(--primary-deep); font-size: 9px; }
.explore-story > .favorite-button { grid-column: 3; grid-row: 1; }
.library-count { padding: 4px 8px; border-radius: 999px; color: var(--primary-deep); background: var(--primary-soft); font-size: 10px; font-weight: 750; }
.empty-library { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 112px; margin-top: 13px; padding: 18px; border: 1px dashed #dcdfea; border-radius: 7px; color: var(--muted); text-align: center; }
.empty-library > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); }
.empty-library svg { width: 16px; height: 16px; }
.empty-library strong { margin-top: 8px; color: var(--ink); font-size: 12px; }
.empty-library p { margin: 4px 0 0; font-size: 10px; }
.no-results { margin: 18px 0 0; padding: 18px; color: var(--muted); background: #fafbfc; font-size: 11px; text-align: center; }

.mobile-bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 80; width: min(750px, 100%); height: 68px; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 auto; padding: 6px 8px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid #e5e7ec; background: rgba(255, 255, 255, .97); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #969ba5; background: transparent; font-size: 10px; font-weight: 600; }
.bottom-nav-item img { width: 23px; height: 23px; object-fit: contain; opacity: .72; }
.bottom-nav-item.active { color: var(--primary); font-weight: 800; }
.bottom-nav-item.active img { opacity: 1; }

/* wallet.js injects its panel after the page has loaded */
.modal-layer { position: fixed; inset: 0; z-index: 220; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(26, 24, 38, .52); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(420px, 100%); padding: 28px 22px 22px; border-radius: 14px; background: var(--surface); box-shadow: 0 28px 65px rgba(29, 25, 52, .22); }
.modal-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: #969ba5; background: transparent; }
.modal-close:hover { color: var(--ink); background: #f1f2f5; }
.modal-close svg { width: 16px; height: 16px; }
.toast { position: fixed; right: 50%; bottom: 82px; z-index: 300; max-width: calc(100% - 40px); padding: 10px 15px; border-radius: 999px; color: #fff; background: rgba(34, 33, 43, .92); font-size: 11px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(50%, 10px); transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translate(50%, 0); }

@media (min-width: 751px) {
  body { padding-bottom: 68px; }
  .home-app { min-height: 100vh; }
  .home-header.scrolled { left: 50%; transform: translateX(-50%); }
}

@media (max-width: 430px) {
  .trending-layout { grid-template-columns: 1fr; }
  .trending-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 10px; }
  .small-story:nth-child(3), .small-story:nth-child(4) { border-bottom: 0; }
}

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