:root {
  --bg: #06070b;
  --bg-elevated: #0d0f14;
  --panel: rgba(19, 20, 28, 0.94);
  --panel-strong: #151824;
  --panel-soft: rgba(33, 35, 46, 0.88);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f2f8;
  --muted: #8f93a7;
  --accent: #6d1cff;
  --accent-soft: rgba(109, 28, 255, 0.18);
  --accent-glow: rgba(109, 28, 255, 0.3);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.48);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

:root[data-theme="violet"] {
  --accent: #9d5cff;
  --accent-soft: rgba(157, 92, 255, 0.18);
  --accent-glow: rgba(157, 92, 255, 0.3);
}

* { box-sizing: border-box; }
html {
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(93, 15, 213, 0.22), transparent 24%),
    linear-gradient(180deg, #06070b 0%, #0a0c12 100%);
  color: var(--text);
}
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { background: none; border: 0; color: inherit; }
h1, h2, h3, p, ul, ol, dl { margin: 0; }
img { max-width: 100%; display: block; }
svg { display: block; }

.app-topbar > *,
.brand-lockup > *,
.topbar-actions > *,
.hero-card > *,
.info-card > *,
.pro-hero > *,
.drill-card__body > *,
.detail-hero__copy > * {
  min-width: 0;
}

#app, .app-shell { min-height: 100vh; }
.app-shell {
  width: min(100%, 1460px);
  margin: 0 auto;
  padding: 22px 18px calc(108px + env(safe-area-inset-bottom));
}

.status-banner,
.app-topbar,
.hero-card,
.control-bar,
.drill-card,
.info-card,
.empty-card,
.pro-hero,
.bottom-nav {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-banner {
  margin-bottom: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: #d5c3ff;
}

.app-topbar,
.control-bar,
.hero-card,
.drill-card,
.info-card,
.empty-card,
.pro-hero { border-radius: var(--radius-xl); }

.app-topbar,
.topbar-actions,
.brand-lockup,
.meta-row,
.hero-actions,
.card-topline,
.card-actions,
.content-header,
.detail-topbar,
.detail-topbar__actions,
.hero-tags,
.form-actions { display: flex; align-items: center; gap: 12px; }

.app-topbar {
  justify-content: space-between;
  padding: 18px 20px;
  margin-bottom: 18px;
  gap: 16px;
}

.brand-lockup { gap: 16px; }
.brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 30px rgba(93, 15, 213, 0.18);
}
.eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: #ad93ff;
  margin-bottom: 8px;
}
.headline {
  font-size: clamp(1.2rem, 2.15vw, 2.25rem);
  max-width: 620px;
  line-height: 1.08;
  text-wrap: balance;
}
.ghost-chip,
.filter-chip,
.pill,
.lock-pill,
.round-button,
.icon-button,
.text-link,
.cta,
.nav-item {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.ghost-chip,
.filter-chip,
.pill,
.lock-pill,
.cta {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.ghost-chip { background: rgba(255,255,255,0.04); color: var(--text); }
.ghost-chip--owner { background: var(--accent-soft); color: #dac7ff; border-color: rgba(164, 120, 255, 0.18); }
.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.hero-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-card {
  padding: 22px;
  min-height: 180px;
}
.hero-card--feature {
  display: grid;
  gap: 20px;
  overflow: hidden;
}
.hero-card--metric {
  display: grid;
  gap: 10px;
  align-content: end;
}
.hero-card--accent {
  background:
    radial-gradient(circle at top right, rgba(109, 28, 255, 0.22), transparent 40%),
    var(--panel);
}
.hero-copy h2,
.content-header h2,
.pro-hero h2,
.info-card h2 {
  font-size: clamp(1.35rem, 2.2vw, 2.2rem);
  line-height: 1.08;
  text-wrap: balance;
}
.info-card h3,
.drill-card h3 {
  font-size: clamp(1.05rem, 1.4vw, 1.45rem);
  line-height: 1.2;
  text-wrap: balance;
}
.hero-copy p,
.drill-card p,
.info-card p,
.empty-card p,
.pro-hero p,
.subscribe-note,
.support-copy { color: var(--muted); line-height: 1.65; }

.meta-row {
  flex-wrap: wrap;
  color: #c4c7d6;
  font-size: 0.92rem;
}
.meta-row span {
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.pill { font-size: 0.8rem; color: #efe7ff; background: rgba(255,255,255,0.04); }
.pill--subtle { color: #c9cddd; }
.lock-pill { font-size: 0.78rem; color: #f4e8ff; background: rgba(109, 28, 255, 0.16); }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.status-chip svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.status-chip--success {
  color: #86f1a9;
  background: rgba(29, 160, 69, 0.14);
  border-color: rgba(84, 218, 125, 0.2);
}
.status-chip--danger {
  color: #ff8c8c;
  background: rgba(191, 47, 47, 0.16);
  border-color: rgba(255, 126, 126, 0.18);
}

.cta {
  font-weight: 700;
  cursor: pointer;
}
.cta--primary {
  background: linear-gradient(135deg, var(--accent), #c04cff);
  color: white;
  box-shadow: 0 12px 30px rgba(109, 28, 255, 0.28);
}
.cta--secondary { background: rgba(255,255,255,0.04); color: var(--text); }

.mini-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}
.mini-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0e4ff, var(--accent));
}
.mini-dots { display: flex; gap: 8px; }
.mini-dots i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.mini-dots .active { background: var(--accent); box-shadow: 0 0 18px var(--accent-glow); }
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #eee5ff;
  padding: 0;
  cursor: pointer;
}
.text-link svg,
.round-button svg,
.icon-button svg,
.ghost-chip svg,
.lock-pill svg,
.nav-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-art,
.drill-card__art,
.detail-hero__art { position: relative; overflow: hidden; border-radius: 22px; }
.signal-art { width: 100%; height: auto; }

.control-bar {
  padding: 18px;
  margin-bottom: 18px;
}
.search-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.search-shell svg { width: 18px; height: 18px; stroke: #8f93a7; fill: none; stroke-width: 1.8; }
.search-shell input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
}
.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.filter-chip {
  white-space: nowrap;
  cursor: pointer;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}
.filter-chip.active {
  color: white;
  background: rgba(109, 28, 255, 0.18);
  border-color: rgba(170, 131, 255, 0.2);
}

.content-header {
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
}
.drill-grid,
.detail-grid,
.pro-grid {
  display: grid;
  gap: 18px;
}

.page-shell {
  width: min(100%, 1080px);
  margin: 0 auto;
}

.page-shell--settings {
  width: min(100%, 760px);
}

.page-shell--pro {
  width: min(100%, 860px);
}

.drill-card {
  overflow: hidden;
}
.drill-card__art { border-radius: 0; min-height: 170px; }
.drill-card__body { padding: 20px; display: grid; gap: 14px; }
.meta-row--tight span { padding: 7px 10px; font-size: 0.85rem; }
.card-actions {
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 10px;
}
.icon-button,
.round-button {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
.icon-button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.icon-button--saved {
  width: auto;
  min-width: 46px;
  padding: 0 14px;
}
.is-locked .drill-card__art,
.is-locked .drill-card__body { filter: saturate(0.7); }

.empty-card,
.profile-empty {
  padding: 26px;
}

.detail-shell { display: grid; gap: 18px; }
.detail-topbar { justify-content: space-between; }
.detail-hero {
  display: grid;
  gap: 18px;
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 22px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.detail-grid .info-card { padding: 22px; display: grid; gap: 14px; }
.info-card--wide { grid-column: span 2; }
.info-card--diagram { grid-column: span 2; }
.info-card ul,
.info-card ol {
  padding-left: 20px;
  color: #d4d6e2;
  line-height: 1.7;
}
.setup-grid {
  display: grid;
  gap: 12px;
}
.setup-grid div {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}
.setup-grid dt { color: var(--muted); font-size: 0.84rem; margin-bottom: 6px; }
.setup-grid dd { margin: 0; color: var(--text); font-weight: 700; }
.diagram-card__image,
.diagram-card__svg {
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.06);
}

.page-shell--pro,
.settings-grid {
  display: grid;
  gap: 18px;
}

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

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

.pro-hero {
  padding: 24px;
  display: grid;
  gap: 22px;
  align-items: start;
  background:
    radial-gradient(circle at top right, rgba(109, 28, 255, 0.22), transparent 32%),
    radial-gradient(circle at bottom left, rgba(255,255,255,0.04), transparent 18%),
    var(--panel);
}
.pro-hero h2 {
  font-size: clamp(1.5rem, 2.5vw, 2.4rem);
  line-height: 1.08;
  text-wrap: balance;
}
.pro-stats {
  display: grid;
  gap: 6px;
  align-content: end;
  justify-items: start;
}
.pro-stats small {
  max-width: 26ch;
  color: var(--muted);
  line-height: 1.55;
}
.subscribe-button {
  width: 100%;
  min-height: 64px;
  padding: 22px 24px;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
  background: linear-gradient(135deg, #f1e8ff 0%, #a45cff 50%, #5d0fd5 100%);
  color: #0c0716;
  box-shadow: 0 24px 60px rgba(109, 28, 255, 0.34);
}
.subscribe-button:disabled {
  opacity: 0.66;
  cursor: default;
}
.subscribe-note { text-align: center; }

.redeem-form,
.profile-form {
  display: grid;
  gap: 14px;
}
.redeem-form label,
.profile-form label { display: grid; gap: 8px; }
.redeem-form span,
.profile-form span { color: #c7c9d6; font-size: 0.92rem; }
.redeem-form input,
.profile-form input,
.profile-form select {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 14px 16px;
}
.redeem-form input { text-transform: uppercase; letter-spacing: 0.12em; }
.support-copy {
  padding-top: 4px;
  overflow-wrap: anywhere;
}

.page-shell--settings .info-card,
.page-shell--pro .info-card {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.page-shell--settings .info-card--wide,
.page-shell--pro .info-card--wide {
  grid-column: auto;
}

.page-shell--settings .info-card,
.page-shell--pro .info-card,
.pro-hero {
  align-content: start;
}

.form-actions {
  flex-wrap: wrap;
  row-gap: 10px;
}

.form-actions .cta {
  min-height: 48px;
  padding-inline: 18px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 20px), 720px);
  border-radius: 28px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px;
  z-index: 40;
}
.nav-item {
  border-radius: 20px;
  padding: 10px 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  place-items: center;
  cursor: pointer;
}
.nav-item.active {
  color: white;
  background: rgba(109, 28, 255, 0.18);
}
.nav-item small { font-size: 0.72rem; font-weight: 700; }

@media (min-width: 780px) {
  .hero-grid {
    grid-template-columns: 2.1fr repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }
  .hero-card--feature {
    grid-column: span 1;
    grid-template-columns: 1.2fr 0.95fr;
    align-items: stretch;
  }
  .drill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pro-hero { grid-template-columns: minmax(0, 1.1fr) auto; }
}

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

@media (max-width: 779px) {
  .app-topbar,
  .content-header,
  .detail-topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { justify-content: flex-start; flex-wrap: wrap; }
  .detail-topbar__actions { justify-content: flex-end; }
  .page-shell {
    width: 100%;
  }
  .pro-hero {
    padding: 22px;
  }
  .page-shell--settings .info-card--wide,
  .page-shell--pro .info-card--wide,
  .info-card--wide,
  .info-card--diagram {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding-inline: 14px;
  }
  .app-topbar,
  .info-card,
  .pro-hero,
  .drill-card__body,
  .detail-grid .info-card,
  .detail-hero {
    padding: 18px;
  }
  .brand-lockup {
    align-items: center;
  }
  .brand-badge {
    width: 50px;
    height: 50px;
  }
  .headline,
  .content-header h2,
  .pro-hero h2,
  .info-card h2 {
    font-size: clamp(1.2rem, 7vw, 1.95rem);
  }
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .cta,
  .ghost-chip,
  .subscribe-button {
    width: 100%;
  }
}
