:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --ink: #102820;
  --muted: #60716b;
  --panel: #fffaf0;
  --panel-strong: #ffffff;
  --line: rgba(16, 40, 32, 0.14);
  --brand: #0f766e;
  --brand-dark: #115e59;
  --gold: #ca8a04;
  --danger: #b42318;
  --blue: #2563eb;
  --plum: #7c3aed;
  --shadow: 0 18px 50px rgba(16, 40, 32, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Navigation redesign: desktop side rail, mobile bottom tabs, safe-area breathing room */
.topbar {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.topbar-more {
  display: none;
}

.testing-server-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 30px);
  background: rgba(16, 40, 32, 0.42);
  backdrop-filter: blur(8px);
}

.testing-server-sheet {
  width: min(560px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(16, 40, 32, 0.28);
}

.testing-server-sheet h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.nav-group {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.nav-group-label {
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-tabbar,
.more-backdrop,
.more-sheet {
  display: none;
}

.compact-btn {
  min-height: 40px;
  padding: 8px 12px;
}

@media (max-width: 920px) {
  body {
    padding-bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    position: sticky;
    top: 0;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: 10px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding-top: 18px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .sidebar {
    display: none;
  }

  .mobile-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px max(10px, env(safe-area-inset-left, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-right, 0px));
    border-top: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 -16px 38px rgba(22, 35, 31, 0.16);
    backdrop-filter: blur(18px);
  }

  .tab-button {
    display: grid;
    min-width: 0;
    min-height: 56px;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.1;
  }

  .tab-button.active {
    background: #e8f2ed;
  }

  .tab-icon {
    display: grid;
    width: 26px;
    height: 24px;
    place-items: center;
    border-radius: 999px;
    background: rgba(22, 35, 31, 0.08);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 950;
  }

  .tab-button.active .tab-icon {
    background: var(--brand-dark);
    color: #fff8da;
  }

  .more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background: rgba(16, 40, 32, 0.24);
  }

  .more-sheet {
    position: fixed;
    right: 10px;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    z-index: 80;
    display: grid;
    gap: 14px;
    max-height: calc(78vh - env(safe-area-inset-top, 0px));
    padding: 16px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fffdf8;
    box-shadow: 0 22px 70px rgba(16, 40, 32, 0.28);
  }

  .more-sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .more-sheet-head h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.08;
  }

  .more-grid {
    display: grid;
    gap: 8px;
  }

  .more-button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fffaf0;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
  }

  .more-button.active,
  .more-button:hover {
    border-color: rgba(8, 122, 109, 0.34);
    background: #eaf5f1;
  }

  .more-button b,
  .more-button small {
    display: block;
  }

  .more-button small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
  }

  .more-button strong {
    color: var(--brand-dark);
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .topbar {
    position: sticky;
  }

  .status-strip {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: start;
  }
}

/* Final mobile learning overrides: keep this as the last cascade layer. */
.study-lesson {
  display: grid;
  gap: 14px;
  scroll-margin-top: calc(86px + env(safe-area-inset-top, 0px));
}

.study-lesson.collapsed {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.lesson-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 78px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.lesson-summary:hover,
.lesson-summary:focus-visible {
  background: rgba(15, 118, 110, 0.07);
  outline: none;
}

.lesson-summary-copy {
  min-width: 0;
}

.lesson-summary small,
.lesson-summary strong,
.lesson-summary em {
  display: block;
}

.lesson-summary small {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lesson-summary strong {
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.25;
}

.lesson-summary em {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-summary > b {
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(16, 40, 32, 0.08);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
}

.study-lesson.expanded {
  border-color: rgba(15, 118, 110, 0.24);
  box-shadow: 0 14px 34px rgba(16, 40, 32, 0.1);
}

.study-lesson.expanded .lesson-heading h3 {
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.12;
}

.study-lesson.expanded .lesson-heading p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}

.study-lesson.expanded .lesson-body {
  gap: 12px;
  color: #263c36;
  font-size: 15px;
  line-height: 1.6;
}

@media (max-width: 920px) {
  .learning-hero,
  .progress-hero {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .learning-hero p,
  .progress-hero p {
    font-size: 15px;
    line-height: 1.45;
  }

  .learning-score {
    width: auto;
    min-width: 0;
    min-height: 0;
    aspect-ratio: auto;
    grid-template-columns: auto minmax(0, 1fr);
    justify-content: start;
    padding: 11px 13px;
    border-radius: 10px;
    text-align: left;
  }

  .learning-score span {
    max-width: none;
  }

  .module-tabs {
    display: flex;
    gap: 8px;
    margin-inline: -14px;
    padding: 0 14px 2px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .module-tabs::-webkit-scrollbar {
    display: none;
  }

  .module-tab {
    flex: 0 0 min(170px, 48vw);
    min-height: 58px;
    scroll-snap-align: start;
  }

  .lesson-study-layout {
    gap: 10px;
  }

  .lesson-card {
    display: grid;
    gap: 10px;
  }

  .lesson-card h2 {
    margin: 0;
  }

  .lesson-card p {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
  }

  .coverage-row {
    margin-top: 0;
  }

  .lesson-list {
    gap: 8px;
  }

  .study-lesson.expanded {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    gap: 8px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    font-size: 11px;
    line-height: 1.25;
  }

  .status-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-inline: -14px;
    padding: 0 14px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .status-strip::-webkit-scrollbar {
    display: none;
  }

  .status-strip .pill {
    flex: 0 0 auto;
    min-height: 30px;
  }

  .layout {
    padding: 12px 14px calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .card {
    padding: 14px;
  }

  .grid {
    gap: 12px;
  }

  .learning-hero,
  .progress-hero {
    gap: 10px;
  }

  .learning-hero h2,
  .progress-hero h2 {
    font-size: clamp(25px, 7vw, 32px);
    line-height: 1.06;
  }

  .learning-hero p,
  .progress-hero p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .learning-score {
    min-height: 46px;
  }

  .learning-score b {
    font-size: 25px;
  }

  .coverage-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .coverage-row div {
    padding: 9px 7px;
  }

  .coverage-row b {
    font-size: 18px;
  }

  .lesson-summary {
    min-height: 76px;
    padding: 12px;
  }

  .lesson-number {
    width: 32px;
    height: 32px;
  }

  .lesson-summary strong {
    font-size: 14px;
  }

  .lesson-summary em {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .lesson-summary > b {
    display: none;
  }

  .study-lesson.expanded .lesson-heading {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .study-lesson.expanded .lesson-heading .lesson-number {
    width: 34px;
    height: 34px;
  }

  .study-lesson.expanded .lesson-body {
    font-size: 14px;
    line-height: 1.55;
  }

  .example-box,
  .trap-box,
  .aaoifi-note,
  .aaoifi-inline {
    padding: 11px;
  }

  .study-lesson .button-row,
  .chapter-complete-card .button-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-tabbar {
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  }

  .calendar-grid,
  .analytics-grid,
  .weak-area-grid {
    grid-template-columns: 1fr;
  }

  .glossary-article {
    padding: 12px;
  }
}

/* v2.7.5 glossary return and richer explanation polish */
.glossary-return-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0 12px;
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.06);
}

.glossary-return-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.glossary-explanation {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
}

.glossary-explanation b {
  color: var(--brand-dark);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.glossary-explanation p {
  margin: 0;
  color: var(--ink);
  line-height: 1.58;
}

.learning-lift-grid,
.analytics-grid,
.weak-area-grid,
.calendar-grid,
.checklist-grid,
.ticket-list {
  display: grid;
  gap: 10px;
}

.coach-card h3,
.study-calendar-card h3,
.exam-checklist-card h3 {
  margin-top: 0;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.calendar-grid {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.calendar-day,
.analytics-card,
.ticket-card,
.checklist-item,
.lesson-note-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.72);
}

.calendar-day,
.analytics-card,
.ticket-card {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.calendar-day {
  align-content: start;
  min-width: 0;
}

.calendar-index {
  width: max-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.calendar-day b {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.calendar-day strong {
  color: var(--brand-dark);
  font-size: 14px;
  line-height: 1.25;
}

.calendar-focus {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.38;
}

.analytics-card span,
.ticket-card span,
.calendar-day small,
.analytics-card small,
.ticket-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.analytics-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.weak-area-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.weak-area-pill,
.pill-button,
.link-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.weak-area-pill {
  display: grid;
  gap: 5px;
  padding: 12px;
  text-align: left;
}

.weak-area-pill span {
  color: var(--muted);
  font-size: 12px;
}

.checklist-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
}

.checklist-item input {
  margin-top: 3px;
}

.checklist-item span {
  display: grid;
  gap: 4px;
}

.checklist-item small {
  color: var(--muted);
  line-height: 1.45;
}

.lesson-note-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.lesson-note-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lesson-note-panel textarea {
  width: 100%;
  resize: vertical;
}

.glossary-article {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: var(--radius);
  background: rgba(15, 118, 110, 0.045);
}

.glossary-article b {
  color: var(--brand-dark);
  font-size: 12px;
  text-transform: uppercase;
}

.glossary-article p {
  margin: 0;
  line-height: 1.64;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.link-button {
  padding: 8px 10px;
  text-align: left;
  border-radius: var(--radius);
}

.saved-term-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-button {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.ticket-card p {
  margin: 0;
}

.glossary-imam-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(16, 52, 43, 0.11);
  border-radius: 8px;
  background: #fffdf8;
}

.glossary-imam-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.glossary-imam-panel b {
  color: var(--brand-dark);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.glossary-imam-grid {
  display: grid;
  gap: 8px;
}

.glossary-imam {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(16, 52, 43, 0.11);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.6);
}

.glossary-imam h5 {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

.glossary-imam p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.theme-dark .glossary-return-row,
.theme-dark .glossary-explanation,
.theme-dark .glossary-imam-panel,
.theme-dark .glossary-imam {
  border-color: var(--line);
  background: rgba(54, 182, 164, 0.08);
}

@media (max-width: 640px) {
  .glossary-return-row {
    align-items: stretch;
  }

  .glossary-return-row .btn {
    width: 100%;
  }
}

/* v2.7.6 learning chapter selector alignment */
.module-tabs-card {
  overflow: hidden;
  padding: 14px;
}

.module-tabs-card .module-tabs {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  scroll-snap-type: none;
}

.module-tabs-card .module-tab {
  width: 100%;
  min-width: 0;
}

.module-tabs-empty {
  display: grid;
  gap: 4px;
  padding: 2px;
}

.module-tabs-empty b {
  color: var(--brand-dark);
  font-size: 16px;
}

.module-tabs-empty span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

@media (max-width: 920px) {
  .module-tabs-card .module-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
  }

  .module-tabs-card .module-tab {
    flex: initial;
    min-height: 58px;
  }
}

/* v2.7.4 Resources library */
.resources-hero .learning-score b {
  font-size: clamp(32px, 5vw, 54px);
}

.resource-note {
  display: grid;
  gap: 6px;
  border-color: rgba(210, 148, 34, 0.24);
  background: rgba(255, 231, 163, 0.16);
}

.resource-note b {
  color: var(--ink);
}

.resource-note p {
  margin: 0;
  color: var(--muted);
  font-weight: 760;
  line-height: 1.5;
}

.resource-section {
  display: grid;
  gap: 12px;
}

.section-heading h3 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.resource-card {
  display: grid;
  gap: 11px;
  align-content: start;
}

.resource-card h4 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
}

.resource-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.resource-card .btn {
  width: 100%;
  margin-top: 4px;
}

.theme-dark .resource-note {
  background: rgba(210, 148, 34, 0.1);
}

/* v2.7 final onboarding and profile polish */
.onboarding-flow {
  min-height: calc(100vh - 150px);
}

.stepped-onboarding {
  display: grid;
  gap: 18px;
  min-height: min(620px, calc(100vh - 160px));
  align-content: start;
}

.onboarding-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.onboarding-progress span {
  display: grid;
  gap: 5px;
  min-height: 58px;
  padding: 9px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.onboarding-progress b {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  justify-self: center;
  border-radius: 999px;
  background: rgba(16, 40, 32, 0.08);
  color: var(--ink);
  font-size: 12px;
}

.onboarding-progress span.active {
  border-color: rgba(210, 148, 34, 0.68);
  background: rgba(255, 231, 163, 0.28);
  color: var(--ink);
}

.onboarding-progress span.active b,
.onboarding-progress span.done b {
  background: var(--ink);
  color: #ffe7a3;
}

.onboarding-step {
  display: grid;
  gap: 14px;
}

.onboarding-step h3 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
}

.onboarding-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.creator-note,
.profile-account-note {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.07);
}

.creator-note b,
.profile-account-note b {
  color: var(--ink);
}

.creator-note p,
.profile-account-note span {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.35;
}

.field input[type="password"],
.field input[type="email"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: var(--ink);
}

.theme-dark .onboarding-progress span {
  background: rgba(255, 255, 255, 0.05);
}

.theme-dark .creator-note,
.theme-dark .profile-account-note {
  background: rgba(255, 255, 255, 0.05);
}

.theme-dark .field input[type="password"],
.theme-dark .field input[type="email"] {
  background: #17221d;
  color: #f8f1df;
}

@media (max-width: 920px) {
  .onboarding-flow {
    min-height: auto;
  }

  .stepped-onboarding {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .welcome-journey.onboarding-flow {
    gap: 12px;
  }

  .welcome-panel {
    min-height: auto;
    padding: 22px;
  }

  .welcome-panel h2 {
    max-width: 13ch;
    font-size: clamp(36px, 12vw, 52px);
  }

  .welcome-flow,
  .welcome-proof,
  .onboarding-progress {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .onboarding-step h3 {
    font-size: 28px;
  }
}

/* v2 final overrides: keep these at the physical end of the cascade. */
.app-shell.theme-dark {
  color-scheme: dark;
  --bg: #101511;
  --ink: #edf6ef;
  --muted: #a9b8af;
  --panel: #18211c;
  --panel-strong: #202b25;
  --line: rgba(237, 246, 239, 0.14);
  --brand: #36b6a4;
  --brand-dark: #72d6c7;
  --gold: #d8a53d;
  --danger: #ef6b5b;
  --blue: #78a6ff;
  --plum: #c8a7ff;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(54, 182, 164, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(216, 165, 61, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
}

.topbar {
  z-index: 120;
  min-height: 64px;
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
  background: rgba(255, 253, 248, 0.98);
}

.theme-dark .topbar {
  background: rgba(16, 21, 17, 0.98);
}

.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar.quiet .question-bank-pill {
  display: none;
}

.profile-button {
  display: inline-flex;
  min-height: 46px;
  max-width: 190px;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.profile-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ink);
  color: #ffe7a3;
  font-size: 12px;
  font-weight: 950;
}

.profile-avatar.large {
  width: 76px;
  height: 76px;
  font-size: 24px;
}

.profile-copy {
  display: grid;
  min-width: 0;
}

.profile-copy b,
.profile-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy b {
  font-size: 13px;
  line-height: 1.05;
}

.profile-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.welcome-journey {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.75fr);
  gap: clamp(14px, 3vw, 26px);
  align-items: start;
}

.welcome-panel {
  display: grid;
  align-content: end;
  min-height: min(620px, calc(100vh - 160px));
  padding: clamp(22px, 5vw, 46px);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(16, 40, 32, 0.96), rgba(15, 118, 110, 0.9)),
    var(--ink);
  color: #fffaf0;
  box-shadow: var(--shadow);
}

.welcome-panel h2 {
  max-width: 12ch;
  margin: 8px 0 12px;
  font-size: clamp(38px, 7vw, 74px);
  line-height: 0.96;
  letter-spacing: 0;
}

.welcome-panel p {
  max-width: 58ch;
  color: rgba(255, 250, 240, 0.86);
  line-height: 1.55;
}

.welcome-flow,
.welcome-proof,
.best-practice-list,
.reference-list {
  display: grid;
  gap: 8px;
}

.welcome-flow {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 22px 0;
}

.welcome-flow span,
.best-practice-list div,
.reference-list a {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.welcome-flow span {
  min-height: 44px;
  padding: 10px;
  background: rgba(255, 250, 240, 0.12);
  color: #fffaf0;
  font-weight: 900;
  text-align: center;
}

.welcome-proof {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 8px;
}

.welcome-proof div {
  min-height: 80px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.12);
}

.welcome-proof b,
.welcome-proof span {
  display: block;
}

.welcome-proof b {
  font-size: clamp(22px, 4vw, 34px);
}

.welcome-proof span {
  color: rgba(255, 250, 240, 0.74);
  font-size: 12px;
  font-weight: 850;
}

.compact-form-grid {
  gap: 10px;
}

.field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: var(--ink);
}

.best-practice-list {
  margin: 12px 0 16px;
}

.best-practice-list div {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px;
  background: rgba(15, 118, 110, 0.06);
}

.best-practice-list b {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #ffe7a3;
}

.best-practice-list span {
  color: var(--muted);
  font-weight: 760;
  line-height: 1.35;
}

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-hero h2 {
  margin: 6px 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
}

.why-box,
.glossary-why {
  padding: 13px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
}

.why-box b,
.glossary-why b {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.glossary-link {
  display: inline;
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: rgba(216, 165, 61, 0.18);
  color: inherit;
  cursor: pointer;
  font-weight: 850;
  text-decoration: underline;
  text-decoration-color: rgba(216, 165, 61, 0.8);
  text-underline-offset: 3px;
}

.reference-list {
  margin: 12px 0;
}

.reference-list > b {
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.reference-list a {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  background: rgba(15, 118, 110, 0.06);
  color: var(--ink);
  text-decoration: none;
}

.reference-list a span {
  font-weight: 900;
}

.reference-list a small {
  color: var(--muted);
  font-weight: 750;
}

.answer-recap {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  font-weight: 850;
}

.theme-dark .card,
.theme-dark .sidebar,
.theme-dark .more-sheet,
.theme-dark .lesson-summary,
.theme-dark .more-button,
.theme-dark .mobile-tabbar,
.theme-dark .pill,
.theme-dark .btn.secondary {
  background: var(--panel);
  color: var(--ink);
}

.theme-dark .btn.ghost,
.theme-dark .profile-button,
.theme-dark .field input,
.theme-dark .field textarea,
.theme-dark .field select {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.theme-dark .nav-button:hover,
.theme-dark .nav-button.active,
.theme-dark .tab-button.active,
.theme-dark .more-button.active,
.theme-dark .more-button:hover {
  background: rgba(54, 182, 164, 0.14);
}

.theme-dark .brand-mark,
.theme-dark .profile-avatar,
.theme-dark .best-practice-list b {
  background: #edf6ef;
  color: #111814;
}

@media (max-width: 920px) {
  .welcome-journey {
    grid-template-columns: 1fr;
  }

  .welcome-panel {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 70px;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 14px 10px;
  }

  .profile-button {
    width: 44px;
    min-height: 44px;
    max-width: 44px;
    justify-content: center;
    padding: 4px;
  }

  .profile-copy,
  .question-bank-pill {
    display: none;
  }

  .welcome-panel h2 {
    max-width: 10ch;
  }

  .welcome-flow,
  .welcome-proof {
    grid-template-columns: 1fr 1fr;
  }

  .welcome-proof div:last-child {
    grid-column: 1 / -1;
  }

  .profile-avatar.large {
    width: 58px;
    height: 58px;
    font-size: 18px;
  }
}

/* v2 shell, onboarding, glossary, profile and Android safe-area polish */
.app-shell.theme-dark {
  color-scheme: dark;
  --bg: #101511;
  --ink: #edf6ef;
  --muted: #a9b8af;
  --panel: #18211c;
  --panel-strong: #202b25;
  --line: rgba(237, 246, 239, 0.14);
  --brand: #36b6a4;
  --brand-dark: #72d6c7;
  --gold: #d8a53d;
  --danger: #ef6b5b;
  --blue: #78a6ff;
  --plum: #c8a7ff;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(54, 182, 164, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(216, 165, 61, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
}

.app-shell.theme-light {
  min-height: 100vh;
}

.topbar {
  z-index: 120;
  min-height: 64px;
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
  background: rgba(255, 253, 248, 0.98);
}

.theme-dark .topbar {
  background: rgba(16, 21, 17, 0.98);
}

.topbar.quiet .question-bank-pill {
  display: none;
}

.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.profile-button {
  display: inline-flex;
  min-height: 46px;
  max-width: 190px;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.profile-button.active,
.profile-button:hover {
  border-color: rgba(15, 118, 110, 0.34);
  box-shadow: 0 10px 24px rgba(16, 40, 32, 0.12);
}

.profile-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ink);
  color: #ffe7a3;
  font-size: 12px;
  font-weight: 950;
}

.profile-avatar.large {
  width: 76px;
  height: 76px;
  font-size: 24px;
}

.profile-copy {
  display: grid;
  min-width: 0;
}

.profile-copy b,
.profile-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy b {
  font-size: 13px;
  line-height: 1.05;
}

.profile-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.welcome-journey {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.75fr);
  gap: clamp(14px, 3vw, 26px);
  align-items: stretch;
}

.welcome-panel {
  display: grid;
  align-content: end;
  min-height: min(620px, calc(100vh - 160px));
  padding: clamp(22px, 5vw, 46px);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(16, 40, 32, 0.96), rgba(15, 118, 110, 0.9)),
    var(--ink);
  color: #fffaf0;
  box-shadow: var(--shadow);
}

.welcome-panel h2 {
  max-width: 12ch;
  margin: 8px 0 12px;
  font-size: clamp(38px, 7vw, 74px);
  line-height: 0.96;
  letter-spacing: 0;
}

.welcome-panel p {
  max-width: 58ch;
  color: rgba(255, 250, 240, 0.86);
  line-height: 1.55;
}

.welcome-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 22px 0;
}

.welcome-flow span,
.best-practice-list div,
.reference-list a {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.welcome-flow span {
  min-height: 44px;
  padding: 10px;
  background: rgba(255, 250, 240, 0.12);
  color: #fffaf0;
  font-weight: 900;
  text-align: center;
}

.welcome-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.welcome-proof div {
  min-height: 80px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.12);
}

.welcome-proof b,
.welcome-proof span {
  display: block;
}

.welcome-proof b {
  font-size: clamp(22px, 4vw, 34px);
}

.welcome-proof span {
  color: rgba(255, 250, 240, 0.74);
  font-size: 12px;
  font-weight: 850;
}

.onboarding-card,
.profile-page .settings-grid {
  align-self: start;
}

.compact-form-grid {
  gap: 10px;
}

.field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: var(--ink);
}

.best-practice-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
}

.best-practice-list div {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px;
  background: rgba(15, 118, 110, 0.06);
}

.best-practice-list b {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #ffe7a3;
}

.best-practice-list span {
  color: var(--muted);
  font-weight: 760;
  line-height: 1.35;
}

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-hero h2 {
  margin: 6px 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
}

.why-box,
.glossary-why {
  padding: 13px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
}

.why-box b,
.glossary-why b {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.glossary-link {
  display: inline;
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: rgba(216, 165, 61, 0.18);
  color: inherit;
  cursor: pointer;
  font-weight: 850;
  text-decoration: underline;
  text-decoration-color: rgba(216, 165, 61, 0.8);
  text-underline-offset: 3px;
}

.glossary-link:hover {
  background: rgba(216, 165, 61, 0.28);
}

.reference-list {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}

.reference-list > b {
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.reference-list a {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  background: rgba(15, 118, 110, 0.06);
  color: var(--ink);
  text-decoration: none;
}

.reference-list a span {
  font-weight: 900;
}

.reference-list a small {
  color: var(--muted);
  font-weight: 750;
}

.answer-recap {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  font-weight: 850;
}

.theme-dark .card,
.theme-dark .sidebar,
.theme-dark .more-sheet,
.theme-dark .lesson-summary,
.theme-dark .more-button,
.theme-dark .mobile-tabbar,
.theme-dark .pill,
.theme-dark .btn.secondary {
  background: var(--panel);
  color: var(--ink);
}

.theme-dark .btn.ghost,
.theme-dark .profile-button,
.theme-dark .field input,
.theme-dark .field textarea,
.theme-dark .field select {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.theme-dark .nav-button:hover,
.theme-dark .nav-button.active,
.theme-dark .tab-button.active,
.theme-dark .more-button.active,
.theme-dark .more-button:hover {
  background: rgba(54, 182, 164, 0.14);
}

.theme-dark .brand-mark,
.theme-dark .profile-avatar,
.theme-dark .best-practice-list b {
  background: #edf6ef;
  color: #111814;
}

@media (max-width: 920px) {
  .welcome-journey {
    grid-template-columns: 1fr;
  }

  .welcome-panel {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 70px;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 14px 10px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .profile-button {
    width: 44px;
    min-height: 44px;
    max-width: 44px;
    justify-content: center;
    padding: 4px;
  }

  .profile-copy,
  .question-bank-pill {
    display: none;
  }

  .welcome-panel h2 {
    max-width: 10ch;
  }

  .welcome-flow,
  .welcome-proof {
    grid-template-columns: 1fr 1fr;
  }

  .welcome-proof div:last-child {
    grid-column: 1 / -1;
  }

  .profile-hero {
    align-items: flex-start;
  }

  .profile-avatar.large {
    width: 58px;
    height: 58px;
    font-size: 18px;
  }
}

.profile-badges {
  display: grid;
  gap: 14px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98), rgba(238, 246, 244, 0.96));
}

.profile-badges-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.profile-badges-head h3 {
  margin: 4px 0 6px;
  font-size: clamp(24px, 3vw, 34px);
}

.profile-badges-head p {
  margin: 0;
  color: var(--muted);
}

.badge-count {
  display: grid;
  min-width: 94px;
  min-height: 82px;
  place-items: center;
  align-content: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff8da;
  text-align: center;
}

.badge-count b,
.badge-count span {
  display: block;
}

.badge-count b {
  font-size: 30px;
  line-height: 1;
}

.badge-count span {
  font-size: 12px;
  font-weight: 850;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.achievement-badge,
.empty-badge,
.chapter-badge-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.achievement-badge.chapter,
.chapter-badge-panel {
  border-color: rgba(202, 138, 4, 0.42);
  background: linear-gradient(135deg, #fffdf8, #fff0cc);
}

.achievement-badge.practice {
  border-color: rgba(15, 118, 110, 0.3);
  background: #f0faf6;
}

.achievement-badge.mock,
.achievement-badge.mastery {
  border-color: rgba(124, 58, 237, 0.24);
  background: #f5f1ff;
}

.badge-medal {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: #fff8da;
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0;
}

.badge-copy,
.chapter-badge-panel span:last-child {
  min-width: 0;
}

.badge-copy strong,
.badge-copy small,
.chapter-badge-panel small,
.chapter-badge-panel strong,
.chapter-badge-panel em {
  display: block;
}

.badge-copy strong,
.chapter-badge-panel strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.badge-copy small,
.chapter-badge-panel em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
  line-height: 1.35;
}

.chapter-badge-panel small {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.badge-share-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-share-row .btn {
  min-height: 38px;
}

@media (max-width: 640px) {
  .profile-badges-head,
  .achievement-badge,
  .empty-badge,
  .chapter-badge-panel {
    grid-template-columns: 1fr;
  }

  .badge-count {
    min-width: 0;
    min-height: 58px;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 8px;
  }

  .badge-count b {
    font-size: 24px;
  }

  .badge-share-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

.scenario-case {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(240, 250, 246, 0.98), rgba(255, 253, 248, 0.98));
}

.scenario-case h3 {
  margin: 4px 0 8px;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.15;
}

.scenario-case p {
  margin: 0;
  color: #485f58;
  line-height: 1.55;
}

.scenario-question-set {
  padding: 12px;
  border-radius: 8px;
  background: #fffdf8;
}

.scenario-question-set strong {
  display: block;
  margin-bottom: 8px;
}

.scenario-question-set ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
}

.scenario-question-set li {
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--muted);
}

.scenario-question-set li.active {
  background: #e6f3ef;
  color: var(--ink);
}

.scenario-question-set span,
.scenario-question-set em {
  display: block;
}

.scenario-question-set span {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.scenario-question-set em {
  margin-top: 2px;
  font-style: normal;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .scenario-case {
    padding: 12px;
  }

  .scenario-question-set {
    max-height: 240px;
    overflow: auto;
  }
}

/* Mobile learning focus pass: one open lesson, compact chapter scan, safe breathing room. */
.study-lesson {
  display: grid;
  gap: 14px;
}

.study-lesson.collapsed {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.lesson-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 78px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.lesson-summary:hover,
.lesson-summary:focus-visible {
  background: rgba(15, 118, 110, 0.07);
  outline: none;
}

.lesson-summary-copy {
  min-width: 0;
}

.lesson-summary small,
.lesson-summary strong,
.lesson-summary em {
  display: block;
}

.lesson-summary small {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lesson-summary strong {
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.25;
}

.lesson-summary em {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-summary > b {
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(16, 40, 32, 0.08);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
}

.study-lesson.expanded {
  border-color: rgba(15, 118, 110, 0.24);
  box-shadow: 0 14px 34px rgba(16, 40, 32, 0.1);
}

.study-lesson.expanded .lesson-heading h3 {
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.12;
}

.study-lesson.expanded .lesson-heading p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}

.study-lesson.expanded .lesson-body {
  gap: 12px;
  color: #263c36;
  font-size: 15px;
  line-height: 1.6;
}

@media (max-width: 920px) {
  .learning-hero,
  .progress-hero {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .learning-hero p,
  .progress-hero p {
    font-size: 15px;
    line-height: 1.45;
  }

  .learning-score {
    width: auto;
    min-width: 0;
    min-height: 0;
    aspect-ratio: auto;
    grid-template-columns: auto minmax(0, 1fr);
    justify-content: start;
    padding: 11px 13px;
    border-radius: 10px;
    text-align: left;
  }

  .learning-score span {
    max-width: none;
  }

  .module-tabs {
    display: flex;
    gap: 8px;
    margin-inline: -14px;
    padding: 0 14px 2px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .module-tabs::-webkit-scrollbar {
    display: none;
  }

  .module-tab {
    flex: 0 0 min(170px, 48vw);
    min-height: 58px;
    scroll-snap-align: start;
  }

  .lesson-study-layout {
    gap: 10px;
  }

  .lesson-card {
    display: grid;
    gap: 10px;
  }

  .lesson-card h2 {
    margin: 0;
  }

  .lesson-card p {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
  }

  .coverage-row {
    margin-top: 0;
  }

  .lesson-list {
    gap: 8px;
  }

  .study-lesson.expanded {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .layout {
    padding: 12px 14px calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .grid {
    gap: 12px;
  }

  .learning-hero h2,
  .progress-hero h2 {
    font-size: clamp(25px, 8vw, 34px);
    line-height: 1.06;
  }

  .learning-hero p,
  .progress-hero p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .coverage-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .coverage-row div {
    padding: 9px 7px;
  }

  .coverage-row b {
    font-size: 18px;
  }

  .lesson-summary {
    min-height: 76px;
    padding: 12px;
  }

  .lesson-number {
    width: 32px;
    height: 32px;
  }

  .lesson-summary strong {
    font-size: 14px;
  }

  .lesson-summary em {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .lesson-summary > b {
    display: none;
  }

  .study-lesson.expanded .lesson-heading {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .study-lesson.expanded .lesson-heading .lesson-number {
    width: 34px;
    height: 34px;
  }

  .study-lesson.expanded .lesson-body {
    font-size: 14px;
    line-height: 1.55;
  }

  .example-box,
  .trap-box,
  .aaoifi-note,
  .aaoifi-inline {
    padding: 11px;
  }

  .study-lesson .button-row,
  .chapter-complete-card .button-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-tabbar {
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  }

  .calendar-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .calendar-day {
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 10px;
    align-items: start;
  }

  .calendar-index {
    grid-row: 1 / span 4;
    min-width: 54px;
    justify-self: start;
    text-align: center;
  }

  .calendar-day b,
  .calendar-day strong,
  .calendar-focus,
  .calendar-day small {
    grid-column: 2;
    min-width: 0;
  }
}

/* Live design-preview overrides: keep these last while iterating in browser. */
@media (max-width: 920px) {
  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .brand p {
    font-size: 11px;
  }

  .status-strip {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .status-strip::-webkit-scrollbar {
    display: none;
  }

  .pill {
    min-height: 28px;
    padding: 5px 9px;
    font-size: 11px;
  }

  .layout {
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .hero {
    margin-bottom: 12px;
  }

  .hero-copy {
    padding: 22px 18px;
  }

  .hero-copy h2 {
    max-width: 10ch;
    font-size: clamp(36px, 11vw, 50px);
    line-height: 0.98;
  }

  .hero-copy p {
    margin-bottom: 16px;
    font-size: 15px;
    line-height: 1.45;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hero-metrics {
    margin-top: 18px;
  }

  .mobile-tabbar {
    padding-top: 7px;
    border-radius: 18px 18px 0 0;
  }

  .tab-button {
    min-height: 52px;
  }

  .tab-icon {
    width: 28px;
    height: 24px;
  }

  .more-sheet {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 640px) {
  .hero-copy h2 {
    max-width: 10ch;
    font-size: clamp(36px, 11vw, 48px);
  }

  .card {
    padding: 14px;
  }

  .study-plan-card h3,
  .mission-panel h3,
  .map-banner h2,
  .lesson-card h2 {
    font-size: clamp(24px, 7vw, 32px);
  }
}

/* Fast preview polish for the web build */
@media (max-width: 920px) {
  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  }

  .brand {
    align-items: center;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .brand p {
    font-size: 11px;
  }

  .status-strip {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .status-strip::-webkit-scrollbar {
    display: none;
  }

  .pill {
    min-height: 28px;
    padding: 5px 9px;
    font-size: 11px;
  }

  .layout {
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .hero {
    margin-bottom: 12px;
  }

  .hero-copy {
    padding: 22px 18px;
  }

  .hero-copy h2 {
    max-width: 10ch;
    font-size: clamp(36px, 11vw, 50px);
    line-height: 0.98;
  }

  .hero-copy p {
    margin-bottom: 16px;
    font-size: 15px;
    line-height: 1.45;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hero-metrics {
    margin-top: 18px;
  }

  .mobile-tabbar {
    padding-top: 7px;
    border-radius: 18px 18px 0 0;
  }

  .tab-button {
    min-height: 52px;
  }

  .tab-icon {
    width: 28px;
    height: 24px;
  }

  .more-sheet {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 640px) {
  .hero-copy h2 {
    max-width: 10ch;
    font-size: clamp(36px, 11vw, 48px);
  }

  .card {
    padding: 14px;
  }

  .study-plan-card h3,
  .mission-panel h3,
  .map-banner h2,
  .lesson-card h2 {
    font-size: clamp(24px, 7vw, 32px);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 35%),
    linear-gradient(315deg, rgba(202, 138, 4, 0.1), transparent 40%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(245, 241, 232, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: #ffe7a3;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.76);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: clamp(14px, 2vw, 24px);
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 28px);
}

.sidebar {
  position: sticky;
  top: 74px;
  height: calc(100vh - 92px);
  padding: 10px;
  align-self: start;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
}

.nav-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  padding: 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: #e7f2ef;
}

.nav-button span:first-child {
  font-weight: 800;
}

.nav-button small {
  color: var(--muted);
  font-weight: 800;
}

.content {
  min-width: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: clamp(16px, 3vw, 30px);
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy {
  padding: clamp(18px, 4vw, 34px);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(16, 40, 32, 0.96), rgba(17, 94, 89, 0.94)),
    var(--ink);
  color: #fffaf0;
  box-shadow: var(--shadow);
}

.hero-copy h2 {
  margin: 0 0 10px;
  max-width: 12ch;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 56ch;
  margin: 0 0 20px;
  color: rgba(255, 250, 240, 0.82);
  line-height: 1.55;
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.secondary {
  background: #e7f2ef;
  color: var(--ink);
}

.btn.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.hero-copy .btn.ghost {
  border-color: rgba(255, 250, 240, 0.38);
  color: #fffaf0;
}

.btn.gold {
  background: var(--gold);
}

.btn.danger {
  background: var(--danger);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.market-board {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.18), transparent),
    #19362f;
  box-shadow: var(--shadow);
}

.ticker-tape {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 34px 34px;
}

.chart-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 23%;
  height: 46%;
  clip-path: polygon(0 70%, 12% 54%, 21% 62%, 32% 31%, 43% 42%, 53% 22%, 65% 34%, 76% 18%, 88% 26%, 100% 8%, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.96), rgba(15, 118, 110, 0.18));
}

.board-card {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.94);
}

.board-card h3 {
  margin: 0 0 6px;
}

.board-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 10px 30px rgba(16, 40, 32, 0.08);
}

.card h3,
.card h4 {
  margin: 0 0 8px;
}

.card p,
.card li {
  color: var(--muted);
  line-height: 1.5;
}

.card ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.quest-card {
  position: relative;
  display: grid;
  min-height: 188px;
  align-content: space-between;
  overflow: hidden;
}

.quest-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--accent, var(--brand));
}

.quest-card.locked {
  opacity: 0.68;
}

.quest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}

.quiz-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.quiz-header .quest-meta {
  margin-top: 0;
}

.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 40, 32, 0.12);
}

.progress-bar > span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--gold));
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.question {
  display: grid;
  gap: 12px;
}

.question h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
}

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.answer:hover {
  border-color: rgba(15, 118, 110, 0.45);
  background: #eef8f5;
}

.answer.correct {
  border-color: rgba(15, 118, 110, 0.7);
  background: #def7ec;
}

.answer.wrong {
  border-color: rgba(180, 35, 24, 0.55);
  background: #fff0ee;
}

.answer-letter {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: #e7f2ef;
  font-weight: 900;
}

.explain {
  padding: 14px;
  border-left: 4px solid var(--brand);
  border-radius: 7px;
  background: #eef8f5;
  color: var(--ink);
}

.explain strong {
  display: block;
  margin-bottom: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 12px;
  border-radius: 8px;
  background: #fffdf7;
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flashcard {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf7;
  cursor: pointer;
  text-align: center;
}

.flashcard h3 {
  margin: 0;
  font-size: clamp(22px, 4vw, 40px);
}

.flashcard p {
  max-width: 52ch;
  margin: 10px auto 0;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 850;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf7;
  color: var(--ink);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.celebration-pop {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 120;
  width: min(360px, calc(100vw - 32px));
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(255, 248, 218, 0.34);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(15, 79, 73, 0.98), rgba(8, 122, 109, 0.94) 58%, rgba(210, 148, 34, 0.88));
  color: #fffdf8;
  box-shadow: 0 20px 60px rgba(16, 40, 32, 0.28);
  animation: celebration-pop 420ms cubic-bezier(0.2, 0.9, 0.25, 1.2);
}

.celebration-pop span {
  display: inline-flex;
  margin-bottom: 8px;
  color: #ffe9ad;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.celebration-pop h3 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.05;
}

.celebration-pop p {
  margin: 0;
  color: rgba(255, 253, 248, 0.86);
  line-height: 1.45;
}

.celebration-shine {
  position: absolute;
  inset: -60% auto auto -20%;
  width: 42%;
  height: 220%;
  transform: rotate(24deg);
  background: rgba(255, 255, 255, 0.22);
  animation: celebration-shine 1200ms ease-out;
}

@keyframes celebration-pop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes celebration-shine {
  from {
    transform: translateX(-120%) rotate(24deg);
  }
  to {
    transform: translateX(360%) rotate(24deg);
  }
}

.fine-print {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: auto;
    overflow: visible;
  }

  .nav-button {
    justify-content: center;
    text-align: center;
  }

  .nav-button small {
    display: none;
  }

  .hero,
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .grid.three,
  .grid.two,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

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

  .hero-copy h2 {
    max-width: 10ch;
  }
}

/* Mastery UI refresh */
:root {
  --bg: #f4f2ea;
  --ink: #16231f;
  --muted: #66746e;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --brand: #087a6d;
  --brand-dark: #0f4f49;
  --gold: #d29422;
  --coral: #d9654f;
  --sky: #2563eb;
  --plum: #6d5bd0;
  --shadow: 0 18px 42px rgba(22, 35, 31, 0.1);
}

body {
  background:
    linear-gradient(180deg, #fbfaf6 0, #f4f2ea 36%, #eceee7 100%);
}

.topbar {
  background: rgba(251, 250, 246, 0.9);
}

.brand-mark {
  background:
    linear-gradient(135deg, var(--brand-dark), var(--brand) 52%, var(--gold));
  color: #fff8da;
}

.sidebar {
  background: rgba(255, 253, 248, 0.84);
}

.nav-button {
  min-height: 50px;
}

.nav-button:hover,
.nav-button.active {
  background: linear-gradient(135deg, rgba(8, 122, 109, 0.12), rgba(210, 148, 34, 0.1));
}

.mastery-hero {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  min-height: 430px;
}

.hero-copy {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: end;
  background:
    linear-gradient(135deg, rgba(17, 37, 32, 0.98), rgba(8, 122, 109, 0.92) 58%, rgba(210, 148, 34, 0.7)),
    var(--ink);
}

.hero-copy::after {
  content: "";
  position: absolute;
  right: -8%;
  bottom: -22%;
  width: 52%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  opacity: 0.5;
}

.hero-copy h2 {
  max-width: 12ch;
  font-size: clamp(42px, 6vw, 78px);
}

.eyebrow,
.section-kicker {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 12px;
  color: #ffe9ad;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.dark,
.section-kicker {
  color: var(--brand-dark);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.hero-metrics div {
  padding: 12px;
  border: 1px solid rgba(255, 250, 240, 0.22);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.1);
}

.hero-metrics b,
.map-score b {
  display: block;
  font-size: 24px;
}

.hero-metrics span,
.map-score span {
  display: block;
  color: rgba(255, 250, 240, 0.76);
  font-size: 12px;
  font-weight: 800;
}

.mission-panel {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 249, 236, 0.94));
  box-shadow: var(--shadow);
}

.mission-panel h3,
.map-banner h2,
.lesson-card h2 {
  margin: 0 0 8px;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.02;
}

.mission-panel p,
.map-banner p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.mission-ring {
  display: grid;
  width: 128px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fffdf8 0 56%, transparent 57%),
    conic-gradient(var(--brand) var(--progress), rgba(22, 35, 31, 0.12) 0);
  box-shadow: inset 0 0 0 1px var(--line);
}

.mission-ring span {
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.75fr) minmax(260px, 0.75fr);
  gap: 14px;
}

.readiness-card,
.drill-card,
.exam-card,
.level-count {
  background: rgba(255, 253, 248, 0.96);
}

.topic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f3eee1;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.topic-row:hover {
  background: #e9f3ef;
}

.topic-row span {
  min-width: 0;
  font-weight: 850;
}

.topic-row b {
  color: var(--brand-dark);
}

.study-plan-card {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 1.1fr);
  gap: 16px;
  align-items: start;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98), rgba(255, 245, 226, 0.92));
}

.study-plan-card h3 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

.plan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.plan-meta span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.study-plan-list {
  display: grid;
  gap: 8px;
}

.plan-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.plan-step:hover,
.study-step:hover {
  background: #eaf5f1;
}

.plan-step b {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 950;
}

.plan-step strong,
.plan-step small {
  display: block;
}

.plan-step strong {
  font-size: 14px;
}

.plan-step small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.pace-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.pace-grid b,
.pace-grid span {
  display: block;
}

.pace-grid b {
  font-size: 22px;
}

.pace-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.mastery-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.mastery-strip span {
  min-height: 38px;
  padding: 10px;
  border-radius: 8px;
  background: #f3eee1;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.map-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(239, 247, 244, 0.94));
}

.map-score {
  display: grid;
  min-width: 132px;
  min-height: 132px;
  align-content: center;
  place-items: center;
  gap: 2px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff8da;
  text-align: center;
}

.map-score span {
  color: rgba(255, 248, 218, 0.78);
}

.quest-card {
  gap: 16px;
  border-top: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 253, 248, 0.92));
}

.quest-card h3 {
  font-size: 23px;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.tier-grid.compact {
  margin: 10px 0;
}

.tier-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.tier-card.applied {
  background: #eef6f4;
}

.tier-card.core {
  background: #eef4ff;
}

.tier-card.mastery {
  background: #fff2df;
}

.tier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.tier-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mini-bar {
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 35, 31, 0.1);
}

.mini-bar span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.tier-card.mastery .mini-bar span {
  background: var(--gold);
}

.tier-card.core .mini-bar span {
  background: var(--sky);
}

.tier-card.applied .mini-bar span {
  background: var(--brand);
}

.level-actions {
  margin-top: 12px;
}

.level-button.compact {
  min-height: 48px;
  padding: 8px 10px;
  font-size: 12px;
}

.level-button small {
  opacity: 0.78;
  font-size: 11px;
  font-weight: 950;
}

.lesson-card h3 {
  margin-top: 18px;
}

.difficulty-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.difficulty-chip.foundation {
  background: var(--brand);
}

.difficulty-chip.applied {
  background: var(--brand-dark);
}

.difficulty-chip.core {
  background: var(--sky);
}

.difficulty-chip.mastery {
  background: var(--gold);
  color: var(--ink);
}

.question-context {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.answer {
  background: #ffffff;
}

.answer:hover {
  border-color: rgba(8, 122, 109, 0.5);
  background: #f1faf6;
}

.level-count.foundation {
  border-top: 4px solid var(--brand);
}

.level-count.applied {
  border-top: 4px solid var(--brand);
}

.level-count.core {
  border-top: 4px solid var(--sky);
}

.level-count.mastery {
  border-top: 4px solid var(--gold);
}

.learning-hero,
.progress-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(238, 246, 244, 0.94));
}

.learning-hero h2,
.progress-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.02;
}

.learning-score {
  display: grid;
  width: 132px;
  min-width: 132px;
  aspect-ratio: 1;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff8da;
  text-align: center;
}

.learning-score b {
  font-size: 28px;
  line-height: 1;
}

.learning-score span {
  max-width: 10ch;
  color: rgba(255, 248, 218, 0.8);
  font-size: 12px;
  font-weight: 850;
}

.danger-score {
  background: var(--danger);
}

.module-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.module-tab {
  display: grid;
  min-height: 62px;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.module-tab.active,
.module-tab:hover {
  border-color: rgba(8, 122, 109, 0.36);
  background: #eaf5f1;
}

.module-tab span {
  font-size: 13px;
  font-weight: 850;
}

.module-tab b {
  color: var(--brand-dark);
  font-size: 18px;
}

.lesson-study-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 14px;
  align-items: start;
}

.lesson-list,
.lesson-body,
.study-steps,
.mistake-list,
.coverage-table {
  display: grid;
  gap: 10px;
}

.coverage-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.coverage-row div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.coverage-row b {
  display: block;
  font-size: 20px;
}

.coverage-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.study-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.study-step b,
.lesson-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff8da;
  font-weight: 950;
}

.study-step span {
  min-width: 0;
  font-weight: 850;
}

.study-step strong,
.study-step small {
  display: block;
}

.study-step strong {
  font-size: 13px;
  line-height: 1.25;
}

.study-step small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.study-lesson.complete {
  border-color: rgba(8, 122, 109, 0.34);
  background: #f1faf6;
}

.chapter-complete-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(210, 148, 34, 0.5);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98), rgba(255, 239, 199, 0.94));
}

.chapter-complete-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--brand), var(--gold));
}

.chapter-complete-card h3 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 34px);
}

.lesson-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.lesson-body p {
  margin: 0;
}

.lesson-diagram {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(8, 122, 109, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98), rgba(237, 247, 243, 0.92));
}

.diagram-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.diagram-heading span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff8da;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.diagram-heading b {
  min-width: 0;
  color: var(--brand-dark);
  font-size: 14px;
}

.diagram-flow-row,
.diagram-compare-grid,
.diagram-cycle-grid {
  display: grid;
  gap: 8px;
}

.diagram-flow-row {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  align-items: stretch;
}

.diagram-compare-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.diagram-cycle-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.diagram-node {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(16, 40, 32, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
}

.diagram-node small {
  color: var(--gold-dark);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.diagram-node strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.diagram-node em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
}

.diagram-arrow {
  display: none;
}

.example-box,
.trap-box,
.aaoifi-note,
.aaoifi-inline,
.memory-hook,
.key-point-box,
.exam-box,
.real-world-box {
  padding: 12px;
  border-radius: 8px;
  background: #f3eee1;
}

.real-world-box {
  border-left: 4px solid #0ea5e9;
  background: #eef9ff;
}

.memory-hook {
  border-left: 4px solid var(--gold);
  background: #fff6dc;
}

.key-point-box {
  border-left: 4px solid var(--brand-dark);
  background: #eef8f5;
}

.key-point-box ul,
.trap-box ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.key-point-box li,
.trap-box li {
  margin: 4px 0;
}

.exam-box {
  border-left: 4px solid #2563eb;
  background: #eef4ff;
}

.example-box {
  border-left: 4px solid var(--brand);
}

.trap-box {
  border-left: 4px solid var(--danger);
}

.aaoifi-note,
.aaoifi-inline {
  border-left: 4px solid var(--plum);
  background: #f3f0ff;
}

.confidence-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.confidence-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.mistake-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.mistake-item.due {
  border-left: 5px solid var(--danger);
}

.mistake-item h4 {
  margin: 6px 0;
}

.coverage-line {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.coverage-line span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.coverage-meter {
  display: grid;
  gap: 5px;
}

.coverage-meter::before {
  content: "";
  grid-row: 1;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--brand) var(--progress, 0%), rgba(22, 35, 31, 0.12) 0);
}

.coverage-meter span {
  display: none;
}

.coverage-meter small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.pathway-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.glossary-list {
  display: grid;
  gap: 10px;
}

.glossary-item,
.pathway-card {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 0;
}

.glossary-item summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 16px;
  background: transparent;
  color: inherit;
}

.glossary-item summary::-webkit-details-marker {
  display: none;
}

.glossary-item summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.glossary-item[open] .glossary-chevron {
  transform: rotate(90deg);
}

.glossary-summary h3,
.glossary-summary p {
  margin: 0;
}

.glossary-summary p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 4px;
}

.glossary-item[open] .glossary-summary {
  border-bottom-color: transparent;
}

.glossary-chevron {
  transition: transform 0.2s ease;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  transform-origin: center;
}

.glossary-item-body {
  padding: 0 16px 16px;
  display: grid;
  gap: 10px;
}

.support-faq {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.support-faq summary {
  list-style: none;
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  color: inherit;
}

.support-faq summary::-webkit-details-marker {
  display: none;
}

.support-faq summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.support-faq p {
  margin: 0;
  color: var(--muted);
}

.pathway-card .lesson-number {
  margin-bottom: 4px;
}

.diagnostic-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.diagnostic-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1020px) {
  .mastery-hero,
  .dashboard-grid,
  .study-plan-card,
  .lesson-study-layout {
    grid-template-columns: 1fr;
  }

  .mission-panel {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }
}

@media (max-width: 920px) {
  body {
    padding-bottom: 0;
  }

  .layout {
    padding-bottom: clamp(14px, 3vw, 28px);
  }

  .sidebar {
    position: sticky;
    top: 72px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    height: auto;
    padding: 8px;
    overflow: visible;
    border-radius: 12px;
    background: #fffdf8;
    box-shadow: 0 14px 38px rgba(22, 35, 31, 0.2);
  }

  .nav-button {
    min-height: 48px;
    margin: 0;
    padding: 8px 6px;
    justify-content: center;
  }

  .nav-button span:first-child {
    font-size: 12px;
  }

  .nav-button small {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    position: static;
  }

  .sidebar {
    top: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-copy h2 {
    max-width: 11ch;
    font-size: clamp(38px, 14vw, 58px);
  }

  .hero-metrics,
  .tier-grid,
  .stat-grid,
  .pace-grid,
  .mastery-strip,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .mission-panel,
  .map-banner,
  .learning-hero,
  .progress-hero,
  .coverage-line,
  .mistake-item {
    grid-template-columns: 1fr;
  }

  .mission-ring,
  .map-score,
  .learning-score {
    width: 104px;
    min-width: 104px;
    min-height: 104px;
  }

  .button-row {
    align-items: stretch;
  }

  .btn,
  .level-button.compact {
    width: 100%;
  }
}

/* Final navigation overrides must sit after the older responsive rules. */
@media (max-width: 920px) {
  body {
    padding-bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    position: sticky;
    top: 0;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: 10px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding-top: 18px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .sidebar {
    display: none;
  }

  .mobile-tabbar {
    display: grid;
  }
}

@media (max-width: 640px) {
  .topbar {
    position: sticky;
  }

  .status-strip {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: start;
  }
}

/* True final mobile learning overrides: keep this as the last cascade layer. */
/* v2.7 swipe onboarding controls */
.onboarding-flow {
  touch-action: pan-y;
}

.onboarding-arrows {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  margin-top: -2px;
}

.onboarding-arrows span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.onboarding-arrow {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(16, 40, 32, 0.14);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(16, 40, 32, 0.08);
}

.onboarding-arrow:hover,
.onboarding-arrow:focus-visible {
  border-color: rgba(210, 148, 34, 0.72);
  outline: none;
}

.onboarding-arrow:disabled {
  cursor: default;
  opacity: 0.34;
  box-shadow: none;
}

.theme-dark .onboarding-arrow {
  border-color: rgba(255, 255, 255, 0.12);
  background: #17221d;
  color: #f8f1df;
}

@media (max-width: 640px) {
  .onboarding-arrows {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .onboarding-arrow {
    width: 42px;
    height: 42px;
  }
}

/* v2.7.2 compact welcome and source extract cards */
.welcome-journey.onboarding-flow {
  grid-template-columns: minmax(240px, 0.68fr) minmax(340px, 1fr);
  align-items: start;
}

.welcome-journey.onboarding-flow .welcome-panel {
  align-content: center;
  min-height: 0;
  padding: clamp(18px, 3vw, 30px);
}

.welcome-journey.onboarding-flow .welcome-panel h2 {
  max-width: 14ch;
  font-size: clamp(30px, 4.5vw, 54px);
  line-height: 1;
}

.welcome-journey.onboarding-flow .welcome-panel p {
  max-width: 46ch;
  font-size: 15px;
}

.welcome-journey.onboarding-flow .welcome-flow {
  margin: 15px 0;
}

.welcome-journey.onboarding-flow .welcome-proof div {
  min-height: 62px;
  padding: 10px;
}

.welcome-journey.onboarding-flow .welcome-proof b {
  font-size: clamp(20px, 3vw, 28px);
}

.reference-item {
  display: grid;
  gap: 8px;
}

.source-extract {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 10px 11px;
  border-left: 3px solid rgba(210, 148, 34, 0.78);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 231, 163, 0.22);
}

.source-extract span,
.source-extract cite {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  letter-spacing: 0;
}

.source-extract q {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.4;
}

.theme-dark .source-extract {
  background: rgba(210, 148, 34, 0.12);
}

@media (max-width: 920px) {
  .welcome-journey.onboarding-flow {
    grid-template-columns: 1fr;
  }

  .welcome-journey.onboarding-flow .welcome-panel {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .welcome-journey.onboarding-flow .welcome-panel {
    padding: 16px;
  }

  .welcome-journey.onboarding-flow .welcome-panel h2 {
    font-size: clamp(28px, 9vw, 38px);
  }

  .welcome-journey.onboarding-flow .welcome-flow {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .welcome-journey.onboarding-flow .welcome-flow span {
    min-height: 34px;
    padding: 8px 4px;
    font-size: 11px;
  }

  .welcome-journey.onboarding-flow .welcome-proof {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .welcome-journey.onboarding-flow .welcome-proof div {
    min-height: 54px;
    padding: 8px 6px;
  }

  .welcome-journey.onboarding-flow .welcome-proof span {
    font-size: 10px;
  }
}

.study-lesson {
  display: grid;
  gap: 14px;
}

.study-lesson.collapsed {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.lesson-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 78px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.lesson-summary:hover,
.lesson-summary:focus-visible {
  background: rgba(15, 118, 110, 0.07);
  outline: none;
}

.lesson-summary-copy {
  min-width: 0;
}

.lesson-summary small,
.lesson-summary strong,
.lesson-summary em {
  display: block;
}

.lesson-summary small {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lesson-summary strong {
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.25;
}

.lesson-summary em {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-summary > b {
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(16, 40, 32, 0.08);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
}

.study-lesson.expanded {
  border-color: rgba(15, 118, 110, 0.24);
  box-shadow: 0 14px 34px rgba(16, 40, 32, 0.1);
}

.study-lesson.expanded .lesson-heading h3 {
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.12;
}

.study-lesson.expanded .lesson-heading p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}

.study-lesson.expanded .lesson-body {
  gap: 12px;
  color: #263c36;
  font-size: 15px;
  line-height: 1.6;
}

@media (max-width: 920px) {
  .learning-hero,
  .progress-hero {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .learning-hero p,
  .progress-hero p {
    font-size: 15px;
    line-height: 1.45;
  }

  .learning-score {
    width: auto;
    min-width: 0;
    min-height: 0;
    aspect-ratio: auto;
    grid-template-columns: auto minmax(0, 1fr);
    justify-content: start;
    padding: 11px 13px;
    border-radius: 10px;
    text-align: left;
  }

  .learning-score span {
    max-width: none;
  }

  .module-tabs {
    display: flex;
    gap: 8px;
    margin-inline: -14px;
    padding: 0 14px 2px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .module-tabs::-webkit-scrollbar {
    display: none;
  }

  .module-tab {
    flex: 0 0 min(170px, 48vw);
    min-height: 58px;
    scroll-snap-align: start;
  }

  .lesson-study-layout {
    gap: 10px;
  }

  .lesson-card {
    display: grid;
    gap: 10px;
  }

  .lesson-card h2 {
    margin: 0;
  }

  .lesson-card p {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
  }

  .coverage-row {
    margin-top: 0;
  }

  .lesson-list {
    gap: 8px;
  }

  .study-lesson.expanded {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    font-size: 11px;
    line-height: 1.25;
  }

  .status-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-inline: -14px;
    padding: 0 14px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .status-strip::-webkit-scrollbar {
    display: none;
  }

  .status-strip .pill {
    flex: 0 0 auto;
    min-height: 30px;
  }

  .layout {
    padding: 12px 14px calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .card {
    padding: 14px;
  }

  .grid {
    gap: 12px;
  }

  .learning-hero,
  .progress-hero {
    gap: 10px;
  }

  .learning-hero h2,
  .progress-hero h2 {
    font-size: clamp(25px, 7vw, 32px);
    line-height: 1.06;
  }

  .learning-hero p,
  .progress-hero p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .learning-score {
    min-height: 46px;
  }

  .learning-score b {
    font-size: 25px;
  }

  .coverage-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .coverage-row div {
    padding: 9px 7px;
  }

  .coverage-row b {
    font-size: 18px;
  }

  .lesson-summary {
    min-height: 76px;
    padding: 12px;
  }

  .lesson-number {
    width: 32px;
    height: 32px;
  }

  .lesson-summary strong {
    font-size: 14px;
  }

  .lesson-summary em {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .lesson-summary > b {
    display: none;
  }

  .study-lesson.expanded .lesson-heading {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .study-lesson.expanded .lesson-heading .lesson-number {
    width: 34px;
    height: 34px;
  }

  .study-lesson.expanded .lesson-body {
    font-size: 14px;
    line-height: 1.55;
  }

  .example-box,
  .trap-box,
  .aaoifi-note,
  .aaoifi-inline {
    padding: 11px;
  }

  .study-lesson .button-row,
  .chapter-complete-card .button-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-tabbar {
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  }
}

.tools-screen {
  gap: 16px;
}

.tools-hero {
  align-items: center;
}

.tool-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.tool-stat {
  display: grid;
  gap: 4px;
  min-height: 112px;
  align-content: center;
}

.tool-stat small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.search-field input {
  min-height: 48px;
}

.search-results,
.coach-list,
.leaderboard-list,
.diagram-link-grid,
.weak-area-list {
  display: grid;
  gap: 8px;
}

.search-result,
.diagram-link {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.search-result:hover,
.diagram-link:hover,
.contract-tabs button:hover {
  border-color: rgba(15, 118, 110, 0.36);
  background: rgba(15, 118, 110, 0.08);
}

.search-result span,
.diagram-link span {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.search-result b,
.diagram-link b {
  font-size: 14px;
  line-height: 1.25;
}

.search-result small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.coach-step,
.leaderboard-list > div,
.weak-area-list > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.44);
}

.coach-step > b,
.leaderboard-list b {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--brand-dark);
  font-size: 13px;
}

.coach-step span,
.coach-step strong,
.coach-step small {
  display: block;
  min-width: 0;
}

.coach-step small,
.weak-area-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.toggle-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.46);
  font-weight: 850;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.mini-bars {
  display: grid;
  gap: 10px;
}

.mini-bars > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
}

.mini-bars .mini-bar {
  grid-column: 1 / -1;
}

.contract-builder {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.section-head h3,
.section-head p {
  margin: 0;
}

.section-head p {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.contract-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.contract-tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.contract-tabs button.active {
  border-color: rgba(15, 118, 110, 0.36);
  background: var(--brand);
  color: #fffdf8;
}

.contract-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.contract-flow > div {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 118px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 118, 110, 0.07);
}

.contract-flow b {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-dark);
  color: #fffdf8;
}

.contract-flow span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.leaderboard-list strong {
  color: var(--brand-dark);
}

.quiz-debrief {
  display: grid;
  gap: 14px;
}

.theme-dark .search-result,
.theme-dark .diagram-link,
.theme-dark .coach-step,
.theme-dark .leaderboard-list > div,
.theme-dark .weak-area-list > div,
.theme-dark .toggle-row,
.theme-dark .contract-tabs button,
.theme-dark .contract-flow > div {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 640px) {
  .section-head,
  .coach-step,
  .leaderboard-list > div,
  .weak-area-list > div {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

  .coach-step > b,
  .leaderboard-list b {
    width: 26px;
    height: 26px;
  }

  .contract-flow {
    grid-template-columns: 1fr;
  }
}

/* Codex 2026-05-16 dashboard, guide, glossary and practice refinement */
.screen-brand {
  gap: 0;
}

.screen-brand h1 {
  font-size: 1rem;
}

.screen-brand p {
  font-size: 0.78rem;
}

.profile-button {
  transition: opacity 180ms ease, transform 180ms ease;
}

.profile-hidden-on-scroll .profile-button {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-16px);
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.55fr);
  gap: 16px;
  align-items: stretch;
  border-radius: 12px;
  padding: 18px;
  background: linear-gradient(135deg, #0f3d34, #17433d 52%, #263b58);
  color: #fff;
  box-shadow: 0 18px 48px rgba(13, 35, 31, 0.18);
}

.dashboard-hero-copy h2 {
  margin: 6px 0;
  font-size: clamp(1.7rem, 2.8vw, 2.5rem);
}

.dashboard-hero-copy p {
  max-width: 720px;
  color: rgba(255, 255, 255, 0.86);
}

.compact-actions {
  margin-top: 14px;
}

.dashboard-snapshot {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.dashboard-ring {
  width: 126px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #173d35 0 57%, transparent 58%),
    conic-gradient(#f4c95d var(--progress), rgba(255, 255, 255, 0.18) 0);
}

.dashboard-ring span,
.dashboard-ring small {
  grid-area: 1 / 1;
}

.dashboard-ring span {
  margin-top: -12px;
  font-size: 1.9rem;
  font-weight: 800;
}

.dashboard-ring small {
  margin-top: 38px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.78);
}

.dashboard-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dashboard-metric-grid div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.dashboard-metric-grid b,
.dashboard-metric-grid span {
  display: block;
}

.dashboard-metric-grid b {
  font-size: 1.35rem;
}

.dashboard-metric-grid span {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.78);
}

.home-dashboard-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(260px, 0.8fr);
}

.dashboard-card h3,
.today-card h3 {
  margin-top: 4px;
}

.home-bar-chart,
.weak-chart {
  display: grid;
  gap: 8px;
}

.home-bar-row,
.weak-chart-row,
.glossary-content-link {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.home-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
}

.home-bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-bar-row em {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #0f766e var(--learn), transparent 0),
    linear-gradient(90deg, rgba(244, 201, 93, 0.9) var(--practice), rgba(20, 31, 36, 0.1) 0);
}

.weak-chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 8px;
  align-items: center;
}

.weak-chart-row em {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d36b47 var(--risk), rgba(20, 31, 36, 0.1) 0);
}

.compact-meter {
  height: 8px;
}

.compact-calendar .calendar-grid {
  gap: 8px;
}

.compact-learning-hero {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 16px;
}

.compact-score {
  min-width: 104px;
  padding: 10px 12px;
  border-radius: 10px;
}

.module-switcher-card {
  padding: 14px;
}

.module-current-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.module-current-row h3,
.module-current-row p {
  margin: 0;
}

.collapsible-module-tabs {
  margin-top: 12px;
}

.compact-coverage {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.compact-coverage div {
  padding: 10px;
}

.syllabus-coverage {
  margin-top: 12px;
  border: 1px solid rgba(22, 35, 31, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.58);
}

.syllabus-coverage summary {
  cursor: pointer;
  font-weight: 800;
}

.syllabus-coverage ul {
  margin-bottom: 0;
}

.diagram-node {
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.diagram-tap-hint {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
  font-size: 0.72rem;
  font-weight: 800;
}

.deep-dive-backdrop,
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 18, 24, 0.48);
  backdrop-filter: blur(5px);
}

.deep-dive-modal,
.guide-card {
  width: min(680px, 100%);
  max-height: min(760px, 88vh);
  overflow: auto;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  padding: 22px;
  box-shadow: 0 24px 80px rgba(13, 35, 31, 0.28);
}

.modal-close {
  float: right;
  border: 0;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  background: rgba(22, 35, 31, 0.08);
  color: inherit;
  font-size: 1.35rem;
}

.deep-dive-section {
  padding: 12px 0;
  border-top: 1px solid rgba(22, 35, 31, 0.1);
}

.deep-dive-section b {
  display: block;
  margin-bottom: 4px;
}

.guide-card {
  position: relative;
  max-width: 520px;
}

.guide-arrow {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-top: 4px solid #f4c95d;
  border-right: 4px solid #f4c95d;
  transform: rotate(-35deg);
}

.guide-dots {
  display: flex;
  gap: 6px;
  margin: 14px 0;
}

.guide-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(22, 35, 31, 0.18);
}

.guide-dots .active {
  background: var(--brand);
}

.glossary-shell {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.glossary-contents {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.glossary-content-group {
  border-top: 1px solid rgba(22, 35, 31, 0.08);
  padding: 7px 0;
}

.glossary-content-group summary {
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 800;
}

.glossary-content-group div {
  display: grid;
  gap: 3px;
  margin-top: 7px;
}

.glossary-content-link {
  padding: 6px 8px;
  border-radius: 7px;
}

.glossary-content-link.active,
.glossary-content-link:hover {
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
}

.practice-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.layout-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 10px;
  background: rgba(22, 35, 31, 0.08);
}

.layout-toggle button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 12px;
  color: inherit;
  font-weight: 800;
}

.layout-toggle button.active {
  background: var(--card);
  box-shadow: 0 6px 18px rgba(13, 35, 31, 0.12);
}

.practice-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.practice-action-card {
  display: grid;
  gap: 8px;
  align-content: start;
}

.practice-module-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.practice-module-card {
  display: grid;
  gap: 12px;
  border-top: 4px solid var(--accent);
}

.practice-module-meters {
  display: grid;
  gap: 8px;
}

.practice-topic-row {
  margin-bottom: 8px;
}

.theme-dark .syllabus-coverage,
.theme-dark .layout-toggle,
.theme-dark .modal-close {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.theme-dark .guide-dots span {
  background: rgba(255, 255, 255, 0.24);
}

@media (max-width: 920px) {
  .dashboard-hero,
  .home-dashboard-grid,
  .glossary-shell,
  .practice-module-list {
    grid-template-columns: 1fr;
  }

  .practice-actions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .glossary-contents {
    position: static;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .dashboard-hero,
  .practice-hero,
  .module-current-row,
  .compact-learning-hero {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dashboard-snapshot {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .dashboard-metric-grid,
  .practice-actions-grid,
  .compact-coverage {
    grid-template-columns: 1fr;
  }

  .layout-toggle {
    width: 100%;
  }

  .layout-toggle button {
    flex: 1;
  }
}

/* Codex 2026-05-16 UI/UX polish pass: calmer Home dashboard and readable tutorials */
.dashboard-hero {
  position: relative;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 20px;
  overflow: hidden;
  border: 1px solid rgba(16, 40, 32, 0.12);
  border-radius: 10px;
  background:
    linear-gradient(90deg, #0f766e 0 6px, transparent 6px),
    linear-gradient(135deg, #fffdf8 0%, #f7f2e7 56%, #eef6f4 100%);
  color: var(--ink);
  box-shadow: 0 18px 46px rgba(16, 40, 32, 0.12);
}

.dashboard-hero::after {
  content: "";
  position: absolute;
  inset: auto -44px -72px auto;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.14), transparent 68%);
  pointer-events: none;
}

.dashboard-hero-copy {
  position: relative;
  z-index: 1;
}

.dashboard-hero .eyebrow {
  color: #0f766e;
}

.dashboard-hero-copy h2 {
  max-width: 13ch;
  margin: 8px 0 10px;
  color: #102820;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.1;
}

.dashboard-hero-copy p {
  max-width: 62ch;
  color: #42534d;
  font-size: 0.98rem;
  line-height: 1.55;
}

.dashboard-hero .hero-actions {
  max-width: 720px;
}

.dashboard-hero .btn.ghost {
  border-color: rgba(15, 118, 110, 0.2);
  background: rgba(255, 255, 255, 0.72);
  color: #12302b;
}

.dashboard-hero .btn.secondary {
  background: #e7f2ef;
  color: #102820;
}

.dashboard-snapshot {
  position: relative;
  z-index: 1;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid rgba(16, 40, 32, 0.12);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.dashboard-ring {
  width: 112px;
  background:
    radial-gradient(circle at center, #fffdf8 0 56%, transparent 57%),
    conic-gradient(#0f766e var(--progress), rgba(16, 40, 32, 0.12) 0);
}

.dashboard-ring span {
  color: #102820;
  font-size: 1.65rem;
}

.dashboard-ring small {
  color: #52635d;
}

.dashboard-metric-grid {
  align-content: center;
}

.dashboard-metric-grid div {
  border: 1px solid rgba(16, 40, 32, 0.08);
  background: #f8faf6;
}

.dashboard-metric-grid b {
  color: #102820;
}

.dashboard-metric-grid span {
  color: #52635d;
}

.home-dashboard-grid .card,
.learning-lift-grid .card,
.study-calendar-card {
  border-color: rgba(16, 40, 32, 0.12);
  background: rgba(255, 250, 240, 0.92);
}

.dashboard-card h3,
.today-card h3,
.coach-card h3,
.study-calendar-card h3 {
  line-height: 1.18;
}

.home-bar-row,
.weak-chart-row {
  min-height: 42px;
}

.btn {
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.64;
  filter: grayscale(0.12);
}

.btn.gold:disabled,
.btn.gold[disabled] {
  background: #e8c879;
  color: rgba(16, 40, 32, 0.68);
}

.guide-overlay {
  z-index: 1000;
  place-items: center;
  padding: clamp(18px, 5vw, 34px);
  background: rgba(10, 18, 24, 0.62);
  backdrop-filter: blur(6px) saturate(0.9);
}

.guide-card {
  width: min(520px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(16, 40, 32, 0.14);
  border-radius: 10px;
  background: #fffdf8;
  color: #102820;
  padding: clamp(18px, 5vw, 26px);
  box-shadow: 0 28px 90px rgba(6, 16, 19, 0.42);
}

.guide-card::before {
  content: "";
  display: block;
  width: 54px;
  height: 5px;
  margin-bottom: 16px;
  border-radius: 999px;
  background: #d99a16;
}

.guide-arrow {
  display: none;
}

.guide-card .eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e7f2ef;
  color: #0f766e;
}

.guide-card h2 {
  margin: 12px 0 8px;
  color: #102820;
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  line-height: 1.16;
}

.guide-card p {
  margin: 0;
  color: #40514a;
  font-size: 1rem;
  line-height: 1.55;
}

.guide-dots {
  margin: 18px 0;
}

.guide-dots span {
  width: 10px;
  height: 10px;
  background: rgba(16, 40, 32, 0.18);
}

.guide-dots .active {
  background: #0f766e;
}

.guide-card .button-row {
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.guide-card .btn {
  min-height: 44px;
}

.guide-card .btn.ghost {
  border-color: rgba(16, 40, 32, 0.16);
  background: #f4efe3;
  color: #102820;
}

.guide-card .btn.secondary {
  background: #e7f2ef;
  color: #102820;
}

.guide-card .btn.gold {
  background: #d99a16;
  color: #fffdf8;
}

.deep-dive-backdrop {
  z-index: 1000;
  background: rgba(10, 18, 24, 0.58);
}

.theme-dark .dashboard-hero {
  border-color: rgba(237, 246, 239, 0.13);
  background:
    linear-gradient(90deg, #72d6c7 0 6px, transparent 6px),
    linear-gradient(135deg, #18211c 0%, #16241f 56%, #192637 100%);
  color: #edf6ef;
}

.theme-dark .dashboard-hero-copy h2,
.theme-dark .dashboard-ring span,
.theme-dark .dashboard-metric-grid b {
  color: #edf6ef;
}

.theme-dark .dashboard-hero-copy p,
.theme-dark .dashboard-ring small,
.theme-dark .dashboard-metric-grid span {
  color: #b8c7bf;
}

.theme-dark .dashboard-snapshot,
.theme-dark .dashboard-metric-grid div {
  border-color: rgba(237, 246, 239, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.theme-dark .dashboard-ring {
  background:
    radial-gradient(circle at center, #18211c 0 56%, transparent 57%),
    conic-gradient(#72d6c7 var(--progress), rgba(237, 246, 239, 0.14) 0);
}

.theme-dark .guide-card {
  border-color: rgba(237, 246, 239, 0.14);
  background: #18211c;
  color: #edf6ef;
}

.theme-dark .guide-card h2 {
  color: #edf6ef;
}

.theme-dark .guide-card p {
  color: #b8c7bf;
}

.theme-dark .guide-card .btn.ghost {
  background: rgba(255, 255, 255, 0.07);
  color: #edf6ef;
}

.theme-dark .home-dashboard-grid .card,
.theme-dark .learning-lift-grid .card,
.theme-dark .study-calendar-card {
  border-color: rgba(237, 246, 239, 0.13);
  background: #18211c;
  color: #edf6ef;
}

.theme-dark .home-dashboard-grid .card p,
.theme-dark .learning-lift-grid .card p,
.theme-dark .study-calendar-card p,
.theme-dark .calendar-day,
.theme-dark .study-step,
.theme-dark .home-bar-row,
.theme-dark .weak-chart-row {
  color: #c2d0c8;
}

.theme-dark .home-dashboard-grid .card h3,
.theme-dark .learning-lift-grid .card h3,
.theme-dark .study-calendar-card h3,
.theme-dark .study-step b,
.theme-dark .calendar-day strong,
.theme-dark .home-bar-row b,
.theme-dark .weak-chart-row b {
  color: #edf6ef;
}

.theme-dark .study-step,
.theme-dark .calendar-day {
  border-color: rgba(237, 246, 239, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.theme-dark .home-bar-row em,
.theme-dark .mini-bar {
  background: rgba(237, 246, 239, 0.14);
}

.theme-dark .calendar-index {
  background: rgba(114, 214, 199, 0.13);
  color: #72d6c7;
}

.theme-dark .learning-lift-grid .btn.secondary,
.theme-dark .home-dashboard-grid .btn.secondary {
  background: rgba(114, 214, 199, 0.12);
  color: #edf6ef;
}

.theme-dark .dashboard-hero .btn.ghost {
  border-color: rgba(237, 246, 239, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #edf6ef;
}

.theme-dark .study-step b,
.theme-dark .plan-step b,
.theme-dark .lesson-number {
  background: #0f2f28;
  color: #fff8da;
}

@media (max-width: 920px) {
  .dashboard-hero {
    gap: 14px;
  }
}

@media (max-width: 640px) {
  .dashboard-hero {
    grid-template-columns: 1fr;
    padding: 16px 16px 18px;
  }

  .dashboard-hero-copy h2 {
    max-width: 15ch;
    font-size: 1.75rem;
  }

  .dashboard-hero-copy p {
    font-size: 0.95rem;
  }

  .dashboard-hero .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dashboard-snapshot {
    grid-template-columns: 98px minmax(0, 1fr);
    justify-items: stretch;
    align-items: center;
    padding: 10px;
  }

  .dashboard-ring {
    width: 92px;
  }

  .dashboard-ring span {
    font-size: 1.35rem;
  }

  .dashboard-ring small {
    margin-top: 32px;
    font-size: 0.66rem;
  }

  .dashboard-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .dashboard-metric-grid div {
    padding: 8px 6px;
  }

  .dashboard-metric-grid b {
    font-size: 1.1rem;
  }

  .dashboard-metric-grid span {
    font-size: 0.68rem;
  }

  .guide-overlay {
    align-items: end;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .guide-card {
    width: 100%;
    max-height: calc(100vh - 120px);
  }

  .guide-card .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Codex 2026-05-17 phone review fixes: consistent Practice width, readable deep dives, compact chrome */
.practice-page,
.practice-page *,
.deep-dive-modal,
.deep-dive-modal * {
  box-sizing: border-box;
}

.practice-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}

.practice-hero {
  align-items: flex-start;
  padding: 14px;
}

.practice-hero h2 {
  margin-bottom: 8px;
  line-height: 1.12;
}

.practice-hero p {
  max-width: 68ch;
}

.practice-actions-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.practice-module-list,
.practice-module-card,
.practice-module-card > *,
.practice-module-card .quest-meta,
.practice-module-card .practice-module-meters,
.practice-module-card .button-row {
  min-width: 0;
  max-width: 100%;
}

.practice-module-card {
  overflow: hidden;
}

.practice-module-card .quest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.practice-module-card .pill {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.practice-module-card h3,
.practice-module-card p {
  overflow-wrap: anywhere;
}

.layout-toggle {
  max-width: 100%;
  flex-wrap: wrap;
}

.deep-dive-backdrop {
  z-index: 1001;
  place-items: center;
  padding: clamp(16px, 4vw, 30px);
  background: rgba(8, 14, 18, 0.68);
  backdrop-filter: blur(8px) saturate(0.86);
}

.deep-dive-modal {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(16, 40, 32, 0.16);
  border-radius: 10px;
  background: #fffdf8;
  color: #102820;
  padding: clamp(18px, 4vw, 26px);
  box-shadow: 0 30px 90px rgba(6, 16, 19, 0.44);
}

.deep-dive-modal h2 {
  margin: 4px 42px 8px 0;
  color: #102820;
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  line-height: 1.14;
}

.deep-dive-modal .fine-print {
  color: #52635d;
  font-weight: 750;
  line-height: 1.45;
}

.deep-dive-section {
  margin-top: 10px;
  padding: 13px 14px;
  border: 1px solid rgba(16, 40, 32, 0.1);
  border-radius: 8px;
  background: #f8faf6;
}

.deep-dive-section:first-of-type {
  margin-top: 16px;
}

.deep-dive-section b {
  color: #0f4f49;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.deep-dive-section p {
  margin: 6px 0 0;
  color: #344740;
  line-height: 1.58;
}

.deep-dive-section .glossary-link {
  border-color: rgba(15, 118, 110, 0.28);
  background: #e7f2ef;
  color: #0f4f49;
}

.modal-close {
  background: #f0eadf;
  color: #102820;
}

.theme-dark .deep-dive-backdrop {
  background: rgba(4, 8, 10, 0.76);
}

.theme-dark .deep-dive-modal {
  border-color: rgba(237, 246, 239, 0.16);
  background: #18211c;
  color: #edf6ef;
}

.theme-dark .deep-dive-modal h2 {
  color: #edf6ef;
}

.theme-dark .deep-dive-modal .fine-print {
  color: #b8c7bf;
}

.theme-dark .deep-dive-section {
  border-color: rgba(237, 246, 239, 0.13);
  background: rgba(255, 255, 255, 0.055);
}

.theme-dark .deep-dive-section b {
  color: #72d6c7;
}

.theme-dark .deep-dive-section p {
  color: #d4ded8;
}

.theme-dark .deep-dive-section .glossary-link {
  background: rgba(114, 214, 199, 0.12);
  color: #edf6ef;
}

.theme-dark .modal-close {
  background: rgba(255, 255, 255, 0.09);
  color: #edf6ef;
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 10px;
  }

  .brand h1,
  .screen-brand h1 {
    font-size: 0.98rem;
    line-height: 1.05;
  }

  .brand p,
  .screen-brand p {
    display: none;
  }

  .topbar-actions {
    flex: 0 0 auto;
  }

  .profile-button {
    width: 38px;
    min-height: 38px;
    max-width: 38px;
    padding: 3px;
  }

  .profile-avatar {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .layout {
    padding-top: 10px;
  }

  .practice-hero {
    gap: 12px;
    padding: 14px;
  }

  .practice-hero h2 {
    font-size: 1.45rem;
  }

  .practice-actions-grid,
  .practice-module-list {
    grid-template-columns: 1fr;
  }

  .practice-module-card .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .deep-dive-backdrop {
    align-items: end;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .deep-dive-modal {
    width: 100%;
    max-height: calc(100vh - 96px);
    padding: 18px;
  }
}
