:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #5f6f7b;
  --line: #d8e0e6;
  --soft: #f7fafc;
  --accent: #176b87;
  --accent-dark: #0f4c5c;
  --success: #247a4b;
  --danger: #a33a32;
  --gold: #8a650f;
  --shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
  --font-ui: "Google Sans", Roboto, Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #fff;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #fff;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px clamp(14px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--accent-dark);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 700;
  text-decoration: none;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.top-nav a,
.nav-button,
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--accent-dark);
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus-visible,
.nav-button:hover,
.nav-button:focus-visible,
.link-button:hover,
.link-button:focus-visible {
  border-color: var(--line);
  background: var(--soft);
  outline: none;
}

.nav-button {
  background: transparent;
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px) clamp(14px, 4vw, 28px) 36px;
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, 0.8fr) minmax(0, 1fr);
  gap: 16px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px clamp(14px, 4vw, 28px) 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.site-footer strong {
  color: var(--ink);
}

.site-footer p {
  margin: 6px 0 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.site-footer a {
  color: var(--accent-dark);
  text-decoration: none;
}

.page-intro {
  max-width: 760px;
  margin-bottom: 16px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 18px;
  align-items: center;
  padding: clamp(16px, 4vw, 28px) 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.home-hero h1 {
  max-width: 720px;
}

.hero-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.hero-panel div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.hero-panel div:last-child {
  border-bottom: 0;
}

.hero-panel strong {
  font-size: 1.2rem;
}

.hero-panel span {
  color: var(--muted);
}

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

.feature-strip article {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.feature-strip p {
  margin-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 10px;
}

.profile-stat {
  margin: 6px 0 0;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2.35rem);
  line-height: 1.12;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  line-height: 1.18;
}

h3 {
  margin: 0 0 5px;
  font-size: 1.05rem;
}

.lede {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.12rem;
}

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

.quiz-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.quiz-pagination-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.quiz-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
}

.pagination-button {
  min-width: 38px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.pagination-button:hover,
.pagination-button:focus-visible,
.pagination-button.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-dark);
  outline: none;
}

.pagination-button.active {
  font-weight: 700;
}

.pagination-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pagination-ellipsis {
  min-width: 24px;
  text-align: center;
}

.compact-field {
  min-width: min(100%, 190px);
  margin: 0;
}

.compact-field select {
  min-height: 38px;
}

.quiz-card {
  overflow: hidden;
}

.quiz-thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--soft);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.subject-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.84rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary {
  background: #fff;
  color: var(--accent-dark);
}

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

.button:hover,
.button:focus-visible {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
  outline: none;
}

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

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

.lesson {
  margin: 0;
}

.lesson-card {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.lesson-card strong {
  font-size: 1.05rem;
}

.lesson-card span:last-child {
  color: var(--muted);
}

.lesson-card:hover,
.lesson-card:focus-visible {
  border-color: var(--accent);
  background: #fff;
  outline: none;
}

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.field {
  display: grid;
  gap: 5px;
  margin: 10px 0;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
}

input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(23, 107, 135, 0.16);
}

.form-error {
  min-height: 1.3em;
  margin: 8px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.quiz-frame {
  display: grid;
  gap: 10px;
}

.quiz-frame .panel {
  padding: 12px;
}

.quiz-frame .panel h1 {
  font-size: clamp(1.15rem, 3vw, 1.75rem);
  line-height: 1.2;
}

.progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.meter {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

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

.option-button {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.option-button:hover,
.option-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.option-button.correct {
  border-color: var(--success);
  background: #f0fbf5;
}

.option-button.incorrect {
  border-color: var(--danger);
  background: #fff4f2;
}

.explanation {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--soft);
}

.explanation h2 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.explanation p {
  margin: 0;
}

.score-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.score-number {
  color: var(--accent-dark);
  font-size: clamp(1.65rem, 5vw, 2.35rem);
  font-weight: 700;
  line-height: 1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: var(--soft);
  color: var(--accent-dark);
}

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
}

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

.summary-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.correct-text {
  color: var(--success);
  font-weight: 700;
}

.incorrect-text {
  color: var(--danger);
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(31, 41, 51, 0.36);
}

.lesson-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.lesson-modal-with-nav {
  width: 100%;
}

.quiz-modal {
  width: 100%;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 3vw, 22px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.lesson-modal h1 {
  font-size: clamp(1.35rem, 4vw, 2rem);
}

.lesson-body {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding: 16px clamp(14px, 3vw, 22px);
}

.lesson-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.lesson-side-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--soft);
}

.lesson-side-nav button {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.lesson-side-nav button span {
  color: var(--muted);
  font-size: 0.78rem;
}

.lesson-side-nav button strong {
  font-size: 0.92rem;
  line-height: 1.2;
}

.lesson-side-nav button:hover,
.lesson-side-nav button:focus-visible,
.lesson-side-nav button.active {
  border-color: var(--line);
  background: #fff;
  outline: none;
}

.quiz-backdrop {
  align-items: stretch;
}

.quiz-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px clamp(14px, 4vw, 34px) 20px;
}

.quiz-modal-body .quiz-frame {
  max-width: 920px;
  margin: 0 auto;
}

.quiz-action-bar {
  display: flex;
  justify-content: flex-end;
  max-width: 920px;
  margin: 8px auto 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  background: #fff;
}

.lesson-body section {
  max-width: 760px;
}

.lesson-videos {
  width: 100%;
}

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

.video-card {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.video-card h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.25;
}

.video-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.video-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-thumb span {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.88rem;
  font-weight: 700;
}

.video-card:hover .video-thumb,
.video-card:focus-visible .video-thumb {
  border-color: var(--accent);
}

.video-card:focus-visible {
  outline: none;
}

.video-backdrop {
  z-index: 70;
  padding: 18px;
}

.video-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  width: min(960px, 100%);
  max-height: calc(100vh - 36px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(31, 41, 51, 0.18);
}

.video-modal h1 {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.35rem);
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.lesson-body ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 22px;
}

.quick-check {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--soft);
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
    width: 100%;
  }

  .top-nav a {
    padding-left: 0;
  }

  .home-hero,
  .feature-strip,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .course-layout {
    grid-template-columns: 1fr;
  }

  .progress {
    align-items: stretch;
    flex-direction: column;
  }

  .actions .button,
  .actions .link-button {
    width: 100%;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .lesson-modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .lesson-shell {
    grid-template-columns: 1fr;
  }

  .lesson-side-nav {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lesson-side-nav button {
    min-width: 170px;
  }

  .modal-header,
  .modal-footer {
    align-items: flex-start;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer .button {
    width: 100%;
  }
}
