@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 100 1000; font-display: swap; src: url("fonts/dm-sans.ttf") format("truetype"); }
@font-face { font-family: "DM Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/dm-mono-regular.ttf") format("truetype"); }
@font-face { font-family: "DM Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/dm-mono-medium.ttf") format("truetype"); }

/* ---- the palette: the Android app's (ui/theme/Theme.kt). The board and its LEDs are dark in both themes, as on the real thing. ---- */
:root {
  color-scheme: dark;
  --base: #0a0a0a; --panel: #141414; --raised: #1c1c1f; --line: #2a2a30; --text: #f5f5f5; --muted: #a1a1aa; --faint: #71717a;
  --accent: #60a5fa; --button: #2563eb; --button-pressed: #1d4ed8; --on-button: #fff;
  --good: #22c55e; --warn: #f59e0b; --error: #fca5a5;
  --pcb: #0b0b0e; --pcb-line: #34343b; --silk: #6b6b75; --led-on: #ff6a5c; --led-glow: #ff2d20; --led-off: #26262c;
  --shadow: 0 12px 32px #0006; --mono: "DM Mono", ui-monospace, monospace; --sans: "DM Sans", system-ui, sans-serif;
  --radius-card: 22px; --radius-button: 14px;
  font: 400 15px/1.5 var(--sans); color: var(--text); background: var(--base);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
:root[data-theme="light"] {
  color-scheme: light;
  --base: #f6f7f8; --panel: #fff; --raised: #f0f1f3; --line: #e2e4e8; --text: #111827; --muted: #4b5563; --faint: #8a9099;
  --accent: #1d4ed8; --good: #16a34a; --warn: #d97706; --error: #b91c1c; --shadow: 0 12px 32px #1118270f, 0 2px 6px #1118270a;
}
/* Before the script runs, a light system theme gets light colours (an explicit dark choice still wins). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --base: #f6f7f8; --panel: #fff; --raised: #f0f1f3; --line: #e2e4e8; --text: #111827; --muted: #4b5563; --faint: #8a9099;
    --accent: #1d4ed8; --good: #16a34a; --warn: #d97706; --error: #b91c1c; --shadow: 0 12px 32px #1118270f, 0 2px 6px #1118270a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 72px; }
body {
  min-height: 100vh; margin: 0; display: flex; flex-direction: column;
  background: radial-gradient(900px 420px at 50% -160px, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%) no-repeat, var(--base);
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
svg, img { max-width: 100%; }
.sr-only, .raw { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- icons ---- */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---- buttons: one shape, clear hierarchy, a press that sinks a little ---- */
button, summary { font: inherit; color: inherit; }
button { margin: 0; padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 22px;
  border: 1px solid transparent; border-radius: var(--radius-button); font: 600 15px/1.2 var(--sans); text-align: center;
  transition: background-color 120ms, border-color 120ms, color 120ms, transform 120ms;
}
.btn .icon { width: 18px; height: 18px; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--button); color: var(--on-button); box-shadow: inset 0 1px 0 #ffffff26, 0 1px 2px #0003; }
.btn.secondary { background: var(--raised); border-color: var(--line); color: var(--text); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--error); }
.btn.quiet { background: transparent; color: var(--accent); }
.btn:disabled, .btn:disabled:hover { background: var(--raised); border-color: var(--line); color: var(--faint); box-shadow: none; }
.btn.block { width: 100%; }
.grow { flex: 1 1 auto; }
@media (hover: hover) {
  .btn.primary:hover:not(:disabled) { background: var(--button-pressed); }
  .btn.secondary:hover:not(:disabled), .btn.danger:hover:not(:disabled), .btn.quiet:hover:not(:disabled) { background: var(--line); }
}
.btn.primary:active:not(:disabled) { background: var(--button-pressed); }

.icon-button {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--text); cursor: pointer; transition: background-color 120ms, color 120ms, transform 120ms;
}
.icon-button.quiet { border-color: transparent; color: var(--muted); }
.icon-button:active { transform: scale(0.92); }
@media (hover: hover) { .icon-button:hover { background: var(--raised); color: var(--text); } }

/* ---- tags: a state in a pill ---- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; white-space: nowrap;
  font: 500 11px/1.4 var(--mono); letter-spacing: 0.04em; color: var(--muted); border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
}
.tag:empty { display: none; }
.tag.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.good, .tag.ok, #firmware-summary[data-state="ok"] { color: var(--good); }
#firmware-summary[data-state="new"], #firmware-summary[data-state="wait"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: transparent; }
.tag.led { color: var(--led-on); background: color-mix(in srgb, var(--led-on) 15%, transparent); border-color: transparent; }
.tag.led::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px var(--led-glow); }
.label { display: block; font: 500 11px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hint { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.hint .icon { width: 16px; height: 16px; color: var(--faint); }
.hint.center { justify-content: center; text-align: center; }

/* ---- header ---- */
header {
  position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--base) 82%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
nav { display: flex; align-items: center; gap: 12px; max-width: 760px; margin: auto; padding: 8px max(16px, env(safe-area-inset-left)); }
.brand { display: inline-flex; align-items: center; min-height: 44px; }
.brand img { display: block; width: 104px; height: auto; }
:root[data-theme="light"] .brand img, :root[data-theme="light"] .footer-mark { filter: invert(1); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .brand img { filter: invert(1); } }
.brand-product { padding-left: 12px; border-left: 1px solid var(--line); font: 500 14px var(--mono); color: var(--muted); }
.nav-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.theme-toggle .icon { width: 20px; height: 20px; }
.theme-toggle .on-light { display: none; }
:root[data-theme="light"] .theme-toggle .on-light { display: block; }
:root[data-theme="light"] .theme-toggle .on-dark { display: none; }

/* language menu (language-menu.js) */
.lang { position: relative; }
.lang-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); }
@media (hover: hover) { .lang-toggle:hover { background: var(--raised); } }
.flag { display: block; width: 24px; height: 16px; border-radius: 3px; box-shadow: 0 0 0 1px #0000004d; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 188px; margin: 0; padding: 6px; list-style: none; display: grid; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.lang-item { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 11px; text-align: left; font-weight: 500; }
@media (hover: hover) { .lang-item:hover { background: var(--raised); } }
.lang-item[aria-checked="true"] { background: var(--raised); }
.lang-item[aria-checked="true"]::after { content: ""; margin-left: auto; width: 10px; height: 6px; border: solid var(--accent); border-width: 0 0 2px 2px; transform: rotate(-45deg) translateY(-2px); }

/* ---- page ---- */
main { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) 8px; flex: 1; }
@media (min-width: 720px) { main { padding-top: 32px; } }
footer { color: var(--faint); }
.footer-inner { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); font: 400 12px var(--mono); }
.footer-mark { width: 14px; height: 14px; opacity: 0.6; }

/* ---- cards ---- */
.card { margin: 0 0 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); }
details.card > summary {
  display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 12px 18px 12px 14px;
  list-style: none; cursor: pointer; border-radius: var(--radius-card); user-select: none; -webkit-user-select: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex: none; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: translateY(-2px) rotate(45deg); transition: transform 160ms;
}
details.card[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
@media (hover: hover) { details.card > summary:hover { background: color-mix(in srgb, var(--raised) 60%, transparent); } }
details.card > summary h2 { flex: none; font: 500 16px/1.3 var(--mono); letter-spacing: -0.01em; }
details.card > summary .tag { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
details.card > summary .tag.led, details.card > summary .tag.dot { display: inline-flex; }
#manual > summary, #sensors > summary { padding-right: 18px; }
.card-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--raised); color: var(--text); }
.summary-note { color: var(--muted); font: 500 12px var(--mono); }
.card-body { position: relative; padding: 4px 18px 20px; }

/* ---- connect (the first card) ---- */
.hero { padding: 20px; }
.hero-top { display: flex; align-items: center; gap: 18px; }
.hero-matrix { width: 92px; flex: none; }
@media (min-width: 720px) { .hero-matrix { width: 112px; } .hero { padding: 24px; } }
.hero-text { min-width: 0; }
.hero-name { display: flex; align-items: center; gap: 10px; font: 500 21px/1.25 var(--mono); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.link-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--faint); transition: background-color 200ms, box-shadow 200ms; }
#connect-card.connected .link-dot { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }
.hero-version { margin-top: 4px; font: 400 13px var(--mono); color: var(--muted); }
#connect-card:not(.connected) .hero-version { display: none; }
#connect-card.connected .connect-help { display: none; }
#connect-card.connected #connect:not(:disabled) { background: var(--raised); border-color: var(--line); color: var(--text); box-shadow: none; }
@media (hover: hover) { #connect-card.connected #connect:hover:not(:disabled) { background: var(--line); } }

.connect-steps { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.connect-steps li { position: relative; display: grid; justify-items: center; gap: 8px; text-align: center; font-size: 13px; line-height: 1.3; color: var(--muted); }
.connect-steps li + li::before { content: ""; position: absolute; top: 22px; right: calc(50% + 30px); width: calc(100% - 52px); border-top: 1px dashed var(--line); }
.step-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--raised); color: var(--accent); }
.hero-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.hero-actions .btn { flex: 1; }
.hero-actions .info summary { width: 50px; height: 50px; border-radius: var(--radius-button); border-color: var(--line); }

.notice {
  display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 14px 16px; border-radius: 16px; line-height: 1.4;
  background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.notice-icon { width: 28px; height: 28px; color: var(--warn); }

.message-line { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--raised); font-size: 14px; line-height: 1.45; }
.message-line::before {
  content: "\2713"; display: grid; place-items: center; width: 20px; height: 20px; flex: none; margin-top: 0; border-radius: 50%;
  border: 1.6px solid currentColor; color: var(--accent); font: 700 11px/1 var(--sans);
}
.message-line.error { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }
.message-line.error::before { content: "!"; color: var(--error); font-size: 12px; }

/* the LED matrix pictures (art.js) */
.matrix-art { display: block; width: 100%; height: auto; }
.matrix-art .bezel { fill: var(--pcb); stroke: var(--pcb-line); stroke-width: 1; }
.matrix-art .unlit { fill: var(--led-off); }
.matrix-art .lit { fill: var(--led-on); filter: drop-shadow(0 0 1.5px var(--led-glow)) drop-shadow(0 0 4px #ff2d2080); }
#connect-card:not(.connected):has(#connect:disabled) .hero-art .lit { animation: scan 1.1s ease-in-out infinite; }
.hero-art .d0 { animation-delay: 0ms !important; }
.hero-art .d1 { animation-delay: 70ms !important; }
.hero-art .d2 { animation-delay: 140ms !important; }
.hero-art .d3 { animation-delay: 210ms !important; }
.hero-art .d4 { animation-delay: 280ms !important; }
.hero-art .d5 { animation-delay: 350ms !important; }
.hero-art .d6 { animation-delay: 420ms !important; }
.hero-art .d7 { animation-delay: 490ms !important; }
.hero-art .d8 { animation-delay: 560ms !important; }
.hero-art .d9 { animation-delay: 630ms !important; }
.hero-art .d10 { animation-delay: 700ms !important; }
.hero-art .d11 { animation-delay: 770ms !important; }
.hero-art .d12 { animation-delay: 840ms !important; }
.hero-art .d13 { animation-delay: 910ms !important; }
.hero-art .d14 { animation-delay: 980ms !important; }
main:has(#unsupported:not([hidden])) .hero-art .lit { animation: none; opacity: 0.35; filter: none; }
@keyframes scan { 50% { opacity: 0.25; } }

/* ---- the little popovers behind (i) ---- */
.info { position: relative; flex: none; }
.info > summary { list-style: none; }
.info > summary::-webkit-details-marker { display: none; }
.info[open] > summary { color: var(--accent); background: var(--raised); }
.info > p {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: max-content; max-width: min(320px, calc(100vw - 48px));
  padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 14px; line-height: 1.45; color: var(--text);
}
.inline-info { margin: 0; }
/* An (i) that belongs to a whole card sits in the card's heading row, left of the fold arrow (it only exists while the card is open). */
.card-body > .inline-info { position: absolute; top: -56px; right: 42px; z-index: 2; }

/* ---- how to use ---- */
.how-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.how-tiles li { display: grid; justify-items: center; align-content: start; gap: 2px; padding: 12px 8px 14px; border-radius: 18px; background: var(--raised); text-align: center; }
.how-tiles b { margin-top: 8px; font: 500 14px/1.25 var(--mono); }
.how-tiles small { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.tile-art { width: 100%; max-width: 150px; }
.board-art { display: block; width: 100%; height: auto; }
.board-art .pcb { fill: var(--pcb); stroke: var(--pcb-line); }
.board-art .tick { stroke: var(--silk); stroke-width: 0.7; }
.board-art .switch { fill: #1c1c21; stroke: #4a4a53; }
.board-art .cap { fill: #2b2b32; stroke: #5a5a64; }
.board-art .cap.on { fill: var(--button); stroke: #93b4ff; }
.board-art .halo { fill: #2563eb40; animation: halo 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.board-art .led { fill: var(--led-off); }
.board-art .led.on { fill: var(--led-on); filter: drop-shadow(0 0 1.2px var(--led-glow)); }
@keyframes halo { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.1); } }

/* ---- apps ---- */
#apps-offline .hint { margin-bottom: 12px; }
#apps-editor .label { margin: 4px 0 10px; }
#apps-editor .label#more-note { margin-top: 22px; }
.app-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { #gallery-list, #more-list { grid-template-columns: 1fr 1fr; } }
.app-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--line); transition: border-color 200ms, box-shadow 200ms;
}
#apps .card-body .app-card { background: color-mix(in srgb, var(--raised) 45%, var(--panel)); }
.app-card.is-playing { border-color: color-mix(in srgb, var(--led-on) 60%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--led-on) 25%, transparent); }
.app-card .order { width: 22px; flex: none; font: 500 15px var(--mono); color: var(--faint); text-align: center; }
.app-card .face { display: block; width: 56px; height: 56px; flex: none; padding: 5px; border-radius: 12px; background: var(--pcb); border: 1px solid var(--pcb-line); }
.app-card.compact .face { width: 44px; height: 44px; padding: 4px; border-radius: 10px; }
.face .unlit { fill: var(--led-off); }
.face .lit { fill: var(--led-on); filter: drop-shadow(0 0 1px var(--led-glow)) drop-shadow(0 0 2.5px #ff2d2070); }
.app-text { flex: 1; min-width: 0; align-self: center; }
.app-text > summary { display: grid; gap: 2px; list-style: none; cursor: pointer; padding: 4px 0; border-radius: 8px; }
.app-text > summary::-webkit-details-marker { display: none; }
.app-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.app-title b { min-width: 0; font: 500 15px/1.3 var(--mono); overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.app-title .icon { width: 15px; height: 15px; color: var(--faint); transition: transform 160ms; }
.app-text[open] .app-title .icon { transform: rotate(180deg); }
.app-text .what { font-size: 13px; line-height: 1.35; color: var(--muted); }
.app-card.compact .app-text:not([open]) .what, #gallery-list .app-text:not([open]) .what { display: none; }
.app-text .how { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13.5px; line-height: 1.45; color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tags i { font-style: normal; }
.tags .playing, .tags .first { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font: 500 11px/1.4 var(--mono); }
.tags .playing { display: none; color: var(--led-on); background: color-mix(in srgb, var(--led-on) 15%, transparent); }
.tags .playing::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px var(--led-glow); }
.app-card.is-playing .tags .playing { display: inline-flex; }
.tags .first { color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.app-card:not(.is-playing) .tags:not(:has(.first)) { display: none; }
.actions { display: grid; grid-auto-flow: column; grid-template-rows: auto auto; gap: 4px 6px; align-items: center; flex: none; }
.actions .remove { grid-row: 1 / 3; }
.actions .add { grid-row: 1 / 3; }
.app-action {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--raised); color: var(--text);
  border: 1px solid var(--line); transition: background-color 120ms, transform 120ms, opacity 120ms;
}
.app-action .icon { width: 20px; height: 20px; }
.app-action.remove { color: var(--error); }
.app-action.add { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.app-action:active:not(:disabled) { transform: scale(0.9); }
.app-action:disabled { opacity: 0.35; }
@media (hover: hover) { .app-action:hover:not(:disabled) { background: var(--line); } }
@media (max-width: 420px) {
  .app-card { gap: 8px; padding: 10px; }
  .app-card .face { width: 48px; height: 48px; }
  .app-card .order { width: 14px; font-size: 14px; }
  .app-title b { font-size: 14px; }
  .app-title .icon { width: 13px; height: 13px; }
}
#apps:not(.menu-open) .menu-open-tag { display: none; }

/* ---- live board ---- */
.board-stage { padding: 10px 0; border-radius: 20px; background: var(--pcb); border: 1px solid var(--line); overflow: hidden; }
.board-svg { display: block; width: 100%; max-width: 880px; height: auto; margin: auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.board-svg .pcb { fill: #0a0a0d; stroke: #34343b; stroke-width: 1.5; }
.board-svg .tick { stroke: #6b6b75; stroke-width: 0.8; }
.board-svg .ruler-text { fill: #6b6b75; font: 500 8px var(--mono); }
.board-svg .holder { fill: #111114; stroke: #2a2a30; }
.board-svg .battery { fill: #17171b; stroke: #34343b; }
.board-svg .battery-text { fill: #55555e; font: 500 18px var(--mono); }
.board-svg .ic { fill: #15151a; stroke: #3a3a42; }
.board-svg .pin { fill: #55555e; }
.board-svg .package { fill: #1a1a1f; stroke: #2e2e35; stroke-width: 0.8; }
.board-svg .dot { fill: #2a2a31; transition: fill 50ms; }
.board-svg .dot.on { fill: #ff6a5c; filter: drop-shadow(0 0 2px #ff2d20) drop-shadow(0 0 6px #ff2d2090); }
.board-svg .pad-button { cursor: pointer; outline: none; touch-action: none; }
.board-svg .pad-button .hit { fill: transparent; }
.board-svg .pad-button .switch { fill: #1c1c21; stroke: #4a4a53; }
.board-svg .pad-button .lead { fill: #6b6b75; }
.board-svg .pad-button .cap { fill: #2b2b32; stroke: #5a5a64; transition: fill 60ms, transform 60ms; transform-box: fill-box; transform-origin: center; }
.board-svg .pad-button:hover .cap { fill: #3a3a43; }
.board-svg .pad-button:focus-visible .switch { stroke: #60a5fa; stroke-width: 2; }
.board-svg .pad-button.down .cap, .board-svg .pad-button.down:hover .cap { fill: #2563eb; stroke: #93b4ff; transform: scale(0.88); }
.board-svg #pad.disabled { opacity: 0.4; }
.board-svg #pad.disabled .pad-button, .board-svg #pad.disabled .pad-both { cursor: default; pointer-events: none; }
.board-svg .pad-both { cursor: pointer; outline: none; }
.board-svg .pad-both .join { stroke: #4a4a53; stroke-width: 1.5; stroke-dasharray: 2 3; }
.board-svg .pad-both .both-pill { fill: #1c1c21; stroke: #5a5a64; transition: fill 80ms; }
.board-svg .pad-both .both-text { fill: #b4b4bd; font: 500 9px var(--mono); pointer-events: none; }
.board-svg .pad-both:hover .both-pill { fill: #2b2b32; }
.board-svg .pad-both:focus-visible .both-pill { stroke: #60a5fa; stroke-width: 2; }

.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 10px; }
.controls button {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; height: 64px; border-radius: 16px; background: var(--raised);
  border: 1px solid var(--line); color: var(--text); touch-action: none; user-select: none; -webkit-user-select: none;
  transition: background-color 80ms, border-color 80ms, color 80ms, transform 80ms;
}
.controls b { font: 600 15px var(--sans); }
@media (hover: hover) { .controls button:hover:not(:disabled) { border-color: var(--faint); } }
.controls .control-button.down { background: var(--button); border-color: var(--button); color: var(--on-button); transform: scale(0.95); }
.controls .both-button { color: var(--accent); }
.controls .both-button.holding { border-color: var(--accent); }
.both-button .fill { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--led-on); box-shadow: 0 0 8px var(--led-glow); }
.both-button.holding .fill { width: 100%; transition: width 1.7s linear; }
.controls button:disabled { color: var(--faint); cursor: not-allowed; }
.controls .both-button.holding:disabled { color: var(--accent); }
#view-note:empty { display: none; }

/* ---- software ---- */
.versions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.versions > div { padding: 14px 16px; border-radius: 16px; background: var(--raised); min-width: 0; }
.version-value { display: block; margin-top: 4px; font: 500 22px/1.2 var(--mono); letter-spacing: -0.02em; overflow-wrap: anywhere; }
#latest:not(:empty) { min-height: 1.2em; }
.progress-wrap { margin-top: 16px; }
.progress-wrap:has(> progress[hidden]) { display: none; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.progress-pct { font: 500 30px/1 var(--mono); letter-spacing: -0.03em; }
progress { display: block; width: 100%; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--raised); color: var(--led-on); }
progress::-webkit-progress-bar { background: var(--raised); }
progress::-webkit-progress-value { background: var(--led-on); border-radius: 3px; transition: width 120ms; }
progress::-moz-progress-bar { background: var(--led-on); }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.row-actions .info > summary { width: 50px; height: 50px; border-radius: var(--radius-button); }
.advanced { margin-top: 10px; }
.advanced > summary {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; list-style: none; cursor: pointer; color: var(--muted);
  font-size: 14px; font-weight: 500; border-radius: 10px; width: fit-content;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary .icon { width: 18px; height: 18px; }
.advanced > summary .chev { width: 14px; height: 14px; transition: transform 160ms; }
.advanced[open] > summary .chev { transform: rotate(90deg); }
@media (hover: hover) { .advanced > summary:hover { color: var(--text); } }
.advanced .hint { margin: 4px 4px 12px; }

/* ---- sensors ---- */
.cal { margin-top: 12px; padding: 16px; border-radius: 18px; background: var(--base); border: 1px solid var(--line); }
#sensors .inline-info + .cal { margin-top: 4px; }
.cal-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.cal-head h3 { font: 500 16px var(--mono); }
.cal-head .info { margin-left: auto; }
.cal-step { margin-top: 12px; font: 500 15px/1.35 var(--mono); }
.cal-step:empty, .cal-reading:empty, .cal-progress:empty { display: none; }
.cal-progress { margin-top: 10px; font-size: 14px; color: var(--muted); text-align: center; }
.cal-reading { margin-top: 4px; font: 400 12px var(--mono); color: var(--faint); text-align: center; }
.faces { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.faces li { display: contents; }
button.face {
  position: relative; display: grid; justify-items: center; gap: 4px; min-height: 96px; padding: 8px 6px 10px; border-radius: 14px;
  background: var(--raised); border: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.25; text-align: center;
  transition: border-color 150ms, background-color 150ms, box-shadow 150ms;
}
@media (hover: hover) { button.face:hover:not(:disabled) { border-color: var(--faint); } }
button.face.want { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
button.face.done { border-color: color-mix(in srgb, var(--good) 70%, transparent); background: color-mix(in srgb, var(--good) 10%, var(--raised)); color: var(--text); }
button.face.holding { box-shadow: inset 0 -3px 0 var(--good); }
.pose { display: block; width: 100%; max-width: 110px; height: auto; }
.pose .ground { stroke: var(--line); stroke-width: 1.2; fill: none; stroke-linecap: round; }
.pose .body { fill: var(--pcb); stroke: var(--pcb-line); stroke-width: 0.8; }
.pose .body.back { fill: #1a1a1f; }
.pose .edge { fill: var(--pcb-line); }
.pose .led { fill: var(--led-off); }
.pose .led.on { fill: var(--led-on); }
.pose .btn-top { fill: var(--accent); }
.pose .btn-bottom { fill: var(--silk); }
.pose .arrow { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pose .glow { fill: var(--led-glow); opacity: 0.45; filter: blur(2.5px); }
.pose .tick { fill: none; stroke: var(--good); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; display: none; }
button.face.done .pose .tick { display: inline; }
button.face:not(.want):not(.done) .pose .arrow { stroke: var(--faint); }
.ring-wrap { position: relative; width: min(220px, 70%); aspect-ratio: 1; margin: 14px auto 0; }
.ring { display: block; width: 100%; height: 100%; }
.ring .cell { fill: var(--raised); stroke: none; transition: fill 150ms; }
.ring .cell.on { fill: var(--good); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font: 500 22px var(--mono); pointer-events: none; }
.fig8 { display: block; width: min(220px, 70%); height: auto; margin: 14px auto 0; overflow: visible; }
.ring-wrap:not([hidden]) + .fig8 { display: none; }
.fig8-path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 6 7; animation: march 1.4s linear infinite; }
.fig8-arrow { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.fig8-board { fill: var(--pcb); stroke: var(--pcb-line); }
.fig8-led { fill: var(--led-on); filter: drop-shadow(0 0 3px var(--led-glow)); }
@keyframes march { to { stroke-dashoffset: -26; } }
#sensors-old { padding: 8px 0; }

/* ---- 3D view, help, log ---- */
#debug3d .hint { margin-bottom: 12px; }
#d3-canvas { display: block; width: 100%; height: auto; aspect-ratio: 640 / 420; background: #0a0a0d; border: 1px solid var(--line); border-radius: 16px; touch-action: none; cursor: grab; }
#d3-canvas:active { cursor: grabbing; }
.d3-readout { margin: 12px 0 0; padding: 12px; background: var(--base); border: 1px solid var(--line); border-radius: 12px; font: 400 12px/1.6 var(--mono); white-space: pre; overflow-x: auto; color: var(--muted); }
.faq details { border-bottom: 1px solid var(--line); }
.faq details:last-child { border-bottom: 0; }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; list-style: none; cursor: pointer; font-weight: 600; }
.faq summary::-webkit-details-marker { display: none; }
.faq .chev { width: 18px; height: 18px; color: var(--faint); transition: transform 160ms; }
.faq details[open] .chev { transform: rotate(180deg); }
.faq p { padding: 0 0 14px; color: var(--muted); font-size: 14px; }
@media (hover: hover) { .faq summary:hover { color: var(--accent); } }
pre.log { margin: 0; padding: 12px; min-height: 96px; max-height: 320px; overflow: auto; background: var(--base); border: 1px solid var(--line); border-radius: 12px; font: 400 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  padding: 12px 20px; border-radius: 999px; background: #166534; color: #fff; font: 500 14px var(--mono); box-shadow: var(--shadow);
  animation: rise 200ms ease-out; white-space: nowrap;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
main:has(#unsupported:not([hidden])) .connect-steps { display: none; }
.app-card:has(.app-text[open]) { align-items: flex-start; }
