:root {
  color-scheme: light dark;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #17202a;
  --muted: #5f6f7f;
  --line: #d8e0e8;
  --accent: #0b6bcb;
  --accent-strong: #07559f;
  --accent-soft: #e8f3ff;
  --success: #176b3a;
  --warning: #8a4b08;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --shadow: 0 10px 32px rgba(31, 50, 75, 0.08);
  --radius: 16px;
  --sidebar: 320px;
  --content: 980px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #141b23;
    --surface-2: #1b2530;
    --text: #edf3f8;
    --muted: #a9b7c5;
    --line: #2b3947;
    --accent: #67b3ff;
    --accent-strong: #93caff;
    --accent-soft: #112d49;
    --success: #80d49e;
    --warning: #f1bc77;
    --shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

button, input { font: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 1000;
  background: var(--surface);
  color: var(--text);
  padding: .65rem 1rem;
  border: 2px solid var(--accent);
  border-radius: 10px;
}
.skip-link:focus { top: 1rem; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 1.25rem 1rem 2rem;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .35rem .45rem 1rem;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: -.04em;
}
.brand-title { font-weight: 800; line-height: 1.15; }
.brand-subtitle { color: var(--muted); font-size: .82rem; }

.search-wrap { margin: .2rem .35rem 1rem; }
.search-wrap label {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .35rem;
}
#lesson-search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: .65rem .75rem;
  outline: none;
}
#lesson-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.nav-section { margin: .8rem 0 1rem; }
.nav-section-title {
  padding: .35rem .55rem;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.nav-link {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: .35rem;
  align-items: start;
  color: var(--text);
  text-decoration: none;
  border-radius: 9px;
  padding: .48rem .55rem;
  margin: .08rem 0;
  font-size: .88rem;
  line-height: 1.3;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[hidden] { display: none !important; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.nav-id { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.nav-link.active .nav-id { color: inherit; }

.main { min-width: 0; }
.mobile-bar { display: none; }
.content { max-width: var(--content); margin: 0 auto; padding: 3rem 2.5rem 8rem; }

.hero {
  padding: 2.2rem;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow);
  border-radius: 22px;
  margin-bottom: 2.2rem;
}
.eyebrow {
  display: inline-block;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: .25rem .65rem;
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.03; margin: .8rem 0 1rem; letter-spacing: -.04em; }
.hero p { font-size: 1.08rem; max-width: 72ch; color: var(--muted); margin: .45rem 0; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: 1.5rem; }
.metric { padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metric strong { display: block; font-size: 1.3rem; }
.metric span { color: var(--muted); font-size: .84rem; }

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 12px 12px 0;
  padding: 1rem 1.2rem;
  margin: 1.25rem 0;
}
.callout p { margin: .2rem 0; }

.schema-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; margin: 1.4rem 0; }
.schema-card { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 1rem 1.1rem; }
.schema-card code { font-weight: 800; color: var(--accent-strong); }
.schema-card p { margin: .25rem 0 0; color: var(--muted); font-size: .92rem; }

.module { margin-top: 3.5rem; scroll-margin-top: 1rem; }
.module-heading { margin-bottom: 1.4rem; }
.module-heading h2 { font-size: 1.8rem; margin: 0; letter-spacing: -.02em; }
.module-heading p { color: var(--muted); margin: .35rem 0 0; }

.lesson {
  scroll-margin-top: 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.55rem;
  margin: 1.2rem 0;
}
.lesson[hidden] { display: none !important; }
.lesson-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.lesson-number { color: var(--accent-strong); font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.lesson h3 { font-size: 1.45rem; line-height: 1.2; margin: .2rem 0 .35rem; letter-spacing: -.015em; }
.objective { color: var(--muted); margin: 0 0 .65rem; }
.tags { display: flex; gap: .4rem; flex-wrap: wrap; margin: .65rem 0 0; }
.tag { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: .18rem .55rem; font-size: .78rem; font-weight: 700; }

.question-box { margin: 1.2rem 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.question-box strong { display: block; margin-bottom: .25rem; }
.question-box p { margin: 0; }

.lesson h4 { margin: 1.25rem 0 .5rem; font-size: 1rem; }
.lesson p { margin: .45rem 0; }
.lesson ul { margin: .45rem 0; padding-left: 1.35rem; }
.lesson li { margin: .25rem 0; }

.code-shell { border-radius: 13px; overflow: hidden; background: var(--code-bg); border: 1px solid #263241; margin: .75rem 0 1rem; }
.code-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem .75rem; border-bottom: 1px solid #263241; color: #a9b7c6; font-size: .78rem; }
.copy-button {
  border: 1px solid #3a4959;
  background: #17212b;
  color: #e6edf3;
  border-radius: 8px;
  padding: .3rem .58rem;
  cursor: pointer;
}
.copy-button:hover, .copy-button:focus-visible { background: #21303e; outline: 2px solid #67b3ff; outline-offset: 2px; }
.highlight { margin: 0; padding: 1rem; overflow-x: auto; color: var(--code-text); font: 500 .91rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.highlight pre { margin: 0; white-space: pre; }

.result-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: .75rem 0 1rem; }
.result-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .65rem .8rem; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .85rem; }
.result-status { color: var(--success); font-weight: 750; }
.result-scroll { overflow-x: auto; }
.result-table { width: 100%; border-collapse: collapse; font-size: .84rem; white-space: nowrap; }
.result-table th, .result-table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.result-table th { background: var(--surface); font-weight: 800; }
.result-table tr:last-child td { border-bottom: 0; }
.null { color: var(--muted); font-style: italic; }
.preview-note { color: var(--muted); font-size: .82rem; }
.result-unavailable { padding: 1rem; color: var(--muted); }

.expected-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: .8rem; }
.expected-card { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; background: var(--bg); }
.expected-card strong { display: block; margin-bottom: .25rem; }
.expected-card p { margin: 0; color: var(--muted); }
.watchout { border-left: 4px solid var(--warning); background: var(--surface-2);
  background: color-mix(in srgb, var(--warning) 9%, var(--surface)); border-radius: 0 10px 10px 0; padding: .8rem 1rem; margin-top: .9rem; }
.watchout strong { color: var(--warning); }

.footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.no-results { display: none; border: 1px dashed var(--line); border-radius: 12px; padding: 1rem; color: var(--muted); }
.no-results.visible { display: block; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 340px);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem 1rem;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .menu-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; padding: .45rem .7rem; cursor: pointer; }
  .mobile-title { font-weight: 800; }
  .content { padding: 1.4rem 1rem 5rem; }
  .hero { padding: 1.35rem; border-radius: 16px; }
  .hero-grid, .schema-grid, .expected-grid { grid-template-columns: 1fr; }
  .lesson { padding: 1.1rem; }
  .lesson, .module { scroll-margin-top: 5rem; }
}

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

@media print {
  .sidebar, .mobile-bar, .copy-button { display: none !important; }
  .layout { display: block; }
  .content { max-width: none; padding: 0; }
  .lesson { box-shadow: none; break-inside: avoid; }
  .hero { box-shadow: none; }
}

.copy-fallback {
  position: fixed;
  inset: 0 auto auto 0;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}



/* Pygments SQL token colors */
pre { line-height: 125%; }
td.linenos .normal { color: #6e7681; background-color: #0d1117; padding-left: 5px; padding-right: 5px; }
span.linenos { color: #6e7681; background-color: #0d1117; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #e6edf3; background-color: #6e7681; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #e6edf3; background-color: #6e7681; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #6e7681 }
.highlight { background: #0d1117; color: #E6EDF3 }
.highlight .c { color: #8B949E; font-style: italic } /* Comment */
.highlight .err { color: #F85149 } /* Error */
.highlight .esc { color: #E6EDF3 } /* Escape */
.highlight .g { color: #E6EDF3 } /* Generic */
.highlight .k { color: #FF7B72 } /* Keyword */
.highlight .l { color: #A5D6FF } /* Literal */
.highlight .n { color: #E6EDF3 } /* Name */
.highlight .o { color: #FF7B72; font-weight: bold } /* Operator */
.highlight .x { color: #E6EDF3 } /* Other */
.highlight .p { color: #E6EDF3 } /* Punctuation */
.highlight .ch { color: #8B949E; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #8B949E; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #8B949E; font-weight: bold; font-style: italic } /* Comment.Preproc */
.highlight .cpf { color: #8B949E; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #8B949E; font-style: italic } /* Comment.Single */
.highlight .cs { color: #8B949E; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { color: #FFA198; background-color: #490202 } /* Generic.Deleted */
.highlight .ge { color: #E6EDF3; font-style: italic } /* Generic.Emph */
.highlight .ges { color: #E6EDF3; font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #FFA198 } /* Generic.Error */
.highlight .gh { color: #79C0FF; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #56D364; background-color: #0F5323 } /* Generic.Inserted */
.highlight .go { color: #8B949E } /* Generic.Output */
.highlight .gp { color: #8B949E } /* Generic.Prompt */
.highlight .gs { color: #E6EDF3; font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #79C0FF } /* Generic.Subheading */
.highlight .gt { color: #FF7B72 } /* Generic.Traceback */
.highlight .g-Underline { color: #E6EDF3; text-decoration: underline } /* Generic.Underline */
.highlight .kc { color: #79C0FF } /* Keyword.Constant */
.highlight .kd { color: #FF7B72 } /* Keyword.Declaration */
.highlight .kn { color: #FF7B72 } /* Keyword.Namespace */
.highlight .kp { color: #79C0FF } /* Keyword.Pseudo */
.highlight .kr { color: #FF7B72 } /* Keyword.Reserved */
.highlight .kt { color: #FF7B72 } /* Keyword.Type */
.highlight .ld { color: #79C0FF } /* Literal.Date */
.highlight .m { color: #A5D6FF } /* Literal.Number */
.highlight .s { color: #A5D6FF } /* Literal.String */
.highlight .na { color: #E6EDF3 } /* Name.Attribute */
.highlight .nb { color: #E6EDF3 } /* Name.Builtin */
.highlight .nc { color: #F0883E; font-weight: bold } /* Name.Class */
.highlight .no { color: #79C0FF; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #D2A8FF; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #FFA657 } /* Name.Entity */
.highlight .ne { color: #F0883E; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #D2A8FF; font-weight: bold } /* Name.Function */
.highlight .nl { color: #79C0FF; font-weight: bold } /* Name.Label */
.highlight .nn { color: #FF7B72 } /* Name.Namespace */
.highlight .nx { color: #E6EDF3 } /* Name.Other */
.highlight .py { color: #79C0FF } /* Name.Property */
.highlight .nt { color: #7EE787 } /* Name.Tag */
.highlight .nv { color: #79C0FF } /* Name.Variable */
.highlight .ow { color: #FF7B72; font-weight: bold } /* Operator.Word */
.highlight .pm { color: #E6EDF3 } /* Punctuation.Marker */
.highlight .w { color: #6E7681 } /* Text.Whitespace */
.highlight .mb { color: #A5D6FF } /* Literal.Number.Bin */
.highlight .mf { color: #A5D6FF } /* Literal.Number.Float */
.highlight .mh { color: #A5D6FF } /* Literal.Number.Hex */
.highlight .mi { color: #A5D6FF } /* Literal.Number.Integer */
.highlight .mo { color: #A5D6FF } /* Literal.Number.Oct */
.highlight .sa { color: #79C0FF } /* Literal.String.Affix */
.highlight .sb { color: #A5D6FF } /* Literal.String.Backtick */
.highlight .sc { color: #A5D6FF } /* Literal.String.Char */
.highlight .dl { color: #79C0FF } /* Literal.String.Delimiter */
.highlight .sd { color: #A5D6FF } /* Literal.String.Doc */
.highlight .s2 { color: #A5D6FF } /* Literal.String.Double */
.highlight .se { color: #79C0FF } /* Literal.String.Escape */
.highlight .sh { color: #79C0FF } /* Literal.String.Heredoc */
.highlight .si { color: #A5D6FF } /* Literal.String.Interpol */
.highlight .sx { color: #A5D6FF } /* Literal.String.Other */
.highlight .sr { color: #79C0FF } /* Literal.String.Regex */
.highlight .s1 { color: #A5D6FF } /* Literal.String.Single */
.highlight .ss { color: #A5D6FF } /* Literal.String.Symbol */
.highlight .bp { color: #E6EDF3 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #D2A8FF; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #79C0FF } /* Name.Variable.Class */
.highlight .vg { color: #79C0FF } /* Name.Variable.Global */
.highlight .vi { color: #79C0FF } /* Name.Variable.Instance */
.highlight .vm { color: #79C0FF } /* Name.Variable.Magic */
.highlight .il { color: #A5D6FF } /* Literal.Number.Integer.Long */
