:root {
  --signal: #268143;
  --warning: #976000;
  --off: #b33737;
}

html.dark {
  --signal: #83ce94;
  --warning: #e7bc69;
  --off: #ed9696;
}

.demo-tag {
  color: var(--muted);
  font: 10px/1.4 var(--mono);
  letter-spacing: .07em;
}

.post-main { padding-top: 64px; }
.post-meta { gap: 7px 14px; }
.post-meta > * + *::before { content: "/"; margin-right: 14px; color: var(--line); }
.post-title { max-width: 650px; margin-bottom: 32px; font-size: clamp(34px, 6vw, 49px); line-height: 1.1; }
.post-body > .opening { font-size: 21px; line-height: 1.6; }

figure { margin: 34px 0; }
.build-photo a { display: block; border-radius: 8px; overflow: hidden; }
.build-photo img { display: block; width: 100%; height: auto; background: var(--panel); }
figcaption { margin-top: 11px; color: var(--muted); font: 12px/1.65 var(--mono); }

.photo-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 30px 0; }
.photo-pair figure { margin: 0; min-width: 0; }
.product-image { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.product-image img { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: contain; }
.photo-pair figcaption { margin-top: 10px; }
.photo-pair figcaption strong { display: block; color: var(--ink); font: 650 14px/1.5 var(--sans); }
.photo-pair figcaption > span { display: block; margin-top: 2px; color: var(--muted); font: 12px/1.6 var(--sans); }
.photo-pair .image-credit { display: inline-block; margin-top: 5px; color: var(--muted); font: 10px/1.5 var(--mono); }
.hardware-examples .product-image img { aspect-ratio: 3 / 4; object-fit: cover; }
.hardware-examples .ereader-photo .product-image { background: #d5d5cf; }
.hardware-examples .ereader-photo img { object-fit: contain; }

.wiring-details { margin: 28px 0 34px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.wiring-details summary { padding: 14px 0; cursor: pointer; font: 650 14px/1.5 var(--sans); }
.wiring-details summary::marker { color: var(--muted); }
.wiring-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.wiring-details figure { margin: 3px 0 20px; }
.wiring-image { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.wiring-image img { display: block; width: 100%; height: auto; }
.wiring-details figcaption { font-size: 11px; }
.wiring-link { display: inline-flex; min-height: 40px; align-items: center; font: 12px/1.5 var(--mono); }
.future-section { margin-top: 40px; padding-top: 30px; border-top: 1px solid var(--line); }
.future-section > h2 { margin: 0 0 22px; font-size: 26px; line-height: 1.25; letter-spacing: -.025em; }

.watchdog-demo { padding: 24px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.demo-heading { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; }
.demo-heading h2 { margin: 0; font: 700 15px/1.4 var(--sans); letter-spacing: -.01em; }
.demo-tag { font-size: 9px; }
.circuit { padding: 30px 0 25px; color: var(--ink); }
.controller { display: grid; grid-template-columns: 1fr 110px 1fr; gap: 14px; align-items: center; }
.usb-input { justify-self: end; text-align: right; }
.usb-input, .controller-task { color: var(--muted); font: 10px/1.5 var(--mono); }
.usb-input span { margin-left: 6px; }
.chip { display: flex; align-items: center; justify-content: center; gap: 10px; height: 45px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); font: 700 12px/1 var(--mono); }
.indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 10%, transparent); }
.control-line { display: flex; height: 26px; justify-content: center; }
.control-line span { border-left: 1px dashed var(--muted); }
.power-path { display: grid; grid-template-columns: 72px 1fr 76px 1fr 72px; align-items: center; }
.power-end { display: grid; justify-items: center; gap: 5px; }
.power-end svg { width: 40px; height: 40px; }
.power-path svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.power-path span { font: 10px/1.4 var(--mono); }
.wire { height: 1px; margin-bottom: 19px; background: var(--signal); }
.wire-in, .wire-out { transition: background .3s; }
.relay { display: grid; justify-items: center; }
.relay svg { width: 76px; height: 48px; margin-top: -8px; color: var(--signal); }
.relay span { margin-top: 5px; }
.relay-contact { transform-origin: 22px 30px; transition: transform .3s ease; }
.router-light { fill: var(--signal); stroke: var(--signal); }
.circuit[data-phase="cut"] .relay-contact { transform: rotate(-27deg); }
.circuit[data-phase="cut"] .wire-out { background: var(--line); }
.circuit[data-phase="cut"] .router { color: var(--muted); }
.circuit[data-phase="cut"] .router-light { fill: var(--line); stroke: var(--line); }
.circuit[data-phase="boot"] .router-light { fill: var(--warning); stroke: var(--warning); }

.demo-status { display: flex; gap: 10px; align-items: baseline; min-height: 76px; padding: 16px 0 12px; border-top: 1px solid var(--line); }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--signal); }
.demo-status strong { display: block; font: 650 14px/1.5 var(--sans); }
.demo-status div > span { display: block; margin-top: 3px; color: var(--muted); font: 12px/1.5 var(--sans); }
.watchdog-demo[data-running="true"] .status-dot,
.watchdog-demo[data-result="held"] .status-dot { background: var(--warning); }
.watchdog-demo[data-phase="cut"] .status-dot { background: var(--off); }

.restart-stages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 20px; padding: 0; list-style: none; }
.restart-stages li { border-top: 2px solid var(--line); padding-top: 9px; }
.restart-stages span { display: block; color: var(--muted); font: 9px/1.5 var(--mono); }
.restart-stages strong { display: block; margin-top: 4px; font: 600 15px/1.4 var(--mono); }
.restart-stages li.active { border-color: var(--accent); }
.restart-stages li.active strong { color: var(--accent); }
.restart-stages li.done { border-color: var(--signal); }

.demo-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.demo-controls[hidden] { display: none; }
.play-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid var(--ink); border-radius: 5px; padding: 8px 12px; background: var(--ink); color: var(--paper); font: 600 12px/1.4 var(--mono); cursor: pointer; }
.play-button:hover { opacity: .85; }
.persist-option { display: inline-flex; min-height: 44px; gap: 7px; align-items: center; color: var(--muted); font: 12px/1.5 var(--sans); cursor: pointer; }
.persist-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.persist-option input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.persist-option:has(input:disabled) { opacity: .6; cursor: default; }
.watchdog-demo figcaption { margin-top: 14px; font-size: 11px; }

.ending { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line); }
.post-body .ending p { font-size: inherit; }
.post-body .last-line { margin-top: 28px; font-weight: 650; }

@media (max-width: 480px) {
  .post-main { padding-top: 36px; }
  .post-title { font-size: 36px; }
  .post-body > .opening { font-size: 19px; }
  .post-meta { font-size: 10px; gap: 6px 10px; }
  .post-meta > * + *::before { margin-right: 10px; }
  .watchdog-demo { padding: 18px 14px; }
  .demo-heading { display: block; }
  .demo-tag { display: block; margin-top: 4px; }
  .controller { grid-template-columns: 1fr 88px 1fr; gap: 8px; }
  .usb-input, .controller-task { font-size: 9px; }
  .power-path { grid-template-columns: 60px 1fr 64px 1fr 60px; }
  .relay svg { width: 64px; }
  .power-path span { font-size: 9px; }
  .restart-stages { gap: 6px; }
  .restart-stages span { min-height: 24px; font-size: 8px; }
  .restart-stages strong { font-size: 13px; }
  .demo-status { min-height: 86px; }
  .persist-option { font-size: 11px; }
  .photo-pair { gap: 14px; }
  .photo-pair figcaption strong { font-size: 13px; }
  .photo-pair figcaption > span { font-size: 11px; }
  .future-section > h2 { font-size: 24px; }
}

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