:root {
  color-scheme: dark;
  --bg: #050910;
  --bg-elevated: rgba(8, 15, 24, 0.9);
  --card: rgba(13, 23, 35, 0.9);
  --card-soft: rgba(18, 30, 45, 0.72);
  --line: rgba(148, 179, 209, 0.14);
  --line-strong: rgba(148, 179, 209, 0.24);
  --text: #e8f1f8;
  --text-soft: #aebfcd;
  --muted: #6f8294;
  --blue: #4b8dff;
  --green: #55e29a;
  --green-soft: rgba(85, 226, 154, 0.13);
  --blue-soft: rgba(75, 141, 255, 0.14);
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
  --radius: 22px;
  --radius-small: 16px;
  --radius-pill: 999px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --card: rgba(255, 255, 255, 0.92);
  --card-soft: rgba(245, 249, 253, 0.92);
  --line: rgba(20, 37, 54, 0.1);
  --line-strong: rgba(20, 37, 54, 0.18);
  --text: #101923;
  --text-soft: #506172;
  --muted: #7d8a96;
  --blue-soft: rgba(47, 111, 235, 0.1);
  --green-soft: rgba(9, 160, 92, 0.11);
  --shadow: 0 18px 48px rgba(34, 54, 82, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html[data-reduced-motion="true"],
html[data-reduced-motion="true"] * {
  scroll-behavior: auto !important;
  animation: none !important;
  transition: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% -6%, rgba(75, 141, 255, 0.2), transparent 24rem),
    radial-gradient(circle at 95% 0%, rgba(85, 226, 154, 0.12), transparent 22rem),
    linear-gradient(180deg, var(--bg) 0%, #02060b 120%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 8% -8%, rgba(75, 141, 255, 0.16), transparent 24rem),
    radial-gradient(circle at 90% 0%, rgba(85, 226, 154, 0.13), transparent 20rem),
    linear-gradient(180deg, #f7faff 0%, #eef3f8 100%);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(75, 141, 255, 0.62);
  outline-offset: 3px;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(720px, calc(100% - 22px));
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 0 calc(92px + env(safe-area-inset-bottom));
}

.masthead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 5px 0 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #061018;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 10px 28px rgba(75, 141, 255, 0.22);
}

.masthead__copy {
  min-width: 0;
}

.masthead h1,
.context-bar h2,
.screen-intro h2,
.story-card h3,
.market-card h3,
.insight-card h3,
.settings-card strong,
.learn-grid h3,
.subsection-heading h3,
.list-title {
  margin: 0;
  letter-spacing: 0;
}

.masthead h1 {
  font-size: 1.08rem;
  line-height: 1.05;
}

.masthead p {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.bot-link,
.ghost-button,
.primary-action,
.soft-action,
.wide-action,
.link-list a,
.link-list button,
.search-form button,
.chip,
.segmented button {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  text-decoration: none;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.bot-link,
.ghost-button {
  border-radius: var(--radius-pill);
  padding: 8px 11px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.context-bar {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 2px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)), var(--bg-elevated);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px);
}

.context-kicker,
.section-kicker {
  margin: 0;
  color: var(--green);
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.context-bar h2 {
  margin-top: 3px;
  font-size: 1.02rem;
  line-height: 1.1;
}

.context-bar p:last-child,
.screen-intro p:last-child {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.screen-stack {
  min-height: 66vh;
}

.screen {
  animation: screenIn 220ms ease both;
}

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

.screen-intro {
  margin: 4px 2px 12px;
}

.screen-intro h2 {
  margin-top: 5px;
  font-size: 1.34rem;
  line-height: 1.06;
}

.story-card,
.market-card,
.insight-card,
.settings-card,
.saved-empty,
.footer-note,
.learn-grid article,
.activity-row,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.014)), var(--card);
  box-shadow: var(--shadow);
}

.story-card,
.insight-card,
.settings-card {
  padding: 16px;
}

.story-card--hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 94% 0%, var(--green-soft), transparent 12rem),
    linear-gradient(145deg, var(--blue-soft), transparent 46%),
    var(--card);
}

.story-card__topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.story-card h3,
.insight-card h3 {
  margin-top: 10px;
  font-size: 1.17rem;
  line-height: 1.18;
}

.story-card p,
.insight-card p,
.market-card p,
.learn-grid p,
.footer-note span,
.settings-row span,
.activity-row p {
  color: var(--text-soft);
}

.story-card p,
.insight-card p {
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.38;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.metric-line span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.metric-line strong {
  font-size: 1.42rem;
  line-height: 1;
}

.watch-copy {
  color: var(--muted) !important;
  font-size: 0.82rem !important;
}

.story-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.market-card {
  padding: 12px;
}

.market-card__main h3,
.activity-row h4 {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.2;
}

.market-card__main p,
.activity-row p {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.32;
}

.pill-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.pill-row {
  margin-top: 10px;
}

.pill {
  border-radius: var(--radius-pill);
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.pill--prob {
  color: #061018;
  background: linear-gradient(135deg, var(--green), #a8ffd0);
}

.pill--pulse {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: var(--blue-soft);
}

.action-row {
  margin-top: 11px;
}

.primary-action,
.soft-action,
.wide-action,
.link-list a,
.link-list button,
.search-form button {
  border-radius: var(--radius-pill);
  padding: 9px 12px;
  font-size: 0.82rem;
}

.primary-action,
.wide-action {
  border-color: transparent;
  color: #061018;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

.soft-action {
  color: var(--text-soft);
}

.wide-action {
  width: 100%;
  margin-top: 12px;
}

.subsection {
  margin-top: 16px;
}

.subsection-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 0 2px 9px;
}

.subsection-heading--spaced {
  margin-top: 14px;
}

.subsection-heading h3,
.list-title {
  font-size: 0.98rem;
}

.subsection-heading span {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.horizontal-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(218px, 74%);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.horizontal-strip > * {
  scroll-snap-align: start;
}

.insight-card {
  margin-bottom: 12px;
}

.activity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  box-shadow: none;
}

.activity-row + .activity-row,
.market-card + .market-card {
  margin-top: 9px;
}

.activity-row__side {
  display: grid;
  gap: 7px;
  justify-items: end;
}

.activity-row__side strong {
  font-size: 0.88rem;
}

.activity-row__side a {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.search-form input {
  width: 100%;
  border: 0;
  outline: 0;
  border-radius: 15px;
  color: var(--text);
  background: transparent;
  padding: 9px 10px;
}

.search-form input::placeholder {
  color: var(--muted);
}

.suggestion-block {
  margin-top: 12px;
}

.suggestion-block p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.chip {
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  padding: 8px 10px;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.search-results {
  margin-top: 12px;
}

.compact-list {
  display: grid;
  gap: 9px;
}

.settings-card {
  display: grid;
  gap: 14px;
}

.settings-row {
  display: grid;
  gap: 9px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.settings-row strong,
.toggle-row span {
  display: block;
  font-size: 0.9rem;
}

.settings-row span {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.segmented button {
  border-radius: 12px;
  border-color: transparent;
  padding: 8px 6px;
  color: var(--text-soft);
  background: transparent;
  font-size: 0.76rem;
}

.segmented button.is-selected {
  color: #061018;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
}

.switch::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 3px;
  left: 4px;
  border-radius: 50%;
  background: var(--text-soft);
  transition: transform 160ms ease, background 160ms ease;
}

.switch.is-on {
  background: var(--green-soft);
  border-color: rgba(85, 226, 154, 0.45);
}

.switch.is-on::after {
  transform: translateX(17px);
  background: var(--green);
}

.learn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.learn-grid article {
  padding: 13px;
  box-shadow: none;
}

.learn-grid h3 {
  font-size: 0.9rem;
}

.learn-grid p {
  margin: 7px 0 0;
  font-size: 0.8rem;
  line-height: 1.32;
}

.link-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.link-list a,
.link-list button {
  text-align: center;
}

.footer-note {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding: 13px;
  box-shadow: none;
}

.footer-note strong {
  font-size: 0.82rem;
}

.footer-note span {
  font-size: 0.76rem;
  line-height: 1.35;
}

.empty-state {
  display: grid;
  gap: 5px;
  padding: 14px;
  color: var(--text-soft);
  box-shadow: none;
  font-size: 0.86rem;
}

.empty-state--compact {
  padding: 11px 12px;
  border-radius: var(--radius-small);
}

.skeleton-card {
  min-height: 132px;
  position: relative;
  overflow: hidden;
}

.skeleton-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.07) 44%, transparent 68%);
  animation: shimmer 1.1s ease-in-out infinite;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(2, 6, 11, 0.94) 24%);
  backdrop-filter: blur(18px);
}

:root[data-theme="light"] .bottom-nav {
  background: linear-gradient(180deg, transparent, rgba(244, 247, 251, 0.95) 24%);
}

.bottom-nav__inner {
  width: min(720px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg-elevated);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
}

.bottom-nav__item {
  border: 0;
  border-radius: 18px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px 7px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 900;
}

.bottom-nav__item span {
  font-size: 1rem;
  line-height: 1;
}

.bottom-nav__item.is-active {
  color: #061018;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

.bot-link:hover,
.ghost-button:hover,
.primary-action:hover,
.soft-action:hover,
.wide-action:hover,
.link-list a:hover,
.link-list button:hover,
.search-form button:hover,
.chip:hover,
.bottom-nav__item:hover {
  transform: translateY(-1px);
  border-color: rgba(85, 226, 154, 0.45);
}

html[data-compact="true"] .story-card,
html[data-compact="true"] .insight-card,
html[data-compact="true"] .market-card,
html[data-compact="true"] .settings-card {
  padding: 11px;
}

html[data-compact="true"] .screen-intro {
  margin-bottom: 8px;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  from {
    transform: translateX(-80%);
  }
  to {
    transform: translateX(80%);
  }
}

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

  .settings-row {
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: center;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 18px, 720px);
  }

  .context-bar {
    padding: 10px;
    border-radius: 18px;
  }

  .story-card,
  .insight-card,
  .settings-card {
    padding: 14px;
  }

  .horizontal-strip {
    grid-auto-columns: minmax(198px, 78%);
  }

  .learn-grid,
  .link-list {
    grid-template-columns: 1fr;
  }
}
