﻿    :root {
      --bg: #f6f7fb;
      --panel: #ffffff;
      --ink: #1f2937;
      --muted: #6b7280;
      --line: #cfd6e4;
      --blue: #2f6fda;
      --blue-fill: #eef4ff;
      --red: #d92d20;
      --red-fill: #fff0ef;
      --edge: #394150;
      --edge-soft: #8a94a6;
      --accent: #111827;
      --shadow: 0 10px 30px rgba(26, 38, 64, 0.08);
      --radius: 18px;
    }

    * { box-sizing: border-box; }
    html, body {
      height: 100%;
      overflow: hidden;
    }

    body {
      margin: 0;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      color: var(--ink);
      background: var(--bg);
      zoom: 1;
    }

    .app {
      display: grid;
      grid-template-columns: 420px 1fr;
      height: 100vh;
      min-height: 0;
      gap: 18px;
      padding: 18px;
      overflow: hidden;
    }

    .panel {
      background: var(--panel);
      border: 1px solid #e7ebf3;
      border-radius: 22px;
      box-shadow: var(--shadow);
    }

    .sidebar {
      padding: 18px;
      display: flex;
      flex-direction: column;
      gap: 14px;
      overflow: auto;
      min-height: 0;
    }

    h1 {
      margin: 0;
      font-size: 26px;
      line-height: 1.1;
      letter-spacing: 0.02em;
      color: #0f3d63;
      margin-bottom: 10px;
    }


    .sub {
      font-size: 13px;
      color: var(--muted);
      line-height: 1.4;
    }

    label {
      display: block;
      font-size: 13px;
      font-weight: 700;
      margin-bottom: 6px;
    }

    textarea {
      width: 100%;
      min-height: 180px;
      resize: vertical;
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 12px 14px;
      font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      color: #10203c;
      background: #fbfcff;
    }

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

    .xml-launcher {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 14px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fafcff;
    }

    .xml-launcher-copy {
      min-width: 0;
    }

    .xml-launcher-title {
      margin: 0;
      font-size: 13px;
      font-weight: 800;
      color: #10203c;
    }

    .xml-launcher-sub {
      margin-top: 4px;
      font-size: 12px;
      color: var(--muted);
      line-height: 1.35;
    }

    .xml-launcher-status {
      margin-top: 6px;
      font-size: 11px;
      color: #475569;
      line-height: 1.35;
      padding: 6px 8px;
      border-radius: 10px;
      border: 1px solid transparent;
      background: transparent;
    }

    .xml-launcher-status.valid {
      color: #166534;
      border-color: #86efac;
      background: #f0fdf4;
    }

    .xml-launcher-status.invalid {
      color: #b42318;
      border-color: #f5b4ae;
      background: #fff1f0;
    }

    .xml-launcher-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 0 0 auto;
    }

    .input-head label {
      margin-bottom: 0;
    }

    .file-btn {
      display: inline-grid;
      place-items: center;
      border: 1px solid #d7dfec;
      border-radius: 10px;
      width: 34px;
      height: 34px;
      padding: 0;
      background: #f3f6fc;
      color: #22304a;
      cursor: pointer;
      flex: 0 0 auto;
    }

    .file-btn svg {
      width: 13.5px;
      height: 13.5px;
      flex: 0 0 auto;
    }

    .file-btn.edit-btn svg {
      width: 12.75px;
      height: 12.75px;
    }

    .file-btn.save-btn {
      color: #1d4ed8;
      background: #eef4ff;
      border-color: #c7d7fe;
    }

    .row { display: flex; gap: 10px; flex-wrap: wrap; }
    .row > * { flex: 1; }

    button {
      border: 0;
      border-radius: 14px;
      padding: 12px 16px;
      background: var(--accent);
      color: white;
      font-weight: 700;
      cursor: pointer;
    }

    button.secondary {
      background: #e9eef8;
      color: #22304a;
    }

    .controls {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

    .canvas-wrap {
      position: relative;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    .canvas-wrap.edit-active {
      box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.55), var(--shadow);
      border-color: #f59e0b;
    }

.topbar {
  padding: 14px 18px;
  border-bottom: 1px solid #edf1f7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 56px;
  flex: 0 0 auto;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.topbar-group-language {
  flex: 0 0 auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.language-menu {
  position: relative;
}

.language-trigger {
  width: 52px;
  height: 52px;
  border: 1px solid #d7dfec;
  border-radius: 16px;
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow);
  color: #22304a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.language-trigger:hover {
  border-color: #b8c7dd;
  background: #ffffff;
}

.language-trigger:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.language-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 60px;
  padding: 8px;
  border: 1px solid #d7dfec;
  border-radius: 16px;
  background: rgba(255,255,255,0.98);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 40;
}

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

.language-option {
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 22px/1 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  cursor: pointer;
}

.language-option:hover {
  background: #f8fafc;
  border-color: #d7dfec;
}

.language-option.active {
  background: #eef4ff;
  border-color: #b8c7dd;
}

    .zoom-btn {
      width: 46px;
      height: 46px;
      border-radius: 14px;
    }

    .zoom-btn svg {
      width: 20px;
      height: 20px;
    }

    .zoom-value {
      min-width: 56px;
      padding: 0 10px;
      height: 46px;
      display: inline-grid;
      place-items: center;
      border: 1px solid #d7dfec;
      border-radius: 14px;
      background: rgba(255,255,255,0.96);
      box-shadow: var(--shadow);
      color: #22304a;
      font-size: 13px;
      font-weight: 800;
    }

    .title-wrap { min-width: 0; }
    .title-wrap h2 {
      margin: 0;
      font-size: 20px;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .title-row {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .edit-warning {
      display: none;
      align-items: center;
      gap: 5px;
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      color: #b42318;
      font-size: 11px;
      font-weight: 800;
      white-space: nowrap;
      letter-spacing: 0.02em;
      line-height: 1;
    }

    .edit-warning.active {
      display: inline-flex;
    }

    .edit-warning svg {
      width: 16px;
      height: 16px;
      flex: 0 0 auto;
    }

    .meta {
      margin-top: 4px;
      color: var(--muted);
      font-size: 13px;
    }

    .machine-header-edit {
      display: none;
      align-items: center;
      gap: 8px;
      min-width: 0;
      flex: 1 1 auto;
    }

    .machine-header-edit.active {
      display: flex;
    }

    .machine-header-edit input {
      min-width: 0;
      height: 36px;
      border: 1px solid #d7dfec;
      border-radius: 12px;
      padding: 0 12px;
      background: #fbfcff;
      color: #10203c;
      font: 13px/1.2 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #machineIdInput {
      width: 180px;
      flex: 0 0 auto;
    }

    #machineNameInput {
      width: min(420px, 100%);
      flex: 1 1 auto;
    }

    .viewport {
      position: relative;
      flex: 1;
      min-height: 0;
      overflow: auto;
      background:
        radial-gradient(circle at 1px 1px, #e8ecf5 1px, transparent 0) 0 0 / 24px 24px,
        #fbfcff;
    }

    .viewport.mode-3d {
      cursor: grab;
      background: transparent;
    }

    .viewport.mode-3d.rotating {
      cursor: grabbing;
    }

    .viewport.wheel-zoom-active {
      box-shadow: inset 0 0 0 2px rgba(47, 111, 218, 0.18);
    }

    svg {
      display: block;
    }


    .legend {
      position: absolute;
      left: 18px;
      bottom: 18px;
      width: 360px;
      max-width: calc(100% - 36px);
      background: rgba(255,255,255,0.92);
      backdrop-filter: blur(10px);
      border: 1px solid #e7ebf3;
      border-radius: 18px;
      box-shadow: var(--shadow);
      padding: 14px 16px;
      font-size: 13px;
      line-height: 1.45;
      z-index: 2;
    }

    .scene-rotate-btn {
      position: absolute;
      top: 86px;
      right: 18px;
      display: none;
      align-items: center;
      justify-content: center;
      min-width: 132px;
      height: 40px;
      padding: 0 14px;
      border: 1px solid #d7dfec;
      border-radius: 12px;
      background: rgba(255,255,255,0.96);
      box-shadow: var(--shadow);
      color: #22304a;
      font-size: 12px;
      font-weight: 800;
      z-index: 5;
    }

    .scene-rotate-btn.active {
      display: inline-flex;
    }

    .scene-orientation {
      position: absolute;
      right: 18px;
      bottom: 18px;
      width: 128px;
      height: 128px;
      display: none;
      align-items: center;
      justify-content: center;
      border: 1px solid #d7dfec;
      border-radius: 16px;
      background: rgba(255,255,255,0.94);
      box-shadow: var(--shadow);
      backdrop-filter: blur(8px);
      z-index: 5;
      pointer-events: none;
    }

    .scene-orientation.active {
      display: flex;
    }

    .scene-orientation svg {
      width: 112px;
      height: 112px;
      overflow: visible;
    }

    .legend.collapsed {
      width: 360px;
      max-width: calc(100% - 36px);
    }

    .legend-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
    }

    .legend.collapsed .legend-header {
      margin-bottom: 0;
    }

    .legend h3 { margin: 0; font-size: 15px; }
    .legend code { background: #f2f5fb; padding: 1px 5px; border-radius: 6px; }
    .legend-body {
      display: block;
    }

    .legend.collapsed .legend-body {
      display: none;
    }

    .collapse-toggle {
      border: 1px solid #d7dfec;
      border-radius: 10px;
      width: 36px;
      height: 36px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: #f3f6fc;
      color: #22304a;
      font-size: 0;
      font-weight: 700;
      cursor: pointer;
    }

    .collapse-toggle::before {
      content: '\2304';
      display: block;
      font-size: 20px;
      font-weight: 800;
      line-height: 1;
      transform: scaleY(0.72);
      transform-origin: center;
      margin-top: -1px;
    }

    .collapse-toggle[data-collapsed="true"]::before {
      content: '\2303';
    }
    .export-btn {
      width: 52px;
      height: 52px;
      display: grid;
      place-items: center;
      border: 1px solid #d7dfec;
      border-radius: 16px;
      background: rgba(255,255,255,0.96);
      box-shadow: var(--shadow);
      color: #22304a;
      padding: 0;
      flex: 0 0 auto;
    }

    .export-btn svg {
      width: 24px;
      height: 24px;
      min-width: 0;
      min-height: 0;
    }

















    .render-mode-btn {
      width: 52px;
      min-width: 52px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .render-mode-btn span {
      font-size: 12px;
      font-weight: 800;
      letter-spacing: 0.03em;
      line-height: 1;
    }

    .new-machine-btn {
      color: #1d4ed8;
      background: rgba(238, 244, 255, 0.96);
      border-color: #c7d7fe;
    }

    .cleanup-btn {
      color: #7c2d12;
      background: rgba(255, 247, 237, 0.96);
      border-color: #fed7aa;
    }

    .render-mode-btn.active {
      border-color: #99d4d6;
      background: rgba(240, 253, 250, 0.96);
      color: #0f766e;
    }

    .edit-mode-btn.active {
      border-color: #f3b7b2;
      background: #fff1f0;
      color: #b42318;
    }

    .edit-toolbar {
      position: absolute;
      top: 86px;
      left: 18px;
      display: none;
      align-items: center;
      gap: 10px;
      z-index: 5;
    }

    .edit-toolbar.active {
      display: flex;
    }

    .edit-action-btn {
      border: 1px solid #d7dfec;
      border-radius: 12px;
      padding: 10px 12px;
      background: rgba(255,255,255,0.96);
      box-shadow: var(--shadow);
      color: #22304a;
      font-size: 12px;
      font-weight: 800;
    }

    .edit-action-btn.icon-only {
      width: 42px;
      height: 42px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .edit-action-btn.icon-only svg {
      width: 18px;
      height: 18px;
    }

    .edit-action-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .edit-actions button:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      filter: saturate(0.4);
    }

    .note { color: var(--muted); font-size: 12px; }
    .error {
      color: #b42318;
      background: #fff1f2;
      border: 1px solid #fecdd3;
      padding: 10px 12px;
      border-radius: 12px;
      font-size: 13px;
      display: none;
    }
    .footer-note {
      font-size: 12px;
      color: var(--muted);
      line-height: 1.45;
    }

    .footer-link {
      color: #1d4ed8;
      font-weight: 700;
      text-decoration: none;
    }

    .footer-link:hover,
    .footer-link:focus-visible {
      text-decoration: underline;
    }

.range-control {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.settings-panel {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafcff;
}

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

.settings-title {
  font-size: 13px;
  font-weight: 800;
  color: #10203c;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-panel.collapsed .settings-body {
  display: none;
}

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

    .semantic-panel {
      padding: 12px 14px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fafcff;
    }

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

    .semantic-head-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 0 0 auto;
    }

    .semantic-title {
      font-size: 13px;
      font-weight: 800;
      color: #10203c;
      text-transform: uppercase;
      letter-spacing: 0.02em;
    }

    .semantic-status {
      padding: 4px 8px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 800;
      line-height: 1;
      color: #334155;
      background: #e2e8f0;
      white-space: nowrap;
    }

    .semantic-status.ok {
      color: #166534;
      background: #dcfce7;
    }

    .semantic-status.warn {
      color: #9a3412;
      background: #ffedd5;
    }

    .semantic-status.error {
      color: #b42318;
      background: #ffe4e6;
    }

    .semantic-body {
      display: flex;
      flex-direction: column;
      gap: 8px;
      font-size: 12px;
      color: #475569;
      line-height: 1.45;
    }

    .semantic-panel.collapsed .semantic-body {
      display: none;
    }

    .semantic-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .semantic-group-title {
      font-size: 11px;
      font-weight: 800;
      color: #334155;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .semantic-item {
      padding: 8px 10px;
      border-radius: 10px;
      border: 1px solid #dbe4f2;
      background: #ffffff;
    }

    .semantic-item.error {
      border-color: #fecdd3;
      background: #fff1f2;
      color: #9f1239;
    }

    .semantic-item.warn {
      border-color: #fed7aa;
      background: #fff7ed;
      color: #9a3412;
    }

    .semantic-item.info {
      border-color: #bfdbfe;
      background: #eff6ff;
      color: #1d4ed8;
    }

    .range-head label {
      margin: 0;
    }

    .range-value {
      font-size: 12px;
      font-weight: 700;
      color: #22304a;
    }

    .range-control input[type="range"] {
      width: 100%;
      margin: 0;
    }

    .summary-panel {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 28px;
      background: rgba(15, 23, 42, 0.34);
      z-index: 20;
    }

    .summary-panel.open {
      display: flex;
    }

    .summary-dialog {
      width: min(920px, calc(100vw - 56px));
      max-height: min(80vh, 900px);
      overflow: auto;
      padding: 18px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: #fcfdff;
      box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .summary-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
    }

    .summary-title {
      margin: 0;
      font-size: 15px;
      line-height: 1.3;
    }

    .summary-sub {
      margin-top: 4px;
      font-size: 12px;
      color: var(--muted);
    }

    .summary-close {
      width: 32px;
      height: 32px;
      display: inline-grid;
      place-items: center;
      border: 1px solid #efb4af;
      border-radius: 10px;
      padding: 0;
      background: #fff1f0;
      color: #b42318;
      font-size: 16px;
      font-weight: 800;
      line-height: 1;
      cursor: pointer;
      transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
    }

    .summary-close:hover {
      background: #ffe2df;
      border-color: #e8928b;
      transform: translateY(-1px);
    }

    .summary-section {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .summary-section h4 {
      margin: 0;
      font-size: 13px;
    }

    .summary-graph {
      width: 100%;
      overflow: auto;
      border: 1px solid #e5eaf3;
      border-radius: 16px;
      background:
        radial-gradient(circle at 1px 1px, #edf1f7 1px, transparent 0) 0 0 / 20px 20px,
        #ffffff;
      padding: 10px;
    }

    .summary-graph svg {
      display: block;
      min-width: 100%;
      min-height: 220px;
    }

    .summary-cards {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
      gap: 10px;
    }

    .summary-card {
      border: 1px solid #dfe6f2;
      border-radius: 14px;
      background: #ffffff;
      padding: 12px;
      box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    }

    .summary-card.loop {
      border-color: #9fdfb5;
      background: rgba(22, 163, 74, 0.08);
    }

    .summary-card.branch {
      border-color: #c9dafc;
      background: rgba(47, 111, 218, 0.07);
    }

    .summary-card.final {
      border-color: #f3b7b2;
      background: rgba(217, 45, 32, 0.08);
    }

    .summary-card h5 {
      margin: 0 0 8px;
      font-size: 13px;
    }

    .summary-card p {
      margin: 0;
      font-size: 12px;
      line-height: 1.45;
      color: #334155;
    }

    .summary-card p + p {
      margin-top: 6px;
    }

    .summary-list {
      margin: 0;
      padding-left: 18px;
      font-size: 12px;
      line-height: 1.45;
      color: #22304a;
    }

    .summary-list li + li {
      margin-top: 6px;
    }

    .summary-empty {
      font-size: 12px;
      color: var(--muted);
    }

    .edit-panel {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 28px;
      background: rgba(15, 23, 42, 0.4);
      z-index: 30;
    }

    .edit-panel.open {
      display: flex;
    }

    .confirm-panel {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 28px;
      background: rgba(15, 23, 42, 0.42);
      z-index: 40;
    }

    .confirm-panel.open {
      display: flex;
    }

    .confirm-dialog {
      width: min(480px, calc(100vw - 56px));
      padding: 18px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: #fcfdff;
      box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .confirm-title {
      margin: 0;
      font-size: 16px;
    }

    .confirm-text {
      font-size: 13px;
      line-height: 1.5;
      color: #475569;
    }

    .confirm-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    .xml-window {
      position: fixed;
      top: 120px;
      left: 120px;
      width: min(720px, calc(100vw - 48px));
      height: min(520px, calc(100vh - 96px));
      min-width: 360px;
      min-height: 260px;
      display: none;
      flex-direction: column;
      border: 1px solid #d7dfec;
      border-radius: 18px;
      background: #fcfdff;
      box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
      overflow: hidden;
      resize: both;
      z-index: 25;
    }

    .xml-window.open {
      display: flex;
    }

    .xml-window[data-kind="kernel"] {
      top: 156px;
      left: 180px;
    }

.xml-window-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
      gap: 12px;
      padding: 14px 16px 10px;
      border-bottom: 1px solid #edf1f7;
      cursor: move;
      user-select: none;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.xml-window-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

    .xml-window-title {
      margin: 0;
      font-size: 14px;
      font-weight: 800;
      color: #0f172a;
    }

    .xml-window-sub {
      margin-top: 4px;
      font-size: 12px;
      color: var(--muted);
    }

.xml-window-body {
  flex: 1;
  padding: 12px;
  min-height: 0;
      display: flex;
      flex-direction: column;
      gap: 12px;
  overflow: hidden;
}

.xml-window.collapsed .xml-window-body {
  display: none;
}

.xml-window.collapsed {
  height: auto !important;
  min-height: 0;
  resize: horizontal;
}

    .xml-toolbar {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 12px;
      flex: 0 0 auto;
    }

    .xml-toolbar-status {
      font-size: 12px;
      color: #475569;
      padding: 7px 10px;
      border-radius: 10px;
      border: 1px solid #d7dfec;
      background: #f8fafc;
      font-weight: 700;
      max-width: 100%;
      white-space: normal;
      overflow-wrap: anywhere;
    }

    .xml-toolbar-status.valid {
      color: #166534;
      border-color: #86efac;
      background: #f0fdf4;
    }

    .xml-toolbar-status.invalid {
      color: #b42318;
      border-color: #f5b4ae;
      background: #fff1f0;
    }

    .xml-editor-layout {
      flex: 1;
      min-height: 0;
      display: block;
      overflow: hidden;
    }

.xml-code-shell {
  min-width: 0;
  min-height: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  border: 1px solid #d7dfec;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
}

    .xml-gutter {
      min-height: 0;
      overflow: hidden;
      border-right: 1px solid #e5eaf3;
      background: #f8fafc;
      font: 12px/20px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      color: #64748b;
      user-select: none;
      padding: 10px 0;
    }

    .xml-gutter-track {
      transform: translateY(0);
    }

    .xml-gutter-line {
      height: 20px;
      display: grid;
      grid-template-columns: 24px minmax(0, 1fr);
      align-items: center;
      gap: 6px;
      padding: 0 8px;
    }

    .xml-gutter-line.error {
      background: rgba(217, 45, 32, 0.12);
      color: #b42318;
    }

    .xml-gutter-fold {
      width: 12px;
      height: 12px;
      display: inline-grid;
      place-items: center;
      border: 1px solid #cfd6e4;
      border-radius: 0;
      background: #ffffff;
      color: #475569;
      font-size: 9px;
      font-weight: 800;
      line-height: 1;
      cursor: pointer;
      padding: 0;
      transform: translate(-3px, -3px);
    }

    .xml-gutter-fold.placeholder {
      border-color: transparent;
      background: transparent;
      cursor: default;
    }

.xml-window textarea {
  min-height: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  padding: 10px 12px;
  line-height: 20px;
  resize: none;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  outline: none;
}

.xml-window textarea.xml-invalid {
  background: linear-gradient(180deg, #ffffff 0%, #fff8f7 100%);
}

    .xml-toast {
      position: fixed;
      right: 24px;
      bottom: 24px;
      display: none;
      align-items: center;
      gap: 10px;
      max-width: min(420px, calc(100vw - 32px));
      padding: 12px 14px;
      border-radius: 14px;
      border: 1px solid #d7dfec;
      background: #ffffff;
      box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
      z-index: 60;
      font-size: 13px;
      font-weight: 700;
      color: #10203c;
    }

    .xml-toast.open {
      display: inline-flex;
    }

    .xml-toast.valid {
      border-color: #86efac;
      background: #f0fdf4;
      color: #166534;
    }

    .xml-toast.invalid {
      border-color: #f5b4ae;
      background: #fff1f0;
      color: #b42318;
    }

    .xml-toast-badge {
      width: 24px;
      height: 24px;
      display: inline-grid;
      place-items: center;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 900;
      line-height: 1;
      flex: 0 0 auto;
    }

    .xml-toast.valid .xml-toast-badge {
      background: rgba(34, 197, 94, 0.14);
    }

    .xml-toast.invalid .xml-toast-badge {
      background: rgba(217, 45, 32, 0.12);
    }

    .edit-dialog {
      width: min(760px, calc(100vw - 56px));
      max-height: min(84vh, 960px);
      overflow: auto;
      padding: 18px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: #fcfdff;
      box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
      display: flex;
      flex-direction: column;
      gap: 14px;
      cursor: default;
    }

    .edit-dialog.transition-editor-dialog {
      width: min(1120px, calc(100vw - 56px));
    }

    .edit-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      cursor: move;
      user-select: none;
    }

    .edit-title {
      margin: 0;
      font-size: 16px;
    }

    .edit-sub {
      margin-top: 4px;
      font-size: 12px;
      color: var(--muted);
    }

    .edit-close {
      width: 32px;
      height: 32px;
      display: inline-grid;
      place-items: center;
      border: 1px solid #efb4af;
      border-radius: 10px;
      padding: 0;
      background: #fff1f0;
      color: #b42318;
      font-size: 16px;
      font-weight: 800;
      line-height: 1;
    }

    .edit-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .edit-structure {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .edit-row-2 {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .edit-section-divider {
      height: 1px;
      background: #e5eaf3;
      border: 0;
      margin: 2px 0;
    }

    .edit-section-title {
      margin: 0;
      font-size: 12px;
      font-weight: 800;
      color: #475569;
      letter-spacing: 0.03em;
      text-transform: uppercase;
    }

    .edit-field {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .edit-field.is-hidden {
      display: none;
    }

    .edit-field label {
      margin: 0;
      font-size: 12px;
    }

    .edit-field input,
    .edit-field select {
      width: 100%;
      border: 1px solid #d7dfec;
      border-radius: 12px;
      padding: 10px 12px;
      font: 13px/1.3 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      color: #10203c;
      background: #ffffff;
    }

    .edit-field.invalid input,
    .edit-field.invalid select {
      border-color: #f5b4ae;
      background: #fff1f0;
    }

    .edit-field input[readonly] {
      background: #f8fafc;
      color: #64748b;
      cursor: default;
    }

    .edit-field.checkbox {
      flex-direction: row;
      align-items: center;
      gap: 8px;
      padding-top: 22px;
    }

    .edit-field.checkbox input {
      width: auto;
    }

    .edit-inline-note {
      font-size: 11px;
      color: var(--muted);
    }

    .edit-inline-error {
      display: none;
      margin: 10px 0 12px;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid #f5b4ae;
      background: #fff1f0;
      color: #b42318;
      font-size: 12px;
      line-height: 1.4;
    }

    .edit-inline-error.active {
      display: block;
    }

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

    .cleanup-report {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .cleanup-report-section {
      border: 1px solid #dfe6f2;
      border-radius: 14px;
      background: #ffffff;
      padding: 12px;
      min-height: 0;
    }

    .cleanup-report-title {
      margin: 0 0 10px;
      font-size: 13px;
      font-weight: 800;
      color: #0f172a;
    }

    .cleanup-report-list {
      margin: 0;
      padding-left: 18px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      font-size: 12px;
      color: #334155;
    }

    .transition-editor-layout {
      display: grid;
      grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
      gap: 14px;
      min-height: 460px;
      height: min(68vh, 720px);
      max-height: min(68vh, 720px);
      align-items: stretch;
    }

    .transition-editor-nav,
    .transition-editor-detail {
      min-height: 0;
    }

    .transition-editor-nav {
      display: flex;
      flex-direction: column;
      gap: 12px;
      height: 100%;
      padding: 14px;
      border: 1px solid #dfe6f2;
      border-radius: 16px;
      background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
      overflow: hidden;
    }

    .transition-editor-nav-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
    }

    .transition-editor-nav-title {
      font-size: 13px;
      font-weight: 800;
      color: #0f172a;
    }

    .transition-editor-nav-sub {
      margin-top: 4px;
      font-size: 12px;
      color: var(--muted);
    }

    .transition-editor-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-height: 0;
      overflow: auto;
      padding-right: 4px;
    }

    .transition-list-item {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 11px 12px;
      border: 1px solid #d7dfec;
      border-radius: 14px;
      background: #ffffff;
      color: #10203c;
      text-align: left;
    }

    .transition-list-item.active {
      border-color: #93c5fd;
      background: #eef4ff;
      box-shadow: inset 0 0 0 1px rgba(47, 111, 218, 0.14);
    }

    .transition-list-item-copy {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .transition-list-item-title {
      font-size: 13px;
      font-weight: 800;
      color: #0f172a;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .transition-list-item-meta {
      font-size: 12px;
      color: #64748b;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .transition-list-item-delete {
      flex: 0 0 auto;
      width: 24px;
      height: 24px;
      display: inline-grid;
      place-items: center;
      border: 1px solid #f2c0bb;
      border-radius: 8px;
      background: #fff1f0;
      color: #b42318;
      font-size: 11px;
      font-weight: 800;
      line-height: 1;
      cursor: pointer;
    }

    .transition-editor-detail {
      min-width: 0;
      min-height: 0;
      overflow: auto;
    }

    .transition-detail-card {
      min-height: 100%;
    }

    .edit-card {
      border: 1px solid #dfe6f2;
      border-radius: 14px;
      background: #ffffff;
      padding: 12px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .edit-card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .edit-card-title {
      margin: 0;
      font-size: 13px;
      font-weight: 800;
    }

    .edit-card-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .edit-mini-btn {
      border: 1px solid #d7dfec;
      border-radius: 10px;
      padding: 7px 9px;
      background: #f7f9fd;
      color: #22304a;
      font-size: 11px;
      font-weight: 800;
    }

    .edit-mini-btn.danger {
      border-color: #f2c0bb;
      background: #fff1f0;
      color: #b42318;
    }

    .edit-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 10px;
    }

    .edit-empty {
      padding: 12px;
      border: 1px dashed #ccd6e7;
      border-radius: 12px;
      color: var(--muted);
      font-size: 12px;
      text-align: center;
      background: #fbfcff;
    }

    @media (max-width: 920px) {
      .edit-dialog.transition-editor-dialog {
        width: min(760px, calc(100vw - 32px));
      }

      .transition-editor-layout {
        grid-template-columns: 1fr;
        min-height: 0;
        height: auto;
        max-height: none;
      }

      .transition-editor-list {
        max-height: 220px;
      }
    }

    .edit-inline-warning {
      display: none;
      padding: 10px 12px;
      border: 1px solid #fdba74;
      border-radius: 12px;
      background: #fff7ed;
      color: #c2410c;
      font-size: 12px;
      line-height: 1.45;
    }

    .edit-inline-warning.active {
      display: block;
    }

    .node-action,
    .edge-action {
      opacity: 0;
      transition: opacity 120ms ease;
    }

    .node:hover .node-action,
    .edge-label:hover .edge-action,
    .edge-label.edit-active .edge-action {
      opacity: 1;
    }

    .edge-tooltip {
      position: absolute;
      display: none;
      max-width: min(420px, calc(100% - 32px));
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(17, 24, 39, 0.7);
      color: #f8fafc;
      box-shadow: 0 12px 28px rgba(15, 23, 42, 0.26);
      font-size: 12px;
      line-height: 1.45;
      pointer-events: none;
      z-index: 3;
      white-space: pre-line;
    }

    .edge-tooltip b {
      display: block;
      margin-bottom: 4px;
      font-size: 12px;
      color: #cdd8ea;
    }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { max-height: 55vh; }

  .topbar {
    flex-wrap: wrap;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 14px;
  }
}
