:root {
  --bg: #F5F1FF;
  --surface: #FFFFFF;
  --ink: #221A36;
  --muted: #6E6685;
  --primary: #5B3FD3;
  --primary-dark: #3E2B9E;
  --primary-soft: #EDE7FF;
  --line: #E5DFF3;
  --success: #16866B;
  --success-soft: #E4F6F0;
  --warning: #9A6415;
  --warning-soft: #FFF3DD;
  --danger: #C23B4A;
  --danger-soft: #FDECEF;
  --shadow: 0 12px 30px rgba(34, 26, 54, .10);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(91, 63, 211, .12), transparent 30%),
    radial-gradient(circle at 100% 100%, rgba(14, 138, 107, .08), transparent 30%),
    #ECE6FB;
  display: grid;
  place-items: center;
  padding: 24px;
}

button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.app {
  width: min(430px, 100%);
  height: min(900px, calc(100dvh - 48px));
  background: var(--bg);
  border-radius: 34px;
  box-shadow: 0 30px 80px rgba(34, 26, 54, .22);
  overflow-y: auto;
  padding: 18px 18px 104px;
  position: relative;
  scrollbar-width: none;
}
.app::-webkit-scrollbar { display: none; }

.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.brand-mark { width: 24px; height: 24px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 900; }
.user-badge { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 7px 10px; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--primary); }
h1 { margin: 0 0 6px; font-size: 34px; line-height: 1.05; letter-spacing: -.03em; }
.hero-sub { margin: 0; font-size: 14px; line-height: 1.4; color: var(--muted); max-width: 240px; }

.ring {
  width: 92px; height: 92px; flex: 0 0 92px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--primary) 0 0%, var(--line) 0 100%);
  position: relative;
}
.ring::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: var(--bg); }
.ring span { position: relative; z-index: 1; font-size: 20px; font-weight: 850; letter-spacing: -.02em; }
.ring small { display: block; font-size: 9px; font-weight: 700; color: var(--muted); text-align: center; letter-spacing: .02em; }

.continue-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--primary); color: #fff;
  border-radius: 20px; padding: 18px;
  box-shadow: 0 14px 28px rgba(91, 63, 211, .24);
  margin-bottom: 16px;
}
.continue-card .eyebrow { color: rgba(255,255,255,.7); }
.continue-card h2 { margin: 0 0 5px; font-size: 20px; line-height: 1.2; }
.continue-card p { margin: 0; font-size: 12px; color: rgba(255,255,255,.76); line-height: 1.35; }
.continue-arrow { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 20px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; }
.stat strong { display: block; font-size: 21px; line-height: 1.1; letter-spacing: -.02em; }
.stat span { display: block; margin-top: 4px; font-size: 10px; line-height: 1.25; color: var(--muted); }

.modules { display: grid; gap: 18px; }
.module-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.module-head h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.module-count { font-size: 11px; color: var(--muted); white-space: nowrap; }
.lesson-list { display: grid; gap: 8px; }
.lesson-row {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 12px; min-height: 64px;
}
.lesson-row:hover { border-color: #CFC5EA; }
.lesson-row.next { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.lesson-status {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: #F4F1FB; color: var(--muted);
  font-size: 12px; font-weight: 850;
}
.lesson-status.done { background: var(--success-soft); color: var(--success); }
.lesson-status.active { background: var(--primary-soft); color: var(--primary); }
.lesson-body { flex: 1; min-width: 0; }
.lesson-title { display: block; font-size: 13px; font-weight: 700; line-height: 1.3; margin-bottom: 3px; }
.lesson-meta { display: block; font-size: 10px; color: var(--muted); line-height: 1.3; }
.lesson-bar { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.lesson-bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.chev { color: #A99FC0; font-size: 20px; line-height: 1; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 24px 2px 10px; }
.section-title h2 { margin: 0; font-size: 16px; }
.section-title span { font-size: 11px; color: var(--muted); }

.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; height: 64px; position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.error-card { background: var(--danger-soft); border-radius: 16px; padding: 16px; font-size: 14px; line-height: 1.45; color: var(--danger); }
.error-card button { margin-top: 10px; border: 0; border-radius: 999px; background: var(--danger); color: #fff; padding: 10px 14px; font-weight: 700; }

.bottom-nav {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  width: min(398px, calc(100% - 36px));
  background: rgba(255,255,255,.94); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 7px; z-index: 20;
}
.bottom-nav button, .bottom-nav a {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 16px; padding: 9px 6px;
  display: grid; place-items: center; gap: 3px;
  font-size: 10px; font-weight: 700;
}
.bottom-nav svg { width: 19px; height: 19px; }
.bottom-nav .active { background: var(--primary-soft); color: var(--primary); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 8px);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 14px;
  font-size: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 600px) {
  body { display: block; padding: 0; background: var(--bg); }
  .app { width: 100%; height: 100dvh; border-radius: 0; box-shadow: none; padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .bottom-nav { bottom: calc(12px + env(safe-area-inset-bottom)); width: calc(100% - 28px); }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}

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

/* --- Auth / paywall --- */
.auth-card, .paywall-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.auth-card h2, .paywall-card h2 { margin: 0 0 8px; font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
.auth-card p, .paywall-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.auth-note { font-size: 12px !important; color: var(--muted); margin-top: 12px !important; margin-bottom: 0 !important; }
.btn-primary {
  width: 100%; border: 0; border-radius: 999px;
  background: var(--primary); color: #fff;
  min-height: 52px; padding: 13px 18px;
  font-size: 15px; font-weight: 750;
}
.btn-primary:disabled { opacity: .55; }
.price { font-size: 38px; font-weight: 850; letter-spacing: -.03em; margin: 14px 0 8px; }
