:root {
  color-scheme: light dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  line-height: 1.65;
  --paper: #faf4e6;
  --sheet: #fffdf7;
  --ink: #202842;
  --muted: #39465a;
  --rule: #c9bea2;
  --blue: #183677;
  --blue-soft: #e2edff;
  --yellow: #ffd268;
  --mono: Consolas, "Liberation Mono", monospace;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 88% 3%, #e4edff 0, transparent 25rem),
    var(--paper);
  color: var(--ink);
  font-size: 1.125rem;
}

a {
  color: var(--blue);
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.16em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

:focus-visible {
  outline: 3px solid #5a2d91;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  transform: translateY(-180%);
  border: 2px solid var(--ink);
  border-radius: 0.4rem;
  background: var(--yellow);
  color: #161c2b;
  font-weight: 700;
}

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

.guide-shell {
  width: min(1160px, 100%);
  margin-inline: auto;
  padding: 0 clamp(1rem, 4vw, 3.25rem);
}

.guide-masthead {
  display: flex;
  min-height: 5rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
}

.guide-brand {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  align-items: center;
}

.guide-nav a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-size: 1rem;
  font-weight: 650;
}

.guide-hero {
  padding: clamp(2.5rem, 7vw, 5.5rem) 0 3rem;
}

.guide-hero h1,
.guide-article > h1 {
  max-width: 18ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.guide-hero > p {
  max-width: 62ch;
  margin-block: 1.2rem 1.7rem;
  color: var(--muted);
  font-size: clamp(1.15rem, 2vw, 1.35rem);
}

.guide-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.guide-switch {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border: 2px solid var(--blue);
  border-radius: 0.5rem;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
}

.guide-switch:hover {
  background: #10285b;
  color: #fff;
}

.guide-section {
  margin-block: 2.5rem;
}

.guide-section > h2,
.guide-example h2 {
  margin: 0 0 0.75rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3vw, 2rem);
  line-height: 1.2;
}

.guide-section > p {
  max-width: 72ch;
  color: var(--muted);
}

.guide-paths,
.guide-results,
.guide-groups {
  padding: 0;
  list-style: none;
}

.guide-paths {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 0.9rem;
  counter-reset: lesson;
}

.guide-card,
.guide-group,
.guide-results li {
  min-width: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 0.7rem;
  background: var(--sheet);
}

.guide-card {
  counter-increment: lesson;
}

.guide-card::before {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--blue);
  content: "Lesson " counter(lesson);
  font-size: 0.92rem;
  font-weight: 750;
}

.guide-card h3,
.guide-results h2,
.guide-results h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.35;
}

.guide-card p,
.guide-results p {
  margin: 0.55rem 0 0;
  color: var(--muted);
}

.guide-track,
.guide-course-progress,
.guide-check {
  padding: clamp(0.85rem, 3vw, 1.35rem);
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  background: var(--sheet);
}

.guide-track {
  margin-block: 0.7rem;
}

.guide-track summary {
  min-height: 44px;
  padding-block: 0.25rem;
  color: var(--blue);
  font-size: 1.2rem;
  font-weight: 750;
  cursor: pointer;
}

.guide-track p {
  margin-block: 0.5rem;
}

.guide-course-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  justify-content: space-between;
  background: var(--blue-soft);
}

.guide-course-progress p {
  margin: 0;
}

.guide-passed {
  display: inline-block;
  margin-top: 0.45rem;
  font-weight: 750;
}

.guide-check fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.guide-check legend {
  margin-bottom: 0.6rem;
  padding: 0;
  font-weight: 700;
}

.guide-choice {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.45rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.45rem;
  cursor: pointer;
}

.guide-choice:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.guide-check button {
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

[data-check-feedback]:empty {
  display: none;
}

.guide-plan-form {
  display: grid;
  gap: 0.65rem;
}

.guide-plan-form label,
#plan-steps label {
  font-weight: 750;
}

.guide-plan-form input,
.guide-plan-form textarea,
#plan-steps select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}

.guide-plan-form textarea,
#plan-query pre {
  font-family: var(--mono);
}

.guide-plan-form textarea {
  resize: vertical;
}

.guide-plan-form .guide-switch {
  justify-self: start;
}

#plan-steps select {
  margin-bottom: 0.75rem;
}

.guide-plan-buttons button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.guide-plan-clear {
  min-height: 44px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  background: var(--sheet);
  color: var(--blue);
}

#plan-operator h4 {
  margin-bottom: 0.4rem;
}

.guide-plan-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-plan-links button {
  width: 100%;
  min-height: 44px;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  background: var(--blue-soft);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#plan-query pre {
  overflow-x: auto;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
}

.guide-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0.7rem;
}

.guide-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.guide-chip {
  flex: none;
  min-width: 2.5rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 99px;
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
  text-align: center;
}

.guide-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem 0.8rem;
  max-width: 48rem;
  margin-block: 1.4rem;
}

.guide-search label {
  grid-column: 1 / -1;
  font-weight: 700;
}

.guide-search input {
  min-width: 0;
  min-height: 48px;
  padding: 0.6rem 0.75rem;
  border: 2px solid #536078;
  border-radius: 0.4rem;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}

.guide-search button {
  min-width: 6.5rem;
  min-height: 48px;
  padding: 0.6rem 1rem;
  border: 2px solid var(--blue);
  border-radius: 0.4rem;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.guide-search button:disabled {
  cursor: wait;
}

#guide-search-status {
  min-height: 1.7em;
  color: var(--muted);
}

.guide-results {
  display: grid;
  gap: 0.75rem;
}

.guide-results li > a {
  font-weight: 750;
}

.guide-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-block: 1.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.guide-article {
  max-width: 78ch;
  padding-block: 1rem 3rem;
}

.guide-article > h1 {
  font-size: clamp(2.2rem, 6vw, 3.7rem);
}

.guide-meta {
  margin-block: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.guide-article > p {
  max-width: 72ch;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 0.75rem;
}

.guide-grid > div {
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--blue);
  background: var(--sheet);
}

.guide-grid dt {
  font-weight: 750;
}

.guide-grid dd {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.guide-prose {
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  background: var(--sheet);
}

.guide-prose h2 {
  margin-top: 1.4rem;
}

.guide-prose h2:first-child {
  margin-top: 0;
}

.guide-prose h3 {
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}

.guide-example {
  margin-block: 1.5rem;
  padding: clamp(1rem, 3vw, 1.4rem);
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  background: var(--sheet);
}

.guide-example .guide-actions {
  justify-content: space-between;
}

.guide-example .guide-actions h2 {
  margin: 0;
}

.guide-example pre {
  max-width: 100%;
  margin: 1rem 0 0;
  padding: 1rem;
  overflow: auto;
  border-radius: 0.5rem;
  background: #162034;
  color: #fff;
  font: 1rem/1.55 var(--mono);
  tab-size: 4;
}

.guide-example code {
  font: inherit;
}

.guide-note {
  padding: 1rem;
  border-left: 4px solid #8a5b00;
  background: var(--yellow);
  color: #201700;
}

.guide-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111827;
    --sheet: #1f2937;
    --ink: #f9fafb;
    --muted: #e5e7eb;
    --rule: #566276;
    --blue: #a9c7ff;
    --blue-soft: #263b5d;
    --yellow: #fbbf24;
  }

  body {
    background:
      radial-gradient(ellipse at 88% 3%, #263b5d 0, transparent 25rem),
      var(--paper);
  }

  .guide-switch,
  .guide-search button {
    border-color: #a9c7ff;
    background: #a9c7ff;
    color: #101a2e;
  }

  .guide-switch:hover {
    background: #c1d6ff;
    color: #101a2e;
  }

  .guide-example pre {
    border: 1px solid #8895aa;
  }

  .guide-note {
    border-color: #fbbf24;
    background: #3a2b0c;
    color: #fff4cf;
  }

  :focus-visible {
    outline-color: #f3beff;
  }
}

@media (max-width: 600px) {
  .guide-masthead {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 0.9rem;
  }

  .guide-nav {
    gap: 0.1rem 0.8rem;
  }

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

  .guide-search button {
    width: 100%;
  }
}

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

@media (forced-colors: active) {
  a,
  .guide-brand {
    color: LinkText;
  }

  .guide-switch,
  .guide-search button,
  .guide-chip,
  .guide-card,
  .guide-group,
  .guide-results li,
  .guide-track,
  .guide-choice,
  .guide-check,
  .guide-course-progress,
  .guide-prose,
  .guide-example {
    border: 1px solid CanvasText;
  }

  :focus-visible {
    outline: 3px solid Highlight;
  }
}
