:root {
  --bg: #f7f8fb; --bg-2: #ffffff; --fg: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #2563eb; --brand-2: #06b6d4; --ok: #16a34a; --err: #dc2626; --warn: #d97706;
  --code-bg: #0d1117; --card-shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --bg-2: #111831; --fg: #e5e7eb; --muted: #94a3b8; --line: #1f2a44;
    --brand: #60a5fa; --brand-2: #22d3ee; --card-shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 640px; }
.center { text-align: center; padding: 80px 16px; }
.muted { color: var(--muted); }
.inline { display: inline; }
h1, h2, h3 { line-height: 1.25; }
.big { font-size: 5rem; margin: 0; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg-2) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--fg); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 0 12px var(--brand-2); }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { color: var(--fg); font-weight: 500; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; font: 600 15px/1.2 inherit; cursor: pointer; text-decoration: none !important; transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn-danger { background: var(--err); }

/* Flash */
.flashes { margin-top: 16px; }
.flash { padding: 10px 14px; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line); background: var(--bg-2); }
.flash-success { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, var(--bg-2)); }
.flash-error { border-color: color-mix(in srgb, var(--err) 40%, transparent); background: color-mix(in srgb, var(--err) 10%, var(--bg-2)); }

/* Hero */
.hero { padding: 64px 0 40px; background: radial-gradient(1000px 400px at 80% -10%, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent), radial-gradient(800px 400px at 0% 0%, color-mix(in srgb, var(--brand) 14%, transparent), transparent); }
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--brand); }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: 8px 0 16px; letter-spacing: -.02em; }
.grad { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 62ch; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stats b { display: block; font-size: 1.8rem; }
.stats span { color: var(--muted); font-size: 14px; }
.stats-cards { margin: 16px 0; }
.stats-cards .card { flex: 1; min-width: 140px; }
.hero-term pre { background: var(--code-bg); color: #c9d1d9; border-radius: var(--radius); padding: 20px; font-size: 13px; overflow: auto; border: 1px solid #30363d; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.hero-term .c { color: #7ee787; } .hero-term .ok { color: #79c0ff; }
.cursor { animation: blink 1s steps(1) infinite; } @keyframes blink { 50% { opacity: 0; } }

/* Sections & cards */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 40px 0 16px; }
.section-head h1, .section-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-top: 24px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--card-shadow); overflow-wrap: anywhere; }
.card h3 { margin: 10px 0 6px; }
.card p { margin: 6px 0; color: var(--muted); }
.course-card { color: var(--fg); display: flex; flex-direction: column; border-top: 3px solid var(--accent, var(--brand)); transition: transform .15s, box-shadow .15s; text-decoration: none !important; }
.course-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15,23,42,.1); }
.course-card.is-soon { opacity: .75; }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.icon { font-size: 1.8rem; }
.card-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: auto; padding-top: 10px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); white-space: nowrap; }
.badge-soon { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge-ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip-lab { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent, var(--brand)), var(--brand-2)); }
.how { margin: 56px auto; }
.notice { margin: 16px 0; }

/* Course page */
.course-hero { padding: 36px 0 28px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent); }
.course-hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 10px 0; }
.crumb { font-size: 14px; color: var(--muted); }
.course-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 16px; }
.progress-block { min-width: 220px; font-size: 13px; color: var(--muted); }
.module { margin: 28px 0; }
.module-title { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 14px; }
.lesson-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.lesson-list li + li { border-top: 1px solid var(--line); }
.lesson-list a, .lesson-list li > span { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--fg); text-decoration: none; flex-wrap: wrap; }
.lesson-list a:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.lesson-list .soon { opacity: .55; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.lesson-list .done .status-dot { background: var(--ok); border-color: var(--ok); }
.l-title { flex: 1; min-width: 180px; }
.l-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* Lesson page */
.lesson-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; padding-top: 24px; }
.sidebar { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; font-size: 14px; }
.side-nav { display: flex; flex-direction: column; margin-top: 12px; }
.side-mod { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 4px; }
.side-nav a, .side-nav span { padding: 5px 10px; border-radius: 8px; color: var(--fg); border-left: 2px solid transparent; }
.side-nav a.active { background: color-mix(in srgb, var(--brand) 12%, transparent); border-left-color: var(--brand); }
.side-nav a.done::before { content: "✓ "; color: var(--ok); }
.side-nav .soon { opacity: .45; }
.lesson { min-width: 0; padding-bottom: 60px; }
.lesson-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.toc { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; background: var(--bg-2); }
.toc summary { cursor: pointer; font-weight: 600; }
.lesson-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.lab-box { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 28px 0; border-left: 4px solid var(--ok); flex-wrap: wrap; }
.lab-box h2 { margin: 0 0 4px; font-size: 1.2rem; }
.quiz { margin: 28px 0; }
.question { border: 1px solid var(--line); border-radius: 10px; margin: 14px 0; padding: 12px 16px; }
.question legend { font-weight: 600; padding: 0 6px; }
.option { display: block; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.option:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.option.correct { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.option.wrong { background: color-mix(in srgb, var(--err) 15%, transparent); }
.explain { font-size: 14px; color: var(--muted); }

/* Prose (markdown) */
.prose { overflow-wrap: anywhere; }
.prose h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.prose h2 { margin-top: 2.2em; padding-bottom: 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 80px; }
.prose h3 { scroll-margin-top: 80px; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose pre { background: var(--code-bg); color: #c9d1d9; padding: 16px; border-radius: 10px; overflow-x: auto; font-size: 14px; line-height: 1.5; }
.prose pre code { background: none; padding: 0; }
.prose :not(pre) > code { background: color-mix(in srgb, var(--brand) 10%, transparent); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.prose blockquote { margin: 1em 0; padding: 8px 16px; border-left: 4px solid var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); border-radius: 0 10px 10px 0; }
.prose pre.mermaid { background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); text-align: center; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
.prose table, .table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td, .table th, .table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th, .table th { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.small { font-size: 14px; }

/* Auth */
.auth { display: grid; place-items: center; padding: 48px 16px; }
.form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.form h1 { margin: 0 0 6px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.form input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.form input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Lab session */
.lab-layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; height: calc(100vh - 61px); }
.lab-guide { overflow: auto; padding: 16px 20px; border-right: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 12px; }
.lab-guide h1 { font-size: 1.3rem; margin: 6px 0; }
.lab-status { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.lab-term { position: relative; background: #000; }
.lab-term iframe { width: 100%; height: 100%; border: 0; display: block; }
.term-placeholder { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #c9d1d9; padding: 24px; gap: 16px; justify-items: center; }
.spinner { width: 42px; height: 42px; border: 4px solid #30363d; border-top-color: var(--brand-2); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--line); }
.pill-running { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.pill-provisioning { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill-error { background: color-mix(in srgb, var(--err) 20%, transparent); color: var(--err); }
.checks ul { list-style: none; padding: 0; margin: 8px 0 12px; }
.checks li { padding: 4px 0; font-size: 14px; }
.checks li.ok .mark { color: var(--ok); }
.checks li.fail .mark { color: var(--err); }

.footer { border-top: 1px solid var(--line); margin-top: 60px; padding: 24px 0; font-size: 14px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .hero-inner, .lesson-layout { grid-template-columns: 1fr; }
  .hero-term { display: none; }
  .sidebar { position: static; max-height: none; }
  .side-nav { display: none; }
  .lab-layout { grid-template-columns: 1fr; height: auto; }
  .lab-term { height: 70vh; }
  .nav { gap: 10px; font-size: 14px; }
}
