:root {
  --paper: #f6f4ef;
  --card: #ffffff;
  --ink: #17171a;
  --muted: #6b6a66;
  --rule: #d9d5cc;
  --accent: #ed5c1f;
  --ch-board: #3f8f5a;
  --ch-converter: #2f6fc4;
  --ch-connectors: #c9a227;
  --ch-hub: #8a4fc4;
  --ch-wiring: #6b7280;
  --ch-install: #d0452f;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 2px solid var(--ink);
  background: var(--card);
}
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.back::before { content: "← "; }
.back:hover { color: var(--ink); }
.product { font-weight: 800; letter-spacing: 0.02em; }
.lang-toggle { margin-left: auto; font-size: 12px; font-weight: 700; }
.lang-toggle button { padding: 3px 9px; }

.sheet {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 0;
}

.panel {
  overflow-y: auto;
  padding: 18px 22px 24px;
  background: var(--card);
  border-right: 2px solid var(--ink);
}
.panel-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.chapter { font-weight: 700; color: var(--ink); }
.step-number {
  font-size: 92px;
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin: 10px 0 2px;
  font-variant-numeric: tabular-nums;
}
.panel h1 { font-size: 22px; margin: 0 0 8px; }
.step-text { font-size: 15px; line-height: 1.5; margin: 0 0 16px; }

.parts-box {
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 10px 12px 6px;
  margin-bottom: 14px;
  background: #eef3f8;
}
.parts-box h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; margin: 0 0 6px; color: var(--muted); }
.parts-box ul { list-style: none; margin: 0; padding: 0; }
.parts-box li {
  display: grid;
  grid-template-columns: 18px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 14px;
  cursor: default;
}
.parts-box li:hover { background: #fff; }
.swatch { width: 16px; height: 16px; border-radius: 3px; border: 1.5px solid var(--ink); }
.qty { font-weight: 900; font-size: 16px; font-variant-numeric: tabular-nums; }
.ref { font-size: 11px; color: var(--muted); text-decoration: none; font-family: ui-monospace, Menlo, monospace; }
.ref:hover { color: var(--accent); }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 13px;
  background: #fff7ec;
}
.tool svg { width: 20px; height: 20px; }

.meter {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
  border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; background: #fff7ec;
}
.meter h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; margin: 0 0 4px; color: var(--muted); }
.meter p { margin: 0; font-size: 14px; line-height: 1.5; }
.meter-dial {
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--ink); background: #1f2f4f; color: #ffd84a;
  display: grid; place-items: center; align-content: center; font-weight: 900; line-height: 1;
}
.meter-ohm { font-size: 22px; }
.meter-beep { font-size: 13px; letter-spacing: -0.05em; }
.checks { list-style: none; padding: 0; margin: 0 0 14px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 14px; }
.checks input { accent-color: var(--accent); width: 17px; height: 17px; margin: 1px 0 0; }

.notes { list-style: none; padding: 0; margin: 0 0 14px; }
.note { font-size: 13px; line-height: 1.45; padding: 8px 10px 8px 30px; border-radius: 8px; position: relative; margin-bottom: 6px; }
.note::before { position: absolute; left: 9px; top: 7px; font-weight: 900; }
.note-model { background: #f3f1ec; border: 1.5px dashed #b5b0a4; color: #4a4843; }
.note-model::before { content: "≈"; }
.note-info { background: #eaf4fb; border: 1.5px solid #9cc7e4; }
.note-info::before { content: "i"; font-family: Georgia, serif; font-style: italic; }

.evidence-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.evidence-label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-right: 4px; border: 1px solid; cursor: help; }
.chip-instructor { border-color: #2f6fc4; color: #2f6fc4; }
.chip-measured { border-color: #2a8a4b; color: #2a8a4b; }
.chip-photo { border-color: #8a4fc4; color: #8a4fc4; }
.chip-model { border-color: #8a877f; color: #8a877f; }

.stage { position: relative; min-height: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: grab; }
#scene.picking { cursor: pointer; }
#scene:active { cursor: grabbing; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.arrow-halo { stroke: var(--paper); stroke-width: 11; stroke-linecap: round; }
.arrow-line { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.arrow-head { fill: var(--ink); }
.leader { stroke: var(--ink); stroke-width: 1.2; }
.leader-dot { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.label {
  position: absolute; left: 0; top: 0;
  --dot: var(--accent);
  padding: 2px 8px 2px 18px;
  font-size: 12px; font-weight: 700;
  font-family: ui-monospace, Menlo, monospace;
  white-space: nowrap;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--ink);
}
.label::before { content: ""; position: absolute; left: 6px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--dot); }

.view-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }
.view-tools button, .segmented {
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  box-shadow: 0 2px 0 var(--ink);
}
.segmented { display: flex; padding: 0; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; box-shadow: none; padding: 5px 10px; background: transparent; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.loader { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; color: var(--muted); background: var(--paper); }
.loader.error { color: #b3261e; padding: 24px; text-align: center; }

.cover { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: flex-start; padding: 28px; pointer-events: none; }
.cover-card {
  pointer-events: auto;
  max-width: 420px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 5px 0 var(--ink);
}
.cover-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.cover-title { font-size: 54px; font-weight: 900; letter-spacing: -0.03em; line-height: 1; margin: 6px 0 8px; }
.cover-sub { font-size: 15px; line-height: 1.45; }
.cover-facts { list-style: none; display: flex; gap: 18px; padding: 0; margin: 14px 0; font-size: 13px; color: var(--muted); }
.cover-facts b { font-size: 22px; color: var(--ink); margin-right: 4px; }
.start {
  background: var(--accent); color: #fff; border: 2px solid var(--ink);
  border-radius: 10px; padding: 10px 18px; font-size: 16px; font-weight: 800;
  box-shadow: 0 3px 0 var(--ink);
}
.start:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.cover-hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.cover-credit { font-size: 12px; line-height: 1.5; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--rule); color: var(--muted); }
.cover-credit a { color: var(--ink); font-weight: 700; }
.cover-credit a:hover { color: var(--accent); }
.credit-links { display: inline-flex; gap: 10px; margin-left: 4px; }
body.cover-open .panel { opacity: 0.35; }

.timeline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 10px 18px 8px;
  border-top: 2px solid var(--ink);
  background: var(--card);
}
.transport { display: flex; gap: 6px; }
.transport button {
  width: 38px; height: 38px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 0 var(--ink);
}
.transport button:disabled { opacity: 0.35; cursor: default; }
#play { background: var(--accent); color: #fff; }
.play-icon { display: inline-block; width: 0; height: 0; border-left: 12px solid #fff; border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }
#play.playing .play-icon { width: 11px; height: 13px; border: 0; border-left: 4px solid #fff; border-right: 4px solid #fff; margin-left: 0; }

.track { display: grid; gap: 3px; min-width: 0; }
.chapters, .ticks { display: flex; gap: 2px; }
.chapter-band {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-bottom: 2px; border-bottom: 3px solid; min-width: 0; color: var(--muted);
}
.chapter-band.ch-board { border-color: var(--ch-board); }
.chapter-band.ch-converter { border-color: var(--ch-converter); }
.chapter-band.ch-connectors { border-color: var(--ch-connectors); }
.chapter-band.ch-hub { border-color: var(--ch-hub); }
.chapter-band.ch-wiring { border-color: var(--ch-wiring); }
.chapter-band.ch-install { border-color: var(--ch-install); }
#scrub { width: 100%; margin: 0; accent-color: var(--accent); }
.tick {
  flex: 1 1 0; min-width: 0;
  border: 0; background: transparent;
  font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 2px 0; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.tick:hover { background: #eee; color: var(--ink); }
.tick.done { color: var(--ink); }
.tick.active { background: var(--ink); color: #fff; }

@media (max-width: 820px) {
  body { overflow: auto; height: auto; min-height: 100dvh; }
  .sheet { grid-template-columns: 1fr; }
  .stage { order: -1; height: 58dvh; border-bottom: 2px solid var(--ink); }
  .panel { border-right: 0; }
  .step-number { font-size: 64px; }
  .timeline { position: sticky; bottom: 0; grid-template-columns: 1fr; gap: 6px; }
  .transport { justify-content: center; }
  .chapters { display: none; }
  .cover { padding: 12px; }
  .cover-title { font-size: 40px; }
  .view-tools { top: 8px; right: 8px; }
}

.arrow-head-halo { fill: var(--paper); stroke: var(--paper); stroke-width: 6; stroke-linejoin: round; }
.stage.subassembly::after {
  content: attr(data-badge);
  position: absolute; top: 12px; left: 12px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--ink); color: #fff; border-radius: 6px;
  pointer-events: none;
}
.stage.subassembly { box-shadow: inset 0 0 0 10px #eef3f8; }

:lang(ja) body { line-break: strict; }
:lang(ja) .step-text, :lang(ja) .note, :lang(ja) .cover-sub { line-height: 1.7; }
:lang(ja) .panel-head, :lang(ja) .chapter-band, :lang(ja) .cover-kicker { letter-spacing: 0.02em; }

@media (max-width: 820px) {
  .stage.subassembly::after { top: auto; bottom: 10px; left: 10px; }
}

.test-badge { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; color: #fff; font-size: 13px; }
.test-badge strong { font-size: 16px; }
.test-badge.beep { background: #12a63d; }
.test-badge.beep strong::before { content: "•))) "; }
.test-badge.silent { background: #3f6cf2; }
.test-badge.silent strong::before { content: "🔇 "; }
.checks.tests li { cursor: pointer; border-radius: 8px; padding: 6px 8px; border-left: 4px solid transparent; }
.checks.tests li.beep { border-left-color: #12c94a; }
.checks.tests li.silent { border-left-color: #3f6cf2; }
.checks.tests li.current { background: #f3f1ec; font-weight: 700; }
.probe-ring { fill: none; stroke-width: 3; }

/* Compact, mouse-rotatable instruction panel for presentations: ?embed=1.
 * Keeps the real step title and transport, with the model taking centre stage. */
html.embedded { --paper: #fff; --accent: #0040ff; --ink: #111; }
.embedded body { height: 100dvh; min-height: 0; overflow: hidden; grid-template-rows: 1fr auto; }
.embedded .topbar, .embedded .cover, .embedded .panel-head,
.embedded .panel > :not(.step-number):not(h1), .embedded .track,
.embedded .view-tools .segmented, .embedded #play, .embedded #replay { display: none !important; }
.embedded .sheet { grid-template-columns: 1fr; grid-template-rows: 76px minmax(0, 1fr); }
.embedded .panel { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: center;
  padding: 10px 14px; overflow: hidden; border-right: 0; border-bottom: 3px solid var(--ink); }
.embedded .step-number { font-size: 38px; margin: 0; color: var(--accent); }
.embedded .panel h1 { font-size: 17px; line-height: 1.25; margin: 0; }
.embedded:lang(ja) .panel h1 { font-size: 14.62px; }
.embedded .stage { order: initial; height: auto; border: 0; box-shadow: none; }
.embedded .stage.subassembly::after { display: none; }
.embedded #labels { display: none; }
.embedded .leader, .embedded .leader-dot { display: none; }
.embedded .view-tools { top: auto; bottom: 10px; right: 10px; gap: 6px; }
.embedded .view-tools button { font-size: 12px; }
.embedded .timeline { position: static; display: block; padding: 6px 14px; border-top: 3px solid var(--ink); }
.embedded .transport { justify-content: space-between; }
.embedded .transport button { width: 44px; height: 30px; }
.embedded .view-tools button, .embedded .transport button, .embedded .label { border-radius: 0; box-shadow: none; }
