:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #edf5f2;
  --ink: #17252d;
  --muted: #586872;
  --accent: #126b5d;
  --accent-strong: #0c5046;
  --accent-contrast: #ffffff;
  --line: #d8e0e4;
  --line-strong: #b8c8cd;
  --code-bg: #142129;
  --code-ink: #edf6f3;
  --high: #9c342d;
  --high-bg: #fff0ed;
  --medium: #765408;
  --medium-bg: #fff5d9;
  --focus: #b34b00;
  --shadow: 0 16px 44px rgb(23 37 45 / 8%);
  --radius: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10171b;
  --surface: #172126;
  --surface-raised: #1c282e;
  --surface-soft: #19332f;
  --ink: #e7eeef;
  --muted: #adbec3;
  --accent: #72cfba;
  --accent-strong: #9bdfcf;
  --accent-contrast: #0c3029;
  --line: #34444b;
  --line-strong: #52676f;
  --code-bg: #0b1216;
  --code-ink: #e6f2ee;
  --high: #ffaaa0;
  --high-bg: #412622;
  --medium: #efd17a;
  --medium-bg: #392f19;
  --focus: #ffc06b;
  --shadow: 0 16px 44px rgb(0 0 0 / 22%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

button,
input {
  font: inherit;
}

button,
a,
input,
summary {
  -webkit-tap-highlight-color: transparent;
}

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

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1080px, calc(100% - 48px));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.site-header .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding-block: 12px;
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.site-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent);
}

.theme-toggle,
.copy-code {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.theme-toggle {
  min-height: 40px;
  padding: 7px 12px;
  font-size: 14px;
}

.theme-toggle:hover,
.copy-code:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-hero,
.lesson-hero {
  margin-block: 36px 28px;
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-soft), var(--surface) 68%);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.25;
}

h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(32px, 5.5vw, 52px);
  letter-spacing: -0.04em;
}

h2 {
  margin: 0 0 16px;
  font-size: clamp(23px, 3vw, 29px);
  letter-spacing: -0.025em;
}

h3 {
  margin: 26px 0 10px;
  font-size: 19px;
}

p {
  margin: 10px 0;
}

.lead {
  max-width: 790px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 20px);
}

.hero-meta,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

.tag.priority-a {
  border-color: transparent;
  background: var(--high-bg);
  color: var(--high);
}

.tag.priority-b {
  border-color: transparent;
  background: var(--medium-bg);
  color: var(--medium);
}

.breadcrumbs {
  margin-top: 26px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 6px;
  color: var(--line-strong);
}

.guide-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
  margin-bottom: 30px;
}

.guide-card,
.filter-panel,
.lesson-section,
.objectives {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.guide-card {
  padding: 24px 26px;
}

.guide-card h2 {
  font-size: 21px;
}

.guide-card ol,
.guide-card ul {
  margin: 10px 0 0;
  padding-left: 22px;
}

.guide-card li + li {
  margin-top: 7px;
}

.priority-list {
  list-style: none;
  padding-left: 0 !important;
}

.priority-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
}

.filter-panel {
  margin: 0 0 24px;
  padding: 22px 24px;
}

.filter-panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 750;
}

.filter-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--ink);
}

.filter-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.filter-status {
  min-height: 1.65em;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.filter-empty {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.topics-grid > li {
  min-width: 0;
}

.topic-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.topic-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.topic-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.topic-number {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topic-card h2 {
  margin: 0 0 10px;
  font-size: 21px;
}

.topic-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.topic-card-link {
  margin-top: auto;
  font-weight: 750;
}

.source-links {
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.source-links p {
  margin: 6px 0;
}

.lesson {
  padding-bottom: 12px;
}

.lesson-hero {
  margin-top: 24px;
}

.lesson-hero h1 {
  font-size: clamp(30px, 5vw, 46px);
}

.lesson-section,
.objectives {
  margin: 20px 0;
  padding: clamp(22px, 4vw, 36px);
}

.lesson-section > :last-child,
.objectives > :last-child {
  margin-bottom: 0;
}

.objectives {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: var(--surface-soft);
}

.objectives ul,
.checklist {
  margin: 10px 0 0;
  padding-left: 23px;
}

.objectives li,
.checklist li,
.lesson-section li {
  margin: 7px 0;
  padding-left: 3px;
}

li::marker {
  color: var(--accent);
}

.lesson-toc {
  margin: 20px 0;
  padding: 20px 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.lesson-toc h2 {
  margin-bottom: 10px;
  font-size: 19px;
}

.lesson-toc ol {
  columns: 2;
  column-gap: 36px;
  margin: 0;
  padding-left: 22px;
}

.lesson-toc li {
  margin: 5px 0;
  break-inside: avoid;
}

.callout {
  margin: 20px 0;
  padding: 17px 20px;
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface-soft);
}

.callout > :first-child {
  margin-top: 0;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout-title {
  color: var(--ink);
  font-weight: 800;
}

.callout.warning {
  border-left-color: var(--medium);
  background: var(--medium-bg);
}

.code-example {
  position: relative;
  margin: 24px 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--code-ink);
}

.code-example figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid rgb(255 255 255 / 15%);
  color: var(--code-ink);
  font-size: 14px;
  font-weight: 700;
}

.code-example pre {
  max-width: 100%;
  margin: 0;
  padding: 20px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  tab-size: 4;
}

.code-example code {
  font: 14px/1.65 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color: inherit;
  white-space: pre;
}

.copy-code {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 5px 10px;
  border-color: rgb(255 255 255 / 35%);
  background: transparent;
  color: var(--code-ink);
  font-size: 12px;
}

.copy-code:hover {
  border-color: var(--code-ink);
  color: var(--code-ink);
}

.copy-code:disabled {
  cursor: wait;
  opacity: 0.75;
}

.copy-code[data-state="success"] {
  border-color: #72cfba;
}

.copy-code[data-state="error"] {
  border-color: #ffaaa0;
}

.example-analysis {
  margin-top: -8px;
  font-size: 15px;
}

.example-analysis strong {
  color: var(--ink);
}

.question {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-raised);
}

.question summary {
  padding: 16px 48px 16px 18px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
}

.question[open] summary {
  border-bottom: 1px solid var(--line);
  border-radius: 11px 11px 0 0;
}

.question-answer {
  padding: 6px 18px 16px;
  color: var(--muted);
}

.question-answer p {
  margin: 10px 0 0;
}

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

.checklist li {
  position: relative;
  padding-left: 30px;
}

.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 900;
}

.table-wrap {
  max-width: 100%;
  margin: 20px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 15px;
}

th,
td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--ink);
}

tr:last-child td {
  border-bottom: 0;
}

code:not(.code-example code) {
  padding: 0.12em 0.32em;
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font: 0.9em/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 30px 0;
}

.pager-link {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
}

.pager-link:last-child {
  text-align: right;
}

.pager-link:hover {
  border-color: var(--accent);
}

.pager-direction {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.pager-title {
  display: block;
  margin-top: 4px;
  font-weight: 750;
}

.site-footer {
  padding: 24px 0 38px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.site-footer p {
  margin: 5px 0;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 28px, 1080px);
  }

  .site-header .shell {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .page-hero,
  .lesson-hero {
    margin-top: 22px;
  }

  .guide-grid,
  .topics-grid {
    grid-template-columns: 1fr;
  }

  .lesson-toc ol {
    columns: 1;
  }

  .code-example figcaption {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .copy-code {
    align-self: flex-end;
  }
}

@media (max-width: 480px) {
  .shell {
    width: min(100% - 20px, 1080px);
  }

  .page-hero,
  .lesson-hero,
  .guide-card,
  .filter-panel,
  .lesson-section,
  .objectives {
    padding: 22px 18px;
  }

  .topic-card {
    padding: 20px 18px;
  }

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

  .pager-link:last-child {
    text-align: left;
  }

  .code-example pre {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

@media print {
  @page {
    margin: 15mm;
  }

  :root,
  [data-theme="dark"] {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-soft: #ffffff;
    --ink: #000000;
    --muted: #333333;
    --accent: #000000;
    --accent-strong: #000000;
    --line: #bbbbbb;
    --line-strong: #888888;
    --code-bg: #f4f4f4;
    --code-ink: #000000;
    --high: #7f211c;
    --high-bg: #fff0ed;
    --medium: #5c4300;
    --medium-bg: #fff4d6;
    --shadow: none;
  }

  body {
    background: #ffffff;
    font-size: 10.5pt;
  }

  .shell {
    width: 100%;
  }

  .skip-link,
  .site-header,
  .filter-panel,
  .copy-code,
  .pager,
  .lesson-toc {
    display: none !important;
  }

  .page-hero,
  .lesson-hero,
  .guide-card,
  .topic-card,
  .lesson-section,
  .objectives {
    padding: 14px 0;
    border: 0;
    border-bottom: 1px solid #bbbbbb;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  .page-hero,
  .lesson-hero {
    margin: 0 0 16px;
  }

  .topics-grid {
    display: block;
  }

  .topic-card {
    break-inside: avoid;
  }

  .lesson-section,
  .objectives {
    margin: 0;
  }

  h1 {
    font-size: 25pt;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  .question {
    break-inside: avoid;
  }

  .question::details-content {
    display: block !important;
    content-visibility: visible !important;
  }

  .question:not([open]) > .question-answer {
    display: block !important;
  }

  .code-example {
    break-inside: avoid;
    border-color: #aaaaaa;
  }

  .code-example pre {
    overflow: visible;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .code-example code {
    white-space: pre-wrap;
  }

  .table-wrap {
    overflow: visible;
  }

  a {
    color: inherit;
  }

  .site-footer {
    padding-bottom: 0;
  }
}
