/* Planar 2R arm demo — three-way sync (arm ↔ graph ↔ live numbers) */
.tc-arm-demo {
  --tc-arm-border: #cbd5e1;
  --tc-arm-muted: #64748b;
  margin: 0 0 1.25rem;
  border: 1px solid var(--tc-arm-border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.tc-arm-demo .tc-arm-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--tc-arm-border);
}

/* パネル間の向き矢印（レイアウトは変えず境界に重ねる） */
.tc-arm-demo .tc-arm-flow-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  /* 横矢印なので「太さ」= ページ上の高さ */
  width: 3.1rem;
  height: 4.6rem;
  margin: 0;
  padding: 0;
  border: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: #16a34a;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.25));
}

.tc-arm-demo .tc-arm-flow-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tc-arm-demo[data-mode="ik"] .tc-arm-flow-arrow,
.tc-arm-demo[data-mode="singularity"] .tc-arm-flow-arrow,
.tc-arm-demo[data-mode="branches"] .tc-arm-flow-arrow,
.tc-arm-demo[data-mode="branches3"] .tc-arm-flow-arrow,
.tc-arm-demo[data-mode="dexterity"] .tc-arm-flow-arrow {
  transform: translate(-50%, -50%) scaleX(-1);
}

.tc-arm-demo .tc-arm-hatch-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.tc-arm-demo .tc-arm-jxg {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  background: transparent;
}

/* 先端座標 infobox を濃く */
.tc-arm-demo .JXGinfobox {
  color: #0f172a !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  opacity: 1 !important;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}

.tc-arm-demo .tc-arm-len {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0.35rem 0 0;
  font-size: 0.85rem;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.tc-arm-demo .tc-arm-len input[type="range"] {
  width: 6.5rem;
  vertical-align: middle;
}

@media (max-width: 720px) {
  .tc-arm-demo .tc-arm-grid {
    grid-template-columns: 1fr;
  }
  /* 縦積み時は下向き（IKは上向き） */
  .tc-arm-demo .tc-arm-flow-arrow {
    left: 50%;
    top: 50%;
    width: 4.2rem;
    height: 2.8rem;
    transform: translate(-50%, -50%) rotate(90deg);
  }
  .tc-arm-demo[data-mode="ik"] .tc-arm-flow-arrow,
  .tc-arm-demo[data-mode="singularity"] .tc-arm-flow-arrow,
  .tc-arm-demo[data-mode="branches"] .tc-arm-flow-arrow,
  .tc-arm-demo[data-mode="branches3"] .tc-arm-flow-arrow,
  .tc-arm-demo[data-mode="dexterity"] .tc-arm-flow-arrow {
    transform: translate(-50%, -50%) rotate(-90deg);
  }
}

.tc-arm-demo .tc-arm-canvas-wrap,
.tc-arm-demo .tc-arm-board-wrap {
  position: relative;
  background: #e2e8f0;
  /* 高さは JS が「列幅と max の小さい方」で正方形にセット */
  width: 100%;
  overflow: hidden;
}

.tc-arm-demo .tc-arm-board-wrap {
  background: #f8fafc;
  border-left: 1px solid var(--tc-arm-border);
}

@media (max-width: 720px) {
  .tc-arm-demo .tc-arm-board-wrap {
    border-left: 0;
    border-top: 1px solid var(--tc-arm-border);
  }
}

.tc-arm-demo canvas.tc-arm-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.tc-arm-demo canvas.tc-arm-canvas.is-dragging {
  cursor: grabbing;
}

.tc-arm-demo .tc-arm-lib-credit,
.tc-arm-demo .tc-arm-drag-hint {
  position: absolute;
  z-index: 3;
  margin: 0;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: rgba(248, 250, 252, 0.9);
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 500;
  pointer-events: none;
  user-select: none;
}

.tc-arm-demo .tc-arm-lib-credit {
  left: 0.45rem;
  bottom: 0.4rem;
}

.tc-arm-demo .tc-arm-drag-hint {
  right: 0.45rem;
  bottom: 0.4rem;
  font-size: 0.85rem;
}

.tc-arm-demo .tc-arm-singularity-badge {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 3;
  margin: 0;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  border: 1px solid #fecaca;
  background: rgba(254, 226, 226, 0.95);
  color: #b91c1c;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
}

.tc-arm-demo .tc-arm-singularity-badge[hidden] {
  display: none !important;
}

.tc-arm-demo .tc-arm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--tc-arm-border);
  background: #f8fafc;
}

.tc-arm-demo .tc-arm-toolbar button {
  appearance: none;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}

.tc-arm-demo .tc-arm-toolbar button[aria-pressed="true"] {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.tc-arm-demo .tc-arm-toolbar button[hidden] {
  display: none !important;
}

.tc-arm-demo .tc-arm-toolbar-sep {
  display: inline-block;
  width: 1px;
  height: 1.15rem;
  margin: 0 0.15rem;
  background: #cbd5e1;
  flex: 0 0 auto;
  align-self: center;
}

.tc-arm-demo .tc-arm-toolbar .tc-arm-tool-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--tc-arm-muted);
}

.tc-arm-demo .tc-arm-readout {
  padding: 0.65rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.tc-arm-demo .tc-arm-live-eq {
  margin: 0 0 0.35rem;
  white-space: pre-wrap;
}

.tc-arm-demo .tc-arm-live-eq .n {
  color: #0369a1;
  font-weight: 600;
}

.lab-eq {
  margin: 0.75rem 0 1rem;
  overflow-x: auto;
}

.lab-code-sub {
  font-size: 0.95rem;
  margin: 0.75rem 0 0.35rem;
  color: #0f172a;
}

.lab-code-note {
  margin: 0 0 0.75rem;
  color: #334155;
  font-size: 1rem;
  line-height: 1.8;
}

.lab-fig-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 0.75rem;
  font-size: 1rem;
  line-height: 1.8;
  color: #1e293b;
}

.lab-fig-table th,
.lab-fig-table td {
  border: 1px solid #cbd5e1;
  padding: 0.45em 0.7em;
  vertical-align: top;
  text-align: left;
  font-size: 1rem;
  line-height: 1.8;
}

.lab-fig-table th {
  width: 7.5em;
  white-space: nowrap;
  background: #f8fafc;
  font-weight: 600;
  color: #0f172a;
}

.lab-fig-table code {
  font-size: 0.92em;
}

.lab-series-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
}

.lab-series-nav .lab-series-label { color: #64748b; }
.lab-series-nav .lab-series-current {
  font-weight: 700;
  color: #0f172a;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #e2e8f0;
}
.lab-series-nav a { color: #2563eb; font-weight: 600; text-decoration: none; }
.lab-series-nav a:hover { text-decoration: underline; }

.tc-arm-demo .tc-arm-branch-badge {
  border-color: #fde68a;
  background: rgba(254, 243, 199, 0.95);
  color: #b45309;
}

/* Compact left-only mini (overview strip) */
.tc-arm-demo--compact {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #e2e8f0;
  pointer-events: none;
}
.tc-arm-demo--compact .tc-arm-grid--solo {
  display: block;
  border-bottom: 0;
}
.tc-arm-demo--compact .tc-arm-canvas-wrap {
  width: 100%;
  background: #e2e8f0;
}
.tc-arm-demo--compact canvas.tc-arm-canvas {
  cursor: default;
}

/* Overview strip — 上4・下4（ロータリー同型） */
.lab-mini-strip {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 auto 1.25rem;
  padding: 0;
  max-width: 48rem;
  border: 1px solid #64748b;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.lab-mini-caption {
  margin: 0;
  padding: 0.45rem 0.5rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0f172a;
  border-bottom: 1px solid #64748b;
  background: #fff;
}
.lab-mini-subheads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #64748b;
  background: #f8fafc;
}
.lab-mini-sub {
  margin: 0;
  padding: 0.35rem 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}
.lab-mini-sub + .lab-mini-sub {
  border-left: 1px solid #64748b;
}
.lab-mini-sub a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}
.lab-mini-sub a:hover {
  text-decoration: underline;
}
.lab-mini-strip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  background: #fff;
}
.lab-mini-card {
  position: relative;
  display: block;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid #64748b;
  border-bottom: 1px solid #64748b;
  background: #fff;
  text-decoration: none;
  color: inherit;
  aspect-ratio: 1 / 1;
}
.lab-mini-card:nth-child(4n) {
  border-right: 0;
}
.lab-mini-card:nth-child(n+5) {
  border-bottom: 0;
}
.lab-mini-card .lab-mini-hit {
  position: absolute;
  inset: 0;
  z-index: 3;
  text-indent: -9999px;
  overflow: hidden;
}
.lab-mini-card .tc-arm-demo--compact {
  width: 100%;
  height: 100%;
}

/* 題名付きカード（リンクはカード全体。題名はオーバーレイを塞がない） */
a.lab-mini-card.lab-mini-card--titled {
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}
a.lab-mini-card.lab-mini-card--titled:hover .lab-mini-title {
  color: #1d4ed8;
  background: #eff6ff;
}
.lab-mini-card--titled .lab-mini-viz {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #e2e8f0;
}
.lab-mini-card--titled .lab-mini-viz .tc-arm-demo--compact {
  width: 100%;
  height: 100%;
}
.lab-mini-card--titled .lab-mini-title {
  flex: 0 0 auto;
  display: block;
  margin: 0;
  padding: 0.28rem 0.2rem 0.32rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  color: #334155;
  background: #fff;
  border-top: 1px solid #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-mini-card--titled:nth-child(n+5) {
  border-bottom: 0;
}

/* ---------------------------------------------------------------------------
 * Live-equation blocks.
 * In the lab these rules sit in an inline <style> in each page; post_content
 * is the wrong place for a stylesheet, so they are folded in here. Lab-only
 * chrome (blog-lab banner, generation nav) is deliberately left behind.
 * ------------------------------------------------------------------------- */
.lab-eq-pairs {
  margin: 0.65rem 0 1.15rem;
  /* ボックス全体を中央へ（行ごと中央揃えはしない＝桁揃えを壊さない） */
  display: flex;
  justify-content: center;
}
.lab-eq-pairs-box {
  display: inline-block;
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding: 0.65rem 0.9rem;
  border: 2px solid #60a5fa;
  border-radius: 2px;
  background: #fff;
  text-align: left;
  box-sizing: border-box;
  overflow-x: auto;
}
.lab-eq-pairs .lab-eq-pair {
  margin: 0;
  padding: 0.15rem 0;
}
.lab-eq-pairs .lab-eq-pair + .lab-eq-pair {
  margin-top: 0.45rem;
  padding-top: 0.55rem;
  border-top: 1px solid #93c5fd;
}
/* 公式・インタラクティブとも等幅・ボックス内は左揃え・同じ桁枠 */
.lab-eq-pairs .lab-live-line {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.55;
  color: #0f172a;
  white-space: pre;
}
.lab-eq-pairs .lab-live-line.lab-live-num {
  color: #334155;
}
.lab-eq-pairs .s,
.lab-eq-pairs .n {
  display: inline-block;
  text-align: center;
  white-space: pre;
  box-sizing: content-box;
  font-weight: 600;
}
.lab-eq-pairs .s { color: #0f172a; }
.lab-eq-pairs .n { color: #0369a1; text-align: right; }
.lab-eq-pairs .s-ang,
.lab-eq-pairs .n-ang { width: 7ch; }
.lab-eq-pairs .s-xy,
.lab-eq-pairs .n-xy { width: 6ch; }
.lab-eq-pairs .s-L,
.lab-eq-pairs .n-L { width: 2ch; }
.lab-eq-pairs .s-br,
.lab-eq-pairs .n-br { width: 2em; }
/* 解説用の体裁よい KaTeX（等幅ペアの上） */
.lab-eq-stack {
  margin: 0.35rem 0 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.lab-eq-stack .lab-eq {
  margin: 0;
  overflow-x: auto;
}
.lab-eq-stack.lab-eq-stack--sm {
  margin: 0.75rem 0 0.45rem;
  font-size: 0.82em;
}


html:not([lang|="ja"]) .lab-eq-pairs .s-br,
html:not([lang|="ja"]) .lab-eq-pairs .n-br { width: 7ch; }

/* ---------------------------------------------------------------------------
 * Which figures live on this page.
 * The strip is a 4x2 grid, but the series splits 3 figures / 5 figures, so the
 * current article's group wraps onto the second row and no single rectangle
 * encloses it. Each card therefore draws only the edges that fall on the
 * group's boundary; together they close the outline. Card order is fixed by
 * ARTICLE-EMBED-robot-ik-mini-strip.md §4, which is what makes nth-child safe.
 * Drawn on a pseudo-element so it sits above the canvas and costs no layout.
 *
 * Green, not blue: the strip already spends blue on the link to the other page,
 * and the figures themselves draw the end effector in blue. The subhead names
 * the colour, so keep the two in step.
 * ------------------------------------------------------------------------- */
.lab-mini-strip--part1 .lab-mini-card:nth-child(-n+3)::after,
.lab-mini-strip--part2 .lab-mini-card:nth-child(n+4)::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border: 0 solid #16a34a;
}

/* The label for that outline. Left plain in the lab, where nothing is outlined. */
.lab-mini-strip--part1 .lab-mini-sub.is-current,
.lab-mini-strip--part2 .lab-mini-sub.is-current {
  color: #16a34a;
}

/* Part 1 owns cards 1-3: a plain rectangle across the top row. */
.lab-mini-strip--part1 .lab-mini-card:nth-child(-n+3)::after {
  border-top-width: 3px;
  border-bottom-width: 3px;
}
.lab-mini-strip--part1 .lab-mini-card:nth-child(1)::after {
  border-left-width: 3px;
}
.lab-mini-strip--part1 .lab-mini-card:nth-child(3)::after {
  border-right-width: 3px;
}

/* Part 2 owns cards 4-8. Card 4 sits directly above card 8, so the shared edge
 * between them stays open and the outline reads as one L-shaped region. */
.lab-mini-strip--part2 .lab-mini-card:nth-child(4)::after {
  border-top-width: 3px;
  border-left-width: 3px;
  border-right-width: 3px;
}
.lab-mini-strip--part2 .lab-mini-card:nth-child(n+5)::after {
  border-top-width: 3px;
  border-bottom-width: 3px;
}
.lab-mini-strip--part2 .lab-mini-card:nth-child(5)::after {
  border-left-width: 3px;
}
.lab-mini-strip--part2 .lab-mini-card:nth-child(8)::after {
  border-top-width: 0;
  border-right-width: 3px;
}