:root {
  --brand-primary: #0b57d0;
  --brand-primary-strong: #0842a0;
  --brand-accent: #1bb3a9;
  --brand-surface: #ffffff;
  --brand-surface-soft: #f5f7fb;
  --brand-ink: #132238;
  --brand-muted: #60708a;
  --brand-border: #d8dfeb;
  --brand-success: #16794a;
  --brand-danger: #b42318;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --shadow-soft: 0 12px 32px rgba(17, 35, 67, 0.08);
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #f7faff 0%, #eef3fb 100%);
  color: var(--brand-ink);
  font-family: var(--font-body);
}

body {
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.9rem + env(safe-area-inset-top)) 1rem 0.9rem;
  background: rgba(247, 250, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(216, 223, 235, 0.7);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--brand-border);
  object-fit: cover;
  box-shadow: var(--shadow-soft);
}

#courseTitle,
.section-head h2,
.hero-copy h2,
.card h3,
.result-card h3,
.toast-card h3,
.sidebar-head h2 {
  margin: 0;
  font-family: var(--font-heading);
}

#courseTitle {
  font-size: 1.1rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-primary);
  font-weight: 700;
}

.ghost-btn,
.primary-btn {
  border: 0;
  border-radius: 999px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.ghost-btn {
  background: #fff;
  color: var(--brand-ink);
  border: 1px solid var(--brand-border);
}

.primary-btn {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  box-shadow: 0 10px 24px rgba(11, 87, 208, 0.22);
}

.ghost-btn:hover,
.primary-btn:hover,
.ghost-btn:focus-visible,
.primary-btn:focus-visible,
.hotspot:hover,
.hotspot:focus-visible,
.step-btn:hover,
.step-btn:focus-visible,
.option-card:hover,
.option-card:focus-within {
  transform: translateY(-1px);
}

.icon-only {
  width: 48px;
  padding-inline: 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(88vw, 340px);
  background: rgba(255, 255, 255, 0.98);
  border-right: 1px solid var(--brand-border);
  padding: 1rem;
  transform: translateX(-105%);
  transition: transform 0.24s ease;
  z-index: 40;
  overflow-y: auto;
  box-shadow: 0 18px 48px rgba(17, 35, 67, 0.16);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.step-nav {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0 1.2rem;
}

.step-btn {
  width: 100%;
  border: 1px solid var(--brand-border);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  text-align: left;
}

.step-btn .step-index {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--brand-surface-soft);
  font-weight: 700;
  color: var(--brand-primary);
}

.step-btn.active {
  border-color: rgba(11, 87, 208, 0.38);
  background: linear-gradient(180deg, rgba(11, 87, 208, 0.08), rgba(27, 179, 169, 0.06));
}

.step-btn.done .step-index {
  background: rgba(22, 121, 74, 0.12);
  color: var(--brand-success);
}

.step-meta strong {
  display: block;
}

.step-meta span {
  display: block;
  font-size: 0.9rem;
  color: var(--brand-muted);
}

.sidebar-card,
.card,
.hero-card,
.status-bar,
.result-card,
.toast-card {
  background: var(--brand-surface);
  border: 1px solid rgba(216, 223, 235, 0.85);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.sidebar-card {
  padding: 1rem;
  margin-bottom: 0.9rem;
}

.sidebar-card.muted {
  background: linear-gradient(180deg, #ffffff, #f7faff);
}

.main-stage {
  padding: 1rem 1rem 5.7rem;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.status-bar {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.status-copy {
  margin: 0;
  color: var(--brand-muted);
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e7edf7;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 14%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  transition: width 0.25s ease;
}

.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  overflow: hidden;
}

.hero-copy h2 {
  font-size: clamp(1.8rem, 4.6vw, 2.7rem);
  line-height: 1.08;
  margin-bottom: 0.75rem;
}

.hero-copy p {
  margin: 0 0 1rem;
}

.hero-illustration {
  width: 100%;
  justify-self: center;
}

.grid {
  display: grid;
  gap: 1rem;
}

.card {
  padding: 1rem;
}

.card p:last-child,
.card ul:last-child,
.card ol:last-child {
  margin-bottom: 0;
}

.card.emphasis {
  background: linear-gradient(180deg, rgba(11, 87, 208, 0.08), rgba(27, 179, 169, 0.08));
}

.section-head {
  margin-bottom: 1rem;
}

.section-head h2 {
  font-size: clamp(1.55rem, 4vw, 2.3rem);
  line-height: 1.1;
  margin-bottom: 0.45rem;
}

.section-head p:last-child {
  margin-bottom: 0;
}

.pill-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.65rem 0.9rem;
  background: rgba(11, 87, 208, 0.08);
  color: var(--brand-primary-strong);
  font-weight: 600;
}

.check-list,
.icon-list,
.process-list {
  margin: 0;
  padding-left: 1.25rem;
}

.icon-list {
  padding-left: 0;
  list-style: none;
}

.icon-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.mini-case {
  margin-top: 1rem;
  border: 1px dashed rgba(11, 87, 208, 0.3);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  background: rgba(11, 87, 208, 0.04);
}

.compact {
  min-height: 100%;
}

.principle-grid {
  grid-template-columns: 1fr;
}

.process-layout {
  align-items: start;
}

.process-list {
  display: grid;
  gap: 0.75rem;
  padding-left: 1.2rem;
}

.illustration-card img {
  width: 100%;
}

.video-shell {
  display: grid;
  gap: 1rem;
}

.video-poster-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--brand-border);
  box-shadow: var(--shadow-soft);
}

.video-poster {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #dfe9f8;
}

.hotspot {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  box-shadow: 0 10px 24px rgba(11, 87, 208, 0.26);
}

.hs-1 { top: 18%; left: 16%; }
.hs-2 { top: 38%; right: 24%; }
.hs-3 { bottom: 16%; left: 48%; }

.note {
  color: var(--brand-muted);
}

.quiz-form {
  display: grid;
  gap: 1rem;
}

.quiz-question {
  border-radius: var(--radius-lg);
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
}

.quiz-question h3 {
  margin: 0 0 0.85rem;
  font-size: 1.02rem;
}

.option-list {
  display: grid;
  gap: 0.7rem;
}

.option-card {
  position: relative;
  display: block;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.95rem 0.85rem 3rem;
  background: #fff;
}

.option-card input {
  position: absolute;
  left: 1rem;
  top: 1rem;
}

.option-card.correct {
  border-color: rgba(22, 121, 74, 0.34);
  background: rgba(22, 121, 74, 0.08);
}

.option-card.incorrect {
  border-color: rgba(180, 35, 24, 0.34);
  background: rgba(180, 35, 24, 0.06);
}

.quiz-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.result-card {
  padding: 1rem;
  margin-top: 1rem;
  display: none;
}

.result-card.show {
  display: block;
}

.result-card.pass {
  border-color: rgba(22, 121, 74, 0.3);
  background: rgba(22, 121, 74, 0.08);
}

.result-card.fail {
  border-color: rgba(180, 35, 24, 0.3);
  background: rgba(180, 35, 24, 0.06);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: rgba(247, 250, 255, 0.94);
  border-top: 1px solid rgba(216, 223, 235, 0.85);
  backdrop-filter: blur(12px);
}

.toast-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

.toast-dialog::backdrop {
  background: rgba(6, 18, 39, 0.42);
}

.toast-card {
  max-width: 420px;
  padding: 1.1rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

@media (min-width: 760px) {
  .hero-card,
  .two-up,
  .video-shell,
  .process-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide-card {
    grid-column: 1 / -1;
  }

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

  .status-bar {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .main-stage {
    padding-bottom: 6.3rem;
  }
}

@media (min-width: 1060px) {
  .app-shell {
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      'topbar topbar'
      'sidebar main'
      'sidebar footer';
  }

  .topbar { grid-area: topbar; }
  .sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 84px;
    transform: none;
    width: auto;
    height: calc(100dvh - 92px);
    z-index: 10;
    box-shadow: none;
    border-right: 1px solid var(--brand-border);
    border-top: 0;
  }

  .main-stage {
    grid-area: main;
    width: 100%;
    max-width: 100%;
    padding: 1rem 1.25rem 7rem;
  }

  .bottom-nav {
    grid-area: footer;
    left: 320px;
    padding-inline: 1.25rem;
  }

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

  .hero-card {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
    padding: 1.3rem;
  }

  .close-desktop-hide,
  #openOverview,
  #closeOverview {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
