:root {
  color-scheme: light dark;
  --language-icon-offset-x-desktop: 11px;
  --language-icon-offset-x-mobile: 1px;
  --language-group-gap-desktop: 1.3rem;
  --language-group-gap-mobile: 0.6rem;
  --language-icon-offset-x: var(--language-icon-offset-x-desktop);
  --language-group-gap: var(--language-group-gap-desktop);
  --bg: #ffffff;
  --surface: transparent;
  --surface-strong: rgba(24, 24, 24, 0.06);
  --surface-soft: rgba(24, 24, 24, 0.04);
  --text: #181818;
  --muted: #707070;
  --accent: #85553a;
  --accent-soft: rgba(133, 85, 58, 0.1);
  --link: #2f6fdb;
  --line: rgba(24, 24, 24, 0.08);
  --diagram-ground: #34495e;
  --diagram-ground-label: #7f8c8d;
  --diagram-pit-fill: #f2f2f2;
  --diagram-pit-stroke: #8d6e63;
  --diagram-pit-label: #5d4037;
  --diagram-rod: #b59410;
  --diagram-label: #2c3e50;
  --diagram-marker-fill: #2c3e50;
  --diagram-marker-roof: #34495e;
  --diagram-marker-roof-stroke: #1a252f;
  --diagram-marker-text: #ecf0f1;
  --diagram-marker-subtext: #e0e0e0;
  --diagram-battery-fill: #f1c40f;
  --diagram-battery-text: #000000;
  --diagram-cable: #7f8c8d;
  --diagram-harrow-fill: rgba(52, 152, 219, 0.15);
  --diagram-harrow-stroke: #2980b9;
  --diagram-harrow-text: #2980b9;
  --diagram-long-needle: #e74c3c;
  --diagram-short-needle: #3498db;
  --diagram-body-fill: #f5cba7;
  --diagram-body-stroke: #d35400;
  --diagram-body-text: #a04000;
  --diagram-cotton-fill: #ffffff;
  --diagram-cotton-stroke: #bdc3c7;
  --diagram-mouthpiece-fill: #8d6e63;
  --diagram-rice-fill: #e67e22;
  --diagram-pipe-fill: #95a5a6;
  --radius-xl: 0;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --max-width: 1400px;
  --sidebar-width: 320px;
  --header-height: auto;
}

:root[data-theme="dark"] {
  --bg: #161616;
  --surface: transparent;
  --surface-strong: rgba(255, 255, 255, 0.08);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --text: #f3efe7;
  --muted: #aea89f;
  --accent: #f0a56f;
  --accent-soft: rgba(240, 165, 111, 0.14);
  --link: #7fb3ff;
  --line: rgba(255, 255, 255, 0.1);
  --diagram-ground: #9fb0c0;
  --diagram-ground-label: #b8c2cc;
  --diagram-pit-fill: #3b3b3b;
  --diagram-pit-stroke: #b9927d;
  --diagram-pit-label: #d7b7a5;
  --diagram-rod: #d9c05c;
  --diagram-label: #d6dde5;
  --diagram-marker-fill: #4b5763;
  --diagram-marker-roof: #5a6672;
  --diagram-marker-roof-stroke: #8593a0;
  --diagram-marker-text: #f4f1ea;
  --diagram-marker-subtext: #d9d5cd;
  --diagram-battery-fill: #e8c958;
  --diagram-battery-text: #1b1b1b;
  --diagram-cable: #b6c0c8;
  --diagram-harrow-fill: rgba(106, 176, 230, 0.18);
  --diagram-harrow-stroke: #71b6e8;
  --diagram-harrow-text: #8fc8ef;
  --diagram-long-needle: #ff867c;
  --diagram-short-needle: #6cc0ff;
  --diagram-body-fill: #8d6a56;
  --diagram-body-stroke: #ff9a57;
  --diagram-body-text: #ffc393;
  --diagram-cotton-fill: #4f565d;
  --diagram-cotton-stroke: #9daab4;
  --diagram-mouthpiece-fill: #bf9f90;
  --diagram-rice-fill: #f0a35c;
  --diagram-pipe-fill: #a4b1ba;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a,
a:visited,
a:hover,
a:active {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 28px auto 20px;
  display: grid;
  gap: 28px;
}

.panel {
  background: var(--surface);
}

.site-header,
.site-footer {
  padding: 0;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.header-title-row {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.header-tag {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  position: relative;
  top: -0.22em;
}

.site-title {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2.2rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.header-theme {
  flex: 0 0 auto;
  align-self: flex-start;
  justify-content: flex-end;
  position: relative;
  top: 2px;
  left: -8px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(240px, var(--sidebar-width)) minmax(0, 1fr);
  gap: 42px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 24px;
  padding: 0;
  transform: translateX(-10px);
}

.toc-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.96rem;
  cursor: pointer;
}

.toc-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toc-toggle-icon {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.toc.is-open .toc-toggle-icon {
  transform: rotate(180deg);
}

.toc-list,
.toc-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item + .toc-item {
  margin-top: 2px;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 0;
  border-radius: 8px;
  color: inherit;
  transition: background-color 0.15s ease;
  width: calc(100% - 14px);
  max-width: calc(100% - 14px);
}

.toc-link i {
  width: 20px;
  text-align: center;
  flex: none;
  font-style: normal;
  font-size: 1rem;
}

.toc-label {
  line-height: 1.3;
  font-size: 0.95rem;
}

.toc-sublist {
  margin-left: 18px;
  margin-top: 0;
}

.toc-sublist .toc-link {
  padding-left: 10px;
}

.toc-link:hover,
.toc-link:focus-visible {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  outline: none;
}

.doc-main {
  padding-top: 2px;
  min-width: 0;
  padding-right: 12px;
}

.lead {
  margin: 0 0 28px;
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 66ch;
}

.section + .section {
  margin-top: 42px;
}

.section h2,
.section h3 {
  margin: 0 0 16px;
  font-weight: 700;
  letter-spacing: -0.04em;
  scroll-margin-top: 24px;
  position: relative;
  padding-left: 0;
}

.section-marker {
  position: absolute;
  left: -40px;
  top: 0.05em;
  width: 20px;
  text-align: right;
  font-style: normal;
  font-size: 0.95em;
  line-height: 1.15;
}

.section h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.section h3 {
  font-size: clamp(1.2rem, 1.6vw, 1.5rem);
  color: var(--text);
}

.section p,
.section li,
.section td,
.section th {
  font-family: "Manrope", sans-serif;
  font-size: 1.03rem;
  line-height: 1.7;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  overflow-wrap: normal;
  word-break: normal;
}

.plain-list li,
.doc-list li,
.doc-list p {
  line-height: 1.5;
}

.section p {
  margin: 0 0 16px;
  color: color-mix(in srgb, var(--text) 90%, transparent);
}

.diagram-wrap {
  margin: 22px 0 24px;
  width: 70%;
}

.device-diagram {
  width: 100%;
  height: auto;
  display: block;
}

.doc-list,
.plain-list {
  margin: 18px 0;
  padding: 0;
}

.plain-list {
  list-style: none;
  display: grid;
  gap: 8px;
}

.plain-list li {
  position: relative;
  padding-left: 24px;
}

.plain-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  transform: translateY(-50%);
}

.doc-list {
  list-style: none;
  counter-reset: process;
  display: grid;
  gap: 10px;
  margin-left: 0;
}

.doc-list li {
  counter-increment: process;
  position: relative;
  padding-left: 0;
}

.doc-list li::before {
  content: counter(process);
  position: absolute;
  left: -34px;
  top: 0;
  width: 20px;
  text-align: right;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.7;
}

.doc-list p {
  margin: 0;
}

.callout {
  margin: 24px 0;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border-left: 2px solid var(--line);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
}

.callout i {
  margin-top: 4px;
  color: var(--accent);
}

.callout p {
  margin: 0;
}

.callout.note p {
  color: var(--muted);
}

.callout.warning {
  border-left-color: var(--accent);
  background: color-mix(in srgb, rgba(177, 58, 58, 0.16) 72%, var(--surface-soft));
}

.doc-main .xref,
.doc-main .xref:visited,
.doc-main .xref:hover,
.doc-main .xref:active {
  color: var(--link) !important;
  text-decoration: none;
}

.table-wrap {
  margin-top: 20px;
  padding: 0;
  border-radius: var(--radius-lg);
  background: transparent;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  text-align: left;
  padding: 14px 16px;
  vertical-align: top;
}

thead th {
  font-family: "Manrope", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  padding-top: 0;
  padding-bottom: 6px;
}

tbody tr + tr td {
  border-top: 1px solid color-mix(in srgb, var(--muted) 14%, transparent);
}

tbody td:first-child {
  font-weight: 600;
}

.section[data-section="troubleshooting"] table th:first-child,
.section[data-section="troubleshooting"] table td:first-child {
  width: 30%;
}

.section[data-section="revisions"] table th:first-child,
.section[data-section="revisions"] table td:first-child {
  width: 20%;
}

.section[data-section="troubleshooting"] th:first-child,
.section[data-section="troubleshooting"] td:first-child,
.section[data-section="revisions"] th:first-child,
.section[data-section="revisions"] td:first-child {
  padding-left: 0;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 10px;
}

.footer-text {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

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

.toc-controls {
  margin-top: 40px;
  display: grid;
  gap: 0px;
  align-items: start;
}

.toc-controls .language-group {
  position: relative;
  top: -15px;
}

.toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-radius: 999px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  margin-right: 0.9rem;
}

.toggle-group.language-group .toggle-label {
  position: relative;
  left: var(--language-icon-offset-x);
  margin-right: var(--language-group-gap);
}

.toggle-group.language-group .toggle-button + .toggle-button {
  margin-left: 0.3rem;
}

.toggle-group.theme-group .toggle-button + .toggle-button {
  margin-left: 0.225rem;
}

.toggle-button {
  border: 0;
  border-radius: 999px;
  padding: 6px 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s ease;
}

.toggle-button.active {
  background: transparent;
  color: var(--accent);
}

.icon-button {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

@media (max-width: 980px) {
  :root {
    --language-icon-offset-x: var(--language-icon-offset-x-mobile);
    --language-group-gap: var(--language-group-gap-mobile);
  }

  .site-header {
    gap: 10px;
    align-items: flex-start;
    padding-top: 6px;
    padding-left: 6px;
  }

  .doc-main {
    padding-right: 0;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .page-shell {
    width: min(calc(100% - 18px), var(--max-width));
    margin: 10px auto;
    gap: 20px;
  }

  .toc {
    top: 0;
    z-index: 4;
    padding: 0;
    background: var(--bg);
    border-bottom: 1px solid color-mix(in srgb, var(--muted) 18%, transparent);
    transform: none;
  }

  .toc-toggle {
    display: flex;
  }

  .toc nav {
    display: none;
    padding: 6px 0 2px;
  }

  .toc.is-open nav {
    display: block;
  }

  .toc-controls {
    margin-top: 14px;
    padding-top: 10px;
  }

  .toc-controls .language-group {
    left: 0;
  }

  .header-title-row {
    gap: 10px;
  }

  .header-theme {
    top: 4px;
    left: 0;
  }

  .doc-list li {
    padding-left: 18px;
  }

  .doc-list li::before {
    left: 0;
    width: 14px;
    text-align: left;
  }

  .doc-main {
    padding-inline: 6px;
  }

  .diagram-wrap,
  .device-diagram {
    width: 100%;
  }

  th,
  td {
    padding: 12px;
  }

  .site-title {
    font-size: clamp(1.35rem, 7vw, 1.85rem);
  }

  .section h2,
  .section h3 {
    scroll-margin-top: 64px;
  }
}

@media (max-width: 980px) {
  .section h2,
  .section h3 {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }

  .section-marker {
    position: static;
    width: auto;
    text-align: left;
    line-height: inherit;
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .header-theme {
    margin-left: 0;
    justify-content: flex-start;
  }
}
