:root {
  --bg: #ffffff;
  --bg-elev: #f7f9fc;
  --bg-code: #0f172a;
  --text: #1e293b;
  --text-muted: #475569;
  --border: #e2e8f0;
  --primary: #0db7ed;
  --primary-dark: #0a8fbf;
  --primary-soft: #e0f5fc;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --code-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --max-width: 1200px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --bg-code: #020617;
  --text: #e2e8f0;
  --text-muted: #cbd5e1;
  --border: #334155;
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --primary-soft: #0c4a6e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
  background-color: color-mix(in srgb, var(--bg) 85%, transparent);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
  color: var(--primary);
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--bg-elev);
  border-color: var(--primary);
}

.hero {
  padding: 4rem 0 3rem;
  text-align: center;
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--bg) 100%);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 auto 1.5rem;
}

.hero-cta {
  display: inline-flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
  color: #fff;
}

.btn-outline {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

main {
  padding: 3rem 0;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
}

.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.module-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}

.module-card:hover::before {
  transform: scaleX(1);
}

.module-card .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.module-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.module-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  flex: 1;
  margin-bottom: 1rem;
}

.module-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.module-card.completed .num {
  background: var(--success);
  color: #fff;
}

.module-card.completed::before {
  transform: scaleX(1);
  background: var(--success);
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 3rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 1rem;
}

.sidebar h4 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.sidebar ul {
  list-style: none;
  border-left: 2px solid var(--border);
}

.sidebar li {
  margin-left: -2px;
}

.sidebar a {
  display: block;
  padding: 0.4rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  border-left: 2px solid transparent;
  margin-left: 2px;
  transition: all 0.15s ease;
}

.sidebar a:hover {
  color: var(--primary);
  text-decoration: none;
}

.sidebar a.active {
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

.content {
  min-width: 0;
}

.content h1 {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.content > p.lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.content h1,
.content h2,
.content h3,
.content > p.lead {
  max-width: 65ch;
}

.content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: 88px;
}

.content h2:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 88px;
}

.content p {
  margin-bottom: 1.25rem;
}

.content ul, .content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.content li {
  margin-bottom: 0.6rem;
}

.content p,
.content ul,
.content ol,
.content pre,
.content table {
  max-width: 65ch;
}

pre {
  position: relative;
  background: var(--bg-code);
  color: var(--code-text);
  padding: 1.25rem 1.4rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 1rem 0;
}

pre code {
  font-family: inherit;
  background: none;
  padding: 0;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--code-text);
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.copy-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

code {
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  background: var(--bg-elev);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--text);
  border: 1px solid var(--border);
}

p code, li code, td code {
  font-size: 0.9em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 1rem;
}

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

th {
  background: var(--bg-elev);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

tr:hover td {
  background: var(--bg-elev);
}

.alert {
  padding: 1rem 1.15rem;
  border-radius: 8px;
  border-left: 4px solid;
  margin: 1.25rem 0;
  background: var(--bg-elev);
}

.alert-info {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--text);
}

.alert-warning {
  border-color: var(--warning);
}

.alert-danger {
  border-color: var(--danger);
}

.alert strong {
  display: block;
  margin-bottom: 0.25rem;
}

.module-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.module-nav .btn {
  min-width: 200px;
}

.module-nav .btn-next {
  margin-left: auto;
}

.progress-bar {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 49;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.25s ease;
}

.completion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 2rem 0;
}

.completion label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-weight: 500;
}

.completion input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
}

.quiz-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}

.quiz-card .qcount {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.quiz-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.quiz-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.quiz-card .score {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 600;
}

.quiz-container {
  max-width: 720px;
  margin: 0 auto;
}

.quiz-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quiz-progress .dots {
  display: flex;
  gap: 0.4rem;
}

.quiz-progress .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s ease;
}

.quiz-progress .dot.answered {
  background: var(--primary);
}

.quiz-progress .dot.correct {
  background: var(--success);
}

.quiz-progress .dot.wrong {
  background: var(--danger);
}

.quiz-question {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.quiz-question h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.95rem;
}

.quiz-option:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.quiz-option input {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.quiz-option.disabled {
  cursor: not-allowed;
}

.quiz-option.correct {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, var(--bg));
}

.quiz-option.wrong {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--bg));
}

.quiz-feedback {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  border-left: 4px solid;
  font-size: 0.92rem;
  display: none;
}

.quiz-feedback.show {
  display: block;
}

.quiz-feedback.correct {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, var(--bg-elev));
}

.quiz-feedback.wrong {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--bg-elev));
}

.quiz-feedback strong {
  display: block;
  margin-bottom: 0.25rem;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.quiz-result {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.quiz-result .score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.quiz-result h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  border: none;
  padding: 0;
}

.quiz-result p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
  .layout > * {
    min-width: 0;
  }
  .sidebar {
    position: static;
    max-height: none;
    padding: 1rem;
    background: var(--bg-elev);
    border-radius: 8px;
    border: 1px solid var(--border);
  }
  .sidebar ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-left: none;
  }
  .sidebar li {
    margin-left: 0;
    min-width: 0;
  }
  .sidebar a {
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 4px;
    margin-left: 0;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
  }
  .sidebar a.active {
    border-left: none;
    border-bottom-color: var(--primary);
  }
  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 600px) {
  .container { padding: 0 1rem; }
  .hero { padding: 2.5rem 0 2rem; }
  .content h1 { font-size: 1.75rem; }
  .content h2 { font-size: 1.35rem; }
  .module-nav .btn { min-width: 0; flex: 1; }
  .nav-toggle { display: inline-flex; }
  .site-header nav { display: none; }
  .site-header nav.open { display: block; position: absolute; top: 64px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 1rem; }
  .site-header nav.open ul { display: flex; flex-direction: column; gap: 0.5rem; }
  .completion {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .completion .btn {
    width: 100%;
    text-align: center;
  }
  .module-nav {
    flex-direction: column;
  }
  .module-nav .btn {
    width: 100%;
    min-width: 0;
  }
  .module-nav .btn-next {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 0.875rem; }
  .content h2 { font-size: 1.2rem; }
  .content h3 { font-size: 1.05rem; }
  .content > p.lead { font-size: 1rem; }
  .module-card { padding: 1.15rem; }
  .module-card .num { width: 30px; height: 30px; font-size: 0.85rem; }
  .module-card h3 { font-size: 1.05rem; }
  .alert { padding: 0.85rem 1rem; }
  pre { font-size: 0.8rem; padding: 0.9rem 1rem; }
  .quiz-question { padding: 1.25rem; }
  .quiz-question h2 { font-size: 1.05rem; }
  .quiz-option { padding: 0.85rem 1rem; font-size: 0.9rem; }
  .quiz-result { padding: 2rem 1.25rem; }
  .quiz-result .score-circle { width: 110px; height: 110px; font-size: 2rem; }
  .breadcrumb { font-size: 0.8rem !important; }
}

@media (max-width: 380px) {
  .brand-text { display: none; }
}

.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s 0.25s, background 0.15s;
  z-index: 40;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s, background 0.15s;
}
.back-to-top:hover {
  background: var(--primary-dark);
}
@media (max-width: 600px) {
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}
