:root {
  color-scheme: dark;
  --bg: #1a1a19;
  --surface-1: #262624;
  --surface-2: #30302e;
  --text-primary: #ecebe6;
  --text-secondary: #a8a7a0;
  --border: rgba(236, 235, 230, 0.14);
  --border-strong: rgba(236, 235, 230, 0.32);
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fcfcfa;
  --surface-1: #f3f2ee;
  --surface-2: #ffffff;
  --text-primary: #1f1f1d;
  --text-secondary: #5c5b57;
  --border: rgba(31, 31, 29, 0.14);
  --border-strong: rgba(31, 31, 29, 0.32);
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

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

svg {
  max-width: 100%;
}

a {
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

main,
.header-row,
.footer-inner {
  max-width: 820px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 10px;
  padding-bottom: 10px;
}

@media (max-width: 479px) {
  .site-header {
    position: static;
  }
}

.brand {
  font-size: 18px;
  font-weight: 500;
  text-decoration: none;
}

.header-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.repo-link {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  text-decoration: none;
}

.donate-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  text-decoration: none;
}

.donate-link[href]:hover {
  background: var(--surface-1);
}

.donate-link[hidden] {
  display: none;
}

.donate-heart {
  color: #e0475b;
  flex: none;
}

.repo-link:not([href]) {
  border-style: dashed;
  color: var(--text-secondary);
  cursor: default;
}

.repo-link[href]:hover {
  background: var(--surface-1);
}

.repo-soon {
  font-size: 12px;
  color: var(--text-secondary);
}

.repo-link[data-repo-ready="true"] .repo-soon {
  display: none;
}

.lang-switch,
.version-switch {
  display: inline-flex;
}

button {
  border: 0.5px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  background: var(--surface-1);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.lang-switch button,
.version-switch button {
  border-radius: 0;
  padding: 6px 12px;
}

.lang-switch button:first-child,
.version-switch button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.lang-switch button:last-child,
.version-switch button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left-width: 0;
}

button[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--bg);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  line-height: 0;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 500;
  line-height: 1.25;
}

h1 {
  font-size: clamp(28px, 6vw, 40px);
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "title"
    "lead"
    "media";
  gap: 16px;
  padding: 32px 0 8px;
  scroll-margin-top: 64px;
}

.hero h1 {
  grid-area: title;
  align-self: end;
}

.hero .lead {
  grid-area: lead;
  align-self: start;
  margin: 0;
  font-size: 17px;
  color: var(--text-secondary);
}

.hero-media {
  grid-area: media;
  display: block;
  width: 100%;
  height: auto;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
}

@media (min-width: 720px) {
  .hero {
    grid-template-columns: 1.1fr 1fr;
    grid-template-areas:
      "title media"
      "lead media";
    column-gap: 32px;
    row-gap: 12px;
    padding-top: 48px;
  }
}

.block {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 0.5px solid var(--border);
  scroll-margin-top: 64px;
}

.section-body:empty {
  display: none;
}

.hero > [data-for-v] {
  display: contents;
}

[data-for-v][hidden] {
  display: none !important;
}

.marks {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.marks li {
  position: relative;
  margin: 8px 0;
  padding-left: 22px;
}

.marks li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}

.fact {
  padding: 12px 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.fact dt {
  font-size: 13px;
  color: var(--text-secondary);
}

.fact dd {
  margin: 4px 0 0;
  font-weight: 500;
}

.section-body h3 {
  margin: 28px 0 0;
}

.section-body h3:first-child {
  margin-top: 16px;
}

.stepper {
  margin: 8px 0 0;
}

.stepper svg {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 599px) {
  .stepper-frame {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .stepper-frame svg {
    min-width: 560px;
    max-width: none;
  }

  .stepper .stepper-caption {
    min-height: 4.8em;
  }

  figure[data-scroll-hint]::before {
    content: attr(data-scroll-hint);
    display: block;
    margin: 0 0 4px;
    font-size: 12px;
    color: var(--text-secondary);
  }
}

.stage-label {
  margin: -2px 0 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stepper-stack {
  display: grid;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #f9f9f9;
}

.stepper-stack > img {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: auto;
}

.stepper [data-s],
.stepper [data-only],
.stepper [data-hide] {
  transition: opacity 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  .stepper [data-s],
  .stepper [data-only],
  .stepper [data-hide] {
    transition: none;
  }
}

.stepper-caption-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 8px 0 10px;
}

.stepper-caption-box > *,
.stepper-caption-sizer > * {
  grid-area: 1 / 1;
}

.stepper-caption {
  min-height: 50px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
}

.stepper-caption-sizer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  visibility: hidden;
  pointer-events: none;
  font-size: 15px;
  line-height: 1.6;
}

.stepper-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.stepper-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.stepper-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.dot[data-on="true"] {
  background: var(--text-primary);
}

.pinmap {
  margin: 8px 0 0;
}

.pinmap svg {
  display: block;
  width: 100%;
  height: auto;
}

.pinmap figcaption {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.photo {
  margin: 20px 0 8px;
  max-width: 420px;
}

.photo img {
  display: block;
  width: 100%;
  height: auto;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
}

.photo figcaption {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 500;
  color: var(--text-secondary);
}

caption {
  caption-side: top;
  padding: 0 10px 8px;
  text-align: left;
  font-size: 13px;
  color: var(--text-secondary);
}

.wire-len {
  white-space: nowrap;
}

tr[data-approx="true"] .wire-len {
  color: var(--text-secondary);
}

.parts-table {
  min-width: 540px;
}

@media (max-width: 599px) {
  .parts-table {
    min-width: 0;
  }

  .parts-table,
  .parts-table tbody,
  .parts-table caption {
    display: block;
  }

  .parts-table caption {
    padding-left: 0;
    padding-right: 0;
  }

  .parts-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .parts-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 16px;
    padding: 10px 0;
    border-bottom: 0.5px solid var(--border);
  }

  .parts-table td {
    display: block;
    padding: 0;
    border-bottom: 0;
  }

  .parts-table .part-name {
    flex: 1 1 100%;
    width: auto;
  }

  .parts-table td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--text-secondary);
  }
}

.part-name {
  width: 42%;
}

.part-qty {
  white-space: nowrap;
}

.part-price {
  white-space: nowrap;
}

.part-link a {
  white-space: nowrap;
}

.part-note {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.part-nolink {
  color: var(--text-secondary);
}

.parts-footnote {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.parts-footnote:empty {
  display: none;
}

.print-common {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.print-archive {
  margin: 14px 0 0;
}

.print-archive a,
.support-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  text-decoration: none;
}

.print-archive a:hover,
.support-link[href]:hover {
  background: var(--surface-1);
}

.support-link[hidden] {
  display: none;
}

.print-archive-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.print-groups {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

.print-group {
  padding: 12px 16px 4px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.section-body .print-group h3 {
  margin: 0;
  font-size: 16px;
}

.print-settings {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.print-table {
  margin: 8px 0 0;
}

.print-table th,
.print-table td {
  padding: 8px 0;
}

.print-table tbody tr:last-child td {
  border-bottom: 0;
}

.print-name a {
  font-weight: 500;
}

.print-table .print-qty {
  width: 1%;
  padding-left: 16px;
  white-space: nowrap;
  text-align: right;
}

.print-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.print-optional {
  color: var(--text-secondary);
}

.print-estimate {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.fw-install {
  min-height: 40px;
  margin: 16px 0 0;
}

esp-web-install-button:not(:defined) {
  display: none;
}

.fw-missing {
  display: none;
}

esp-web-install-button:not(:defined) + .fw-missing {
  display: block;
  visibility: hidden;
  animation: fw-missing-reveal 0s 8s forwards;
}

@keyframes fw-missing-reveal {
  to {
    visibility: visible;
  }
}

.fw-button {
  padding: 9px 20px;
  border-color: var(--text-primary);
  background: var(--text-primary);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
}

.fw-button:hover {
  border-color: var(--text-secondary);
  background: var(--text-secondary);
}

.fw-note {
  margin: 0;
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 14px;
}

.fw-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 4px;
  font-size: 14px;
}

.steps {
  list-style: none;
  counter-reset: step;
  margin: 14px 0 0;
  padding: 0;
}

.steps li {
  position: relative;
  counter-increment: step;
  margin: 10px 0;
  padding-left: 34px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 24px;
  height: 24px;
  border: 0.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 23px;
  text-align: center;
}

.cmd {
  margin: 10px 0 0;
  padding: 10px 14px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
}

.cmd code {
  font: inherit;
}

.steps .cmd,
.trouble-item .cmd {
  margin-top: 8px;
}

.trouble-item .cmd {
  background: var(--bg);
}

.trouble {
  margin: 16px 0 0;
}

.trouble-item {
  margin-top: 12px;
  padding: 12px 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.trouble-item:first-child {
  margin-top: 0;
}

.trouble-item dt {
  font-weight: 500;
}

.trouble-item dd {
  margin: 6px 0 0;
  color: var(--text-secondary);
}

.trouble-after {
  display: block;
  margin-top: 10px;
}

.env {
  margin: 14px 0 0;
}

.env dt {
  margin-top: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.env dt:first-child {
  margin-top: 0;
}

.env dd {
  margin: 2px 0 0;
  color: var(--text-secondary);
}

.support-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0;
}

.support-link:not([href]) {
  border-style: dashed;
  color: var(--text-secondary);
  cursor: default;
}

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

.site-footer {
  margin-top: 48px;
  border-top: 0.5px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

.footer-inner {
  padding-top: 20px;
  padding-bottom: 40px;
}

.footer-license {
  margin: 0;
}

.footer-license a {
  color: inherit;
  white-space: nowrap;
}

.toc {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  font-size: 14px;
  line-height: 1.35;
}

.toc summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc ol {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(260px, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

.toc a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
}

.toc a:hover {
  color: var(--text-primary);
  background: var(--surface-1);
}

.toc a[aria-current] {
  color: var(--text-primary);
  background: var(--surface-1);
  font-weight: 600;
}

@media (max-width: 1279px) {
  body {
    padding-bottom: 64px;
  }
}

@media (min-width: 1280px) {
  .toc {
    top: 88px;
    right: auto;
    bottom: auto;
    left: calc(50% + 434px);
    width: 200px;
  }

  .toc summary {
    display: none;
  }

  .toc ol {
    position: static;
    width: auto;
    max-height: calc(100vh - 120px);
    padding: 0 0 0 8px;
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
}
