

    .node-menu {
      pointer-events: none;
    }
    .group:hover .node-menu {
      pointer-events: auto;
    }
    /* モバイル用：ノードメニューを明示的に表示 */
    .node-menu.mobile-open {
      opacity: 1 !important;
      pointer-events: auto !important;
    }
    .node-hover-area {
      pointer-events: none;
    }
    .group:hover .node-hover-area {
      pointer-events: auto;
    }
    .node-hover-area:has(.node-menu.mobile-open) {
      pointer-events: auto;
    }
    @media (max-width: 639px) {
      .group:hover .node-menu {
        opacity: 0 !important;
        pointer-events: none !important;
      }
      .group:hover .node-hover-area {
        pointer-events: none !important;
      }
      .node-menu.mobile-open {
        opacity: 0 !important;
        pointer-events: none !important;
      }
    }

    /* ノード全体を角丸でクリップし、内側の背景を隙間なく表示 */
    .node {
      overflow: visible;
    }
    .node .node-body {
      border-radius: inherit;
      overflow: hidden;
      padding-right: 0.75rem; /* 右上アイコンぶんの固定余白を確保（やや控えめ） */
      padding-left: 0.75rem;
    }
    .node .node-header {
      padding-right: 0.75rem; /* タイトル行も余白を確保 */
      min-width: 0;
    }
    /* 折り畳みアイコンの強制非表示用クラス（最終優先） */
    .nm-collapse-hidden {
      display: none !important;
    }
    .node .node-title {
      white-space: nowrap; /* 折り返し/省略なしで横に伸ばす */
    }
    .node.node-detail-visible {
      min-width: 320px;
      max-width: 420px;
    }
    .node.node-detail-visible .node-title {
      white-space: normal;
      overflow-wrap: anywhere;
    }
    .node-detail-fields {
      display: none;
      margin-top: 6px;
      padding-top: 6px;
      border-top: 1px solid rgba(55, 65, 81, 0.18);
      gap: 6px;
    }
    .node.node-detail-visible .node-detail-fields {
      display: flex;
      flex-direction: column;
    }
    .node-detail-field {
      display: block;
      min-width: 0;
    }
    .node-detail-field-header {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 4px;
      min-width: 0;
    }
    .node-detail-label {
      font-size: 10px;
      line-height: 1.25;
      color: rgba(31, 41, 55, 0.7);
      min-width: 0;
    }
    .node-detail-value {
      margin-top: 2px;
      font-size: 12px;
      line-height: 1.45;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      color: rgba(17, 24, 39, 0.92);
    }
    .node-detail-value.is-empty {
      color: rgba(107, 114, 128, 0.78);
    }
    .node-detail-edit-btn {
      display: inline-flex;
      width: 16px;
      height: 16px;
      align-items: center;
      justify-content: center;
      border: 1px solid rgba(255, 255, 255, 0.72);
      border-radius: 4px;
      background: rgba(255, 255, 255, 0.86);
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.16);
      font-size: 12px;
      line-height: 1;
      flex: none;
      visibility: hidden;
      opacity: 0;
      pointer-events: none;
    }
    .node-detail-edit-btn:hover {
      background: rgba(255, 255, 255, 0.98);
      filter: brightness(0.96);
    }
    .node-detail-edit-btn img {
      width: 10px;
      height: 10px;
      pointer-events: none;
      opacity: 0.78;
    }
    .node.node-selected .node-detail-edit-btn,
    .node-detail-field:hover .node-detail-edit-btn {
      visibility: visible;
      opacity: 1;
      pointer-events: auto;
    }
    .node-detail-editor {
      grid-column: 1 / -1;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .node-detail-editor input,
    .node-detail-editor textarea,
    .node-detail-editor select {
      width: 100%;
      min-width: 0;
      font-size: 16px;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      padding: 7px 9px;
      background: #fff;
      color: #111827;
    }
    .node-detail-quick-edit-control {
      width: 100%;
      min-width: 0;
      font-size: 16px;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      padding: 8px 10px;
      background: #fff;
      color: #111827;
    }
    textarea.node-detail-quick-edit-control {
      height: 132px;
      min-height: 132px;
      max-height: 132px;
      overflow-y: auto;
      resize: none;
    }
    .node-detail-editor-actions {
      display: flex;
      gap: 6px;
      justify-content: flex-end;
    }
    .node-detail-editor-actions button {
      min-height: 30px;
      padding: 4px 10px;
      border-radius: 7px;
      border: 1px solid #d1d5db;
      background: #fff;
      font-size: 12px;
    }
    .node-detail-editor-actions .node-detail-save-btn {
      border-color: #2563eb;
      background: #2563eb;
      color: #fff;
    }
    @media (max-width: 639px) {
      .node.node-detail-visible {
        min-width: 260px;
        max-width: 320px;
      }
      .node-detail-edit-btn {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
      }
    }
    html.dark .node-detail-label {
      color: rgba(226, 232, 240, 0.72);
    }
    html.dark .node-detail-value {
      color: rgba(248, 250, 252, 0.92);
    }
    html.dark .node-detail-value.is-empty {
      color: rgba(203, 213, 225, 0.68);
    }
    html.dark .node-detail-editor input,
    html.dark .node-detail-editor textarea,
    html.dark .node-detail-editor select,
    html.dark .node-detail-quick-edit-control,
    html.dark .node-detail-editor-actions button {
      border-color: #475569;
      background: #1e293b;
      color: #f8fafc;
    }
    html.dark .node-detail-edit-btn {
      border-color: rgba(255, 255, 255, 0.78);
      background: rgba(255, 255, 255, 0.9);
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
    }
    html.dark .node-detail-edit-btn:hover {
      background: #fff;
    }
    .node-settings-actions {
      display: grid;
      grid-template-columns: minmax(58px, 0.58fr) repeat(2, minmax(0, 1fr));
      gap: 6px;
    }
    .node-settings-action-card {
      min-width: 0;
      padding: 6px;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      background: #f9fafb;
    }
    .node-settings-action-title {
      min-height: 30px;
      margin-bottom: 6px;
      color: #4b5563;
      font-size: 11px;
      font-weight: 500;
      line-height: 1.35;
    }
    .node-settings-action-buttons {
      display: flex;
      flex-wrap: nowrap;
      align-items: center;
      gap: 3px;
    }
    .node-settings-action-btn {
      min-width: 0;
      padding: 4px 3px;
      border: 1px solid #d1d5db;
      border-radius: 4px;
      background: #fff;
      font-size: 10px;
      line-height: 1.2;
      white-space: nowrap;
    }
    .node-settings-action-btn:hover {
      background: #f3f4f6;
    }
    .nm-action-button:disabled,
    .nm-select-display:disabled {
      border-color: #e5e7eb !important;
      background: #f3f4f6 !important;
      color: #9ca3af !important;
      cursor: not-allowed !important;
      opacity: 1 !important;
      box-shadow: none !important;
    }
    .nm-action-button:disabled:hover,
    .nm-select-display:disabled:hover {
      border-color: #e5e7eb !important;
      background: #f3f4f6 !important;
      color: #9ca3af !important;
    }
    .nm-readonly-control:disabled {
      border-color: #e5e7eb !important;
      background: #f3f4f6 !important;
      color: #4b5563 !important;
      cursor: not-allowed !important;
      opacity: 1 !important;
    }
    #node-settings-type-list > button,
    .node-settings-tab-btn,
    #custom-node-list > button,
    #custom-state-list > button {
      box-shadow: none;
    }
    #node-settings-type-list > button:focus:not(:focus-visible),
    .node-settings-tab-btn:focus:not(:focus-visible),
    #custom-node-list > button:focus:not(:focus-visible),
    #custom-state-list > button:focus:not(:focus-visible) {
      outline: none;
      box-shadow: none;
    }
    #node-settings-type-list > button:focus-visible,
    .node-settings-tab-btn:focus-visible,
    #custom-node-list > button:focus-visible,
    #custom-state-list > button:focus-visible {
      outline: 2px solid #2563eb;
      outline-offset: 2px;
    }
    .custom-settings-list-button {
      box-shadow: none;
    }
    .custom-settings-list-button:focus:not(:focus-visible) {
      outline: none;
      box-shadow: none;
    }
    .custom-settings-list-button:focus-visible {
      outline: 2px solid #2563eb;
      outline-offset: 2px;
    }
    #custom-state-list .custom-settings-list-button {
      background-color: #e2e8f0 !important;
      color: #111827 !important;
    }
    html.dark #custom-state-list .custom-settings-list-button {
      background-color: #374151 !important;
      color: #f9fafb !important;
    }
    html.dark #custom-state-list .custom-settings-list-button.border-gray-900 {
      border-color: #f9fafb !important;
    }
    .custom-node-basic-grid {
      grid-template-columns: minmax(0, 1fr) auto;
    }
    .custom-node-title-field {
      grid-column: 1 / -1;
    }
    @container (min-width: 620px) {
      .custom-node-basic-grid {
        grid-template-columns: minmax(0, 1fr) 120px minmax(180px, auto);
      }
      .custom-node-title-field {
        grid-column: auto;
      }
    }
    .custom-icon-setting-row {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .custom-icon-setting-preview {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 40px;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      background: #fff;
      color: #9ca3af;
      flex: 0 0 auto;
    }
    .custom-icon-setting-preview img {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
    .custom-icon-setting-btn,
    .custom-icon-reset-btn {
      min-width: 0;
      padding: 8px 10px;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      background: #fff;
      color: #111827;
      font-size: 13px;
      line-height: 1.2;
      white-space: nowrap;
    }
    .custom-icon-setting-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 40px;
      padding-top: 0;
      padding-bottom: 0;
    }
    .custom-icon-setting-btn:hover,
    .custom-icon-reset-btn:hover {
      background: #f3f4f6;
    }
    .custom-icon-setting-btn:focus:not(:focus-visible),
    .custom-icon-reset-btn:focus:not(:focus-visible),
    .custom-icon-picker-tile:focus:not(:focus-visible) {
      outline: none;
      box-shadow: none;
    }
    .custom-icon-setting-btn:focus-visible,
    .custom-icon-reset-btn:focus-visible,
    .custom-icon-picker-tile:focus-visible {
      outline: 2px solid #2563eb;
      outline-offset: 2px;
    }
    .custom-icon-editor-preview-bar {
      flex: 0 0 auto;
      display: flex;
      justify-content: center;
      padding: 12px 16px;
      border-bottom: 1px solid #e5e7eb;
      background: #ffffff;
    }
    .custom-icon-editor-preview-shell {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      max-width: 220px;
      padding: 10px;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      background: #f9fafb;
    }
    .custom-icon-preview-large {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 104px;
      height: 104px;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      background: #fff;
      color: #9ca3af;
    }
    .custom-icon-preview-large img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      filter: none !important;
    }
    @media (min-width: 640px) {
      .custom-icon-preview-large {
        width: 144px;
        height: 144px;
      }

      .custom-icon-editor-preview-bar {
        padding: 14px 20px;
      }
    }
    .custom-icon-editor-section {
      display: flex;
      flex-direction: column;
      gap: 10px;
      min-width: 0;
      padding: 12px;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      background: #f9fafb;
    }
    .custom-icon-editor-section-title {
      color: #374151;
      font-size: 13px;
      font-weight: 600;
    }
    .custom-icon-picker-grid {
      display: flex;
      flex-direction: column;
      gap: 10px;
      max-height: 260px;
      overflow-y: auto;
      padding-right: 2px;
    }
    .custom-icon-picker-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
      min-width: 0;
    }
    .custom-icon-picker-heading {
      color: #6b7280;
      font-size: 12px;
      font-weight: 600;
      line-height: 1.4;
    }
    .custom-icon-picker-tiles {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
      gap: 8px;
    }
    .custom-icon-picker-tile {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      aspect-ratio: 1 / 1;
      min-width: 44px;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      background: #fff;
      box-shadow: none;
    }
    .custom-icon-picker-tile:hover {
      background: #f3f4f6;
    }
    .custom-icon-picker-tile[aria-checked="true"] {
      border-color: #111827;
      border-width: 2px;
    }
    .custom-icon-picker-tile img {
      width: 26px;
      height: 26px;
      object-fit: contain;
      pointer-events: none;
    }
    .custom-icon-adjust-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 8px;
    }
    .custom-icon-adjust-control {
      display: grid;
      grid-template-columns: 64px minmax(0, 1fr) 58px;
      align-items: center;
      gap: 8px;
      color: #374151;
      font-size: 13px;
    }
    .custom-icon-adjust-control input[type="range"] {
      width: 100%;
      min-width: 0;
    }
    .custom-icon-adjust-value {
      box-sizing: border-box;
      width: 58px;
      min-width: 0;
      min-height: 36px;
      padding: 4px 6px;
      appearance: textfield;
      border: 1px solid #d1d5db;
      border-radius: 4px;
      background: #fff;
      color: #6b7280;
      text-align: right;
      font-size: 16px;
      font-variant-numeric: tabular-nums;
    }
    .custom-icon-adjust-value::-webkit-inner-spin-button,
    .custom-icon-adjust-value::-webkit-outer-spin-button {
      margin: 0;
      appearance: none;
    }
    .custom-icon-adjust-value:hover {
      border-color: #9ca3af;
    }
    .custom-icon-adjust-value:focus {
      border-color: #2563eb;
      outline: 2px solid rgba(37, 99, 235, 0.2);
      outline-offset: 1px;
    }
    .custom-icon-adjust-value[aria-invalid="true"] {
      border-color: #ef4444;
    }
    @media (pointer: coarse) {
      .custom-icon-adjust-value {
        min-height: 44px;
      }
    }
    html.dark .custom-icon-setting-preview,
    html.dark .custom-icon-preview-large,
    html.dark .custom-icon-picker-tile,
    html.dark .custom-icon-setting-btn,
    html.dark .custom-icon-reset-btn {
      border-color: #4b5563;
      background: #111827;
      color: #d1d5db;
    }
    html.dark .custom-icon-editor-preview-bar {
      border-color: #374151;
      background: #0f172a;
    }
    html.dark .custom-icon-editor-preview-shell {
      border-color: #4b5563;
      background: #111827;
    }
    html.dark .custom-icon-setting-preview img,
    html.dark .custom-icon-preview-large img {
      filter: invert(1) brightness(1.15) !important;
    }
    html.dark .custom-icon-picker-tile img {
      filter: invert(1) brightness(1.15);
    }
    html.dark .custom-icon-setting-btn:hover,
    html.dark .custom-icon-reset-btn:hover,
    html.dark .custom-icon-picker-tile:hover {
      background: #1f2937;
    }
    html.dark .custom-icon-picker-tile[aria-checked="true"] {
      border-color: #f9fafb;
    }
    html.dark .custom-icon-editor-section {
      border-color: #374151;
      background: #111827;
    }
    html.dark .custom-icon-editor-section-title,
    html.dark .custom-icon-picker-heading,
    html.dark .custom-icon-adjust-control {
      color: #d1d5db;
    }
    html.dark .custom-icon-adjust-value {
      border-color: #4b5563;
      background: #111827;
      color: #d1d5db;
    }
    html.dark .custom-icon-adjust-value:hover {
      border-color: #6b7280;
    }
    html.dark .custom-icon-adjust-value:focus {
      border-color: #60a5fa;
      outline-color: rgba(96, 165, 250, 0.25);
    }
    html.dark .custom-icon-adjust-value[aria-invalid="true"] {
      border-color: #f87171;
    }
    .node-settings-action-label-desktop {
      display: none;
    }
    .node-settings-compact-list {
      max-height: 10.5rem;
    }
    .custom-settings-mobile-editor-action { display:flex; align-items:center; justify-content:space-between; gap:8px; padding-bottom:10px; border-bottom:1px solid #e5e7eb; }
    @media (max-width: 639px) {
      .custom-icon-picker-grid {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
      }
      #custom-node-list, #custom-state-list { display:flex; flex:none; width:100%; min-width:0; max-width:100%; max-height:none; flex-direction:row; gap:8px; overflow-x:auto; overflow-y:hidden; padding-bottom:8px; }
      #custom-node-list .custom-settings-list-button, #custom-state-list .custom-settings-list-button { flex:0 0 auto; width:max-content; height:auto; min-width:max-content; white-space:nowrap; }
      #custom-node-list .custom-settings-list-button > span,
      #custom-state-list .custom-settings-list-button > span { flex:none; overflow:visible; text-overflow:clip; white-space:nowrap; }
      .custom-settings-list-row { display:block; flex:0 0 auto; width:max-content; min-width:max-content; }
      .custom-settings-list-row > .custom-settings-list-button { width:max-content; }
      .custom-settings-list-delete-desktop { display:none; }
      .custom-settings-group-label--default { display:none; }
      .custom-settings-group-label--custom { display:flex; flex:0 0 auto; align-items:center; padding:0 4px 0 12px; border-left:1px solid #d1d5db; white-space:nowrap; }
      .custom-settings-list-empty { flex:0 0 auto; min-width:min(240px, 75vw); padding-top:11px; padding-bottom:11px; }
    }
    .node-settings-field-layout {
      display: grid;
      grid-template-columns: 26px minmax(0, 1fr);
      align-items: stretch;
      gap: 10px;
      width: 100%;
    }
    .node-settings-drag-handle {
      align-self: stretch;
      min-height: 100%;
      border-right: 1px solid #e5e7eb;
      touch-action: none;
    }
    @media (pointer: coarse) {
      .node-settings-field-layout {
        grid-template-columns: 44px minmax(0, 1fr);
      }
    }
    .node-settings-field-content {
      display: flex;
      min-width: 0;
      flex-direction: column;
      gap: 10px;
    }
    .custom-schema-editor {
      container-type: inline-size;
      max-width: 100%;
      overflow-x: hidden;
    }
    .custom-field-row {
      grid-template-columns: 26px minmax(0, 1fr);
      max-width: 100%;
      overflow: hidden;
    }
    @media (pointer: coarse) {
      .custom-field-row .nm-sortable-drag-handle {
        min-width: 26px;
      }
    }
    .custom-field-content,
    .custom-field-controls {
      min-width: 0;
      max-width: 100%;
    }
    .custom-field-controls {
      grid-template-areas: "name type action";
      grid-template-columns: minmax(0, 1fr) minmax(104px, 112px) auto;
    }
    .custom-field-controls--system {
      grid-template-columns: minmax(0, 1fr) 76px 58px;
    }
    .custom-field-controls--system .custom-field-type,
    .custom-field-controls--system .custom-field-action {
      font-size: 11px;
    }
    .custom-field-controls--has-extra {
      grid-template-areas:
        "name type action"
        "extra extra extra";
    }
    .custom-field-name {
      grid-area: name;
    }
    .custom-field-type {
      grid-area: type;
    }
    .custom-field-extra {
      grid-area: extra;
    }
    .custom-field-action {
      grid-area: action;
    }
    .custom-field-controls > input,
    .custom-field-controls > select,
    .custom-field-controls > button {
      width: 100%;
      min-width: 0;
      max-width: 100%;
    }
    .custom-field-controls > .custom-field-action {
      width: auto;
    }
    @container (min-width: 620px) {
      .custom-field-controls {
        grid-template-areas: none;
        grid-template-columns: minmax(0, 1fr) 150px 150px auto;
      }
      .custom-field-controls--system {
        grid-template-columns: minmax(0, 1fr) 120px 72px;
      }
      .custom-field-name,
      .custom-field-type,
      .custom-field-extra,
      .custom-field-action {
        grid-area: auto;
      }
    }
    @media (min-width: 640px) {
      .custom-settings-mobile-editor-action { display:none; }
      .custom-settings-list-row { display:grid; grid-template-columns:minmax(0, 1fr) auto; align-items:center; gap:8px; }
      .node-settings-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
      }
      .node-settings-action-card {
        padding: 10px 12px;
      }
      .node-settings-action-title {
        min-height: 0;
        margin-bottom: 8px;
        font-size: 12px;
      }
      .node-settings-action-btn {
        padding: 4px 6px;
        font-size: 11px;
      }
      .node-settings-action-label-mobile {
        display: none;
      }
      .node-settings-action-label-desktop {
        display: inline;
      }
      .node-settings-compact-list {
        max-height: none;
      }
      .node-settings-field-content {
        flex-direction: row;
        align-items: center;
      }
    }
    html.dark .node-settings-action-card {
      border-color: #374151;
      background: #111827;
    }
    html.dark .node-settings-action-title {
      color: #d1d5db;
    }
    html.dark .node-settings-action-btn {
      border-color: #4b5563;
      background: #1f2937;
      color: #f3f4f6;
    }
    html.dark .node-settings-action-btn:hover {
      background: #374151;
    }
    html.dark .nm-action-button:disabled,
    html.dark .nm-select-display:disabled,
    html.dark .nm-action-button:disabled:hover,
    html.dark .nm-select-display:disabled:hover {
      border-color: #4b5563 !important;
      background: #374151 !important;
      color: #9ca3af !important;
    }
    html.dark .nm-readonly-control:disabled {
      border-color: #4b5563 !important;
      background: #374151 !important;
      color: #d1d5db !important;
    }
    html.dark .node-settings-drag-handle {
      border-color: #374151;
    }
    .nm-root-highlight {
      position: absolute;
      inset: 0px;
      border-radius: inherit;
      pointer-events: none;
      box-shadow:
        0 0 18px rgba(0, 150, 255, 0.65),
        0 0 8px rgba(0, 150, 255, 0.45);
    }

    /* 線タイプ/見た目ボタンの選択色（ダークモードで白くならないようにする） */
    .nm-line-btn--active {
      background-color: #eff6ff;
    }
    html.dark .nm-line-btn--active {
      background-color: #0f172a;
    }

    /* 関係線の矢印ボタン（モバイルSafari含む環境差を抑制） */
    .relation-edge-arrow-btn,
    .new-relation-arrow-btn {
      appearance: none;
      -webkit-appearance: none;
      background: transparent;
      border-color: #d1d5db;
      color: #374151;
      -webkit-text-fill-color: currentColor;
      transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
    }
    .relation-edge-arrow-btn:hover:not(:disabled),
    .new-relation-arrow-btn:hover:not(:disabled) {
      background: #f9fafb;
    }
    html:not(.dark) .relation-edge-arrow-btn,
    html:not(.dark) .new-relation-arrow-btn {
      background: transparent;
      border-color: #0f172a;
      color: #374151;
      -webkit-text-fill-color: #374151;
      color-scheme: light;
    }
    html.dark .relation-edge-arrow-btn,
    html.dark .new-relation-arrow-btn {
      background: transparent;
      border-color: #64748b;
      color: #e2e8f0;
      -webkit-text-fill-color: #e2e8f0;
      color-scheme: dark;
    }
    html.dark .relation-edge-arrow-btn:hover:not(:disabled),
    html.dark .new-relation-arrow-btn:hover:not(:disabled) {
      background: #1e293b;
      border-color: #93c5fd;
    }

    /* 親子線の矢印ボタン（モバイルSafari含む環境差を抑制） */
    .edge-start-arrow-btn,
    .edge-end-arrow-btn {
      appearance: none;
      -webkit-appearance: none;
      background-color: transparent;
      border-color: #d1d5db;
      color: #374151;
      -webkit-text-fill-color: currentColor;
      opacity: 1;
      transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
    }
    .edge-start-arrow-btn:hover:not(:disabled),
    .edge-end-arrow-btn:hover:not(:disabled) {
      background-color: #f9fafb;
    }
    html:not(.dark) .edge-start-arrow-btn,
    html:not(.dark) .edge-end-arrow-btn {
      background-color: transparent;
      border-color: #0f172a;
      color: #374151;
      -webkit-text-fill-color: #374151;
      color-scheme: light;
      opacity: 1;
    }
    html.dark .edge-start-arrow-btn,
    html.dark .edge-end-arrow-btn {
      background-color: transparent;
      border-color: #64748b;
      color: #e2e8f0;
      -webkit-text-fill-color: #e2e8f0;
      color-scheme: dark;
    }
    html.dark .edge-start-arrow-btn:hover:not(:disabled),
    html.dark .edge-end-arrow-btn:hover:not(:disabled) {
      background-color: #1e293b;
      border-color: #93c5fd;
    }

    /* 線タイプ選択モーダルの矢印ボタン（モバイルSafari含む環境差を抑制） */
    .new-node-start-arrow-btn,
    .new-node-end-arrow-btn {
      appearance: none;
      -webkit-appearance: none;
      background-color: transparent;
      border-color: #d1d5db;
      color: #374151;
      -webkit-text-fill-color: currentColor;
      opacity: 1;
      transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
    }
    .new-node-start-arrow-btn:hover:not(:disabled),
    .new-node-end-arrow-btn:hover:not(:disabled) {
      background-color: #f9fafb;
    }
    html:not(.dark) .new-node-start-arrow-btn,
    html:not(.dark) .new-node-end-arrow-btn {
      background-color: transparent;
      border-color: #0f172a;
      color: #374151;
      -webkit-text-fill-color: #374151;
      color-scheme: light;
      opacity: 1;
    }
    html.dark .new-node-start-arrow-btn,
    html.dark .new-node-end-arrow-btn {
      background-color: transparent;
      border-color: #64748b;
      color: #e2e8f0;
      -webkit-text-fill-color: #e2e8f0;
      color-scheme: dark;
    }
    html.dark .new-node-start-arrow-btn:hover:not(:disabled),
    html.dark .new-node-end-arrow-btn:hover:not(:disabled) {
      background-color: #1e293b;
      border-color: #93c5fd;
    }

    /* 線タイプ選択ボタン・関係線タイプ選択ボタン（モバイルSafari含む環境差を抑制） */
    #line-style-select-btn,
    #relation-line-style-select-btn {
      appearance: none;
      -webkit-appearance: none;
      opacity: 1;
    }
    html:not(.dark) #line-style-select-btn,
    html:not(.dark) #relation-line-style-select-btn {
      background-color: #ffffff;
      border-color: #d1d5db;
      color: #374151;
      -webkit-text-fill-color: #374151;
      color-scheme: light;
    }
    html.dark #line-style-select-btn,
    html.dark #relation-line-style-select-btn {
      background-color: #0f172a;
      border-color: #64748b;
      color: #e2e8f0;
      -webkit-text-fill-color: #e2e8f0;
      color-scheme: dark;
    }

    /* 親子線・関係線のメモ入力欄（モバイルSafari含む環境差を抑制） */
    #edge-memo-input,
    #relation-edge-memo-input {
      appearance: none;
      -webkit-appearance: none;
      -webkit-text-fill-color: currentColor;
      opacity: 1;
      color-scheme: light;
    }
    html:not(.dark) #edge-memo-input,
    html:not(.dark) #relation-edge-memo-input {
      background-color: #f9fafb;
      border-color: #d1d5db;
      color: #1f2937;
      -webkit-text-fill-color: #1f2937;
      color-scheme: light;
    }
    html.dark #edge-memo-input,
    html.dark #relation-edge-memo-input {
      -webkit-text-fill-color: currentColor;
      color-scheme: dark;
    }

    /* パネル・モーダルのラベルテキスト（モバイルSafari含む環境差を抑制） */
    html:not(.dark) #panel-edge .text-gray-500,
    html:not(.dark) #panel-relation-edge .text-gray-500,
    html:not(.dark) #line-style-modal .text-gray-500,
    html:not(.dark) #relation-line-style-modal .text-gray-500 {
      color: #6b7280;
      -webkit-text-fill-color: #6b7280;
    }
    html.dark #panel-edge .text-gray-500,
    html.dark #panel-relation-edge .text-gray-500,
    html.dark #line-style-modal .text-gray-500,
    html.dark #relation-line-style-modal .text-gray-500 {
      color: #cbd5e1;
      -webkit-text-fill-color: #cbd5e1;
    }

    /* ダークモード：ヘッダー以外のSVGアイコンを白反転 */
    html.dark .nm-dark-icon-scope img[src*="/img/icon/"],
    html.dark .nm-dark-icon-scope img[src*="/img/line/"],
    html.dark .nm-dark-icon-scope img[src*="/img/node/"],
    html.dark .nm-dark-icon-scope img[src*="/img/state/"] {
      filter: invert(1) brightness(1.1);
    }

    /* ダークモード：線プレビュー画像は右パネル/モーダルでも常に視認可能にする */
    html.dark #line-style-select-icon img,
    html.dark #relation-line-style-select-icon img,
    html.dark .edge-lineType-btn img,
    html.dark .edge-strokeStyle-btn img,
    html.dark .relation-edge-lineType-btn img,
    html.dark .relation-edge-strokeStyle-btn img,
    html.dark .new-node-lineType-btn img,
    html.dark .new-node-strokeStyle-btn img,
    html.dark .new-relation-lineType-btn img,
    html.dark .new-relation-strokeStyle-btn img {
      filter: invert(1) brightness(1.15);
    }

    /* ダークモード：閉じるボタンの×アイコンを明るく保つ */
    html.dark button[id$="-close"] img[src*="Map_Icon_CrossMark.svg"],
    html.dark button[id$="-close-btn"] img[src*="Map_Icon_CrossMark.svg"] {
      filter: invert(1) brightness(1.2);
    }

    /* ダークモード：ゴミ箱ボタンの見た目を他ボタンに合わせる */
    html.dark .delete-node-btn {
      background: #0f172a !important;
      border-color: #cbd5e1 !important;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35) !important;
    }

    /* ホバー時のボタン強調（全メニュー共通） */
    .menu-btn {
      transition: border-color 120ms ease, box-shadow 120ms ease;
    }
    .menu-btn:hover {
      border-color: #2563eb !important;
      box-shadow:
        0 0 0 2px rgba(37, 99, 235, 0.35),
        0 1px 2px rgba(0, 0, 0, 0.15) !important;
    }
    html.dark .menu-btn:hover {
      border-color: #60a5fa !important;
      box-shadow:
        0 0 0 2px rgba(96, 165, 250, 0.35),
        0 1px 2px rgba(0, 0, 0, 0.35) !important;
      background: #0f172a !important;
    }

    /* カスタムドロップダウン（ノード種/ステートと同じ仕様に統一） */
    .nm-select-display {
      min-height: 40px;
      min-width: 220px;
      display: inline-flex;
      width: 100%;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 8px 12px;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      background: #ffffff;
      color: #111827;
      font-size: 15px;
      line-height: 1.5;
      transition: border-color 150ms ease, box-shadow 150ms ease;
    }
    .nm-select-display:focus-visible {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    }
    #relation-modal .nm-select-inner,
    #relation-modal .nm-select-display {
      min-width: 0;
    }
    .nm-select-dropdown {
      background: #ffffff;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
    }
    .nm-select-search-wrap {
      position: sticky;
      top: 0;
      z-index: 1;
      padding: 8px;
      background: inherit;
      border-bottom: 1px solid #e5e7eb;
    }
    .nm-select-search {
      width: 100%;
      min-height: 40px;
      padding: 8px 10px;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      background: #ffffff;
      color: #111827;
      font-size: 16px;
      line-height: 1.5;
    }
    .nm-select-search:focus {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
    }
    .nm-select-options {
      padding: 4px 0;
    }
    .nm-select-option {
      width: 100%;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      text-align: left;
    }
    .nm-select-option:hover,
    .nm-select-option[aria-current="true"] {
      background: #f1f5f9;
    }
    .nm-select-empty {
      padding: 14px 12px;
      color: #6b7280;
      text-align: center;
      font-size: 14px;
    }
    html.dark .nm-select-display {
      background: #0f172a;
      border-color: #1f2937;
      color: #e2e8f0;
    }
    html.dark .nm-select-display:focus-visible {
      border-color: #60a5fa;
      box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
    }
    html.dark .nm-select-dropdown {
      background: #0f172a;
      border-color: #1f2937;
      box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
      color: #e2e8f0;
    }
    html.dark .nm-select-search-wrap {
      border-bottom-color: #1f2937;
    }
    html.dark .nm-select-search {
      background: #111827;
      border-color: #334155;
      color: #e2e8f0;
    }
    html.dark .nm-select-search::placeholder {
      color: #94a3b8;
    }
    html.dark .nm-select-empty {
      color: #94a3b8;
    }
    html.dark .nm-select-option {
      color: #e2e8f0;
    }
    html.dark .nm-select-option:hover,
    html.dark .nm-select-option[aria-current="true"] {
      background: #1f2937;
    }

    /* ノード種 / ステートのドロップダウンを共通見た目に合わせる */
    #node-type-dropdown,
    #state-dropdown {
      background: #ffffff;
      border-color: #e5e7eb;
      color: #111827;
      box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
    }
    html.dark #node-type-dropdown,
    html.dark #state-dropdown {
      background: #0f172a;
      border-color: #1f2937;
      color: #e2e8f0;
      box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    }
    .node-type-option-btn,
    .state-option-btn {
      background: transparent;
      color: inherit;
    }

    /* Right panel / node info property form */
    .nm-editor-property-panel {
      gap: 20px;
      color: #1f2937;
    }
    .nm-editor-property-fields {
      gap: 18px;
      min-width: 0;
    }
    .nm-editor-property-fields > .nm-editor-property-field {
      margin-bottom: 0;
    }
    .nm-editor-property-field,
    .nm-editor-property-group {
      min-width: 0;
    }
    .nm-editor-property-label {
      color: #374151;
      font-size: 13px;
      font-weight: 600;
      line-height: 1.4;
    }
    .nm-editor-property-control {
      width: 100%;
      min-width: 0;
      font-size: 16px;
      min-height: 40px;
      border: 1px solid #cbd5e1;
      border-radius: 7px;
      background: #ffffff;
      color: #111827;
      line-height: 1.5;
      box-shadow: none;
      transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
      appearance: none;
      -webkit-appearance: none;
      -webkit-text-fill-color: currentColor;
    }
    textarea.nm-editor-property-control {
      min-height: 96px;
    }
    .nm-editor-property-control:focus,
    .nm-editor-property-control:focus-visible {
      outline: none;
      border-color: #2563eb;
      background: #ffffff;
      box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
    }
    input.nm-editor-property-control:read-only,
    textarea.nm-editor-property-control:read-only {
      border-color: #d1d5db;
      background: #f8fafc;
      color: #475569;
      cursor: default;
      opacity: 1;
    }
    .nm-editor-property-control:disabled {
      border-color: #d1d5db;
      background: #f1f5f9;
      color: #64748b;
      cursor: not-allowed;
      opacity: 1;
    }
    .nm-editor-property-select-trigger {
      text-align: left;
    }
    .nm-editor-property-actions {
      min-height: 32px;
    }
    .nm-editor-property-action {
      min-height: 32px;
      border-color: #cbd5e1;
      background: #ffffff;
      color: #334155;
      font-weight: 600;
      box-shadow: none;
      transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
    }
    .nm-editor-property-action:hover:not(:disabled):not([aria-disabled="true"]) {
      border-color: #94a3b8;
      background: #f8fafc;
      color: #0f172a;
    }
    .nm-editor-property-action:focus-visible {
      outline: none;
      border-color: #2563eb;
      box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
    }
    .nm-editor-property-action[aria-disabled="true"] {
      cursor: not-allowed;
    }
    .nm-editor-property-choice {
      color: #475569;
      line-height: 1.4;
      cursor: default;
    }
    .nm-editor-property-choice:not(:has(.nm-editor-property-checkbox:disabled)) {
      cursor: pointer;
    }
    .nm-editor-property-choice--compact {
      font-size: 12px;
    }
    .nm-editor-property-checkbox {
      accent-color: #2563eb;
    }
    .nm-editor-property-checkbox:focus-visible {
      outline: 2px solid #2563eb;
      outline-offset: 2px;
    }
    .nm-editor-property-group {
      gap: 10px;
    }
    .nm-editor-property-unit {
      flex: none;
      color: #64748b;
    }
    html.dark .nm-editor-property-panel {
      color: #e2e8f0;
    }
    html.dark .nm-editor-property-label {
      color: #cbd5e1;
    }
    html.dark .nm-editor-property-control {
      border-color: #475569;
      background: #0f172a;
      color: #e2e8f0;
      color-scheme: dark;
    }
    html.dark .nm-editor-property-control:focus,
    html.dark .nm-editor-property-control:focus-visible {
      border-color: #60a5fa;
      background: #111827;
      box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
    }
    html.dark input.nm-editor-property-control:read-only,
    html.dark textarea.nm-editor-property-control:read-only,
    html.dark .nm-editor-property-control:disabled {
      border-color: #334155;
      background: #1e293b;
      color: #94a3b8;
    }
    html.dark .nm-editor-property-action {
      border-color: #475569;
      background: #0f172a;
      color: #cbd5e1;
    }
    html.dark .nm-editor-property-action:hover:not(:disabled):not([aria-disabled="true"]) {
      border-color: #64748b;
      background: #1e293b;
      color: #f8fafc;
    }
    html.dark .nm-editor-property-action:focus-visible {
      border-color: #60a5fa;
      box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
    }
    html.dark .nm-editor-property-choice,
    html.dark .nm-editor-property-unit {
      color: #94a3b8;
    }
    @media (prefers-reduced-motion: reduce) {
      .nm-editor-property-control,
      .nm-editor-property-action {
        transition-duration: 1ms;
      }
    }

    /* 視覚補助用グリッド（JSで背景サイズ/位置を更新） */
    #scroll-area {
      background-repeat: repeat;
      background-position: 0 0;
      background-size: 32px 32px;
    }
    html.dark #scroll-area {
      /* 色は JS 側で上書きするが、初期表示のために薄色をセット */
      background-color: transparent;
    }
    /* アプリ全体でテキスト選択とOS標準calloutを無効化（入力系は下で許可） */
    .nm-no-select {
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none;
    }
    /* 入力系は選択を許可 */
    .nm-no-select input,
    .nm-no-select textarea {
      user-select: text;
      -webkit-user-select: text;
      -webkit-touch-callout: default;
    }
    #panel-info,
    #panel-edge,
    #panel-filter,
    #panel-relation-edge > .overflow-y-auto {
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      overflow-anchor: none;
      touch-action: pan-y;
    }
    .nm-autogrow-textarea {
      overflow-anchor: none;
      resize: none;
    }
    .nm-right-panel-viewport-probe {
      position: fixed;
      top: 0;
      left: 0;
      width: 1px;
      height: 1px;
      visibility: hidden;
      pointer-events: none;
    }
    /* Safariのflex末尾padding欠落を避け、scrollHeightへ実際に寄与させる。 */
    #right-panel [data-nm-panel-scroll-reserve]::after {
      content: "";
      display: block;
      /* 関連原稿(order: 9999)を含む全項目より後ろに余力を置く。 */
      order: 10000;
      flex: 0 0 var(--nm-right-panel-scroll-reserve);
      height: var(--nm-right-panel-scroll-reserve);
      min-height: var(--nm-right-panel-scroll-reserve);
      margin-top: calc(-1 * var(--nm-right-panel-scroll-gap, 0px));
      pointer-events: none;
    }
    .nm-writing-ios-input-proxy {
      position: fixed !important;
      top: 2px !important;
      left: 2px !important;
      z-index: 2147483647 !important;
      width: 2px !important;
      height: 2px !important;
      min-width: 0 !important;
      min-height: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      overflow: hidden !important;
      pointer-events: none !important;
      opacity: .001 !important;
      border: 0 !important;
      outline: 0 !important;
      resize: none !important;
      font-size: 16px !important;
      line-height: 1 !important;
      color: transparent !important;
      background: transparent !important;
      caret-color: transparent !important;
    }
    #right-panel textarea.nm-writing-input-preflight-armed:read-only {
      opacity: 1;
      -webkit-text-fill-color: currentColor;
    }
    @media (max-width: 639px) {
      #panel-info,
      #panel-edge,
      #panel-filter,
      #panel-relation-edge > .overflow-y-auto {
        scroll-padding-bottom: max(32px, env(safe-area-inset-bottom));
        padding-bottom: max(24px, env(safe-area-inset-bottom));
      }
      #right-panel textarea {
        font-size: 16px;
      }
    }

    /* ===========================================
       Node Search Feature
    =========================================== */
    #search-icon-btn {
      transition: all 0.2s ease;
    }
    #search-icon-btn:hover {
      background-color: rgba(255, 255, 255, 1.0);
      transform: scale(1.05);
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    html.dark #search-icon-btn {
      background-color: rgba(31, 41, 55, 0.6);
      color: #e5e7eb;
    }
    html.dark #search-icon-btn:hover {
      background-color: rgba(31, 41, 55, 0.9);
      color: #ffffff;
    }

    #node-search-modal {
      transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
    }
    #node-search-modal.hidden {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }
    #node-search-modal:not(.hidden) {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    #node-search-modal-content {
      transform-origin: top left;
      transition: transform 0.2s ease-out, opacity 0.2s ease-out;
    }
    #node-search-modal.hidden #node-search-modal-content {
      transform: scale(0.95);
      opacity: 0;
    }
    #node-search-modal:not(.hidden) #node-search-modal-content {
      transform: scale(1);
      opacity: 1;
    }

    /* 親子線パネル：iPhone 下部UIとの被り回避 */
    #panel-edge {
      padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 20px);
    }
    @media (min-width: 640px) {
      #panel-edge {
        padding-bottom: 1rem;
      }
    }

    /* Relation edge delete footer/button:
       iPhone 下部UIとの被り回避 + 実機の自動色変換差を抑制 */
    .nm-relation-edge-footer {
      flex-shrink: 0;
      border-top: 1px solid #e5e7eb;
      padding: 0.75rem 1rem calc(env(safe-area-inset-bottom, 0px) + 20px);
      background: #ffffff;
    }
    @media (min-width: 640px) {
      .nm-relation-edge-footer {
        padding-bottom: 0.75rem;
      }
    }
    html:not(.dark) .nm-relation-edge-footer {
      border-top-color: #e5e7eb;
      background: #ffffff;
    }
    html.dark .nm-relation-edge-footer {
      border-top-color: #334155;
      background: #0f172a;
    }

    .nm-danger-btn {
      width: 100%;
      border-radius: 0.375rem;
      border: 1px solid #fca5a5;
      background: #ffffff;
      color: #dc2626;
      font-size: 0.875rem;
      font-weight: 600;
      line-height: 1.25rem;
      padding: 0.5rem 0.75rem;
      transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
      appearance: none;
      -webkit-appearance: none;
      -webkit-text-fill-color: currentColor;
    }
    html:not(.dark) .nm-danger-btn {
      border-color: #fca5a5;
      background: #ffffff;
      color: #dc2626;
      -webkit-text-fill-color: #dc2626;
      color-scheme: light;
    }
    html:not(.dark) .nm-danger-btn:hover:not(:disabled) {
      background: #fef2f2;
      border-color: #f87171;
      color: #b91c1c;
      -webkit-text-fill-color: #b91c1c;
    }
    html:not(.dark) .nm-danger-btn:disabled {
      border-color: #e5e7eb;
      background: #f3f4f6;
      color: #9ca3af;
      -webkit-text-fill-color: #9ca3af;
      cursor: not-allowed;
      opacity: 1;
    }

    html.dark .nm-danger-btn {
      border-color: #7f1d1d;
      background: #0f172a;
      color: #fca5a5;
      -webkit-text-fill-color: #fca5a5;
      color-scheme: dark;
    }
    html.dark .nm-danger-btn:hover:not(:disabled) {
      border-color: #b91c1c;
      background: rgba(127, 29, 29, 0.35);
      color: #fecaca;
      -webkit-text-fill-color: #fecaca;
    }
    html.dark .nm-danger-btn:disabled {
      border-color: #334155;
      background: #1e293b;
      color: #64748b;
      -webkit-text-fill-color: #64748b;
    }

    .node.nm-writing-related-context:not(.selected):not(.search-highlight) {
      outline: 3px dashed rgba(139, 92, 246, .62);
      outline-offset: 3px;
    }
    .node.nm-writing-related-direct:not(.selected):not(.search-highlight) {
      outline: 4px solid rgba(37, 99, 235, .78);
      outline-offset: 3px;
      box-shadow: 0 0 16px rgba(37, 99, 235, .3);
    }
    .node.search-highlight {
      box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.6), 0 0 20px rgba(250, 204, 21, 0.4) !important;
      border-color: #eab308 !important;
      z-index: 100 !important;
    }
  
