/* モバイル以外では非表示 */
#toc-floating-btn,
#toc-popup-overlay {
    display: none;
}

@media screen and (max-width: 768px) {
    /* フローティングボタン */
    #toc-floating-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 11%;
        right: 3%;
        width: 44px;
        height: 44px;
        background-color: #fff;
        border: 1px solid #ddd;
        border-radius: 8px; /* 角丸 */
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 9990;
        cursor: pointer;
        color: #333;
        transition: opacity 0.3s;
        padding: 3px; /* 内側の余白を少し縮小 */
    }
    
    #toc-floating-btn .toc-icon {
        width: 20px; /* 45pxに収めるため少し縮小 */
        height: 20px;
        fill: currentColor; /* 文字色に合わせる */
        margin-bottom: 2px; /* 間隔も縮小 */
    }
    
    #toc-floating-btn .toc-label {
        font-size: 9px; /* フォントサイズも微調整 */
        line-height: 1;
        font-weight: bold;
    }

    #toc-floating-btn:hover {
        opacity: 0.9;
    }

    /* ポップアップオーバーレイ */
    #toc-popup-overlay {
        display: none; /* 初期状態はJSで制御 */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.5);
        z-index: 9999;
        justify-content: center;
        align-items: center;
    }
    
    /* bodyがスクロールしないように */
    body.toc-popup-open {
        overflow: hidden;
    }

    /* ポップアップコンテンツ */
    #toc-popup-content {
        position: absolute; /* 中央配置のため */
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 400px;
        max-height: 80vh;
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        display: flex;
        flex-direction: column;
    }

    /* ポップアップヘッダー */
    .toc-popup-header {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 15px;
        border-bottom: 1px solid #eee;
        position: relative;
        font-weight: bold;
        font-size: 16px;
    }
    
    /* 目次アイコン（疑似要素で追加する場合） */
    .toc-popup-header::before {
        content: "\f228"; /* dashicons-list-view */
        font-family: "dashicons";
        margin-right: 5px;
        font-weight: normal;
        color: #666;
    }

    /* 閉じるボタン */
    #toc-popup-close {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
        color: #999;
        padding: 0 10px;
    }
    
    /* ポップアップボディ（スクロールエリア） */
    .toc-popup-body {
        padding: 15px 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Arkhe Block TOC のスタイル調整 (ポップアップ内) */
    .toc-popup-body .ark-block-toc__list {
        margin: 0;
        padding: 0;
        list-style: none; /* Arkhe側で設定されているかもしれないが念のため */
    }

    .toc-popup-body .ark-block-toc__list li {
        margin-bottom: 8px;
    }
    
    .toc-popup-body .ark-block-toc__list li a {
        text-decoration: none;
        color: #333;
        font-size: 14px;
        display: block;
        line-height: 1.5;
    }

    /* 階層インデント */
    .toc-popup-body .ark-block-toc__list .ark-block-toc__list {
        margin-top: 8px;
        margin-left: 15px;
        padding-left: 10px;
        border-left: 1px solid #eee;
    }
    
    /* 参考画像のような番号付きスタイルが必要な場合はArkheの設定に依存するが、
       強制的にスタイルを充てるならここに追記 */
}
