:root {
  --brand: #2563eb;
  --brand-soft: #e8f0ff;
  --navy: #15233b;
  --lane-yellow: #f5c72e;
  --success: #1f9e61;
  --danger: #db3838;
  --page-bg: #f4f1ea;
  --muted: #6b7385;
  --card: #ffffff;
  --border: #e4e0d6;
  --shadow: 0 8px 28px rgba(21, 35, 59, 0.07);
  --radius: 18px;
  --radius-sm: 12px;
  --max-width: 480px;
  --desk-max: 1080px;
  --tab-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Plus Jakarta Sans", "Nunito", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--navy);
  background: var(--page-bg);
  min-height: 100dvh;
}

.mobile-only {
  display: initial;
}

.desktop-only {
  display: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--brand);
}

#app,
#app.site {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

#app.app-wide {
  max-width: none;
  margin: 0;
}

@media (min-width: 900px) {
  #app.site:not(.app-wide) {
    max-width: none;
    margin: 0;
  }

  .mobile-only {
    display: none !important;
  }

  .desktop-only {
    display: initial;
  }
}

/* Loading */
.boot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 12px;
  color: var(--muted);
}

.boot-loading img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Onboarding — desktop split layout */
.onboarding {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: #f3f1ec;
  overflow: hidden;
}

.onboarding-hero {
  display: none;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #cfe6fb 0%, #e8f3fc 45%, #d9e8f4 100%);
}

.onboarding-hero-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  display: block;
}

.onboarding-panel {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  background: #f3f1ec;
  overflow: hidden;
}

.onboarding-panel-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px calc(20px + var(--safe-bottom));
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.onboarding-brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.onboarding-brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.onboarding-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(21, 35, 59, 0.12);
}

.onboarding-product {
  margin: 0 0 2px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.01em;
}

.onboarding-brand h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.onboarding-lede {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.onboarding-brand .app-store-badge {
  margin-top: 2px;
  align-self: flex-start;
}

.onboarding-footer-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.onboarding-legal {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.onboarding-legal a {
  color: var(--brand);
  text-decoration: none;
}

.onboarding-legal a:hover {
  text-decoration: underline;
}

.paywall-legal {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.paywall-legal a {
  color: var(--brand);
  text-decoration: none;
}

.paywall-legal a:hover {
  text-decoration: underline;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid #dde3ee;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(26, 41, 71, 0.04);
}

.search-field--icon .search-icon {
  color: #9aa3b5;
  flex-shrink: 0;
}

.search-field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--navy);
  font-weight: 600;
}

.search-field input::placeholder {
  color: #9aa3b5;
  font-weight: 600;
}

.state-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  padding-right: 4px;
  align-content: start;
}

.state-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.state-card:hover {
  border-color: #c7d4ea;
}

.state-card.selected {
  border-color: var(--brand);
  background: #eef4ff;
  box-shadow: 0 0 0 1px var(--brand);
}

.state-card .code {
  font-weight: 800;
  color: var(--brand);
  min-width: 28px;
  font-size: 0.95rem;
}

.state-card .divider {
  width: 1px;
  height: 18px;
  background: #d7dee9;
  flex-shrink: 0;
}

.state-card .name {
  flex: 1;
  font-weight: 700;
  color: var(--navy);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-card .check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #d0d7e3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.state-card.selected .check {
  background: var(--brand);
  border-color: var(--brand);
}

.onboarding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid #e5e1d8;
  margin-top: 0;
  flex-shrink: 0;
  background: #f3f1ec;
}

.onboarding-status {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}

.btn-continue {
  width: auto;
  min-width: 160px;
  border-radius: 14px;
  padding: 14px 22px;
  font-weight: 800;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max-width);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(transparent, var(--page-bg) 20%);
}

@media (min-width: 900px) {
  .onboarding {
    grid-template-columns: minmax(320px, 38%) 1fr;
  }

  .onboarding-hero {
    display: block;
    min-height: 100dvh;
  }

  .onboarding-panel-inner {
    padding: 52px 64px 36px;
    max-width: 820px;
    margin: 0;
  }

  .onboarding-brand h1 {
    font-size: 2.4rem;
  }

  .onboarding-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
  }

  .onboarding .state-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-right: 8px;
  }

  .onboarding-footer {
    padding-top: 18px;
  }

  .btn-continue {
    min-width: 190px;
    font-size: 1.05rem;
  }
}

@media (max-width: 899px) {
  .onboarding {
    grid-template-rows: 150px 1fr;
    height: 100dvh;
  }

  .onboarding-hero {
    display: block;
    height: 150px;
  }

  .onboarding-hero-art {
    object-position: center 35%;
  }

  .onboarding-panel {
    min-height: 0;
    height: auto;
  }

  .onboarding-panel-inner {
    padding-top: 20px;
  }

  .onboarding-footer {
    flex-wrap: wrap;
  }

  .btn-continue {
    width: 100%;
  }
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 20px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  border-radius: 14px;
  text-align: center;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-primary.btn-inline {
  width: auto;
  padding: 14px 22px;
  font-weight: 800;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px 18px;
  background: var(--card);
  color: var(--navy);
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.btn-ghost {
  padding: 8px 12px;
  color: var(--brand);
  font-weight: 700;
}

/* Shell */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom));
  background: var(--page-bg);
}

.shell-main,
.page-wrap {
  flex: 1;
  padding: 16px 16px 28px;
  width: 100%;
}

.top-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(244, 241, 234, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(21, 35, 59, 0.06);
}

.top-nav-inner {
  max-width: var(--desk-max);
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 0;
  color: var(--navy);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
}

.brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.home-brand-header {
  margin-bottom: 24px;
}

.home-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.home-brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(21, 35, 59, 0.12);
}

.home-brand .page-title {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
}

.home-brand .page-lede {
  margin: 4px 0 0;
}

.app-store-badge {
  display: inline-flex;
  margin-top: 16px;
  line-height: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.app-store-badge:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.app-store-badge img {
  display: block;
  height: 44px;
  width: auto;
}

@media (min-width: 900px) {
  .home-brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
  }

  .home-brand-header .app-store-badge {
    margin-top: 0;
  }

  .home-brand-header .page-sub {
    width: 100%;
  }
}

.top-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
}

.top-tab {
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.top-tab:hover {
  color: var(--navy);
}

.top-tab.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--navy);
  box-shadow: 0 2px 8px rgba(21, 35, 59, 0.04);
  flex-shrink: 0;
}

.state-chip svg:first-child {
  color: var(--brand);
}

.tab-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max-width);
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-top: 6px;
}

.tab-btn.active {
  color: var(--brand);
}

.tab-btn svg {
  width: 24px;
  height: 24px;
}

.screen-title,
.page-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--navy);
}

.page-header {
  margin-bottom: 20px;
}

.page-lede,
.page-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.section-heading {
  margin: 0 0 14px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.btn-inline {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Home dashboard */
.home-hero-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 28px;
}

.quiz-hero-card {
  display: grid;
  gap: 16px;
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(21, 35, 59, 0.04);
  overflow: hidden;
}

.quiz-hero-copy .eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.quiz-hero-copy h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.quiz-hero-desc {
  margin: 10px 0 18px;
  color: var(--muted);
  font-weight: 600;
  max-width: 28ch;
}

.quiz-hero-art {
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #d7e9fb, #eaf4fc);
  min-height: 140px;
}

.quiz-hero-art img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  object-position: center 40%;
  display: block;
}

.glance-card {
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(21, 35, 59, 0.04);
}

.glance-card h3 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 800;
}

.glance-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.glance-list li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.glance-num {
  min-width: 58px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  font-size: 1.05rem;
  border-radius: 12px;
  padding: 0 10px;
}

.glance-label {
  font-weight: 700;
  color: var(--navy);
}

.modes-section,
.desk-section {
  margin-bottom: 28px;
}

.modes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.modes-grid--2 {
  grid-template-columns: 1fr;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  background: var(--card);
  border: 1px solid rgba(21, 35, 59, 0.05);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  color: var(--navy);
  min-height: 140px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mode-card:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(21, 35, 59, 0.1);
}

.mode-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mode-icon {
  color: var(--brand);
  margin-bottom: 4px;
}

.mode-title {
  font-weight: 800;
  font-size: 1.05rem;
}

.mode-sub {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.35;
}

.mode-lock {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  background: #f3f5f8;
  border-radius: 999px;
  padding: 5px 9px;
}

.page-links {
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 8px 0 12px;
}

.page-links button {
  color: var(--brand);
  font-weight: 700;
}

.desk-card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(21, 35, 59, 0.04);
}

.empty-inline {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.progress-layout {
  display: grid;
  gap: 16px;
}

.progress-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.danger-text {
  color: var(--danger) !important;
}

.empty-state.compact img {
  max-width: 160px;
}

@media (min-width: 900px) {
  .shell {
    padding-bottom: 0;
  }

  .top-nav {
    display: block;
  }

  .page-wrap {
    max-width: var(--desk-max);
    margin: 0 auto;
    padding: 28px 28px 48px;
  }

  .page-title {
    font-size: 2.15rem;
  }

  .home-hero-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.7fr);
    gap: 20px;
    align-items: stretch;
  }

  .quiz-hero-card {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: center;
    padding: 8px 8px 8px 28px;
    min-height: 260px;
  }

  .quiz-hero-copy h2 {
    font-size: 1.85rem;
  }

  .quiz-hero-art {
    height: 100%;
    min-height: 244px;
    border-radius: 16px;
  }

  .quiz-hero-art img {
    height: 100%;
    min-height: 244px;
  }

  .modes-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .modes-grid--2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .topics-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .progress-layout,
  .settings-grid {
    grid-template-columns: 0.9fr 1.1fr;
    gap: 20px;
    align-items: start;
  }

  .tab-bar {
    max-width: none;
  }
}

/* Banner */
.state-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  width: 100%;
  text-align: left;
}

.state-banner strong {
  color: var(--brand);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card h2,
.card h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 800;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.access-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 600;
}

.access-banner.premium {
  background: linear-gradient(135deg, #1f9e61 0%, #16804d 100%);
  color: #fff;
}

.access-banner.free {
  background: var(--brand-soft);
  color: var(--navy);
}

.access-banner.locked {
  background: #fff4e5;
  color: #8a5a00;
}

.stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-pill {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.stat-pill .val {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brand);
}

.stat-pill .lbl {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

/* Action list */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  font-weight: 700;
  transition: background 0.12s;
}

.action-btn:active {
  background: var(--brand-soft);
}

.action-btn .icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-btn .meta {
  flex: 1;
}

.action-btn .sub {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.action-btn.locked .icon-wrap {
  background: #f0f0f0;
}

.action-btn .lock {
  color: var(--muted);
  font-size: 0.85rem;
}

.link-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.link-row button {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand);
  padding: 10px;
  background: transparent;
}

/* Study */
.topic-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-align: left;
  width: 100%;
}

.topic-card .count {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.section-label {
  margin: 18px 0 8px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.bookmark-empty {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.bookmark-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bookmark-item {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  text-align: left;
  width: 100%;
}

/* Progress */
.progress-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.progress-pct {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--brand);
}

.progress-sub {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.score-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.score-item .badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
}

.score-item .pass {
  color: var(--success);
  font-weight: 800;
}

.score-item .fail {
  color: var(--danger);
  font-weight: 800;
}

/* Settings */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  text-align: left;
  width: 100%;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row .chev {
  color: var(--muted);
}

.settings-row.danger {
  color: var(--danger);
}

/* Quiz */
.quiz-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  max-width: var(--max-width);
  margin: 0 auto;
}

@media (min-width: 900px) {
  .quiz-screen,
  .results-screen {
    max-width: 720px;
    padding: 28px 24px 40px;
  }

  .quiz-question {
    font-size: 1.45rem;
  }
}

.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quiz-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width 0.2s;
}

.quiz-meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 8px;
}

.quiz-question {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 20px;
  line-height: 1.35;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  font-weight: 600;
  transition: border-color 0.12s, background 0.12s;
}

.choice-btn.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.choice-btn.selected .choice-letter {
  background: var(--brand);
  color: #fff;
}

.quiz-footer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 0;
  flex: 0 0 auto;
}

.quiz-footer button {
  flex: 1;
}

.bookmark-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--muted);
  padding: 6px 10px;
}

.bookmark-toggle.active {
  color: var(--lane-yellow);
}

/* Results */
.results-screen {
  min-height: 100dvh;
  padding: 24px 16px calc(24px + var(--safe-bottom));
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.results-hero {
  font-size: 3rem;
  font-weight: 800;
  margin: 12px 0;
}

.results-hero.pass {
  color: var(--success);
}

.results-hero.fail {
  color: var(--danger);
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

/* Flash / Browse study */
.study-mode {
  min-height: 100dvh;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  max-width: var(--max-width);
  margin: 0 auto;
}

.flash-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 16px;
}

.flash-card.revealed {
  background: var(--brand-soft);
}

.browse-item {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.browse-item .answer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--success);
  font-weight: 700;
}

/* Overlays */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 41, 71, 0.45);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.overlay-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  bottom: 0;
  width: 100%;
  max-width: var(--max-width);
  max-height: 85dvh;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  z-index: 210;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bottom);
  overflow-x: hidden;
  box-sizing: border-box;
}

.sheet.open {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 8px;
}

.sheet-header {
  padding: 8px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
}

.sheet-body {
  padding: 0 20px 20px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.sheet-body .state-grid {
  max-height: min(50vh, 420px);
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .sheet {
    top: 50%;
    bottom: auto;
    width: min(640px, calc(100vw - 48px));
    max-width: 640px;
    max-height: min(80dvh, 720px);
    border-radius: 20px;
    transform: translate(-50%, -46%) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    padding-bottom: 0;
    box-shadow: 0 24px 64px rgba(21, 35, 59, 0.22);
  }

  .sheet.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }

  .sheet-handle {
    display: none;
  }

  .sheet-body .state-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    max-height: min(52vh, 440px);
  }
}

.sheet-close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
}

/* Paywall modal */
.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: calc(100% - 32px);
  max-width: 400px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  z-index: 220;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.top-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--navy);
}

.account-chip.ghost {
  background: transparent;
  color: var(--brand);
  border-color: transparent;
}

.account-chip img,
.account-initial {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.account-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 800;
}

.account-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-hint {
  margin: 0;
  padding: 4px 4px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
}

.settings-row.static {
  cursor: default;
}

.settings-row .sub-active {
  color: var(--success, #1a7f4b);
  font-weight: 700;
}

.settings-row .sub-free {
  color: var(--muted);
  font-weight: 700;
}

.auth-modal {
  max-width: 420px;
}

.auth-modal.forced {
  box-shadow: 0 24px 70px rgba(21, 35, 59, 0.35);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  font: inherit;
  font-weight: 600;
  color: var(--navy);
  box-sizing: border-box;
}

.auth-input:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}

.auth-switch {
  margin-top: 12px;
  width: 100%;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.92rem;
}

.auth-forgot {
  align-self: flex-end;
  margin: -2px 0 2px;
  padding: 0;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.88rem;
  background: none;
  border: none;
  cursor: pointer;
}

.auth-agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 2px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.4;
  cursor: pointer;
}

.auth-agree input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--brand);
}

.auth-agree a {
  font-weight: 800;
  text-decoration: underline;
}

.auth-info {
  margin: 12px 0 0;
  color: var(--success);
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.auth-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.paywall-hero {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.paywall-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
}

.paywall-msg {
  margin: 0 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.plan-btn {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  text-align: left;
  position: relative;
}

.plan-btn.best {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.plan-btn .plan-tag {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.plan-btn .plan-name {
  font-weight: 800;
  display: block;
}

.plan-btn .plan-price {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.plan-btn .plan-note {
  display: block;
  margin-top: 4px;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.82rem;
}

.req-block {
  margin-bottom: 16px;
}

.req-block h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.req-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.disclaimer-text {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.empty-state img {
  width: 120px;
  opacity: 0.7;
  margin-bottom: 12px;
}

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

@media (min-width: 481px) {
  body {
    background: #e8ecf4;
  }

  #app {
    box-shadow: 0 0 0 1px var(--border);
    background: var(--page-bg);
  }
}
