/* ===========================================
   UI/UX Styles - PC & Base
   =========================================== */
#ui-layer br, #cluster-legend br, #side-panel br { display: none !important; }

.network-breakout {
    position: relative !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    left: 0 !important;
    background: #fff;
    overflow: visible !important;
    font-family: sans-serif;
    z-index: 100;
}

#cy {
    width: 100%;
    height: 100vh;
    background: #ffffff;
    border: 1px solid #eee;
}

#ui-layer {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    width: 280px;
}

/* 検索エリア：横並び調整 */
.search-container {
    position: relative;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 10px;
}

.search-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

#node-search {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 25px 6px 8px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

#search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #ccc;
    display: none;
    font-size: 18px;
    font-weight: bold;
}

/* 戻るボタン（キャンセル色） */
.back-btn {
    flex-shrink: 0;
    background: #e0e0e0;
    color: #666;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.2s;
}
.back-btn:hover { background: #d0d0d0; }

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 110;
}

.search-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 13px; }
.search-item:hover { background: #f0f0f0; }

/* モードコントロールエリア：1列に集約 */
.mode-controls {
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 6px 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 105;
}

.control-btn {
    width: 24px;
    height: 24px;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 50%;
    object-fit: contain;
}
.control-btn.off { filter: grayscale(1) opacity(0.4); }

.search-mode-switch {
    display: flex;
    background: #eee;
    border-radius: 14px;
    padding: 2px;
    cursor: pointer;
    flex: 1;
}
.search-mode-switch span {
    flex: 1;
    text-align: center;
    padding: 3px 0;
    font-size: 11px;
    border-radius: 12px;
    transition: 0.2s;
    color: #666;
    white-space: nowrap;
}
.search-mode-switch span.active {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: #333;
    font-weight: bold;
}

/* リストボタン */
.list-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    color: #555;
    transition: 0.2s;
}
.list-btn.active {
    background: #009688;
    color: #fff;
    border-color: #00796b;
}

/* 料理候補リストの調整（コンパクト化） */
#recipe-list-display {
    display: none;
    max-height: 300px;
    overflow-y: auto;
    margin: 8px 0;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #eee;
    font-size: 12px;
}
.recipe-list-item { padding: 6px 10px; border-bottom: 1px solid #eee; cursor: pointer; }
.recipe-list-item:hover { background-color: #e0f2f1 !important; }

#active-tags-container { margin: 4px 0; padding: 0 5px; }

/* 勢力図 */
#cluster-legend {
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 8px;
    overflow: hidden;
}
.legend-header {
    padding: 10px 12px;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
#legend-list { max-height: 0; overflow-y: auto; transition: max-height 0.3s ease; }
#cluster-legend.open #legend-list { max-height: 300px; }
.legend-item { display: flex; align-items: center; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.color-box { width: 12px; height: 12px; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }

/* Side Panel */
#side-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 15px rgba(0,0,0,0.1);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#side-panel.open { transform: translateX(0); }

@media screen and (max-width: 768px) {
    #ui-layer {
        top: 10px;
        left: 10px;
        width: 300px;
        max-width: calc(100% - 20px);
    }

    /* 修正点：モバイルで勢力図を非表示 */
    #cluster-legend { display: none !important; }

    #side-panel { top: auto; bottom: 0; width: 100%; height: 90vh; transform: translateY(100%); border-radius: 20px 20px 0 0; }
    #side-panel.open { transform: translateY(0); }
}

/* --- サイドパネル内部のデザイン（復元分） --- */
.gem_close_btn {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    z-index: 11;
}

.gem_main_img {
    width: 100%;
    max-height: 380px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 10px 0;
}

.gem_thumb_container {
    display: flex;
    gap: 5px;
    padding: 0 15px;
    margin-bottom: 10px;
}

.gem_thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
}

.gem_thumb.active { border-color: #4A90E2; }

.gem_tag_link, .gem_panel_link {
    display: inline-block;
    padding: 4px 10px;
    background: #f0f0f0;
    border-radius: 15px;
    font-size: 11px;
    color: #555;
    text-decoration: none;
    margin: 0 4px 4px 0;
}

.gem_work_btn {
    display: block;
    background: #FF69B4;
    color: #fff;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    margin: 15px;
}

/* モバイル専用：ハンドルと半開き状態の制御（復元分） */
@media screen and (max-width: 768px) {
    #side-panel.is-half { transform: translateY(60%); }
    .gem_handle {
        width: 40px;
        height: 5px;
        background: #ddd;
        border-radius: 3px;
        margin: 10px auto;
        cursor: pointer;
    }
}

/* style.css の末尾に追加、または該当箇所を上書き */

.gem_main_img {
    width: 100%;
    max-height: 250px; /* 高さを抑える */
    height: auto;
    object-fit: contain;
    display: block;
    margin: 8px 0;
}

.gem_thumb {
    width: 36px; /* 少し小さく */
    height: 36px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
}

.gem_tag_link, .gem_panel_link {
    font-size: 10px !important; /* 文字を極小化 */
    padding: 2px 5px !important;
    margin-bottom: 2px !important;
}

.gem_work_btn {
    padding: 10px !important;
    font-size: 12px !important;
    margin: 10px !important;
}

/* モバイル版ボトムシートのハンドル調整 */
@media screen and (max-width: 768px) {
    .gem_handle {
        width: 40px;
        height: 4px; /* より細く */
        background: #ccc;
        border-radius: 2px;
        margin: 5px auto; /* 余白を詰める */
    }

    #side-panel {
        height: 85vh; /* 少し高さを抑えて背後を見せやすく */
    }
}

/* 「除外設定」の文字を小さく、ボタンらしく見せる設定 */
.exclude-trigger {
    display: inline-block;
    font-size: 11px;      /* 文字をかなり小さく */
    color: #888;          /* 目立ちすぎない色 */
    text-decoration: underline; /* リンク風にする */
    cursor: pointer;      /* iPhoneで反応させるために必須 */
    padding: 5px;
    margin-bottom: 5px;
    -webkit-tap-highlight-color: transparent; /* タップ時の青枠消去 */
}

/* スマホではさらに微調整 */
@media screen and (max-width: 768px) {
    .exclude-trigger {
        font-size: 10px;  /* スマホではさらに小さく */
    }
}
