/* =========================================================
   Platform shell — header, dashboard, course tree, auth, landing, errors.
   Built only from the design tokens in site.css (the original demo design
   system). Lesson pages keep using site.css exactly as in the demo.
   ========================================================= */

/* ---------- Page container ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}
.page--narrow { max-width: 880px; }

.page__header { margin-bottom: var(--space-6); }
.page__header .stage__title { margin-top: var(--space-2); }
.page__lead { margin-top: var(--space-3); color: var(--color-text-muted); max-width: 60ch; }

.section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-4);
}

/* ---------- Site header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 245, 249, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.site-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
.brand--link { color: inherit; text-decoration: none; }
.brand--link { border-radius: var(--radius-sm); }
.brand--link:hover .logo { opacity: 0.85; }
.brand__name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }

.site-nav { flex: 1; min-width: 0; }
.site-nav__list {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.site-nav__link:hover { background: var(--color-surface); color: var(--color-text); }
.site-nav__link[aria-current="page"] { background: var(--color-accent-soft); color: var(--color-accent-strong); }

.user-area { display: flex; align-items: center; gap: var(--space-3); }
.user-chip { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.user-chip__avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
  font-weight: 700;
  font-size: var(--text-sm);
}
.user-chip__text { display: grid; line-height: 1.25; min-width: 0; }
.user-chip__name { font-weight: 650; font-size: var(--text-sm); }
.user-chip__email {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-form { margin: 0; }

.btn--sm { min-height: 40px; padding: 0 var(--space-4); font-size: var(--text-sm); }
.btn--link {
  background: transparent;
  color: var(--color-text-muted);
  padding: 0 var(--space-3);
}
.btn--link:hover { color: var(--color-text); background: var(--color-surface); }
a.btn { text-decoration: none; }
.btn[aria-disabled="true"], .btn:disabled { cursor: not-allowed; }

/* ---------- Site footer ---------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-7);
}
.site-footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.site-footer a { color: inherit; }

/* ---------- Progress meter (reuses the lesson progress bar look) ---------- */

.meter { display: grid; gap: var(--space-2); }
.meter__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.meter__value { font-size: 1.75rem; font-weight: 700; color: var(--color-accent-strong); font-variant-numeric: tabular-nums; }
.meter__label { font-size: var(--text-sm); color: var(--color-text-muted); }
.meter__track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: #e3e6f0;
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-accent), #6a55ee);
  transition: width var(--dur-slow) var(--ease);
}
.meter--sm .meter__track { height: 6px; }

/* ---------- Dashboard hero ---------- */

.dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: var(--space-5);
  align-items: stretch;
  margin-bottom: var(--space-6);
}
.dash-hero__intro { padding: var(--space-4) 0; }
.dash-hero__intro .lead { margin-top: var(--space-3); color: var(--color-text-muted); font-weight: 400; }
.dash-hero__stats { margin-top: var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); }
.dash-hero__stats strong { color: var(--color-text); }

.progress-card { display: grid; gap: var(--space-4); align-content: start; }
.continue-card {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.continue-card__label { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.continue-card__title { font-weight: 650; }
.continue-card .btn { justify-self: start; margin-top: var(--space-2); }

/* ---------- Chapters (collapsible) ---------- */

.chapters { display: grid; gap: var(--space-4); }

.chapter {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.chapter__summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 220px) auto;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  cursor: pointer;
  list-style: none;
}
.chapter__summary::-webkit-details-marker { display: none; }
.chapter__summary:hover { background: var(--color-surface-muted); }
.chapter__summary:focus-visible { outline-offset: -3px; border-radius: var(--radius-lg); }
.chapter__title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; margin-top: var(--space-1); }
.chapter__meta { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--color-text-muted); }
.chapter__chevron {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: transform var(--dur-med) var(--ease);
}
.chapter[open] .chapter__chevron { transform: rotate(180deg); }
.chapter[open] .chapter__body { animation: fade-in var(--dur-med) var(--ease); }
.chapter__body { border-top: 1px solid var(--color-border); }

/* ---------- Section rows ---------- */

.section-list { margin: 0; padding: 0; list-style: none; }
.section-row {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: 90px;
}
.section-row:last-child { border-bottom: 0; }
.section-row:target { background: var(--color-accent-soft); }
.section-row__head {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-4);
}
.section-row__num {
  font-family: var(--font-math);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-accent-strong);
  font-variant-numeric: tabular-nums;
}
.section-row--soon .section-row__num { color: var(--color-text-muted); }
.section-row__title { font-weight: 600; line-height: 1.4; }
.section-row--soon .section-row__title { color: var(--color-text-muted); font-weight: 500; }
.section-row__title sub, .section-row__title sup { font-size: 0.7em; }
.section-row__action { min-width: 132px; }
.section-row__action .btn { width: 100%; min-height: 40px; font-size: var(--text-sm); padding: 0 var(--space-4); }

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 650;
  white-space: nowrap;
}
.status__icon {
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 0.65rem;
  line-height: 1;
}
.status--completed { background: var(--color-success-soft); color: var(--color-success-strong); }
.status--completed .status__icon { background: var(--color-success); color: #fff; }
.status--inprogress { background: var(--color-accent-soft); color: var(--color-accent-strong); }
.status--inprogress .status__icon { background: var(--color-accent); color: #fff; }
.status--notstarted { background: var(--color-surface-muted); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.status--notstarted .status__icon { border: 2px solid var(--color-border-strong); }
.status--available { background: var(--color-accent-soft); color: var(--color-accent-strong); }
.status--available .status__icon { background: var(--color-accent); color: #fff; }
.status--soon { background: transparent; color: var(--color-text-muted); border: 1px dashed var(--color-border-strong); }
.status--soon .status__icon { color: var(--color-text-muted); }

.btn--soon {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  box-shadow: none;
}

/* Lessons / activities inside a section */
.lesson-list {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0 0 calc(3.2rem + var(--space-4));
  padding: 0;
  list-style: none;
}
.lesson-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}
.lesson-item__icon {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-accent);
  font-family: var(--font-math);
  font-style: italic;
  font-weight: 700;
}
.lesson-item__title { font-weight: 600; color: var(--color-text); text-decoration: none; }
.lesson-item__title:hover { color: var(--color-accent-strong); text-decoration: underline; }
.lesson-item__meta { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }
.lesson-item__meta span + span::before { content: "·"; margin: 0 var(--space-2); }
.lesson-item__progress { width: 64px; }

/* ---------- Course catalogue ---------- */

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-4); }
.course-card { display: grid; gap: var(--space-4); }
.course-card__title { font-size: var(--text-lg); font-weight: 700; }
.course-card__desc { color: var(--color-text-muted); font-size: var(--text-sm); }
.course-card .btn { justify-self: start; }

/* ---------- Progress page ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat { padding: var(--space-5); }
.stat__value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__label { font-size: var(--text-sm); color: var(--color-text-muted); }

.chapter-progress { display: grid; gap: var(--space-4); margin-bottom: var(--space-6); }
.chapter-progress__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 280px); gap: var(--space-5); align-items: center; }
.chapter-progress__row + .chapter-progress__row { padding-top: var(--space-4); border-top: 1px solid var(--color-border); }

.progress-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.progress-table th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: 0 var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.progress-table td { padding: var(--space-3); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.progress-table tr:last-child td { border-bottom: 0; }
.progress-table a { color: var(--color-text); font-weight: 600; }
.table-scroll { overflow-x: auto; }

.empty-note { color: var(--color-text-muted); font-size: var(--text-sm); }

/* ---------- Auth ---------- */

.auth {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-4);
}
.auth__card { width: 100%; max-width: 440px; padding: var(--space-6); }
.auth__card .stage__title { font-size: clamp(1.5rem, 1.2rem + 1vw, 1.9rem); margin-bottom: var(--space-2); }
.auth__intro { color: var(--color-text-muted); margin-bottom: var(--space-5); }
.auth__footer { margin-top: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--color-text-muted); }
.auth__footer a, .form-link { color: var(--color-accent-strong); font-weight: 600; }

.form { display: grid; gap: var(--space-4); }
.field { display: grid; gap: var(--space-2); }
.field__label { font-size: var(--text-sm); font-weight: 600; }
.field__input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field__input:hover { border-color: var(--color-accent); }
.field__input:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(80, 70, 214, 0.16);
}
.field__input.input-validation-error { border-color: var(--color-danger); }
.field__error { font-size: var(--text-xs); color: var(--color-danger-strong); }
.field__error:empty { display: none; }
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--color-accent); }

.form-errors:empty, .form-errors.validation-summary-valid { display: none; }
.form-errors ul {
  margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  background: var(--color-danger-soft);
  border: 1px solid rgba(212, 67, 79, 0.3);
  color: var(--color-danger-strong);
  font-size: var(--text-sm);
}
.form .btn--primary { width: 100%; }

/* ---------- Landing ---------- */

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-7);
  align-items: center;
  padding: var(--space-6) 0 var(--space-7);
}
.landing-hero__title {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 750;
  margin-top: var(--space-3);
}
.landing-hero__text { margin-top: var(--space-4); font-size: var(--text-lg); color: var(--color-text-muted); max-width: 46ch; }
.landing-hero__actions { margin-top: var(--space-6); display: flex; flex-wrap: wrap; gap: var(--space-3); }
.btn--outline { background: var(--color-surface); color: var(--color-text); border: 1.5px solid var(--color-border-strong); }
.btn--outline:hover { border-color: var(--color-accent); background: var(--color-accent-soft); }

.preview-card { display: grid; gap: var(--space-4); }
.preview-card__caption { font-size: var(--text-sm); color: var(--color-text-muted); }

.landing-block { padding: var(--space-6) 0; }
.landing-block__head { margin-bottom: var(--space-5); }
.landing-block__head .stage__title { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); }

.chapter-preview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.chapter-preview { display: grid; gap: var(--space-3); align-content: start; }
.chapter-preview__list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); }
.chapter-preview__list li { display: flex; gap: var(--space-2); }
.chapter-preview__list b { color: var(--color-text); font-family: var(--font-math); font-weight: 600; min-width: 2.4em; }
.chapter-preview__more { font-size: var(--text-xs); color: var(--color-text-muted); }

.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.step-card__num {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: var(--space-3);
}
.step-card__title { font-weight: 700; margin-bottom: var(--space-1); }
.step-card p:not(.step-card__title) { color: var(--color-text-muted); font-size: var(--text-sm); }

.sample-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-warning-soft);
  color: #8a5f06;
  font-size: var(--text-xs);
  font-weight: 700;
}

.cta-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6);
  background: linear-gradient(180deg, var(--color-accent-soft), var(--color-surface) 90%);
  border-color: rgba(80, 70, 214, 0.25);
}

/* ---------- Error pages ---------- */

.error-page { min-height: calc(100vh - 150px); display: grid; place-items: center; padding: var(--space-6) var(--space-4); }
.error-card { max-width: 520px; text-align: center; padding: var(--space-7) var(--space-6); }
.error-card__code {
  font-family: var(--font-math);
  font-size: 4rem;
  line-height: 1;
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}
.error-card p { color: var(--color-text-muted); margin-top: var(--space-3); }
.error-card .controls-row { justify-content: center; margin-top: var(--space-5); }

.prose { max-width: 70ch; }
.prose p, .prose ul { color: var(--color-text-muted); margin: var(--space-3) 0; }
.prose h2 { margin-top: var(--space-5); font-size: var(--text-lg); }

/* ---------- Lesson shell (shared header above every interactive lesson) ---------- */

.lesson-topbar .topbar__inner { gap: var(--space-4); }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.back-link:hover { border-color: var(--color-accent); background: var(--color-accent-soft); }
.lesson-topbar .brand { min-width: 0; flex-shrink: 1; }
.lesson-topbar .brand > div { min-width: 0; }
.lesson-topbar .brand__eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-topbar .brand__title { display: flex; align-items: baseline; gap: var(--space-2); }
.lesson-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
  font-family: var(--font-math);
  font-size: 0.9em;
  font-weight: 600;
  flex-shrink: 0;
}

.lesson-complete {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}
.lesson-complete__status { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.lesson-complete__title { font-weight: 700; }
.lesson-complete__save { font-size: var(--text-sm); color: var(--color-text-muted); }
.lesson-complete__save[data-state="saved"] { color: var(--color-success-strong); }
.lesson-complete__save[data-state="error"] { color: var(--color-danger-strong); }
.lesson-complete__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.lesson-complete__actions .btn { min-height: 46px; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .dash-hero { grid-template-columns: minmax(0, 1fr); }
  .landing-hero { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .chapter-preview-grid, .steps-grid { grid-template-columns: minmax(0, 1fr); }
  .user-chip__text { display: none; }
}

@media (max-width: 720px) {
  .site-header__inner { flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-4); }
  .site-nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .site-nav__link { padding: 0 var(--space-3); }
  .user-area { margin-left: auto; }

  .page { padding: var(--space-5) var(--space-4) var(--space-6); }
  .chapter__summary { grid-template-columns: minmax(0, 1fr) auto; padding: var(--space-4); gap: var(--space-3); }
  .chapter__summary .meter { grid-column: 1 / -1; grid-row: 2; }
  .section-row { padding: var(--space-4); }
  .section-row__head { grid-template-columns: 2.6rem minmax(0, 1fr); gap: var(--space-2) var(--space-3); }
  .section-row__head .status { grid-column: 2; justify-self: start; }
  .section-row__action { grid-column: 1 / -1; min-width: 0; }
  .lesson-list { margin-left: 0; }
  .lesson-item { grid-template-columns: auto minmax(0, 1fr); }
  .lesson-item .status { grid-column: 2; justify-self: start; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .chapter-progress__row { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .auth__card { padding: var(--space-5); }
  .cta-band { padding: var(--space-5); }

  .back-link span { display: none; }
  .back-link { padding: 0 var(--space-3); }
  .lesson-topbar .topbar__inner { flex-wrap: wrap; }
  .lesson-topbar .brand { flex: 1; }
}

/* =========================================================
   StudyScope — brand, subjects and lesson step navigation
   ========================================================= */

/* ---------- Logo (supplied PNG, transparent; never stretched) ---------- */

.logo { display: block; width: auto; max-width: 100%; object-fit: contain; }
.logo--nav { height: 30px; }
.logo--auth { height: 34px; }
.logo--hero { height: 40px; }
.brand--link { padding: 4px 0; }

/* Lesson header: the StudyScope icon replaces the old “f′” tile — identity, not decoration. */
.brand__logo-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  object-fit: contain;
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.breadcrumb a { color: var(--color-accent-strong); font-weight: 600; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--color-text); font-weight: 600; }

/* ---------- Subject cards ---------- */

.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}
.subject-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.subject-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.subject-card__title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; margin-top: var(--space-1); line-height: 1.3; }
.subject-card__desc { color: var(--color-text-muted); font-size: var(--text-sm); }
.subject-card__note { color: var(--color-text-muted); font-size: var(--text-xs); }
.subject-card__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }
.subject-card__meta strong { color: var(--color-text); }
/* Actions sit at the bottom so cards of different length line up. */
.subject-card > .btn { margin-top: auto; align-self: flex-start; }
.subject-card--soon { background: var(--color-surface-muted); box-shadow: none; }
.subject-card--soon .subject-card__title { color: var(--color-text-muted); }

.subject-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 13px;
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
}
.subject-card--soon .subject-icon,
.subject-progress__row--soon .subject-icon {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.continue-card--plain { padding-top: 0; border-top: 0; }
.continue-card__subject { font-size: var(--text-sm); color: var(--color-accent-strong); font-weight: 650; }

/* ---------- Progress page (per subject) ---------- */

.subject-progress { display: grid; gap: var(--space-4); margin-bottom: var(--space-6); }
.subject-progress__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(120px, 280px);
  gap: var(--space-4);
  align-items: center;
}
.subject-progress__row + .subject-progress__row { padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.subject-progress__row > .status { justify-self: start; }
.subject-progress__title { font-weight: 700; }
.subject-progress__meta { font-size: var(--text-sm); color: var(--color-text-muted); }
.subject-progress__row--soon .subject-progress__title { color: var(--color-text-muted); font-weight: 600; }
.subject-detail { margin-top: var(--space-6); }
.subsection-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* ---------- Auth & CTA branding ---------- */

.auth__brand { margin-bottom: var(--space-5); }
.cta-band__brand { display: grid; gap: var(--space-3); justify-items: start; }

/* ---------- Lesson shell: step navigation ---------- */

.steps-toggle {
  order: 3;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.steps-toggle:hover { border-color: var(--color-accent); background: var(--color-accent-soft); }
.steps-toggle svg { transition: transform var(--dur-med) var(--ease); }
.steps-toggle[aria-expanded="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); color: var(--color-accent-strong); }
.steps-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.step-nav {
  display: none;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.step-nav__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.step-nav__title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.step-nav__count { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.step-nav__close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.step-nav__close:hover { color: var(--color-text); border-color: var(--color-border-strong); }

.step-nav__list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.step-nav__btn {
  display: grid;
  grid-template-columns: 22px 1.7em minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 40px;
  padding: 6px var(--space-2);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.step-nav__btn:hover { background: var(--color-surface-muted); }
.step-nav__btn:focus-visible { outline-offset: -2px; }
.step-nav__num { color: var(--color-text-muted); font-variant-numeric: tabular-nums; font-size: var(--text-xs); font-weight: 600; }
.step-nav__label { min-width: 0; overflow-wrap: anywhere; }

.step-nav__marker {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--color-border-strong);
  background: var(--color-surface);
  color: #fff;
}
/* Completed: green check. */
.step-nav__item.is-done .step-nav__marker { background: var(--color-success); border-color: var(--color-success); }
/* Current: accent ring with a centre dot (a check when it is also completed). */
.step-nav__item.is-current .step-nav__btn { background: var(--color-accent-soft); color: var(--color-accent-strong); font-weight: 650; }
.step-nav__item.is-current .step-nav__num { color: var(--color-accent-strong); }
.step-nav__item.is-current .step-nav__marker { border-color: var(--color-accent); background: var(--color-accent); box-shadow: 0 0 0 3px rgba(80, 70, 214, 0.18); }
.step-nav__item.is-current:not(.is-done) .step-nav__marker::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
/* Available (unlocked, not yet completed): the default hollow ring. */
/* Locked: muted text, lock icon, not clickable. */
.step-nav__item.is-locked .step-nav__btn { color: var(--color-text-muted); cursor: not-allowed; }
.step-nav__item.is-locked .step-nav__btn:hover { background: transparent; }
.step-nav__item.is-locked .step-nav__marker { border: 0; background: transparent; color: var(--color-text-muted); }
.step-nav__item.is-locked .step-nav__label { opacity: 0.8; }

.step-nav__msg { font-size: var(--text-xs); }
.step-nav__msg:not(:empty) {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-warning-soft);
  color: #7a5405;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.step-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(21, 32, 59, 0.12);
}

/* Tablet & small desktop: dropdown panel under the lesson header. */
@media (max-width: 1279.98px) {
  .step-nav.is-open {
    display: flex;
    position: fixed;
    z-index: 40;
    top: calc(var(--lesson-topbar-h, 66px) + var(--space-2));
    right: max(var(--space-4), calc((100vw - 1180px) / 2 + var(--space-5)));
    width: min(360px, calc(100vw - 2 * var(--space-4)));
    max-height: calc(100vh - var(--lesson-topbar-h, 66px) - var(--space-5));
    max-height: calc(100dvh - var(--lesson-topbar-h, 66px) - var(--space-5));
    animation: fade-in var(--dur-med) var(--ease);
  }
}

/* Phones: bottom sheet. */
@media (max-width: 640px) {
  .step-nav.is-open {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 78vh;
    max-height: 78dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .step-nav-backdrop { background: rgba(21, 32, 59, 0.32); }
  .step-nav__btn { min-height: 44px; }
}

/* Wide screens: permanent side rail; the lesson keeps its full layout next to it. */
@media (min-width: 1280px) {
  .lesson-shell {
    --rail-w: 244px;
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    column-gap: var(--space-2);
    padding-left: var(--space-5);
  }
  .step-nav {
    display: flex;
    position: sticky;
    top: calc(var(--lesson-topbar-h, 66px) + var(--space-5));
    align-self: start;
    margin-top: var(--space-6);
    max-height: calc(100vh - var(--lesson-topbar-h, 66px) - var(--actionbar-height) - var(--space-7));
  }
  .step-nav__close, .steps-toggle, .step-nav-backdrop { display: none; }
  .lesson-shell__main { min-width: 0; }
  /* The fixed action bar spans the lesson column only. */
  .lesson-shell .actionbar { left: calc(var(--rail-w) + var(--space-5)); }
}

/* ---------- StudyScope responsive ---------- */

@media (max-width: 1024px) {
  .subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Lesson header: with the “Όλα τα βήματα” button the progress row needs its own line below ~1080px. */
@media (max-width: 1079.98px) {
  .lesson-topbar .topbar__inner { flex-wrap: wrap; row-gap: var(--space-2); }
  .lesson-topbar .brand { flex: 1; }
  .lesson-topbar .progress { flex-basis: 100%; }
}

@media (max-width: 720px) {
  .subject-grid { grid-template-columns: minmax(0, 1fr); }
  .subject-progress__row { grid-template-columns: auto minmax(0, 1fr); }
  .subject-progress__row > .meter, .subject-progress__row > .status { grid-column: 2; }
  .logo--nav { height: 26px; }
  .brand__logo-mark { width: 30px; height: 30px; }
}
