
:root {
  color-scheme: dark;
  --bg: #0c0a12;
  --surface: #15121e;
  --surface2: #1c1728;
  --line: #2b2439;
  --text: #f6f1ff;
  --muted: #a69bb7;
  --purple: #a78bfa;
  --purple2: #7c3aed;
  --green: #7ce5b0;
  --radius: 20px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #08070c; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #08070c;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
}
button:disabled { opacity: .45; cursor: not-allowed; }

.app-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  border-left: 1px solid #201a2a;
  border-right: 1px solid #201a2a;
  overflow: clip;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}
.topbar {
  height: 65px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(12,10,18,.93);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  font-size: 13px;
  letter-spacing: 2px;
  font-weight: 900;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: white;
  background: linear-gradient(140deg, #c4b5fd, #7c3aed);
  font-size: 20px;
}
.brand-light { color: var(--purple); }
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 13px;
  min-width: 40px;
  min-height: 40px;
  font-size: 23px;
  display: grid;
  place-items: center;
}
.search-panel {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.search-panel input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 11px;
}
.hidden { display: none !important; }
.page { display: none; padding: 20px 18px 30px; }
.page.active { display: block; animation: appear .2s ease; }
@keyframes appear {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid #38264f;
  border-radius: 26px;
  padding: 25px 21px 18px;
  background: linear-gradient(145deg,#211632 0%,#171124 54%,#11101b 100%);
}
.hero-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  top: -90px;
  right: -75px;
  background: #8b5cf6;
  filter: blur(100px);
  opacity: .24;
  pointer-events: none;
}
.eyebrow {
  color: var(--purple);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.7px;
}
.hero h1 {
  position: relative;
  font-size: clamp(32px, 9vw, 41px);
  letter-spacing: -1.7px;
  line-height: 1.13;
  margin: 17px 0 14px;
}
.hero h1 span {
  color: var(--purple);
}
.hero p, .page-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}
.primary-button, .secondary-button {
  width: 100%;
  border: 0;
  border-radius: 13px;
  padding: 13px 16px;
  font-weight: 750;
}
.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(100deg,#a78bfa,#8054e9);
  color: #130d20;
}
.primary-button span { font-size: 20px; }
.hero-bottom {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  border-top: 1px solid #3a2c4d;
  margin-top: 24px;
  padding-top: 17px;
}
.hero-bottom div { display: grid; gap: 1px; }
.hero-bottom strong { font-size: 19px; }
.hero-bottom small {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--muted);
}
.section-block { margin-top: 29px; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 15px;
}
.section-heading h2, .page-heading h1 {
  font-size: 24px;
  letter-spacing: -.7px;
  line-height: 1.25;
  margin: 5px 0 0;
}
.text-button, .back-button {
  background: none;
  border: 0;
  color: var(--purple);
  font-size: 12px;
  font-weight: 700;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 11px;
}
.category-card {
  text-align: left;
  padding: 15px 13px;
  min-height: 145px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg,var(--surface2),var(--surface));
}
.category-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 21px;
  margin-bottom: 13px;
  background: #302343;
}
.category-card strong { display: block; font-size: 13px; }
.category-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.article-list { display: grid; gap: 11px; }
.article-card {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.article-card .article-open {
  min-width: 0;
  flex: 1;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
}
.article-card h3 {
  margin: 4px 0 5px;
  font-size: 14px;
  line-height: 1.4;
}
.article-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}
.article-meta {
  color: var(--purple);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .7px;
}
.article-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #292037;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 20px;
}
.favorite-button {
  border: 0;
  background: none;
  color: #887b9a;
  font-size: 22px;
  padding: 1px;
}
.favorite-button.is-favorite { color: #f49bc8; }
.quote-card {
  margin-top: 25px;
  border: 1px solid #3a2c4d;
  border-radius: 18px;
  background: #171122;
  padding: 18px;
}
.quote-icon { color: var(--purple); font-size: 23px; }
.quote-card p { font-size: 16px; font-weight: 700; line-height: 1.5; }
.quote-card small { font-size: 9px; color: var(--muted); letter-spacing: 1px; }
.page-heading { margin: 8px 0 23px; }
.page-heading h1 { font-size: 30px; margin: 6px 0 8px; }
.filter-row {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 13px;
  scrollbar-width: none;
}
.filter-chip {
  white-space: nowrap;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 30px;
  font-size: 11px;
}
.filter-chip.active {
  background: #34234b;
  color: #e9ddff;
  border-color: #7654a5;
}
.library-count { font-size: 11px; color: var(--muted); margin: 0 0 12px; }
.back-button { margin: 0 0 18px; padding: 5px 0; }
.reader-header { margin-bottom: 18px; }
.reader-icon {
  width: 60px; height: 60px; border-radius: 19px;
  display: grid; place-items: center; background: #2a203b;
  font-size: 29px; margin: 12px 0;
}
.reader-title { font-size: 29px; line-height: 1.22; letter-spacing: -.8px; margin: 7px 0 12px; }
.reader-description { color: var(--muted); font-size: 13px; }
.reader-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 19px 0;
}
.reader-tools button, .audio-button {
  border: 1px solid var(--line);
  background: var(--surface2);
  padding: 11px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}
.audio-player {
  border: 1px solid #49345f;
  border-radius: 17px;
  background: linear-gradient(120deg,#251b36,#171321);
  padding: 15px;
  margin: 18px 0 24px;
}
.audio-player h3 { margin: 0 0 2px; font-size: 13px; }
.audio-player p { color: var(--muted); font-size: 11px; margin: 0 0 12px; }
.audio-actions { display: flex; gap: 8px; }
.audio-actions button { flex: 1; }
.audio-main { background: var(--purple); color: #130d20; border: 0; }
.reader-body h2 { font-size: 19px; line-height: 1.35; margin: 27px 0 10px; }
.reader-body h3 { font-size: 15px; margin: 19px 0 7px; }
.reader-body p, .reader-body li { color: #d2c9dd; font-size: 13px; }
.reader-body ul, .reader-body ol { padding-left: 21px; }
.reader-body li { padding-left: 3px; margin-bottom: 7px; }
.reader-body strong { color: #fff; }
.info-box {
  background: #1b1725;
  border-left: 3px solid var(--purple);
  border-radius: 0 12px 12px 0;
  padding: 13px 14px;
  margin: 17px 0;
  font-size: 12px;
}
.warning-box { border-left-color: #f0bc70; }
.reader-footer {
  border-top: 1px solid var(--line);
  margin-top: 27px;
  padding-top: 20px;
}
.progress-card, .settings-card, .stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 13px;
}
.progress-number { font-size: 40px; font-weight: 850; letter-spacing: -2px; margin: 5px 0; }
.progress-track { height: 7px; background: #30283b; border-radius: 9px; overflow: hidden; }
.progress-track div { width: 0; height: 100%; background: linear-gradient(90deg,#a78bfa,#7ce5b0); transition: width .2s; }
.progress-card p { color: var(--muted); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card strong { display: block; font-size: 27px; }
.stat-card span { color: var(--muted); font-size: 11px; }
.subheading { font-size: 17px; margin: 25px 0 13px; }
.secondary-button { background: #292136; border: 1px solid #443554; color: var(--text); margin-top: 10px; }
.danger-button { color: #f3a5b1; border-color: #63303f; }
.settings-card h3 { font-size: 15px; margin: 0 0 5px; }
.settings-card p { color: var(--muted); font-size: 12px; }
.settings-card label { display: block; font-size: 12px; margin-top: 15px; }
.settings-card select, .settings-card input[type=range] {
  width: 100%; margin-top: 7px;
}
.settings-card select {
  padding: 11px; border-radius: 11px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line);
}
.muted { color: var(--muted); }
.empty-state { text-align: center; padding: 36px 15px; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 8px; }
.toast {
  position: fixed;
  z-index: 30;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 12px);
  width: max-content;
  max-width: calc(100vw - 40px);
  background: #332746;
  border: 1px solid #634986;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.bottom-nav {
  position: fixed;
  z-index: 20;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 460px);
  display: grid;
  grid-template-columns: repeat(5,minmax(0,1fr));
  padding: 9px 5px calc(9px + env(safe-area-inset-bottom));
  background: rgba(18,15,25,.96);
  backdrop-filter: blur(18px);
  border: 1px solid #30263d;
  border-bottom: 0;
  border-radius: 19px 19px 0 0;
}
.nav-item {
  min-width: 0;
  border: 0;
  background: none;
  color: #93869f;
  font-size: 9px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 4px 0;
}
.nav-icon { font-size: 21px; line-height: 1.25; }
.nav-item.selected { color: var(--purple); }
.nav-item.selected .nav-icon { text-shadow: 0 0 15px #a78bfa66; }

@media (min-width: 600px) {
  body { padding: 20px 0; }
  .app-shell {
    min-height: calc(100dvh - 40px);
    border: 1px solid #30263d;
    border-radius: 27px;
    padding-bottom: 82px;
  }
  .topbar { border-radius: 26px 26px 0 0; }
  .bottom-nav {
    bottom: 20px;
    border-radius: 0 0 26px 26px;
  }
}
@media (max-width: 350px) {
  .page { padding-left: 13px; padding-right: 13px; }
  .hero { padding: 20px 16px 16px; }
  .hero h1 { font-size: 32px; }
  .category-grid { gap: 8px; }
  .category-card { padding: 12px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
