/* =====================================================================
 * DNCL2 Studio — 1画面完結型 共通テスト用プログラム言語 ⇄ Python ラボ
 * Light Cobalt CAD | WCAG 2.1 Readability | Strict Aligned Height
 * ===================================================================== */

@font-face {
  font-family: 'DNCL Courier Bold';
  src: local('Courier New Bold'), local('CourierNewPS-BoldMT'), local('CourierNew-Bold');
  font-weight: 400;
  font-style: normal;
  unicode-range: U+0020-007E, U+00F7;
}

@font-face {
  font-family: 'DNCL Courier Bold';
  src: local('Courier New Bold'), local('CourierNewPS-BoldMT'), local('CourierNew-Bold');
  font-weight: 500;
  font-style: normal;
  unicode-range: U+0020-007E, U+00F7;
}

@font-face {
  font-family: 'DNCL Courier Bold';
  src: local('Courier New Bold'), local('CourierNewPS-BoldMT'), local('CourierNew-Bold');
  font-weight: 700;
  font-style: normal;
  unicode-range: U+0020-007E, U+00F7;
}

:root {
  --bg-canvas: #e6ecf5;
  --code-fs: 14.5px;
  --bg-grid: rgba(100, 116, 139, 0.16);
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --surface-tint: #eff6ff;
  --border: #94a3b8;
  --border-strong: #64748b;

  --text-main: #0f172a;
  --text-sub: #334155;
  --text-muted: #475569;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --indigo: #4f46e5;

  --write: #059669;
  --write-bg: #ecfdf5;
  --write-border: #34d399;

  --read: #0284c7;
  --read-bg: #e0f2fe;
  --read-border: #38bdf8;

  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 10px 26px -16px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-pop: 0 18px 36px -12px rgba(15, 23, 42, 0.25), 0 4px 12px rgba(15, 23, 42, 0.08);

  --font-ui: 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Meiryo', system-ui, -apple-system, sans-serif;
  --font-code: 'Courier New', Courier, 'SF Mono', 'Menlo', 'Consolas', monospace;
  --font-py: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', 'DejaVu Sans Mono', monospace;
  --font-dncl: 'DNCL Courier Bold', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Meiryo', monospace;
  --spring: cubic-bezier(0.22, 1.35, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.5;
  background-color: var(--bg-canvas);
  background-image:
    linear-gradient(to right, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2.5px solid rgba(37, 99, 235, 0.45);
  outline-offset: 1px;
}

.mono {
  font-family: var(--font-code);
  font-variant-numeric: tabular-nums;
}

/* ---------- Ultra-Slim 1-Row Header (46px) ---------- */
.topbar {
  height: 46px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 22%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
  white-space: nowrap;
}

.brand-pen {
  color: var(--primary);
}

.btn-guide-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--primary);
  background: var(--surface-tint);
  border: 1px solid #bfdbfe;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  transition: transform 0.16s var(--spring), background 0.16s ease, box-shadow 0.16s ease;
}

.btn-guide-pill:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.15);
}

.topbar-debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.topbar-debug-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.topbar-debug-toggle.is-debug-on {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--primary);
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-inline-settings,
.topbar-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar .topbar-settings-btn {
  display: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-sub-tag {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
  margin-left: 1px;
}

.history-sep {
  width: 1px;
  height: 18px;
  background: #cbd5e1;
  margin: 0 3px;
}

.btn-history-reset:hover:not(:disabled) {
  color: var(--danger);
}

.history-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.btn-history {
  border: none;
  background: transparent;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.btn-history:hover:not(:disabled) {
  background: var(--surface);
  color: var(--primary);
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.btn-history:disabled {
  color: var(--text-muted);
  opacity: 0.42;
}

.btn-history-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.preset-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  padding: 3px 8px 3px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.preset-select {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  padding: 2px 4px;
  max-width: 240px;
}

.seg-control {
  display: inline-flex;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.seg-compact {
  background: #e2e8f0;
  border-color: #cbd5e1;
  padding: 2px;
  border-radius: 8px;
}

.seg-compact .seg-btn {
  padding: 2px 7px;
  font-size: 12.5px;
  border-radius: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 700;
  padding: 5px 11px;
  white-space: nowrap;
  transition: transform 0.15s var(--spring), background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-xs {
  padding: 3px 9px;
  font-size: 13px;
  border-radius: 8px;
  white-space: nowrap;
}

.btn-run-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-emerald {
  background: var(--write);
  border-color: var(--write);
  color: #ffffff;
}

.btn-emerald:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
}

.btn-soft {
  background: var(--surface-tint);
  border-color: #bfdbfe;
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: #dbeafe;
}

.btn-toggle.is-on {
  background: var(--primary-soft);
  border-color: #93c5fd;
  color: var(--primary);
}

/* ---------- 1-Screen Cockpit Shell + Expanded Bottom Table ---------- */
.workspace-shell {
  height: calc(100vh - 46px);
  padding: 10px 14px;
  max-width: 1840px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cockpit {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, var(--left-pane-fr, 1fr)) 10px minmax(260px, var(--right-pane-fr, 1fr));
  gap: 0;
  align-items: stretch;
}

.v-splitter {
  position: relative;
  width: 10px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  z-index: 6;
}

.v-splitter-grip {
  width: 4px;
  height: 44px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.15s ease, height 0.15s ease, width 0.15s ease;
}

.v-splitter:hover .v-splitter-grip,
.v-splitter.is-dragging .v-splitter-grip {
  width: 5px;
  height: 64px;
  background: var(--primary);
}

body.is-exercise .v-splitter-grip {
  background: #fcd34d;
}

body.is-exercise .v-splitter:hover .v-splitter-grip,
body.is-exercise .v-splitter.is-dragging .v-splitter-grip {
  background: #d97706;
}

.expanded-splitter {
  display: none;
  margin: 5px 0;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.expanded-trace-dock {
  display: none;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 10px 14px;
  overflow: hidden;
}

.workspace-shell.is-trace-expanded .cockpit {
  flex: 0 0 auto;
  height: clamp(250px, 44%, 390px);
}

.workspace-shell.is-trace-expanded #leftSplitter,
.workspace-shell.is-trace-expanded #leftBottomDock {
  display: none !important;
}

.workspace-shell.is-trace-expanded #rightViewTrace .trace-scroll {
  display: none !important;
}

.workspace-shell.is-trace-expanded #rightViewTrace .trace-body {
  overflow-y: auto;
}

.workspace-shell.is-trace-expanded .expanded-splitter {
  display: grid;
}

.workspace-shell.is-trace-expanded .expanded-trace-dock {
  display: flex;
  flex-direction: column;
}

.workspace-shell.is-trace-expanded .expanded-trace-dock #traceTablePane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.workspace-shell.is-trace-expanded .expanded-trace-dock .matrix-wrap {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.tab-meta-actions>.is-hidden {
  display: none !important;
}

.py-sync-pill {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-tint);
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Compact Vertical-Stacked Orange Conversion Bridge Inside Right Header */
.panel-bridge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 2px 7px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(234, 88, 12, 0.1);
  flex-shrink: 0;
}

.bridge-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bridge-mini-btn {
  min-width: 78px;
  height: 15px;
  border-radius: 5px;
  border: 1px solid #fdba74;
  background: #ffedd5;
  color: #c2410c;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  transition: transform 0.14s var(--spring), background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.bridge-mini-btn:hover {
  background: #fed7aa;
  border-color: #f97316;
  transform: scale(1.03);
}

.bridge-arrow-mark {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  transition: transform 0.16s var(--spring);
}

.bridge-mini-btn.is-dir-active,
.bridge-mini-btn.is-flash {
  background: #ea580c;
  border-color: #c2410c;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(234, 88, 12, 0.35);
}

.bridge-mini-btn.is-dir-active .bridge-arrow-mark,
.bridge-mini-btn.is-flash .bridge-arrow-mark {
  transform: scale(1.24);
}

.bridge-mini-btn.is-dir-active:hover,
.bridge-mini-btn.is-flash:hover {
  background: #c2410c;
  border-color: #9a3412;
}

.bridge-checks-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bridge-mini-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 800;
  color: #7c2d12;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 0 3px;
  border-radius: 4px;
  line-height: 1.25;
}

.bridge-mini-toggle input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: #ea580c;
}

.bridge-auto-toggle.is-auto-on {
  background: #ffedd5;
  color: #c2410c;
}

.bridge-mini-mark {
  color: var(--text-muted);
}

.bridge-mini-mark input {
  accent-color: var(--primary);
}

.pane-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* CAD Corner Crop Marks */
.pane-card::before,
.pane-card::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  z-index: 4;
}

.pane-card::before {
  top: 6px;
  left: 6px;
  border-top: 2px solid #93c5fd;
  border-left: 2px solid #93c5fd;
  border-top-left-radius: 3px;
}

.pane-card::after {
  bottom: 6px;
  right: 6px;
  border-bottom: 2px solid #93c5fd;
  border-right: 2px solid #93c5fd;
  border-bottom-right-radius: 3px;
}

/* Exact Identical Top Chrome Height on Left & Right Panes */
.panel-tabs {
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border);
  background: #f1f5f9;
  overflow-x: auto;
  scrollbar-width: none;
}

.panel-tabs::-webkit-scrollbar {
  display: none;
}

.tab-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 34px;
  padding: 3px;
  border-radius: 10px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}

.tab-btn {
  position: relative;
  border: none;
  background: transparent;
  color: #475569;
  font-size: 13.5px;
  font-weight: 800;
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tab-btn:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
}

.tab-btn.is-active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.tab-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

.pane-title-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  white-space: nowrap;
}

.tab-meta-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Exact Identical 42px Slim Toolbar Height -> Editor Tops Align to Exact Pixel! */
.panel-toolbar {
  height: 42px;
  flex-shrink: 0;
  padding: 0 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  z-index: 15;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.toolbar-left {
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-right {
  flex-shrink: 0;
}

.toolbar-left::-webkit-scrollbar {
  display: none;
}

/* Dropdown Snippet Menus (zero vertical bloat!) */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: fixed;
  z-index: 70;
  min-width: 390px;
  max-width: min(560px, calc(100vw - 24px));
  max-height: 74vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
}

.settings-menu {
  min-width: 310px;
  padding: 10px 12px;
  gap: 6px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  padding: 5px 8px;
  border-radius: 9px;
}

.setting-check-row {
  cursor: pointer;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.setting-check-row:hover {
  background: var(--surface-tint);
}

.setting-check-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.setting-scale-row {
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.setting-scale-seg {
  background: var(--surface);
}

.setting-scale-seg .seg-btn {
  padding: 3px 7px;
  font-size: 11.5px;
}

body.is-exercise .setting-check-row,
body.is-exercise .setting-scale-row {
  background: #fffdf0;
  border-color: #fcd34d;
}

body.is-exercise .setting-check-row:hover {
  background: #fef3c7;
}

body.is-exercise .setting-scale-seg .seg-btn.is-active {
  background: #d97706;
  color: #ffffff;
}

.dropdown-menu.is-open {
  display: flex;
}

.rename-popover {
  min-width: 340px;
  max-width: min(440px, calc(100vw - 24px));
  padding: 12px 14px;
  gap: 10px;
}

.rename-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rename-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
}

.rename-target-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

.rename-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rename-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}

.rename-sub {
  font-weight: 500;
  color: var(--text-muted);
}

.rename-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  background: #f8fafc;
  border: 1.5px solid var(--border-strong);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rename-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.rename-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 76px;
  overflow-y: auto;
}

.rename-chip {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.12s ease;
}

.rename-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.rename-chip.is-array {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.rename-chip.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.rename-option-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rename-chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
}

.rename-preview {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text-sub);
  line-height: 1.45;
}

.rename-preview.is-ok {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.rename-preview.is-warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.rename-preview.is-error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.rename-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.menu-section-label {
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  background: #f1f5f9;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 6px;
  user-select: none;
  pointer-events: none;
}

.menu-section-label:first-child {
  margin-top: 0;
}

.menu-item {
  border: 1px solid transparent;
  background: #ffffff;
  width: calc(100% - 4px);
  margin-left: 4px;
  text-align: left;
  padding: 7px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.menu-item:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.menu-item-code {
  font-family: var(--font-dncl);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
}

#menuPySyntax .menu-item-code,
#menuPyFunc .menu-item-code,
#menuPyOps .menu-item-code {
  font-family: var(--font-code);
  font-weight: 600;
}

.menu-item-code::before {
  content: '› ';
  color: var(--primary);
  font-weight: 800;
}

.menu-item-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 1px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.chip--pipe,
.chip--L {
  font-family: var(--font-dncl);
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-tint);
  border-color: #bfdbfe;
  min-width: 28px;
}

/* Tab Content Bodies */
.tab-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tab-view.is-active {
  display: flex;
}

/* Collapsible Prelude (問題定義関数) Drawer */
.prelude-drawer {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  flex-shrink: 0;
}

.prelude-drawer.is-open {
  display: flex;
}

.prelude-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.prelude-title {
  font-size: 13.5px;
  font-weight: 800;
  color: #1e40af;
}

.prelude-textarea {
  width: 100%;
  height: 92px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #93c5fd;
  background: #ffffff;
  font-family: var(--font-dncl);
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
}

/* Editor Stage with (01) DNCL Gutter & Narrow Indent Support */
.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  background: #ffffff;
  overflow: hidden;
}

.dncl-editor-wrap {
  grid-template-columns: 58px minmax(0, 1fr);
}

.dncl-editor-wrap .editor-gutter,
.dncl-editor-wrap .editor-highlight-inner,
.dncl-editor-wrap .code-input {
  font-family: var(--font-dncl);
  font-weight: 500;
}

.editor-gutter {
  background: #f8fafc;
  border-right: 1px solid var(--border);
  padding: 12px 6px;
  text-align: right;
  font-family: var(--font-code);
  font-size: var(--code-fs);
  line-height: 1.65;
  color: #64748b;
  user-select: none;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.gutter-line {
  height: calc(var(--code-fs) * 1.65);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
  border-radius: 5px;
}

.gutter-line.is-exec {
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

.gutter-line.is-err {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 800;
}

.editor-stage {
  position: relative;
  min-width: 0;
  height: 100%;
}

.editor-active-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--code-fs) * 1.65);
  background: rgba(37, 99, 235, 0.08);
  border-left: 3px solid var(--primary);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.18s var(--ease-out), opacity 0.14s ease;
  z-index: 1;
}

.editor-active-bar.is-visible {
  opacity: 1;
}

.editor-highlight-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.editor-highlight-inner {
  padding: 12px 14px;
  font-family: var(--font-code);
  font-size: var(--code-fs);
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  color: transparent;
  will-change: transform;
}

.py-highlight-inner {
  tab-size: 4;
}

.editor-drop-hint {
  position: absolute;
  inset: 8px;
  border: 2.5px dashed var(--primary);
  border-radius: 12px;
  background: rgba(239, 246, 255, 0.92);
  color: var(--primary);
  font-size: 14.5px;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 45;
  pointer-events: none;
}

.editor-stage.is-dragover .editor-drop-hint {
  display: flex;
}

.ph-mark {
  background: rgba(251, 191, 36, 0.34);
  color: transparent;
  border-bottom: 2px solid #d97706;
  border-radius: 3px;
}

.ph-hl {
  display: inline-block;
  background: #fef3c7;
  color: #b45309;
  border-bottom: 1.5px dashed #d97706;
  border-radius: 4px;
  padding: 0 4px;
  font-weight: 800;
}

.code-input {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  background: transparent;
  padding: 12px 14px;
  font-family: var(--font-code);
  font-size: var(--code-fs);
  line-height: 1.65;
  color: var(--text-main);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

.py-code-input {
  tab-size: 4;
}

.code-input:focus {
  outline: none;
}

/* VSCode-style Floating Autocomplete Popup */
.ac-popup {
  position: absolute;
  z-index: 50;
  min-width: 260px;
  max-width: 390px;
  max-height: 230px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #93c5fd;
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 5px;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.ac-popup.is-open {
  display: flex;
}

.ac-item {
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ac-item.is-selected,
.ac-item:hover {
  background: var(--primary-soft);
}

.ac-label {
  font-family: var(--font-code);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-kind {
  font-size: 12px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}

.ac-kind--arr {
  background: #fef3c7;
  color: #92400e;
}

.ac-kind--var {
  background: #dbeafe;
  color: #1e40af;
}

.ac-kind--fn {
  background: #e0e7ff;
  color: #3730a3;
}

.ac-kind--tpl {
  background: #ecfdf5;
  color: #065f46;
}

/* Unified Diagnostic & Debug Bar (Hideable!) */
.diag-dock {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 92px;
  overflow-y: auto;
}

.diag-dock.is-hidden {
  display: none;
}

.diag-empty {
  color: var(--write);
  font-size: 13.5px;
  font-weight: 700;
}

.diag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  border: 1px solid transparent;
  background: var(--surface);
  width: 100%;
  text-align: left;
}

.diag-item-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.diag-item.is-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

.diag-item.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: #92400e;
}

.diag-item.is-info {
  background: var(--surface-tint);
  border-color: #bfdbfe;
  color: #1e40af;
}

.diag-badge {
  font-family: var(--font-code);
  font-size: 12.5px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  flex-shrink: 0;
}

/* Status Pill when Debug is Hidden */
.error-mini-pill {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.error-mini-pill.is-visible {
  display: inline-flex;
}

/* Official Notation View */
.official-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.official-row {
  display: grid;
  grid-template-columns: 44px auto minmax(0, 1fr);
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 9px;
  font-family: var(--font-code);
  font-size: 14.5px;
  line-height: 1.5;
  border: 1px solid transparent;
  transition: background 0.16s ease, transform 0.18s var(--spring);
}

.official-row.is-active {
  background: var(--surface-tint);
  border-color: #60a5fa;
  transform: translateX(3px);
}

.official-row.is-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.off-no {
  color: #64748b;
  font-weight: 700;
}

.off-marks {
  display: inline-flex;
  gap: 4px;
  font-weight: 800;
}

.mark-pipe,
.mark-L {
  color: var(--primary);
  display: inline-block;
  width: 1ch;
  text-align: center;
}

.off-code {
  color: var(--text-main);
  word-break: break-word;
}

.stack-rule-bar {
  padding: 8px 14px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-sub);
  flex-shrink: 0;
}

/* ---------- Right Panel: Conversion Packet + Trace Stage ---------- */
.sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
}

.sync-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.bridge-flash {
  font-size: 13px;
  font-weight: 800;
  color: var(--write);
  white-space: nowrap;
}

.bridge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.bridge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.35;
}

.bridge-dot.is-flash {
  animation: dotPulse 0.6s var(--spring);
}

@keyframes dotPulse {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }

  45% {
    transform: scale(1.9);
    opacity: 1;
    background: var(--write);
  }

  100% {
    transform: scale(1);
    opacity: 0.45;
  }
}

/* Trace Sub-Layout Inside Right Panel */
.trace-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scrubber-strip {
  padding: 8px 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.scrubber-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.scrubber-wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 22px;
}

.scrubber-fill {
  position: absolute;
  left: 0;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--write) 100%);
  pointer-events: none;
  width: 0%;
}

.scrubber {
  position: relative;
  z-index: 2;
  width: 100%;
  appearance: none;
  background: rgba(203, 213, 225, 0.55);
  height: 6px;
  border-radius: 999px;
  cursor: pointer;
}

.scrubber::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.narration-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 14px;
  font-weight: 700;
}

.narration-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

.narration-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.narration-align {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-left: 3.5px solid var(--primary);
  overflow-x: auto;
}

.narration-align:empty {
  display: none;
}

.ta-row {
  display: inline-flex;
  align-items: stretch;
  flex-wrap: nowrap;
  font-family: var(--font-code);
  font-size: 13.5px;
  line-height: 1.35;
  min-width: max-content;
}

.ta-col {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 3px;
  white-space: pre;
  gap: 2px;
}

.ta-col.is-punct-open {
  padding: 0 1px 0 3px;
}

.ta-col.is-punct-comma {
  padding: 0 4px 0 0;
}

.ta-col.is-punct-close {
  padding: 0 2px 0 0;
}

.ta-top,
.ta-bot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  padding: 1px 4px;
  border-radius: 5px;
}

.ta-top {
  font-weight: 700;
  color: var(--text-sub);
}

.ta-bot {
  font-weight: 800;
  color: var(--text-main);
}

.ta-col.is-write .ta-top {
  color: #065f46;
}

.ta-col.is-write .ta-bot {
  color: var(--write);
  background: var(--write-bg);
  border-color: var(--write-border);
}

.ta-col.is-read .ta-top {
  color: #0369a1;
}

.ta-col.is-read .ta-bot {
  color: var(--read);
  background: var(--read-bg);
  border-color: var(--read-border);
}

.ta-col.is-call .ta-top {
  color: #3730a3;
}

.ta-col.is-call .ta-bot {
  color: var(--indigo);
  background: #eef2ff;
  border-color: #c7d2fe;
}

.ta-col.is-lit .ta-top {
  color: var(--text-muted);
}

.ta-col.is-lit .ta-bot {
  color: var(--text-muted);
  font-weight: 700;
}

.ta-col.is-op .ta-top,
.ta-col.is-op .ta-bot {
  color: #475569;
  font-weight: 800;
  padding-left: 2px;
  padding-right: 2px;
}

.ta-col.is-punct .ta-top,
.ta-col.is-punct .ta-bot,
.ta-col.is-punct-open .ta-top,
.ta-col.is-punct-open .ta-bot,
.ta-col.is-punct-comma .ta-top,
.ta-col.is-punct-comma .ta-bot,
.ta-col.is-punct-close .ta-top,
.ta-col.is-punct-close .ta-bot {
  color: #64748b;
  padding-left: 1px;
  padding-right: 1px;
  font-weight: 700;
}

.ta-col.is-skip .ta-top {
  color: #94a3b8;
  text-decoration: line-through;
}

.ta-col.is-skip .ta-bot {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: var(--warn-border);
  font-size: 11.5px;
}

.matrix-trace-align {
  margin-top: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  overflow-x: auto;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ta-row.is-compact {
  font-size: 12px;
  line-height: 1.25;
}

.ta-row.is-compact .ta-col {
  padding: 0 2px;
  gap: 1px;
}

.ta-row.is-compact .ta-col.is-punct-open {
  padding: 0 1px 0 2px;
}

.ta-row.is-compact .ta-col.is-punct-comma {
  padding: 0 3px 0 0;
}

.ta-row.is-compact .ta-col.is-punct-close {
  padding: 0 1px 0 0;
}

.ta-row.is-compact .ta-top,
.ta-row.is-compact .ta-bot {
  padding: 0 3px;
  border-radius: 4px;
}

.kind-pill {
  font-family: var(--font-code);
  font-size: 12.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  flex-shrink: 0;
}

.kind-pill--assign {
  background: var(--write);
}

.kind-pill--cond {
  background: var(--indigo);
}

.kind-pill--loop {
  background: var(--primary);
}

.kind-pill--print {
  background: #0284c7;
}

.kind-pill--error {
  background: var(--danger);
}

.kind-pill--end {
  background: #475569;
}

.cond-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.cond-badge.is-true {
  background: var(--write-bg);
  color: var(--write);
  border: 1px solid var(--write-border);
}

.cond-badge.is-false {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

/* Resizable Left Top & Bottom (I/O + Unified Diagnostics) */
.left-top-area {
  flex: 1;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.h-splitter {
  height: 9px;
  flex-shrink: 0;
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  display: grid;
  place-items: center;
  user-select: none;
  touch-action: none;
  transition: background 0.14s ease;
}

.h-splitter:hover,
.h-splitter.is-dragging {
  background: #dbeafe;
}

.h-splitter-grip {
  width: 42px;
  height: 3px;
  border-radius: 999px;
  background: #94a3b8;
}

.h-splitter:hover .h-splitter-grip,
.h-splitter.is-dragging .h-splitter-grip {
  background: var(--primary);
}

.left-bottom-dock {
  height: 196px;
  min-height: 88px;
  max-height: 60vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
}

/* IO Strip inside Left Bottom Dock (flex-1 grows as user drags splitter!) */
.io-strip {
  flex: 1;
  min-height: 62px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: minmax(135px, 0.72fr) minmax(0, 1.35fr);
  gap: 10px;
}

.io-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.io-label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

.input-queue-box {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-family: var(--font-code);
  font-size: 13.5px;
  background: #ffffff;
  resize: none;
}

.console-output {
  flex: 1;
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 7px 10px;
  border-radius: 9px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  font-family: var(--font-code);
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-output.has-error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: #991b1b;
}

.py-bottom-dock {
  height: 196px;
  min-height: 88px;
  max-height: 60vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
}

.py-console-box {
  flex: 1;
  min-height: 54px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-menu {
  min-width: 340px;
}

.compact-menu {
  min-width: 280px;
  max-width: 340px;
}

.menu-warn-note {
  margin: 4px 4px 2px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.export-opts-box {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 10px;
  margin: 2px 4px 4px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.export-preview {
  padding: 5px 8px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: var(--font-dncl);
  font-size: 12.5px;
  color: var(--primary);
  font-weight: 600;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Scrollable Trace Stage (Variables + Table views) */
.trace-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trace-subpane.is-hidden {
  display: none;
}

.callstack-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
}

.stack-frame-pill {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-family: var(--font-code);
}

.stack-frame-pill.is-top {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.memory-subhead {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scalar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  gap: 8px;
}

.var-card {
  padding: 9px 11px;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.2s var(--spring);
}

.var-card.is-written {
  background: var(--write-bg);
  border-color: var(--write-border);
  animation: varPopWrite 0.38s var(--spring);
}

.var-card.is-read {
  background: var(--read-bg);
  border-color: var(--read-border);
}

.var-card.is-exit {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

@keyframes varPopWrite {
  0% {
    transform: scale(0.95);
  }

  55% {
    transform: scale(1.045);
  }

  100% {
    transform: scale(1);
  }
}

.var-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.var-name {
  font-family: var(--font-code);
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-sub);
}

.rw-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
}

.rw-badge--write {
  background: var(--write);
  color: #fff;
}

.rw-badge--read {
  background: var(--read);
  color: #fff;
}

.rw-badge--exit {
  background: var(--warn);
  color: #fff;
}

.var-value {
  font-family: var(--font-code);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  word-break: break-all;
}

.var-delta {
  font-family: var(--font-code);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--write);
}

.var-delta--exit {
  color: var(--warn);
}

.var-prev-strike {
  text-decoration: line-through;
  color: #64748b;
  margin-right: 4px;
}

.array-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.arr-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
}

.arr-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.arr-title {
  font-family: var(--font-code);
  font-size: 14.5px;
  font-weight: 800;
}

.arr-meta {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.arr-1d-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arr-slot {
  min-width: 56px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.arr-slot.is-written {
  background: var(--write-bg);
  border-color: var(--write);
  animation: varPopWrite 0.38s var(--spring);
}

.arr-slot.is-read {
  background: var(--read-bg);
  border-color: var(--read);
}

.slot-idx {
  font-family: var(--font-code);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.slot-val {
  font-family: var(--font-code);
  font-size: 15.5px;
  font-weight: 800;
}

.slot-pointers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
}

.ptr-tag {
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
}

.arr-2d-wrap {
  overflow-x: auto;
}

.arr-2d-table {
  border-collapse: separate;
  border-spacing: 5px;
}

.arr-2d-table th {
  font-family: var(--font-code);
  font-size: 13px;
  color: var(--text-muted);
  padding: 3px 6px;
  white-space: nowrap;
}

.arr-2d-cell {
  min-width: 48px;
  padding: 6px 8px;
  text-align: center;
  border-radius: 8px;
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  font-family: var(--font-code);
  font-size: 15px;
  font-weight: 800;
}

.arr-2d-cell.is-written {
  background: var(--write-bg);
  border-color: var(--write);
}

.arr-2d-cell.is-read {
  background: var(--read-bg);
  border-color: var(--read);
}

/* Trace Table (Resizable Columns + Expanded Dock Support) */
.matrix-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  max-height: 360px;
}

.trace-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13.5px;
}

.trace-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 800;
  text-align: left;
  padding: 9px 12px 9px 10px;
  border-bottom: 2px solid var(--border-strong);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.th-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  border-right: 2px solid transparent;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.th-resizer:hover,
.trace-table th.is-resizing .th-resizer {
  border-right-color: var(--primary);
  background: rgba(37, 99, 235, 0.14);
}

body.is-col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

.trace-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #cbd5e1;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trace-row {
  cursor: pointer;
}

.trace-row:hover {
  background: #f8fafc;
}

.trace-row.is-active {
  background: #dbeafe !important;
}

.trace-row.is-active td:first-child {
  box-shadow: inset 4px 0 0 var(--primary);
  font-weight: 800;
  color: var(--primary);
}

.cell-changed {
  background: var(--write-bg);
  color: var(--write);
  font-weight: 800;
}

.cell-action {
  white-space: normal !important;
  word-break: break-word;
  overflow: visible !important;
}

/* Modal / Detailed Rules Reference */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 90;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 28px 64px -20px rgba(15, 23, 42, 0.35);
  width: min(940px, 94vw);
  height: min(740px, 88vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-tabs {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rule-group-head {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  padding: 4px 10px;
  background: var(--surface-tint);
  border-left: 3.5px solid var(--primary);
  border-radius: 6px;
  margin-top: 4px;
}

.rule-section {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.rule-section.is-active {
  display: flex;
}

.rule-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.rule-box h4 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--primary);
}

.rule-box pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: var(--font-dncl);
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1.5;
  overflow-x: auto;
}

.rule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.rule-table th,
.rule-table td {
  padding: 9px 11px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.rule-table th {
  background: var(--surface-soft);
  font-size: 13px;
}

.rule-group-cell {
  background: #f8fafc;
  vertical-align: middle !important;
}

.op-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 2px 8px;
  margin-right: 6px;
  border-radius: 7px;
  border: 1.5px solid #60a5fa;
  background: #eff6ff;
  color: #1d4ed8;
  font-family: var(--font-dncl);
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.25;
  vertical-align: baseline;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.14);
}

.rule-code {
  margin: 0;
  font-family: var(--font-py);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-main);
}

.rule-dncl {
  font-family: var(--font-dncl);
  font-weight: 700;
}

.modal-body code {
  font-family: var(--font-dncl);
  font-weight: 700;
  font-size: 0.94em;
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 4px;
}

.rule-res {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  font-family: var(--font-code);
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}

.rule-res-arrow {
  color: var(--primary);
  font-size: 11px;
  font-family: var(--font-ui);
}

.rule-ex-cell {
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap;
}

.rule-ex-btn {
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.rule-ex-btn.is-open {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.rule-example-row td {
  padding: 12px 14px;
  background: #f8fafc;
  border-color: var(--border-strong);
}

.rule-example-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rule-example-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.rule-example-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
}

.rule-example-pre {
  margin: 0;
  padding: 7px 9px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--font-py);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  color: var(--text-main);
}

.rule-example-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 12.5px;
  color: var(--text-sub);
}

.rule-example-out {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: #ecfdf5;
  border: 1px solid #86efac;
  border-radius: 6px;
  color: #065f46;
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 700;
}

.rule-example-in {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1e40af;
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 700;
}

.rule-pre-wrap {
  position: relative;
}

.rule-pre-copy {
  position: absolute;
  top: 8px;
  right: 8px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 95;
  background: var(--text-main);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 14px 28px -12px rgba(15, 23, 42, 0.45);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.22s var(--spring);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
}

.stale-badge {
  display: none;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
}

.stale-badge.is-stale {
  display: inline-flex;
}

.rule-example-pre-dncl {
  font-family: var(--font-dncl);
  font-weight: 700;
}

/* Python Debug Variable Snapshot Strip */
.py-vars-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12.5px;
}

.py-vars-label {
  font-weight: 800;
  color: var(--text-sub);
  margin-right: 2px;
}

.py-var-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-family: var(--font-code);
  font-size: 12px;
}

.py-var-name {
  font-weight: 800;
  color: var(--primary);
}

.py-var-val {
  color: var(--text-main);
  font-weight: 600;
}

/* Interactive Motion Guide Tour Overlay */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  pointer-events: auto;
}

.tour-layer.is-open {
  display: block;
}

@keyframes tourPulse {

  0%,
  100% {
    border-color: #f97316;
  }

  50% {
    border-color: #fdba74;
  }
}

.tour-spotlight {
  position: fixed;
  border-radius: 14px;
  border: 2.5px solid #f97316;
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.54);
  pointer-events: none;
  animation: tourPulse 2s ease-in-out infinite;
  transition: top 0.3s ease-out, left 0.3s ease-out, width 0.3s ease-out, height 0.3s ease-out;
}

.tour-popover {
  position: fixed;
  width: min(360px, calc(100vw - 24px));
  background: #ffffff;
  border: 1.5px solid #fdba74;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 24px 54px -14px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: top 0.36s var(--spring), left 0.36s var(--spring), opacity 0.22s ease;
}

.tour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tour-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: #c2410c;
  font-size: 12px;
  font-weight: 800;
}

.tour-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-main);
}

.tour-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-sub);
}

.tour-desc strong {
  color: var(--text-main);
  font-weight: 800;
}

.tour-em {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  background: #fff7ed;
  border-bottom: 1.5px solid #fb923c;
  color: #c2410c;
  font-weight: 800;
}

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.tour-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: width 0.2s var(--spring), background 0.2s ease;
}

.tour-dot.is-active {
  width: 18px;
  background: #ea580c;
}

.tour-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tour-orange {
  background: #ea580c;
  border-color: #c2410c;
  color: #ffffff;
}

.btn-tour-orange:hover:not(:disabled) {
  background: #c2410c;
  border-color: #9a3412;
}

@media (max-width: 1024px) {
  .workspace-shell {
    height: auto;
  }

  .cockpit,
  .workspace-shell.is-trace-expanded .cockpit {
    height: auto !important;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .v-splitter {
    display: none;
  }

  .pane-card {
    min-height: 520px;
  }

  .workspace-shell.is-trace-expanded .expanded-trace-dock {
    min-height: 360px;
  }
}

body.is-slim-subtags .btn-sub-tag {
  display: none;
}

body.is-compact-topbar .topbar-inline-settings,
body.is-compact-topbar .topbar-inline-actions {
  display: none;
}

body.is-compact-topbar .topbar-settings-btn {
  display: inline-flex;
}

@media (max-width: 920px) {

  .topbar .topbar-inline-settings,
  .topbar .topbar-inline-actions {
    display: none;
  }

  .topbar .topbar-settings-btn {
    display: inline-flex;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 46px;
    padding: 6px 12px;
    row-gap: 6px;
  }

  .brand {
    flex-wrap: wrap;
    gap: 6px;
  }

  .rule-example-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {

  .btn-history-label,
  .btn-sub-tag {
    display: none;
  }

  .btn-history {
    padding: 4px 7px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================================================
 * 授業モード（プロジェクター・電子黒板向け）
 * 文字を大きく・枠線を濃く・補助表示を隠して後ろの席からでも読みやすくする
 * ===================================================================== */
body.is-classroom {
  --code-fs: 18px;
  --border: #64748b;
  --border-strong: #334155;
}

/* 左右パネル上部（高さ固定 44px）は実行/トレースボタンが見切れないよう元のサイズを維持 */
body.is-classroom .topbar .btn,
body.is-classroom .topbar .btn-guide-pill {
  font-size: 15.5px;
}

body.is-classroom .topbar .btn-xs {
  padding: 5px 12px;
}

body.is-classroom .panel-toolbar .chip,
body.is-classroom .panel-toolbar .btn {
  font-size: 15px;
}

body.is-classroom .console-output,
body.is-classroom .input-queue-box {
  font-size: 16.5px;
  line-height: 1.6;
}

body.is-classroom .io-label {
  font-size: 14px;
}

body.is-classroom .btn-sub-tag {
  display: none;
}

body.is-classroom .editor-wrap {
  grid-template-columns: 56px minmax(0, 1fr);
}

body.is-classroom .dncl-editor-wrap {
  grid-template-columns: 80px minmax(0, 1fr);
}

body.is-classroom .editor-gutter {
  padding-left: 4px;
  padding-right: 4px;
}

/* =====================================================================
 * 共テ非対応構文の「教材化」書き換え補助チップ
 * ===================================================================== */
.diag-item.is-learn {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.diag-learn-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 12px;
  color: #1e3a8a;
  line-height: 1.45;
}

body.is-classroom .diag-learn-hint {
  font-size: 14px;
}

.btn-rewrite-apply {
  flex-shrink: 0;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-rewrite-apply:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

/* =====================================================================
 * トレース画面（変数図・履歴表・ナレーション）の授業モード＆視認性強化
 * ===================================================================== */
body.is-classroom .narration-bar {
  font-size: 16px;
  padding: 10px 14px;
}

body.is-classroom .kind-pill {
  font-size: 14px;
  padding: 3px 10px;
}

body.is-classroom .memory-subhead {
  font-size: 14.5px;
}

body.is-classroom .var-card {
  padding: 11px 14px;
  border-width: 2px;
}

body.is-classroom .var-name {
  font-size: 15.5px;
}

body.is-classroom .var-val {
  font-size: 20px;
}

body.is-classroom .arr-cell-val {
  font-size: 16px;
}

body.is-classroom .trace-table {
  font-size: 16px;
}

body.is-classroom .trace-table th,
body.is-classroom .trace-table td {
  padding: 10px 13px;
}

body.is-classroom #stepCounter {
  font-size: 16px !important;
}

/* =====================================================================
 * 文字倍率選択（100% / 120% / 140% / 160%）
 * ===================================================================== */
.topbar-scale-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 6px 0 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
  white-space: nowrap;
}

.topbar-select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  cursor: pointer;
  outline: none;
}

body.scale-100 {
  --code-fs: 14.5px;
}

body.scale-120 {
  --code-fs: 17.5px;
}

body.scale-140 {
  --code-fs: 20.5px;
}

body.scale-160 {
  --code-fs: 23.5px;
}

body.scale-140 .dncl-editor-wrap {
  grid-template-columns: 88px minmax(0, 1fr);
}

body.scale-160 .dncl-editor-wrap {
  grid-template-columns: 98px minmax(0, 1fr);
}

/* =====================================================================
 * 折り返し表示モード（折り返し行に行番号なし・インデント記号のみ表示）
 * ===================================================================== */
body.is-wrap .code-input,
body.is-wrap .editor-highlight-inner {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.gutter-line.is-wrap-cont {
  justify-content: flex-end;
  color: #94a3b8;
  font-weight: 800;
  letter-spacing: -0.04em;
  opacity: 0.9;
}

.wrap-indent-mark {
  display: inline-block;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.14);
  color: #64748b;
  font-size: 0.85em;
  line-height: 1.2;
}

/* =====================================================================
 * 演習モード（黄色・アンバー系テーマ ＋ 右ペインデフォルト非表示）
 * ===================================================================== */
body.is-exercise {
  --bg-canvas: #fefce8;
  --bg-grid: rgba(217, 119, 6, 0.14);
  --surface-soft: #fef9c3;
  --surface-tint: #fffbeb;
  --primary: #d97706;
  --primary-hover: #b45309;
  --primary-soft: #fef3c7;
  --indigo: #ea580c;
  --border: #fcd34d;
  --border-strong: #d97706;
}

body.is-exercise .btn:hover:not(:disabled) {
  background: #fef3c7;
  border-color: #f59e0b;
}

body.is-exercise .btn-soft {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
}

body.is-exercise .btn-soft:hover:not(:disabled) {
  background: #fef3c7;
  border-color: #f59e0b;
}

body.is-exercise .btn-toggle.is-on {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}

body.is-exercise .history-group,
body.is-exercise .topbar-scale-wrap,
body.is-exercise .topbar-debug-toggle,
body.is-exercise .tab-group,
body.is-exercise .seg-control {
  background: #fffdf0;
  border-color: #fcd34d;
}

body.is-exercise .dropdown-menu,
body.is-exercise .modal-card,
body.is-exercise .ac-popup {
  border-color: #fcd34d;
}

body.is-exercise .dropdown-item:hover {
  background: #fef3c7;
  color: #92400e;
}

body.is-exercise .topbar {
  border-bottom-color: #f59e0b;
  background: linear-gradient(180deg, #fffdf4 0%, #fef9c3 100%);
}

body.is-exercise .brand-icon {
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.28);
}

body.is-exercise .btn-guide-pill {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #b45309;
}

body.is-exercise .btn-guide-pill:hover {
  background: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.18);
}

body.is-exercise .topbar-debug-toggle.is-debug-on {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #b45309;
}

body.is-exercise .pane-card {
  border-color: #fcd34d;
}

body.is-exercise .panel-tabs {
  background: linear-gradient(180deg, #fffdf5 0%, #fef3c7 100%);
  border-bottom-color: #fcd34d;
}

body.is-exercise .tab-btn.is-active {
  color: #b45309;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.16);
}

body.is-exercise .h-splitter {
  background: #fffbeb;
  border-color: #fcd34d;
}

body.is-exercise .io-box,
body.is-exercise .console-output,
body.is-exercise .input-queue-box {
  border-color: #fcd34d;
}

body.is-exercise .console-output:focus,
body.is-exercise .input-queue-box:focus {
  border-color: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.16);
}

body.is-exercise .editor-active-bar {
  background: rgba(217, 119, 6, 0.1);
  border-left-color: #d97706;
}

.mode-switch-seg {
  padding: 2px;
  border-radius: 10px;
}

.mode-switch-seg .seg-btn {
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 800;
  border-radius: 8px;
}

body.is-exercise .mode-switch-seg #btnModeExercise {
  background: #d97706;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(217, 119, 6, 0.3);
}

body:not(.is-exercise) .mode-switch-seg #btnModeNormal {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.25);
}

/* 演習モード：右ペインは最初から常時表示（各ステップ中身のみ初期非表示） */
body.is-exercise .ex-help-pane {
  display: flex;
}

/* 演習モードではトレースボタン・添字切替トグル・双方向ブリッジ・右ペイン元タブバーを非表示 */
body.is-exercise #btnRun,
body.is-exercise #baseSegGroup,
body.is-exercise #btnMenuPreset,
body.is-exercise .panel-bridge,
body.is-exercise .cockpit>section[aria-label="Python変換と変数トレースエリア"]>.panel-tabs,
body.is-exercise #tabRightPython,
body.is-exercise #tabRightTrace,
body.is-exercise #rightViewPython,
body.is-exercise #rightViewTrace,
body.is-exercise #expandedSplitter,
body.is-exercise #expandedTraceDock {
  display: none !important;
}

/* 演習モードでは変換・トレースモードの履歴表拡大やペイン高さに依存せず、常に画面いっぱいを使用する */
body.is-exercise .workspace-shell .cockpit {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0;
}

body.is-exercise .workspace-shell.is-trace-expanded #leftSplitter {
  display: grid !important;
}

body.is-exercise .workspace-shell.is-trace-expanded #leftBottomDock {
  display: flex !important;
}

/* 演習モードでは右ペインに #rightViewExerciseHelp を最初から表示する */

/* 演習バー＆問題ボックス */
.exercise-bar {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  background: #fffbeb;
  border-bottom: 1.5px solid #fcd34d;
  flex-shrink: 0;
}

body.is-exercise .exercise-bar {
  display: flex;
}

.exercise-bar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.exercise-selectors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ex-select {
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1.5px solid #f59e0b;
  background: #ffffff;
  color: #78350f;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.ex-select-problem {
  min-width: 240px;
  max-width: 420px;
}

.exercise-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ex-free-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid #f59e0b;
  background: #ffffff;
  font-size: 12.5px;
  font-weight: 800;
  color: #92400e;
  cursor: pointer;
}

.ex-free-toggle input {
  accent-color: #d97706;
}

.btn-ex-help {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 800;
}

.btn-ex-help[aria-expanded="true"] {
  background: #d97706;
  color: #ffffff;
  border-color: #b45309;
}

.ex-prompt-box {
  background: #ffffff;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ex-prompt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ex-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #b45309;
  font-size: 11.5px;
  font-weight: 900;
}

.ex-index-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 900;
  border: 1px solid #cbd5e1;
}

.ex-index-pill.is-base1 {
  background: #fff7ed;
  border-color: #fb923c;
  color: #9a3412;
}

.ex-index-pill.is-base0 {
  background: #eff6ff;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.ex-title {
  font-size: 14.5px;
  font-weight: 900;
  color: #0f172a;
}

.ex-goal-pill {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 800;
  color: #334155;
}

.ex-prompt-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #334155;
  font-weight: 600;
}

.ex-judge-banner {
  display: none;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 800;
}

.ex-judge-banner.is-ok {
  display: block;
  background: #ecfdf5;
  border: 1.5px solid #10b981;
  color: #065f46;
}

.ex-judge-banner.is-ng {
  display: block;
  background: #fef2f2;
  border: 1.5px solid #ef4444;
  color: #991b1b;
}

/* 保護付き空欄エディタ（自由改変OFF時） */
.ex-blank-view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #ffffff;
}

body.is-exercise:not(.is-ex-free) .ex-blank-view {
  display: block;
}

body.is-exercise:not(.is-ex-free) #leftViewEditor,
body.is-exercise:not(.is-ex-free) #leftViewPython {
  display: none !important;
}

.ex-blank-code-stage {
  padding: 12px 0;
  font-family: var(--font-dncl);
  font-weight: 700;
  font-size: var(--code-fs);
  line-height: 1.8;
}

.ex-code-line {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: baseline;
  padding: 2px 14px 2px 0;
  transition: background 0.15s ease;
}

.ex-code-line:hover {
  background: #fffbeb;
}

.ex-code-line.has-blank {
  background: rgba(254, 243, 199, 0.45);
}

.ex-line-no {
  text-align: right;
  padding-right: 12px;
  color: #94a3b8;
  font-family: var(--font-dncl);
  font-weight: 700;
  font-size: 0.9em;
  user-select: none;
}

.ex-line-code {
  white-space: pre;
  color: #0f172a;
  font-family: var(--font-dncl);
  font-weight: 700;
}

body.is-wrap .ex-line-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ex-blank-slot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 1px 6px;
  margin: 0 3px;
  vertical-align: baseline;
}

.ex-blank-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 5px;
  background: #d97706;
  color: #ffffff;
  font-family: var(--font-ui);
  font-size: 0.78em;
  font-weight: 900;
}

.ex-blank-input,
.ex-blank-select {
  border: none;
  background: transparent;
  font-family: var(--font-dncl);
  font-size: 0.95em;
  font-weight: 700;
  color: #78350f;
  outline: none;
  padding: 1px 2px;
}

.ex-blank-slot.is-correct {
  background: #ecfdf5;
  border-color: #10b981;
}

.ex-blank-slot.is-correct .ex-blank-tag {
  background: #059669;
}

.ex-blank-slot.is-wrong {
  background: #fef2f2;
  border-color: #ef4444;
}

.ex-blank-slot.is-wrong .ex-blank-tag {
  background: #dc2626;
}

.step4-answer-code {
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.75;
}

.step4-answer-code.is-dncl {
  font-family: var(--font-dncl);
  font-weight: 700;
  font-size: 13.5px;
}

.step4-answer-code.is-py {
  font-family: var(--font-py);
  font-weight: 600;
  font-size: 13px;
}

.step4-answer-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: pre;
}

.step4-answer-ln {
  flex: 0 0 auto;
  color: #94a3b8;
  font-family: var(--font-code);
  font-size: 11.5px;
  font-weight: 600;
  user-select: none;
}

.step4-answer-body {
  color: #0f172a;
}

.step4-answer-blank {
  display: inline-block;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 7px;
  padding: 0 6px;
  margin: 0 2px;
  color: #78350f;
  font-weight: 700;
  line-height: 1.45;
  vertical-align: baseline;
}

/* 右ペイン：演習ヒント＆モーショングラフィック解説 */
.ex-help-pane {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #fffdf7;
}

.ex-help-head {
  justify-content: space-between;
  padding: 0 14px;
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
}

.ex-help-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ex-help-heading {
  font-size: 13.5px;
  font-weight: 900;
  color: #78350f;
}

.ex-help-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ex-scaffold-card {
  background: #ffffff;
  border: 1.5px solid #fde68a;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 4px 12px -8px rgba(180, 83, 9, 0.2);
}

.ex-scaffold-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 900;
  color: #92400e;
  margin-bottom: 6px;
}

.ex-step-pill {
  padding: 2px 7px;
  border-radius: 6px;
  background: #d97706;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.ex-scaffold-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
  font-weight: 500;
}

.ex-motion-stage {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ex-motion-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ex-motion-controls .btn:disabled {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #94a3b8;
  opacity: 0.72;
  cursor: not-allowed;
  box-shadow: none;
}

.ex-motion-counter {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  transition: all 0.2s ease;
}

.ex-motion-counter.is-end {
  color: #065f46;
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.ex-motion-canvas {
  position: relative;
  background: #ffffff;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 16px 14px 14px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.ex-motion-stage-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 12px 4px 4px;
}

.ex-motion-stage-area.is-no-alu {
  padding-top: 28px;
}

.motion-svg-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}

.motion-path-bg {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.16;
}

.motion-path-bg.is-read {
  stroke: #0284c7;
}

.motion-path-bg.is-write {
  stroke: #d97706;
}

.motion-path-active {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.motion-path-active.is-read {
  stroke: #0ea5e9;
  filter: drop-shadow(0 0 3px rgba(14, 165, 233, 0.35));
}

.motion-path-active.is-write {
  stroke: #f59e0b;
  filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.45));
}

.motion-path-chevron {
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.25s ease;
}

.motion-path-chevron.is-read {
  stroke: #0284c7;
}

.motion-path-chevron.is-write {
  stroke: #d97706;
}

/* 直接代入レイアウト（左辺BOX ← 代入 右辺の式） */
.motion-assign-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}

.motion-assign-arrow {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 2px;
  flex-shrink: 0;
}

.motion-assign-arrow-svg {
  overflow: visible;
}

.motion-assign-arrow-line {
  stroke: #d97706;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 38;
  stroke-dashoffset: 0;
}

.motion-assign-arrow-head {
  stroke: #d97706;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.motion-assign-arrow.is-preview .motion-assign-arrow-line,
.motion-assign-arrow.is-preview .motion-assign-arrow-head {
  stroke: #cbd5e1;
}

.motion-assign-arrow.is-flowing .motion-assign-arrow-line {
  animation: assignLineDraw 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.motion-assign-arrow.is-flowing .motion-assign-arrow-head {
  animation: assignHeadPop 0.35s var(--spring) 0.22s both;
}

.motion-assign-pulse-dot {
  fill: #f59e0b;
  stroke: #ffffff;
  stroke-width: 1.6;
  opacity: 0;
}

.motion-assign-arrow.is-flowing .motion-assign-pulse-dot {
  animation: assignDotFly 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes assignLineDraw {
  0% { stroke-dashoffset: 38; }
  100% { stroke-dashoffset: 0; }
}

@keyframes assignHeadPop {
  0% { opacity: 0; transform: translateX(4px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes assignDotFly {
  0% { opacity: 1; transform: translateX(0); }
  80% { opacity: 1; transform: translateX(-34px); }
  100% { opacity: 0; transform: translateX(-36px); }
}

.motion-mem-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.motion-mem-strip.is-swap-large {
  padding: 12px 16px;
  border-radius: 12px;
  border-width: 2px;
  border-color: #cbd5e1;
  font-size: 16px;
  gap: 10px;
  width: 100%;
}

.motion-mem-strip.is-swap-large .motion-mem-pill {
  font-size: 16px;
  border-radius: 8px;
}

.motion-mem-strip.is-swap-large .motion-mem-pill .mvp-k,
.motion-mem-strip.is-swap-large .motion-mem-pill .mvp-v {
  padding: 5px 11px;
}

.motion-mem-target-sep {
  color: #cbd5e1;
  font-weight: 400;
}

.motion-mem-target {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.motion-mem-target-lbl {
  color: #0369a1;
  font-weight: 900;
}

.motion-mem-pill {
  display: inline-flex;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 800;
  color: #334155;
}

.motion-mem-pill .mvp-k {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 7px;
  border-right: 1px solid #cbd5e1;
}

.motion-mem-pill .mvp-v {
  background: #ffffff;
  color: #0f172a;
  padding: 2px 8px;
}

.motion-mem-pill.is-write {
  border-color: #f59e0b;
}

.motion-mem-pill.is-write .mvp-k {
  background: #fde68a;
  color: #78350f;
  border-right-color: #f59e0b;
}

.motion-mem-pill.is-write .mvp-v {
  background: #fffbeb;
  color: #92400e;
}

.motion-mem-pill.is-focus-key {
  border: 2px solid #059669;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
  font-size: 13.5px;
}

.motion-mem-pill.is-focus-key .mvp-k {
  background: #d1fae5;
  color: #065f46;
  border-right-color: #059669;
  font-weight: 900;
  padding: 3px 9px;
}

.motion-mem-pill.is-focus-key .mvp-v {
  background: #ecfdf5;
  color: #064e3b;
  font-weight: 900;
  padding: 3px 10px;
}

.motion-mem-pill.is-focus-key.is-write {
  border-color: #d97706;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.26);
}

.motion-mem-pill.is-focus-key.is-write .mvp-k {
  background: #fde68a;
  color: #78350f;
  border-right-color: #d97706;
}

.motion-mem-pill.is-focus-key.is-write .mvp-v {
  background: #fffbeb;
  color: #92400e;
}

.motion-mem-pill.is-read,
.motion-mem-pill.is-target {
  border-color: #38bdf8;
}

.motion-mem-pill.is-read .mvp-k,
.motion-mem-pill.is-target .mvp-k {
  background: #bae6fd;
  color: #0369a1;
  border-right-color: #38bdf8;
}

.motion-mem-pill.is-read .mvp-v,
.motion-mem-pill.is-target .mvp-v {
  background: #f0f9ff;
  color: #0c4a6e;
}

/* ライブ計算パイプライン（式カード ➜ 結果カード 分離スタイル） */
.motion-alu-rail {
  position: relative;
  z-index: 5;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-dncl);
  font-weight: 700;
}

.motion-expr-card {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 8px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.motion-alu-token {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-family: var(--font-dncl);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.35s var(--spring), background 0.3s ease, border-color 0.3s ease;
}

.motion-alu-token.is-var {
  background: #e0f2fe;
  border: 1.5px solid #7dd3fc;
  color: #0369a1;
}

.motion-alu-token.is-var.is-resolved {
  background: #0284c7;
  border-color: #0369a1;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.26);
  animation: aluPopIn 0.45s var(--spring) both;
}

.motion-alu-var-float {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 999px;
  background: #0369a1;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.3);
}

.motion-alu-token.is-op {
  min-width: auto;
  padding: 0 2px;
  color: #475569;
  font-size: 18px;
  font-weight: 900;
}

.motion-alu-token.is-lit {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
}

.motion-alu-arrow-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #64748b;
  padding: 0 2px;
}

.motion-alu-arrow-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.02em;
}

.motion-alu-result {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 54px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 19px;
  font-weight: 900;
  background: #ffffff;
  border: 1.5px dashed #cbd5e1;
  color: #94a3b8;
}

.motion-alu-result-cap {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 800;
  opacity: 0.88;
  line-height: 1.1;
  margin-bottom: 1px;
}

.motion-alu-result.is-ready {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: 1.5px solid #b45309;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.32);
  animation: aluPopIn 0.5s var(--spring) 0.15s both;
}

.motion-port {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1.5px solid #ffffff;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 6;
}

.motion-port-bottom {
  bottom: -4px;
  background: #0ea5e9;
}

.motion-alu-result .motion-port-bottom {
  background: #f59e0b;
}

.motion-port-top {
  top: -4px;
}

.motion-var-box.is-reading .motion-port-top {
  background: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.motion-var-box.is-changed .motion-port-top {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

@keyframes aluPopIn {
  0% { transform: scale(0.84); opacity: 0.4; }
  65% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* コードトークン色リンク */
.motion-tok-write {
  color: #b45309;
  background: #fef3c7;
  padding: 0 4px;
  border-radius: 4px;
  border-bottom: 2px solid #d97706;
}

.motion-tok-read {
  color: #0369a1;
  background: #e0f2fe;
  padding: 0 4px;
  border-radius: 4px;
  border-bottom: 2px solid #0284c7;
}

.motion-note-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 12px;
}

.motion-code-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 10px 8px;
  border-radius: 9px;
  background: #fffbeb;
  border-left: 3.5px solid #d97706;
  border-bottom: 1.5px solid #fcd34d;
  color: #0f172a;
  font-family: var(--font-dncl);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.motion-code-list.is-slide-in {
  animation: exCodeSlideIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes exCodeSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-18px);
    background: #fef08a;
  }

  65% {
    opacity: 1;
    transform: translateX(0);
    background: #fef08a;
  }

  100% {
    opacity: 1;
    transform: translateX(0);
    background: #fffbeb;
  }
}

.motion-code-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.motion-code-row.is-empty,
.motion-loop-var-bar.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.motion-code-lineno {
  color: #92400e;
  opacity: 0.65;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}

.motion-desc-text {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
  color: #78350f;
}

/* 折りたたみ式ステップアコーディオン */
.ex-accordion-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.ex-accordion-chevron {
  font-size: 12px;
  font-weight: 900;
  color: #b45309;
  transition: transform 0.2s ease;
}

.ex-accordion-card.is-open .ex-accordion-chevron {
  transform: rotate(180deg);
}

.ex-accordion-body {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #fde68a;
}

.ex-accordion-card.is-open .ex-accordion-body {
  display: block;
}

/* ステップ解説内の重要語強調＆インラインコード */
.ex-key-hl {
  background: linear-gradient(transparent 58%, #fde047 58%);
  color: #78350f;
  font-weight: 900;
  padding: 0 2px;
  border-radius: 3px;
}

.ex-inline-code {
  display: inline-block;
  padding: 0 5px;
  margin: 0 1px;
  border-radius: 5px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-family: var(--font-dncl);
  font-size: 0.92em;
  font-weight: 700;
}

/* モーション視線誘導バー（①コードを見る → ②動きを見る） */
.ex-gaze-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ex-gaze-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  transition: all 0.3s ease;
}

.ex-gaze-step.is-active {
  background: #d97706;
  color: #ffffff;
  border-color: #b45309;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.28);
  transform: scale(1.03);
}

.ex-gaze-arrow {
  color: #94a3b8;
  font-weight: 900;
  font-size: 12px;
}

.ex-code-line.is-motion-focus {
  background: #fef08a !important;
  box-shadow: inset 3px 0 0 #d97706;
}

/* 演算子・記号ワンクリック入力パレット */
.ex-op-palette {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  position: sticky;
  top: 0;
  z-index: 4;
}

.ex-op-label {
  font-size: 11.5px;
  font-weight: 800;
  color: #92400e;
  margin-right: 4px;
  white-space: nowrap;
}

.ex-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1.5px solid #fcd34d;
  background: #ffffff;
  color: #78350f;
  font-family: var(--font-dncl);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.ex-op-btn:hover {
  background: #fef3c7;
  border-color: #d97706;
  transform: translateY(-1px);
}

.ex-op-btn:active {
  transform: translateY(0);
}

.motion-2d-table td.is-cross-line {
  background: #fffbeb;
}

.ex-motion-note {
  font-size: 13px;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  padding: 6px 10px;
  border-radius: 8px;
}

/* 各種モーション部品（メモリ・レジスタカード ＆ スロット上書き） */
.motion-var-grid {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.motion-var-box {
  position: relative;
  width: 156px;
  min-width: 156px;
  min-height: 94px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px 10px;
  border-radius: 14px;
  border: 1.5px solid #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  text-align: center;
  transition: transform 0.55s var(--spring), border-color 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.motion-var-box.is-reading {
  border-color: #38bdf8;
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.16);
}

.motion-var-box.is-changed {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.22);
  transform: translateY(-2px);
}

.motion-var-box.is-arrived {
  animation: varCardPulse 0.65s var(--spring);
}

@keyframes varCardPulse {
  0% { transform: translateY(-2px) scale(1); }
  45% { transform: translateY(-4px) scale(1.06); box-shadow: 0 10px 24px rgba(217, 119, 6, 0.32); }
  100% { transform: translateY(-2px) scale(1); }
}

.motion-var-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 22px;
  flex-shrink: 0;
  white-space: nowrap;
  margin-bottom: 4px;
}

.motion-var-name {
  font-family: var(--font-dncl);
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.motion-var-tag {
  font-size: 10px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.motion-var-tag.is-read {
  background: #0284c7;
  color: #ffffff;
}

.motion-var-tag.is-write {
  background: #d97706;
  color: #ffffff;
}

.motion-var-tag.is-new {
  background: #059669;
  color: #ffffff;
}

.motion-var-val-stage {
  position: relative;
  height: 42px;
  min-height: 42px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.motion-var-old-val {
  font-family: var(--font-dncl);
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-decoration: line-through;
  line-height: 1.1;
  margin-bottom: 1px;
  animation: exSlotOldFade 0.5s ease-out both;
}

.motion-var-val {
  font-family: var(--font-dncl);
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.motion-var-val.is-empty {
  color: #94a3b8;
  font-size: 15px;
  font-weight: 700;
}

.motion-var-val.is-slot-enter {
  color: #b45309;
  animation: exSlotNewEnter 0.55s var(--spring) both;
}

@keyframes exSlotOldFade {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes exSlotNewEnter {
  0% { opacity: 0; transform: translateY(10px) scale(0.88); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.motion-sort-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  height: 120px;
  padding-top: 12px;
}

.motion-sort-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.9s var(--spring);
}

.motion-sort-bar {
  width: 38px;
  border-radius: 8px 8px 4px 4px;
  background: #f3ead3;
  color: #451a03;
  font-family: var(--font-dncl);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  transition: background 0.5s ease, height 0.7s ease, transform 0.7s var(--spring);
}

.motion-sort-bar.is-compare {
  background: #fde047;
  border: 2px solid #d97706;
  transform: translateY(-6px);
}

.motion-sort-bar.is-swap {
  background: #fb923c;
  color: #ffffff;
  border: 2px solid #c2410c;
  transform: translateY(-10px) scale(1.06);
}

.motion-sort-bar.is-copy-src {
  background: #dbeafe;
  color: #1e3a8a;
  border: 2px dashed #2563eb;
}

.motion-sort-bar.is-overwrite {
  background: #34d399;
  color: #064e3b;
  border: 2px solid #059669;
}

.motion-2d-table {
  border-collapse: collapse;
  margin: 0 auto;
  font-family: var(--font-dncl);
  font-size: 13px;
  font-weight: 700;
}

.motion-2d-table th,
.motion-2d-table td {
  border: 1.5px solid #e2e8f0;
  padding: 6px 12px;
  text-align: center;
  font-weight: 700;
  transition: background 0.25s ease, transform 0.25s ease;
}

.motion-2d-table th {
  background: #fef9c3;
  color: #78350f;
  white-space: nowrap;
}

.motion-2d-table td.is-active-cell {
  background: #fef08a;
  border-color: #d97706;
  color: #92400e;
  transform: scale(1.08);
}

.motion-2d-table td.is-pair-cell {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e40af;
  font-weight: 900;
}

.motion-1d-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.motion-1d-cell {
  min-width: 44px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 2px solid #e7dec8;
  background: #ffffff;
  text-align: center;
  font-family: var(--font-dncl);
  font-weight: 700;
  transition: all 0.25s ease;
}

.motion-1d-cell.is-focus {
  background: #fef08a;
  border-color: #d97706;
  transform: translateY(-4px);
}

.motion-1d-cell.is-dim {
  opacity: 0.35;
}

.motion-1d-cell.is-keep {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e3a8a;
}

.step4-bin-diagram {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 12px;
}

.step4-bin-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
}

.step4-bin-head {
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 8px;
}

.step4-bin-cap {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.6;
  margin-top: 8px;
}

.step4-bin-card .motion-1d-row {
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 6px 2px;
  margin-top: 4px;
}

.step4-bin-card .motion-1d-arrname {
  width: 72px;
  min-width: 72px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.step4-bin-card .motion-1d-cell {
  width: 62px;
  min-width: 62px;
  min-height: 70px;
  flex-shrink: 0;
  justify-content: flex-start;
}

.step4-bin-tag {
  margin-top: 3px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 800;
  padding: 0 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.step4-bin-tag.is-mid {
  background: #f59e0b;
  color: #ffffff;
}

.step4-bin-tag.is-keep {
  background: #2563eb;
  color: #ffffff;
}

.step4-bin-tag.is-drop {
  background: #94a3b8;
  color: #ffffff;
}

.step4-bin-tag.is-exit {
  background: #dc2626;
  color: #ffffff;
}

.step4-bin-tag.is-done {
  background: #16a34a;
  color: #ffffff;
}

.motion-1d-cell.is-done {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}

.step4-bin-tags {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 3px;
}

.step4-bin-tags .step4-bin-tag {
  margin-top: 0;
}

.step4-bin-out-slot {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 6px 4px;
}

.step4-bin-sub {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  margin: 8px 0 4px;
}

.motion-branch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.motion-branch-join {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -4px 0;
}

.motion-branch-join::before {
  content: '';
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: #cbd5e1;
}

.motion-branch-join-pill {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 12px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  color: #1d4ed8;
  font-family: var(--font-dncl);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.motion-branch-join.is-true .motion-branch-join-pill {
  background: #ecfdf5;
  border-color: #34d399;
  color: #047857;
}

.motion-branch-join.is-false .motion-branch-join-pill {
  background: #fef2f2;
  border-color: #f87171;
  color: #b91c1c;
}

.motion-branch-join.is-current-gate .motion-branch-join-pill {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  transform: scale(1.06);
}

.motion-branch-join-note {
  position: relative;
  z-index: 1;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 11.5px;
  font-weight: 700;
  color: #0f172a;
}

.motion-branch-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid #e7dec8;
  background: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
}

.motion-branch-node.is-true {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
}

.motion-branch-node.is-false {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.motion-branch-node.is-skipped {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #64748b;
  opacity: 0.85;
}

.motion-branch-node code {
  font-family: var(--font-dncl);
  font-weight: 700;
}

.dncl-indent-glyph {
  display: inline-block;
  width: 0.6em;
  text-align: center;
  text-indent: 0;
  font-family: var(--font-ui);
  font-weight: 500;
  color: #64748b;
}

.ex-answer-toggle-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px dashed #d97706;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.ex-answer-box {
  display: none;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #ecfdf5;
  border: 1px solid #34d399;
  font-size: 13px;
  line-height: 1.6;
  color: #065f46;
  font-weight: 600;
}

.ex-answer-box.is-open {
  display: block;
}

/* 解説パネル内の段落・スペーサー・テーブル */
.ex-scaffold-p {
  margin: 2px 0;
  line-height: 1.6;
}

.ex-scaffold-spacer {
  height: 8px;
}

.ex-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  -webkit-overflow-scrolling: touch;
}

.ex-explain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid #a7f3d0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ex-explain-table th {
  background: #d1fae5;
  color: #065f46;
  font-weight: 800;
  padding: 7px 10px;
  border: 1px solid #a7f3d0;
  text-align: center;
  white-space: nowrap;
}

.ex-explain-table td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  font-family: var(--font-dncl);
  font-weight: 700;
  text-align: center;
}

.ex-explain-table tr:nth-child(even) td {
  background: #f0fdf4;
}

/* =====================================================================
 * Branch / Loop / Func Enhanced Visual Motion Stages
 * ===================================================================== */
.ex-motion-stage-area.is-branch-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  margin-bottom: 8px;
}

.motion-branch-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.motion-branch-in-lbl {
  font-size: 11.5px;
  font-weight: 800;
  color: #64748b;
}

.motion-gate-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.motion-gate-expr {
  padding: 8px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
  font-family: var(--font-dncl);
  font-size: 13px;
  font-weight: 700;
}

.motion-gate-badge {
  min-width: 96px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  border: 1.5px solid #cbd5e1;
  transition: transform 0.35s var(--spring), box-shadow 0.35s ease;
}

.motion-gate-badge.is-pending {
  background: #f1f5f9;
  color: #64748b;
}

.motion-gate-badge.is-true {
  background: linear-gradient(180deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: #10b981;
  color: #065f46;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transform: scale(1.04);
}

.motion-gate-badge.is-false {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  border-color: #ef4444;
  color: #991b1b;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.motion-gate-badge.is-skipped {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #64748b;
}

.motion-branch-node.is-current-gate {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45);
}

.motion-branch-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.motion-branch-icon {
  font-size: 13px;
}

.motion-loop-progress-wrap {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.motion-loop-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24 0%, #d97706 100%);
  border-radius: 999px;
  transition: width 0.65s var(--ease-out);
}

.motion-func-outer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.motion-func-caller-assign {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
}

.motion-func-enclosure {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 14px;
  padding: 22px 18px 14px;
  border-radius: 16px;
  border: 2px dashed #94a3b8;
  background: rgba(248, 250, 252, 0.85);
}

.motion-func-enclosure-title {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-family: var(--font-dncl);
  font-size: 13.5px;
  font-weight: 800;
  color: #1e293b;
  background: #e2e8f0;
  border: 1.5px solid #94a3b8;
  padding: 3px 14px;
  border-radius: 999px;
}

.motion-func-pipeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.motion-func-card {
  width: fit-content;
  min-width: 210px;
  max-width: 100%;
  padding: 8px 18px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  text-align: center;
  transition: transform 0.35s var(--spring), box-shadow 0.35s ease;
}

.motion-func-card.is-arg {
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #38bdf8;
}

.motion-func-card.is-factory {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
}

.motion-func-card.is-active-factory {
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.25);
  transform: translateY(-2px);
}

.motion-func-card.is-ret {
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #10b981;
}

.motion-func-card.is-arrived {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25);
  transform: scale(1.04);
}

.motion-func-card-lbl {
  font-size: 12px;
  font-weight: 800;
  color: #475569;
  margin-bottom: 4px;
}

.motion-func-card-val {
  font-family: var(--font-dncl);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  color: #0f172a;
  word-break: break-word;
}

.motion-1d-arrname {
  font-family: var(--font-dncl);
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  padding: 4px 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  align-self: center;
  margin-right: 4px;
}

.motion-2d-arrname-wrap {
  text-align: center;
  margin-bottom: 6px;
}

.motion-2d-arrname {
  display: inline-block;
  font-family: var(--font-dncl);
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  padding: 3px 10px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.ex-op-dropdown {
  position: relative;
  display: inline-block;
}

.ex-op-drop-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  min-width: 190px;
  padding: 6px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  flex-direction: column;
  gap: 4px;
}

.ex-op-dropdown.is-open .ex-op-drop-menu {
  display: flex;
}

.ex-op-drop-menu.is-grid {
  display: none;
  min-width: 240px;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 5px;
}

.ex-op-dropdown.is-open .ex-op-drop-menu.is-grid {
  display: flex;
}

.ex-op-drop-item {
  appearance: none;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #78350f;
  font-family: var(--font-dncl);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, transform 0.1s ease;
}

.ex-op-drop-item:hover {
  background: #fef3c7;
  transform: translateY(-1px);
}

.motion-concrete-code {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px 10px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 12px;
}

.motion-concrete-lbl {
  font-weight: 800;
  color: #1d4ed8;
}

.motion-concrete-code code {
  font-family: var(--font-dncl);
  font-weight: 700;
  color: #0f172a;
}

.motion-concrete-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.motion-loop-var-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.motion-loop-var-pill {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  font-family: var(--font-dncl);
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  border-radius: 8px;
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  color: #92400e;
}

.motion-loop-var-pill .mvp-k {
  background: #fde68a;
  color: #78350f;
  padding: 2px 7px;
  border-right: 1px solid #f59e0b;
}

.motion-loop-var-pill .mvp-v {
  background: #fffbeb;
  color: #92400e;
  padding: 2px 8px;
  font-weight: 800;
}

/* =====================================================================
 * CodeMirror 5 統合スタイル（既存 <textarea> 表示の完全再現 ＋ ぶら下げインデント）
 * ===================================================================== */
body.cm-enabled .editor-wrap {
  grid-template-columns: minmax(0, 1fr);
}

body.cm-enabled .editor-gutter,
body.cm-enabled .editor-active-bar,
body.cm-enabled .editor-highlight-layer {
  display: none !important;
}

body.cm-enabled .CodeMirror {
  width: 100%;
  height: 100%;
  font-size: var(--code-fs);
  line-height: 1.65;
  background: #ffffff;
  color: var(--text-main);
  tab-size: 2;
}

body.cm-enabled .CodeMirror.cm-dncl-theme {
  font-family: var(--font-dncl);
  font-weight: 500;
  tab-size: 2;
}

body.cm-enabled .CodeMirror.cm-py-theme {
  font-family: var(--font-py);
  font-weight: 400;
  tab-size: 4;
}

body.cm-enabled .CodeMirror-gutters {
  background: #f8fafc;
  border-right: 1px solid var(--border);
}

body.cm-enabled .cm-dncl-theme .CodeMirror-gutters {
  width: 58px;
}

body.cm-enabled .cm-py-theme .CodeMirror-gutters {
  width: 44px;
}

body.cm-enabled .CodeMirror-linenumber {
  padding: 0 6px 0 2px;
  color: #64748b;
  text-align: right;
  font-family: var(--font-code);
  font-size: var(--code-fs);
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
}

body.cm-enabled .CodeMirror-lines {
  padding: 12px 0;
}

body.cm-enabled .CodeMirror pre.CodeMirror-line,
body.cm-enabled .CodeMirror pre.CodeMirror-line-like {
  padding: 0 14px;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

body.cm-enabled .cm-s-default .cm-dncl-indent {
  display: inline-block;
  width: 0.6em;
  text-align: center;
  text-indent: 0;
  font-family: var(--font-ui);
  font-weight: 500;
  color: #64748b;
}

body.cm-enabled .cm-s-default .cm-keyword {
  color: #1d4ed8;
  font-weight: 700;
}

body.cm-enabled .cm-s-default .cm-string {
  color: #047857;
}

body.cm-enabled .cm-s-default .cm-number {
  color: #b45309;
}

body.cm-enabled .cm-s-default .cm-comment {
  color: #64748b;
  font-style: italic;
}

body.cm-enabled .CodeMirror .ph-mark {
  background: rgba(251, 191, 36, 0.34);
  color: inherit;
  border-bottom: 2px solid #d97706;
  border-radius: 3px;
}

body.cm-enabled .CodeMirror .is-exec .CodeMirror-linenumber {
  background: var(--primary);
  color: #ffffff !important;
  font-weight: 800;
  border-radius: 5px;
}

body.cm-enabled .CodeMirror .is-err .CodeMirror-linenumber {
  background: var(--danger-bg);
  color: var(--danger) !important;
  font-weight: 800;
  border-radius: 5px;
}

body.cm-enabled .CodeMirror .cm-exec-line {
  background: rgba(37, 99, 235, 0.08);
}