:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #647084;
  --line: #d8dee8;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --brand: #174ea6;
  --brand-2: #0f766e;
  --accent: #b45309;
  --danger: #b42318;
  --success: #147a43;
  --shadow: 0 18px 50px rgba(24, 33, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--ink);
  background: #e9edf3;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  padding: 12px clamp(16px, 4vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.main-view {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px);
  flex: 1;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 26px;
  align-items: end;
  margin-bottom: 26px;
}

.eyebrow {
  color: var(--brand-2);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1.1;
}

h3 {
  font-size: 1.05rem;
}

p {
  line-height: 1.58;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  border-left: 4px solid var(--brand);
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 1.4rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.completion-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 22px;
  padding: 22px;
  background: #f0f9f6;
  border: 1px solid #b8d9d5;
  border-left: 6px solid var(--brand-2);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15, 118, 110, 0.12);
}

.completion-panel h2 {
  margin: 4px 0 8px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
}

.completion-panel p {
  margin: 0 0 8px;
}

.unit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
  min-height: 210px;
  box-shadow: 0 12px 32px rgba(24, 33, 47, 0.08);
}

.unit-card header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.unit-number {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #e8f0fe;
  color: var(--brand);
  font-weight: 800;
}

.unit-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  height: 8px;
  background: #e5e9f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  width: 0%;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.answer-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

.secondary-button {
  background: #eef6f5;
  color: var(--brand-2);
  border-color: #b8d9d5;
}

.ghost-button {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.progress-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--brand-2);
  background: #e7f5f3;
  font-weight: 800;
  font-size: 0.9rem;
}

.lesson-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
}

.unit-sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  align-self: start;
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 118px);
  overflow: auto;
}

.side-unit {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 8px;
  border-radius: 8px;
}

.side-unit.is-active {
  background: #e8f0fe;
  color: var(--brand);
}

.side-unit small {
  color: var(--muted);
}

.lesson-panel,
.exam-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lesson-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.lesson-count {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.lesson-body {
  display: grid;
  grid-template-columns: minmax(520px, 1.42fr) minmax(300px, 0.58fr);
  gap: 0;
}

.slide-frame {
  background: #111827;
  min-height: 430px;
  display: grid;
  place-items: center;
  padding: 10px;
}

.slide-frame img {
  display: block;
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: #fff;
}

.slide-frame .no-image {
  color: #fff;
  text-align: center;
  padding: 30px;
}

.study-notes {
  padding: 22px;
  max-height: 76vh;
  overflow: auto;
}

.study-notes ul {
  margin: 14px 0 0;
  padding-left: 1.2rem;
}

.study-notes li {
  margin: 0 0 10px;
  line-height: 1.5;
}

.study-notes a {
  color: var(--brand);
  font-weight: 800;
  overflow-wrap: anywhere;
  text-decoration: underline;
}

.study-notes a:hover {
  color: var(--brand-2);
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.keyword {
  border: 1px solid #cbd5e1;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

.lesson-footer,
.exam-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}

.exam-panel,
.result-panel {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

.exam-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--muted);
  font-weight: 800;
}

.question-text {
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.18;
  margin-bottom: 20px;
}

.answer-list {
  display: grid;
  gap: 10px;
}

.answer-button {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.answer-button.is-selected {
  border-color: var(--brand);
  background: #e8f0fe;
}

.answer-button.is-correct {
  border-color: var(--success);
  background: #e8f7ee;
}

.answer-button.is-wrong {
  border-color: var(--danger);
  background: #fff0ed;
}

.score-badge {
  display: inline-grid;
  place-items: center;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 18px;
}

.score-badge.pass {
  background: var(--success);
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.review-item strong {
  display: block;
  margin-bottom: 8px;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
}

@media (max-width: 980px) {
  .hero-band,
  .lesson-layout,
  .lesson-body {
    grid-template-columns: 1fr;
  }

  .unit-sidebar {
    position: static;
    max-height: none;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .lesson-header,
  .lesson-footer,
  .exam-footer,
  .completion-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .button-row {
    justify-content: stretch;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .main-view {
    padding: 14px;
  }

  .slide-frame {
    min-height: 220px;
  }
}
