:root {
  color-scheme: dark;
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-raised: #242424;
  --surface-soft: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f3ee;
  --muted: #aaa8a2;
  --quiet: #77756f;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #d7efb2;
  --accent-ink: #1a2115;
  --warm: #f0c48a;
  --danger: #ee9d9d;
  --on-media: #f5f3ee;
  --on-media-muted: #d4d1ca;
  --radius-card: 26px;
  --radius-control: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #090909; }
body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  background: #090909;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.app {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  background: var(--bg);
}
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon--small { width: 17px; height: 17px; }

.topbar {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto;
  width: 100%;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
  background: rgba(17, 17, 17, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.topbar__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wordmark { color: var(--text); font-size: 17px; font-weight: 750; letter-spacing: -0.04em; text-decoration: none; }
.topbar__hint { display: none; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
}
.icon-button:hover { background: var(--surface-strong); }
.feed-tabs { display: flex; gap: 20px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; }
.feed-tabs::-webkit-scrollbar { display: none; }
.feed-tab {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.feed-tab:hover, .feed-tab[aria-selected="true"] { color: var(--text); }
.feed-tab[aria-selected="true"] { border-color: var(--accent); }

.feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100svh;
  padding: 104px 14px 92px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.discovery-card {
  position: relative;
  flex: 0 0 calc(100svh - 164px);
  min-height: 560px;
  overflow: hidden;
  scroll-snap-align: start;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.discovery-card[hidden] { display: none; }
.discovery-card.is-removing { opacity: 0; transform: translateY(-12px) scale(0.98); transition: opacity 180ms ease, transform 180ms ease; }
.discovery-card__media { position: absolute; inset: 0; background: var(--surface-raised); }
.discovery-card__media img { width: 100%; height: 100%; object-fit: cover; opacity: 0.82; }
.discovery-card__media::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.04) 38%, rgba(0, 0, 0, 0.86) 100%);
}
.generated-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--generated-ink, #f2e8d5);
  background: var(--generated-bg, #332d25);
}
.generated-cover::before, .generated-cover::after { position: absolute; content: ""; border: 1px solid currentColor; opacity: 0.2; transform: rotate(-12deg); }
.generated-cover::before { width: 74%; height: 54%; border-radius: 42% 58% 46% 54%; }
.generated-cover::after { width: 42%; height: 78%; border-radius: 52% 48% 58% 42%; transform: rotate(25deg); }
.generated-cover svg { position: relative; z-index: 1; width: 31%; height: auto; stroke-width: 1.2; opacity: 0.9; }
.generated-cover--calligraphy { --generated-bg: #4b4035; --generated-ink: #f0c48a; }
.generated-cover--radio { --generated-bg: #26383a; --generated-ink: #bfe6d2; }
.generated-cover--story { --generated-bg: #3a3540; --generated-ink: #d7c5f1; }
.generated-cover--try { --generated-bg: #3d3c2f; --generated-ink: #d7efb2; }
.discovery-card__fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.8);
}
.discovery-card__fallback svg { width: 46%; max-width: 180px; height: auto; }
.discovery-card__content { position: absolute; inset: auto 16px 16px; z-index: 1; color: var(--on-media); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  color: var(--on-media);
  background: rgba(20, 20, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}
.discovery-card h1 { max-width: 340px; margin: 0; color: var(--on-media); font-size: clamp(28px, 8vw, 38px); line-height: 0.98; letter-spacing: -0.055em; }
.discovery-card__description { display: -webkit-box; max-width: 340px; margin: 12px 0 0; overflow: hidden; color: var(--on-media-muted); font-size: 14px; line-height: 1.42; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.discovery-card__meta { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--on-media-muted); font-size: 11px; }
.card-actions { display: grid; grid-template-columns: repeat(5, 42px); gap: 8px; margin-top: 16px; }
.card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--on-media);
  background: rgba(20, 20, 20, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}
.card-action:hover, .card-action[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.card-action:active { transform: scale(0.94); }
.card-action[aria-pressed="true"] .icon { fill: currentColor; }
.try-button {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px;
  margin-left: 0;
  padding: 0 15px;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 750;
}
.try-button:hover { filter: brightness(1.06); }
.try-button[aria-pressed="true"] { color: var(--text); background: rgba(20, 20, 20, 0.75); border: 1px solid var(--accent); }

.bottom-nav {
  position: fixed;
  z-index: 20;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  background: rgba(17, 17, 17, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.bottom-nav__item {
  display: flex;
  min-height: 52px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--quiet);
  background: none;
  border: 0;
  border-radius: var(--radius-control);
  font-size: 10px;
  font-weight: 650;
}
.bottom-nav__item span { display: none; }
.bottom-nav__item[aria-current="page"] span, .bottom-nav__create span { display: block; }
.bottom-nav__item:hover, .bottom-nav__item[aria-current="page"] { color: var(--text); background: var(--surface-soft); }
.bottom-nav__item[aria-current="page"] .icon { color: var(--accent); }
.bottom-nav__create { color: var(--accent-ink); background: var(--accent); }
.bottom-nav__create:hover { color: var(--accent-ink); background: var(--accent); }

.screen {
  height: 100svh;
  overflow-y: auto;
  padding: 102px 16px 98px;
}
.screen[hidden], .overlay[hidden] { display: none; }
.screen__header { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.screen__header h1 { flex: 1; margin: 0; font-size: 32px; letter-spacing: -0.055em; }
.back-button { color: var(--text); background: none; border: 0; }
.explore-intro { margin: 0 0 24px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.explore-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.explore-card { min-height: 126px; padding: 16px; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.explore-card:hover { background: var(--surface-raised); }
.explore-card svg { width: 28px; height: 28px; margin-bottom: 18px; color: var(--accent); }
.explore-card strong { display: block; font-size: 14px; }
.explore-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.profile-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; }
.profile-card__row { display: flex; align-items: center; gap: 14px; }
.avatar { display: grid; place-items: center; width: 54px; height: 54px; color: var(--accent-ink); background: var(--accent); border-radius: 50%; font-weight: 800; }
.profile-card h2 { margin: 0; font-size: 18px; }
.profile-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 20px; text-align: center; }
.profile-stats strong { display: block; font-size: 19px; }
.profile-stats span { color: var(--muted); font-size: 11px; }
.profile-section { margin-top: 26px; }
.profile-section h3 { margin: 0 0 10px; font-size: 16px; }
.saved-topic { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.saved-topic strong { font-size: 14px; }
.saved-topic span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.overlay { position: fixed; z-index: 40; inset: 0; background: var(--bg); }
.search-panel { height: 100%; overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) 16px 28px; }
.search-panel__top { display: flex; align-items: center; gap: 10px; }
.search-input-wrap { display: flex; align-items: center; flex: 1; gap: 8px; min-height: 50px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.search-input-wrap input { width: 100%; color: var(--text); background: transparent; border: 0; outline: 0; }
.search-input-wrap input::placeholder { color: var(--muted); }
.search-close { color: var(--text); background: none; border: 0; }
.search-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.suggestion { min-height: 36px; padding: 0 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.suggestion:hover { color: var(--text); border-color: var(--accent); }
.search-results { margin-top: 28px; }
.search-results h2 { margin: 0 0 12px; font-size: 16px; }
.result-card { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.result-card__icon { display: grid; place-items: center; width: 44px; height: 44px; color: var(--accent); background: var(--surface-raised); border-radius: 13px; }
.result-card strong { display: block; font-size: 14px; }
.result-card span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.topic-view { position: fixed; z-index: 30; inset: 0; overflow-y: auto; background: var(--bg); }
.topic-hero { position: relative; min-height: 390px; overflow: hidden; }
.topic-hero img { width: 100%; height: 390px; object-fit: cover; opacity: 0.76; }
.topic-hero::after { position: absolute; inset: 0; content: ""; background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), var(--bg) 95%); }
.topic-hero__top { position: absolute; z-index: 1; inset: max(16px, env(safe-area-inset-top)) 16px auto; display: flex; justify-content: space-between; }
.topic-hero__content { position: absolute; z-index: 1; inset: auto 16px 20px; }
.topic-hero h1 { margin: 0; font-size: 38px; line-height: 1; letter-spacing: -0.06em; }
.topic-hero p { max-width: 340px; margin: 10px 0 0; color: #d4d1ca; font-size: 14px; line-height: 1.45; }
.topic-body { padding: 4px 16px 96px; }
.topic-metrics { display: flex; gap: 18px; margin: 0 0 20px; color: var(--muted); font-size: 12px; }
.topic-metrics strong { color: var(--text); }
.topic-cta-row { display: flex; gap: 8px; margin-bottom: 28px; }
.topic-cta-row button { min-height: 44px; padding: 0 15px; border-radius: var(--radius-control); font-size: 13px; font-weight: 750; }
.topic-interest { color: var(--text); background: var(--surface); border: 1px solid var(--line); }
.topic-try { color: var(--accent-ink); background: var(--accent); border: 0; }
.topic-cta-row button[aria-pressed="true"] { color: var(--text); background: var(--surface-raised); border-color: var(--accent); }
.info-block { padding: 18px 0; border-top: 1px solid var(--line); }
.info-block h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.info-block p { margin: 9px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.topic-section-list { display: flex; flex-direction: column; gap: 8px; }
.topic-section-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) 20px; align-items: center; gap: 12px; min-height: 72px; padding: 12px; color: var(--text); text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.topic-section-card:hover { background: var(--surface-raised); }
.topic-section-card__icon { display: grid; place-items: center; width: 38px; height: 38px; color: var(--accent); background: var(--surface-soft); border-radius: 12px; }
.topic-section-card strong { display: block; font-size: 13px; }
.topic-section-card span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.topic-section-card .icon--chevron { color: var(--quiet); }
.related-row { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; scrollbar-width: none; }
.related-row::-webkit-scrollbar { display: none; }
.related-card { flex: 0 0 150px; min-height: 100px; padding: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; text-align: left; }
.related-card strong { display: block; font-size: 13px; }
.related-card span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.toast { position: fixed; z-index: 60; right: 16px; bottom: 88px; left: 16px; padding: 14px 16px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 28px rgba(0,0,0,.26); font-size: 13px; transform: translateY(12px); opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.bottom-sheet {
  position: fixed;
  z-index: 55;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 14px 16px max(18px, env(safe-area-inset-bottom));
  background: var(--surface-raised);
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -14px 36px rgba(0, 0, 0, 0.26);
}
.bottom-sheet[hidden] { display: none; }
.bottom-sheet__handle { width: 36px; height: 4px; margin: 0 auto 14px; background: var(--quiet); border-radius: 4px; }
.bottom-sheet h2 { margin: 0 0 12px; font-size: 17px; }
.bottom-sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bottom-sheet__actions button { min-height: 44px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.bottom-sheet__actions button:hover { border-color: var(--accent); }
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-raised: #eeece7;
  --surface-soft: rgba(32, 34, 31, 0.06);
  --surface-strong: rgba(32, 34, 31, 0.12);
  --text: #20221f;
  --muted: #676962;
  --quiet: #8a8d85;
  --line: rgba(32, 34, 31, 0.14);
  --accent: #476b2d;
  --accent-ink: #f7f9f1;
  --warm: #b2773a;
}
[data-theme="light"] html, [data-theme="light"] body { background: var(--bg); }
[data-theme="light"] .topbar, [data-theme="light"] .bottom-nav { background: rgba(244, 242, 237, 0.94); }
[data-theme="light"] .discovery-card__description, [data-theme="light"] .discovery-card__meta { color: #f3f2ed; }
[data-theme="light"] .discovery-card__media::after { background: linear-gradient(180deg, rgba(0, 0, 0, 0.02) 34%, rgba(0, 0, 0, 0.82) 100%); }

@media (min-width: 600px) {
  body { padding: 20px 0; }
  .app { max-width: 480px; min-height: calc(100svh - 40px); border: 1px solid #2a2a2a; border-radius: 30px; box-shadow: 0 20px 70px rgba(0,0,0,.35); }
  .topbar, .bottom-nav { max-width: 480px; margin: auto; left: 50%; transform: translateX(-50%); }
  .topbar { inset: 20px auto auto; border-radius: 30px 30px 0 0; }
  .bottom-nav { inset: auto auto 20px; border-radius: 0 0 30px 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
