html, body {
    height: 100%;
    margin: 0;
}
#diagram-preview-container {
    height: 100%;
    position: relative;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none; /* Disable pull-to-refresh */ 
}

.diagram-preview {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    user-select: none;
    touch-action: none; /* タッチイベントのデフォルト動作を無効化 */
    background-color: #f0f0f0;
    background-image:
        linear-gradient(to right, #e0e0e0 1px, transparent 1px),
        linear-gradient(to bottom, #e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
}
.diagram-modal {
    background-image: linear-gradient(45deg, Gainsboro 25%, transparent 25%, transparent 75%, Gainsboro 75%),
        linear-gradient(45deg, Gainsboro 25%, transparent 25%, transparent 75%, Gainsboro 75%); /* 市松模様になるようグラデーションで単色を入れる */
    background-position: 0 0, 10px 10px;  /* 「0 0」と1マス（1色）の大きさ「30px 30px」をそれぞれ指定 */
    background-size: 20px 20px;           /* 1マス分の倍の大きさを指定「60px 60px」 */
    background-color: Silver ;               /* もう一つの単色を入れる */
    touch-action: none;
}

#modalImage {
    background-color: white;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .175) !important;
    display: flex;
    touch-action: none;
}
.diagram-preview .diagram-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
}
.diagram-preview .diagram-node {
    cursor: grab; /* デフォルトは 'grab' */
    position: absolute;
    display: flex;
    flex-direction: column;
    z-index: 1;
    transition: z-index 0.2s ease;
    border: 1px solid darkgray;
    box-sizing: border-box;
    overflow: hidden;
    min-height: 6rem; 
    min-width: 12.5rem;
    touch-action: none;
}
.diagram-preview .diagram-node.pinned {
    cursor: move !important; /* ピン留めされている場合は 'move' */
}
.diagram-preview .diagram-node.unpinned {
    cursor: grab !important; /* ピン留め解除されている場合は 'grab' */
}
.diagram-preview .diagram-node-header {
    position: relative;
    padding: 0.25rem 0.75rem; /* Bootstrapの標準的なヘッダーのパディング */
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: gray; 
    color: white;
    min-height: 2rem; 
    box-sizing: border-box; /* パディングを含んだボックスサイズにする */
}
#diagramModal .diagram-node-controls,
.diagram-preview .diagram-node-controls{
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    display: flex;
    align-items: center;
    color: black!important;
}

#diagram-preview-container .diagram-node-controls i{
    font-size: 1rem;
    opacity: 0.5;
    margin-left: 0.5rem;
    cursor: pointer; /* コントロールアイコンは 'pointer' */
}

.diagram-preview .diagram-node-title-container {
    font-size: 1rem;
    flex: 1;
    min-width: 0; /* これにより、flex item が親の幅を超えて縮小できるようになります */
    overflow: hidden;
}

#diagram-preview-container .diagram-node-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
#diagram-preview-container .modal-refresh,
#diagram-preview-container .diagram-refresh {
    margin-right: 0.3rem!important;
}

.diagram-preview .diagram-node-img-top {
    width: 100%;
    height: auto;
}
.diagram-minimap {
    position: absolute;
    bottom: 40px; /* フッターの高さに合わせて調整 */
    right: 10px;
    width: 150px;
    height: 100px;
    border: 2px solid silver;
    background-color: #f0f0f0;
    overflow: hidden;
    z-index: 800; /* フッターの z-index より高い値に設定 */
}
.diagram-minimap-content {
    width: 100%;
    height: 100%;
    position: relative;
    user-select: none;
}
#diagram-minimap-viewport {
    position: absolute;
    border: 1px solid rgba(255, 0, 0, 0.5);
    box-sizing: border-box;
}
.diagram-node-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background-color: transparent;
    cursor: nwse-resize !important; /* リサイズ時のカーソル */
    display: block;
    margin: 2px;
    margin-bottom: 4px;
}

#diagramModal .modal-header {
    padding: 0.25rem 0.75rem;
}
/* モーダル用のスタイル */
#diagramModal .modal-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none; /* 初期状態では非表示 */
    justify-content: center;
    align-items: center;
    z-index: 2000; /* キャンバスより前面に表示 */
}

#diagramModal .modal-content-custom {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#diagramModal .modal-content-custom object {
    max-width: 100%;
    max-height: 100%;
    cursor: grab;
}

#diagramModal .modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: red;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    z-index: 2100; /* モーダルよりさらに前面に表示 */
}
/* モーダルのスタイルをcanvasの範囲いっぱいに表示 */
#diagramModal .modal-custom {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8); /* 半透明の黒背景 */
    display: none;
    z-index: 10000;
    overflow: hidden;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* モーダルコンテンツのスタイル（画像を中央に配置） */
#diagramModal .modal-content-custom {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#diagramModal .modal-dialog {
    user-select: none;
}

.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: whitesmoke;
    height: 180px;
    color: #666;
    font-size: 1.2rem;
}

.minimized-nodes-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex; /* アイコンを横方向に並べるためにフレックスレイアウトを使用 */
    flex-direction: row; /* アイコンを横に並べる */
    gap: 5px; /* アイコン間のスペースを設定 */
    align-items: center; /* 各アイコンを中央に揃える */
    z-index: 900;
}

.minimized-node-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

/* CSS - 再配置ボタンのスタイル */
.rearrange-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 950;
    opacity: 0.6;
    cursor: pointer;
    background-color: rgba(240, 240, 240, 0.5); /* 少し背景色を加えて視認性を上げる */
    padding: 5px;
    border-radius: 5px;
    transition: transform 0.1s ease, background-color 0.1s ease; /* フィードバック用のトランジション */
}

.rearrange-button:hover {
    transform: scale(1.1); /* クリック感を出すために少し拡大 */
    background-color: rgba(240, 240, 240, 0.8); /* ホバー時に背景色を少し濃くする */
}
.diagram-node.selected {
    box-shadow: rgb(0 100 165 / 33%) 0px 0px 0px 4px;
}
