@charset "utf-8";

:root {
  color-scheme: light;
  --paper: #f4f6f2;
  --surface: #fff;
  --ink: #21332d;
  --muted: #52645d;
  --line: #d9e2db;
  --accent: #145945;
  --accent-soft: #e8f3ed;
  --wire: #35464d;
  --amber: #a05009;
  --blue: #166387;
  --jade: #147659;
  --violet: #78527b;
  --danger: #a73a42;
  --transport-height: 116px;
  font-family: system-ui, "Yu Gothic UI", "Hiragino Sans", Meiryo, sans-serif;
  line-height: 1.58;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(var(--transport-height) + 24px); }
button, select, input { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

.wrap { width: min(100% - 48px, 1192px); margin-inline: auto; }
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner { display: flex; gap: 12px; align-items: center; min-height: 72px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent);
  color: white;
}
h1 { font-size: clamp(1.1rem, 2.4vw, 1.48rem); letter-spacing: .025em; line-height: 1.25; }
.presets { margin-block: 22px 16px; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-buttons button, .mobile-select select {
  min-height: 44px;
  padding: 7px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .93rem;
  font-weight: 650;
}
.preset-buttons button:hover, .playback button:not(:disabled):hover { border-color: var(--accent); }
.preset-buttons button[aria-pressed="true"] {
  color: var(--accent);
  border-color: #79a893;
  background: var(--accent-soft);
  box-shadow: inset 0 -2px var(--accent);
}
.mobile-select { display: none; }
.workspace { display: grid; grid-template-columns: minmax(0, 2.25fr) minmax(295px, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; min-width: 0; }
.diagram { overflow: hidden; }
.diagram-heading { padding: 17px 22px 15px; }
.diagram-heading h2 { font-size: clamp(1.15rem, 2.6vw, 1.54rem); line-height: 1.35; }
.diagram-heading p { color: var(--muted); margin-top: 4px; }
.graph {
  background-color: #fcfdfb;
  background-image: linear-gradient(#e8eee9 1px, transparent 1px), linear-gradient(90deg, #e8eee9 1px, transparent 1px);
  background-size: 19px 19px;
  background-position: center;
  border-block: 1px solid var(--line);
}
.graph svg { display: block; width: 100%; user-select: none; -webkit-user-select: none; }
.circuit-line { fill: none; stroke: currentColor; stroke-width: 3.2px; stroke-linecap: round; }
.part { color: var(--wire); cursor: grab; touch-action: none; outline: none; }
.part:active { cursor: grabbing; }
.part[data-tone="amber"], .legend .amber { color: var(--amber); }
.part[data-tone="blue"], .legend .blue { color: var(--blue); }
.part[data-tone="jade"], .legend .jade { color: var(--jade); }
.part[data-tone="violet"], .legend .violet { color: var(--violet); }
.part[data-tone="muted"] { color: #637783; }
.part.is-highlighted { color: var(--amber); }
.part.is-highlighted .circuit-line { stroke-width: 5px; }
.part.is-highlighted .body, .part:focus-visible .body { stroke-width: 4.8px; }
.part:focus-visible .body { stroke: var(--blue); }
.part .hit { fill: transparent; }
.part .edge-hit { fill: none; stroke: transparent; stroke-width: 33px; }
.part .body { stroke: currentColor; fill: #fcfdfb; stroke-width: 3px; }
.part .node-body { fill: currentColor; }
.part .terminal { stroke-width: 3.5px; }
.diagram-text {
  fill: currentColor;
  stroke: #fcfdfb;
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
  dominant-baseline: central;
  text-anchor: middle;
  font-size: 25px;
  font-weight: 750;
  pointer-events: none;
}
.diagram-text .sub { font-size: .65em; baseline-shift: sub; }
.diagram-text.aux { font-size: 23px; }
.diagram-text.cross { fill: var(--danger); font-size: 37px; }
.annotation { color: var(--blue); pointer-events: none; }
.annotation-box {
  fill: #eaf4fa;
  fill-opacity: .65;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-dasharray: 8 7;
  rx: 13px;
}
.diagram-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 20px; padding: 12px 20px; }
.legend { margin: 0; padding: 0; display: flex; gap: 4px 14px; flex-wrap: wrap; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .83rem; }
.legend i { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: currentColor; }
.legend .cross { color: var(--danger); font-size: 1.12rem; font-weight: 750; line-height: .9; }
.drag-label { color: var(--muted); font-size: .85rem; }
.notes { padding: 16px; }
.notes-heading { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 10px; }
.notes-heading h2 { font-size: 1.02rem; }
#step-count { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.current-step {
  min-height: 160px;
  padding: 13px 13px 13px 15px;
  border-radius: 9px;
  background: #f0f6f2;
  border-left: 3px solid #42876c;
}
.current-step h3 { font-size: 1.12rem; }
.current-step p { margin-top: 5px; font-size: 1rem; overflow-wrap: anywhere; }
.formula { overflow-x: auto; margin-top: 10px; color: #144634; }
.formula:empty { display: none; }
.formula math { display: block; width: max-content; max-width: none; margin: 0; padding: 2px 5px 4px 0; font-size: 1.22rem; }
.formula math + math { margin-top: 4px; }
.steps { display: grid; gap: 2px; margin: 12px 0 0; padding: 0; list-style: none; }
.steps button {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  width: 100%;
  min-height: 39px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 4px 6px;
  font-size: .9rem;
}
.steps button:hover, .steps button[aria-current="step"] { background: var(--accent-soft); }
.steps button[aria-current="step"] { font-weight: 700; color: var(--accent); }
.steps span:first-child {
  display: grid;
  flex: 0 0 23px;
  min-height: 23px;
  place-items: center;
  background: #edf1ee;
  border-radius: 50%;
  font-size: .77rem;
  color: var(--muted);
}
.steps button[aria-current="step"] span:first-child { color: white; background: var(--accent); }
.transport {
  position: fixed;
  z-index: 2;
  inset: auto 0 0;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -5px 21px #21332d0a;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
.transport-inner { display: flex; gap: 30px; align-items: center; justify-content: space-between; }
.seek { flex: 1 1 auto; min-width: 0; padding-inline: 3px; }
.seek-label { display: flex; justify-content: space-between; color: var(--muted); font-size: .875rem; }
#progress { color: var(--accent); font-weight: 750; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; margin: 0; width: 100%; height: 29px; cursor: pointer; accent-color: var(--accent); }
.ticks { height: 5px; position: relative; margin-inline: 7px; }
.ticks span { position: absolute; width: 1px; height: 4px; background: #7d9188; }
.playback { display: flex; gap: 7px; }
.playback button {
  border-radius: 8px;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  background: white;
  font-weight: 650;
  font-size: .9rem;
  white-space: nowrap;
}
.playback .play { min-width: 112px; color: white; background: var(--accent); border-color: var(--accent); }
.playback .play:hover { background: #0f4837; }
.playback button:disabled { color: #778780; background: #f6f8f6; }
.playback button span[aria-hidden] { font-size: .76em; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .diagram { max-width: 720px; width: 100%; margin-inline: auto; }
  .notes { max-width: 720px; width: 100%; margin-inline: auto; }
}
@media (max-width: 640px) {
  .wrap { width: calc(100% - 24px); }
  .masthead-inner { min-height: 52px; gap: 9px; }
  .brand-mark { width: 33px; height: 33px; border-radius: 8px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .preset-buttons { display: none; }
  .presets { margin-block: 10px; }
  .mobile-select { display: flex; align-items: center; gap: 9px; font-size: .88rem; font-weight: 650; }
  .mobile-select select { flex: 1; min-width: 0; padding-inline: 7px; }
  .workspace { gap: 9px; }
  .diagram-heading, .diagram-footer { padding: 8px 11px; }
  .diagram-heading p { font-size: .94rem; }
  .diagram-footer { gap: 2px 9px; }
  .notes { padding: 9px; }
  .notes-heading { margin-bottom: 5px; }
  .current-step { padding: 8px 10px; min-height: 0; }
  .transport { padding-top: 6px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .transport-inner { display: grid; gap: 4px; }
  .playback { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .playback button, .playback .play { min-width: 0; min-height: 44px; padding-inline: 2px; white-space: normal; }
  .diagram-text { font-size: 29px; }
  .diagram-text.aux { font-size: 27px; }
}
@media (max-height: 450px) and (max-width: 900px) and (orientation: landscape) {
  .graph svg { max-height: 185px; }
}
