/* ========== ベース ========== */
:root {
    --z-map: 1;
    --z-ui: 1000;
    --z-fab: 11000;
    --z-info: 12000;
    --z-modal: 13000;
    --tkm-info-bottom-offset: 0px;

    --bg: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e5e7eb;

    --brand: #2563eb;
    --ghost: #eef2f7;
    --accent: #f59e0b;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans JP, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg);
}

body.tkm-info-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

body.tkm-info-open::before {
    content: "INFO LOCKED";
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 99999;
    background: rgba(200, 0, 0, 0.9);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 6px;
    pointer-events: none;
}

/* 地図本体 */
#tkm-map {
    width: 100%;
    height: 100vh;
    position: relative;
    z-index: var(--z-map);
}

/* 共通 */
.hidden {
    display: none !important;
}

.muted {
    color: var(--muted);
}

/* OSMナビボタン用：リンクだけど普通のボタン風に */
.nav-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ========== 上部：検索ボタン＆パネル ========== */
.top-left {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
    touch-action: manipulation;
    pointer-events: auto;
}

.btn:hover {
    filter: brightness(0.98);
}

.btn.main {
    background: var(--brand);
    color: #fff;
    border-color: transparent;
}

.btn.ghost {
    background: var(--ghost);
    border-color: var(--border);
}

.search-panel {
    margin-top: 46px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}

.search-panel-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
}

.search-panel-row input {
    flex: 1 1 auto;
    min-width: 0;
}

.search-panel input {
    width: 220px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
}

.search-panel input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* ========== カテゴリフィルタ（折りたたみ） ========== */
.filter-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.filter-search-row {
    justify-content: flex-end;
}

.filter-search-toggle {
    background: var(--ghost);
    font-size: 12px;
}

.filter-row-wrap {
    position: relative;
    max-width: 92vw;
    align-self: flex-end;
    padding: 0 18px;
}

.filter-category-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    justify-content: flex-start;
}

.filter-row-wrap::before,
.filter-row-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.filter-row-wrap::before {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.filter-row-wrap::after {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.filter-row-wrap.is-scrollable:not(.is-at-start)::before {
    opacity: 1;
}

.filter-row-wrap.is-scrollable:not(.is-at-end)::after {
    opacity: 1;
}

.filter-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    line-height: 1;
    color: #475569;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.filter-scroll-btn--left {
    left: 2px;
}

.filter-scroll-btn--right {
    right: 2px;
}

.filter-row-wrap.is-scrollable .filter-scroll-btn {
    display: inline-flex;
}

.filter-row-wrap.is-at-start .filter-scroll-btn--left,
.filter-row-wrap.is-at-end .filter-scroll-btn--right {
    opacity: 0.35;
    pointer-events: none;
}

.filter-layer-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.filter-layer-toggle {
    font-size: 12px;
    opacity: 0.85;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
    font-size: 13px;
    white-space: nowrap;
}

.filter-chip.is-off {
    opacity: 0.45;
}

.filter-chip.is-layer {
    font-size: 12px;
    padding: 5px 9px;
    border-style: dashed;
}

.filter-chip--all {
    background: var(--ghost);
    font-family: inherit;
}

.filter-chip--more {
    width: 36px;
    justify-content: center;
    font-weight: 700;
    font-family: inherit;
}

.filter-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.filter-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.filter-group-title {
    font-size: 11px;
    color: var(--muted);
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px dashed var(--border);
    background: #f8fafc;
    margin-right: 2px;
}

@media (max-width: 640px) {
    .filter-row-wrap {
        padding: 0 14px;
    }

    .filter-scroll-btn {
        width: 18px;
        height: 18px;
        font-size: 12px;
    }
}

/* ========== 右下：FAB メニュー ========== */
.fab-wrap {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: var(--z-fab);
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
}

/* メインFABボタン（HTMLの class="fab-main" と一致させる） */
.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 22px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
    touch-action: manipulation;
    pointer-events: auto;
}

.fab-menu {
    position: absolute;
    right: 0;
    bottom: 64px;
    display: none;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
}

.fab-menu.open {
    display: flex;
}

.fab-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    touch-action: manipulation;
    pointer-events: auto;
}

.fab-item .sub {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

/* ========== 下部：情報バー（idに合わせて修正） ========== */
#info-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--tkm-info-bottom-offset);
    display: none;
    /* 初期は非表示 */
    background: #fff;
    border-top: 2px solid var(--border);
    box-shadow: 0 -12px 32px rgba(0, 0, 0, .15);
    z-index: var(--z-info);
    padding: 12px 14px;
    height: 55vh;
    max-height: 55vh;
    overflow: hidden;
    pointer-events: auto;
}

#info-bar.active {
    display: flex;
    flex-direction: column;
}

#info-content h3 {
    margin: 6px 0 8px;
    font-size: 16px;
}

#info-content {
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    flex: 1 1 auto;
    height: auto;
    padding-top: 36px;
    padding-bottom: 56px;
}

.info-img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin: 6px 0 8px;
}

.desc {
    line-height: 1.6;
}

.detail {
    color: #334155;
    font-size: 13px;
    margin-top: 6px;
}

.info-ops {
    margin-top: 8px;
}

.info-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 8px 0;
    z-index: 2;
}

/* ========== スタンプ帳（モーダル） ========== */
/* 画面全体のオーバーレイ（#stampModal） */
#stampModal {
    position: fixed;
    inset: 0;
    /* top:0; right:0; bottom:0; left:0; と同じ */
    display: none;
    /* JSで display: flex にされる */
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, .35);
    z-index: var(--z-modal);
    pointer-events: auto;
}

/* JS側で .open クラスを付けるので保険で */
#stampModal.open {
    display: flex;
}

/* 中の白いカード（.modal-content） */
#stampModal .modal-content {
    width: min(92vw, 780px);
    max-height: 80vh;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
    padding: 14px;
    pointer-events: auto;
}

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

.modal-head .title {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding-top: 4px;
}

/* スタンプ帳カード */
.rally-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    margin: 12px 0;
}

.rally-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.rally-title {
    font-weight: 600;
}

.rally-meta {
    font-size: 12px;
    color: var(--muted);
}

.rally-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
}

.progress {
    margin-top: 6px;
    font-size: 13px;
    color: #334155;
}

.spot-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.spot-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px dashed var(--border);
    padding: 8px 0;
}

.spot-name {
    font-size: 14px;
}

.spot-ops {
    display: flex;
    align-items: center;
    gap: 8px;
}

.done-badge {
    font-size: 12px;
    color: #059669;
}

/* 進捗タグの見た目 */
.progress {
    font-weight: bold;
    color: #333;
    background: #fff8e1;
    border-radius: 6px;
    padding: 8px 10px;
}

/* ========== ラベル（近距離ズーム） ========== */
/* JSのクラス名に合わせて .spot-label を定義 */
.spot-label {
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
    transform: translateY(-10px);
}

/* ========== アイコン＋ラベル一体表示用（高ズーム） ========== */

/* Leaflet の divIcon ラッパー */
.spot-with-label-wrap {
    width: var(--tkm-icon-wrap-w, 84px);
    height: var(--tkm-icon-wrap-h, 96px);
}

/* 中身のレイアウト：縦にアイコン＋名前 */
.spot-with-label {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.anchor-origin {
    position: absolute;
    left: var(--tkm-icon-anchor-x, 42px);
    top: var(--tkm-icon-anchor-y, 21px);
    width: 0;
    height: 0;
}

.anchor-origin .spot-icon-box {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
}

/* 画像アイコン：中域と同じくらいのサイズ感に固定 */
.spot-icon-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

/* 画像がないときの丸いダミー */
.spot-icon-fallback {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #dd161600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

/* 高ズーム時にアイコンの「下」に出る名前ラベル */
/* Recent comment highlight (ring + gentle pulse) */
.leaflet-marker-icon.tkm-marker--recent-comment {
}

.leaflet-marker-icon.tkm-marker--recent-comment::before,
.leaflet-marker-icon.tkm-marker--recent-comment::after {
    content: none;
    animation: none;
}

.leaflet-marker-icon.tkm-marker--recent-comment::before {
}

.leaflet-marker-icon.tkm-marker--recent-comment::after {
}

@keyframes tkmRecentCommentPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.85);
        opacity: 0.65;
    }

    70% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .leaflet-marker-icon.tkm-marker--recent-comment::after {
        animation: none;
    }
}

.spot-label-under {
    margin-top: 0;
    font-size: 11px;
    padding: 1px 4px;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--border);
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}

.anchor-origin .spot-label-under {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(calc(-50% + var(--label-x, 0px)),
            calc(-50% + var(--label-y, 0px)));
}

/* ========== Leaflet UI の軽い調整 ========== */
.leaflet-control-zoom a {
    border-radius: 8px !important;
}

.leaflet-control-zoom {
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15) !important;
}

/* 地図は通常どおり操作可能 */
.leaflet-container {
    touch-action: pan-x pan-y;
    pointer-events: auto;
}

/* ========== レスポンシブ ========== */
@media (max-width: 640px) {
    .search-panel input {
        width: 160px;
    }

    #stampModal .modal-content {
        width: 94vw;
    }
}

/* ========== 保険：スクロール時の「残像」対策 ========== */
.fab-wrap,
.top-left,
#info-bar,
#stampModal,
#stampModal .modal-content {
    will-change: transform;
}

/* メインFABボタン（テキスト入りの長方形） */
.fab-main {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    padding: 10px 16px;
    width: auto;
    min-width: 0;
    height: 44px;

    border-radius: 9999px;
    /* 角丸の長方形（ピル型） */
    background: var(--brand);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
    touch-action: manipulation;
    pointer-events: auto;
    white-space: nowrap;
}

.fab-main-label {
    font-size: 13px;
    white-space: nowrap;
}

/* ナビ距離バッジ：検索ウィンドウと被らない位置に調整 */
#tkm-route-badge {
    top: 140px !important;
}

/* ========== ラリーモーダル ========== */
.rally-modal {
    position: fixed;
    inset: 0;
    display: none;
    /* JSで .open を付けて表示 */
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, .35);
    z-index: calc(var(--z-modal) - 1);
    /* ★ スタンプ帳より一段下にする */
    pointer-events: auto;
}


.rally-modal.open {
    display: flex;
}

.rally-modal-content {
    width: min(92vw, 720px);
    max-height: 80vh;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
    padding: 14px 16px;
    pointer-events: auto;
}

.rally-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
}

.rally-modal-desc {
    font-size: 13px;
    margin: 0 0 10px;
}

.rally-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

/* 各ラリーの行 */
.rally-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    display: block;
    align-items: flex-start;
    gap: 8px;
}

.rally-item input[type="checkbox"] {
    margin-top: 4px;
}

.rally-item-main {
    flex: 1;
}

.rally-item-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.rally-item-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
}

.rally-item-desc {
    font-size: 12px;
    color: #334155;
}

.rally-modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

/* 開催終了ラリー用（期間外） */
.rally-item.disabled {
    opacity: 0.45;
}

/* スマホ調整 */
@media (max-width: 640px) {
    .rally-modal-content {
        width: 94vw;
    }
}

/* ========== ラリーモーダル内：スタンプ状況パネル ========== */
.rally-stamp-status {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.rally-stamp-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.rally-stamp-group {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.rally-stamp-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.rally-stamp-group-title {
    font-size: 13px;
    font-weight: 600;
}

.rally-stamp-progress {
    font-size: 12px;
    color: #334155;
}

.rally-stamp-spots {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
}

.rally-stamp-spot-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rally-stamp-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #e5e7eb;
    flex-shrink: 0;
}

.rally-stamp-dot.done {
    background: #22c55e;
    /* 押印済み */
}

.rally-stamp-spot-name {
    flex: 1;
}

.rally-stamp-spot-state {
    font-size: 11px;
    color: var(--muted);
}

/* アイコン画像（必ず枠内の中心に収まる） */
.spot-icon-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

/* 画像アイコンのボックス（中心基準） */
.spot-icon-box {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ラベル（施設名） */
.spot-label-under {
    margin-top: 4px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, .9);
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}

/* Override list label styles for high-zoom marker labels */
.spot-with-label-wrap .spot-label-under {
    margin-top: 0;
    padding: 1px 4px;
    font-size: 11px;
}

/* Debug: crosshair at spot latlng */
.anchor-crosshair {
    position: relative;
    width: 16px;
    height: 16px;
}

.anchor-crosshair::before,
.anchor-crosshair::after {
    content: "";
    position: absolute;
    background: #ef4444;
}

.anchor-crosshair::before {
    width: 1px;
    height: 100%;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

.anchor-crosshair::after {
    height: 1px;
    width: 100%;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.anchor-crosshair--tip::before,
.anchor-crosshair--tip::after {
    background: #2563eb;
}

.anchor-crosshair-label {
    position: absolute;
    top: -14px;
    left: 10px;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.15);
    color: #1e293b;
    white-space: nowrap;
    pointer-events: none;
}

/* Debug: icon anchor dot inside high-zoom divIcon */
.anchor-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    border: 1px solid #fff;
    left: var(--tkm-icon-anchor-x, 42px);
    top: var(--tkm-icon-anchor-y, 21px);
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    z-index: 5;
    pointer-events: none;
}

/* Debug: anchor-origin dot inside high-zoom divIcon */
.anchor-origin-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    border: 1px solid #fff;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    z-index: 5;
    pointer-events: none;
}

/* Debug: label origin dot (anchor + label offsets) */
.label-origin-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    border: 1px solid #fff;
    left: 0;
    top: 0;
    transform: translate(calc(-50% + var(--label-x, 0px)),
            calc(-50% + var(--label-y, 0px)));
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    z-index: 5;
    pointer-events: none;
}

/* ========== 耳寄り情報（コメント機能） ========== */

.comments-block {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #e5e7eb;
    font-size: 13px;
}

/* <hr> はデザイン的には使わないので非表示 */
.comments-sep {
    display: none;
}

/* タイトル行（「本日の施設耳寄り情報」） */
.comments-title {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 6px;
}

.comments-title::before {
    content: "💬";
    font-size: 14px;
}

/* --- 上部：本日のコメント（ハイライト） --- */
/* 今日のコメントを上に並べて、3件分くらいの高さでスクロール */

.comments-highlight {
    max-height: 180px;
    /* 高さを変えると「見える件数」が変わる */
    overflow-y: auto;
    margin-bottom: 6px;
}

.comments-highlight .comment-item-compact {
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.5;
}

/* --- 「＋ 詳細＆コメントする」ボタン --- */
/* ここを押すと下の詳細ブロックが開閉 */

.comment-toggle-btn {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f9fafb;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #374151;
    text-align: center;
    margin-bottom: 6px;
}

.comment-toggle-btn:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}

/* 折りたたまれる部分（全コメント＋フォームのラッパ） */
.comment-detail-wrap {
    margin-top: 2px;
}

/* --- 詳細側：コメント一覧（折りたたみ内） --- */

.comments-list-full {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.comments-list-full .comment-item {
    background: #f9fafb;
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    border: 1px solid #e5e7eb;
}

/* 共通のメタ情報・本文・状態表示 */

.comment-meta {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.comment-name {
    font-weight: 600;
}

.comment-body {
    font-size: 12px;
    color: #111827;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Compact highlight: clamp body to 2 lines */
.comments-highlight .comment-body {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#tkm-layer-toggle {
    position: fixed;
    right: 16px;
    top: 120px;
    z-index: 2147483000;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    cursor: pointer;
}

#tkm-layer-panel {
    position: fixed;
    right: 16px;
    top: 168px;
    min-width: 140px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 1210;
}

#tkm-layer-panel.is-open {
    display: block;
}

#tkm-layer-panel .layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin: 4px 0;
    cursor: pointer;
}

.comments-empty,
.comments-loading,
.comments-error {
    font-size: 11px;
    color: #6b7280;
    padding: 4px 0;
}

/* --- コメント入力フォーム --- */

.comment-form {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* （必要なら JS 側で is-collapsed を付けて非表示にもできるよう残しておく） */
.comment-form.is-collapsed {
    display: none;
}

#comment-message {
    width: 100%;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    resize: vertical;
    min-height: 54px;
    box-sizing: border-box;
    background: #f3f4f6;
}

#comment-message:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
    background: #ffffff;
}

#comment-name {
    width: 100%;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px dashed #e5e7eb;
    box-sizing: border-box;
    background: #f9fafb;
}

#comment-name:focus {
    outline: none;
    border-color: #9ca3af;
    background: #ffffff;
}

.comment-form .btn {
    align-self: flex-end;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
}

/* 詳細表示中（.is-open が付いたら）ハイライト3件を非表示にする */
.comments-block.is-open .comments-highlight {
    display: none;
}

/* ========== 情報バー：タブUI ========== */

.info-head h3 {
    margin: 4px 0 6px;
    font-size: 16px;
    font-weight: 600;
}

.info-head {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    padding: 6px 0;
}

#info-bar>#info-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 20000;
    background: #fff;
}

/* タブのバー */
.info-tabs {
    display: flex;
    gap: 6px;
    margin: 6px 0 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

/* 各タブボタン */
.info-tab {
    border: none;
    background: transparent;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--muted);
    border-radius: 999px 999px 0 0;
    cursor: pointer;
    white-space: nowrap;
}

.info-tab.active {
    color: #111827;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-bottom-color: transparent;
}

/* パネル本体 */
.info-tab-panels {
    margin-top: 4px;
}

.info-tab-panel {
    display: none;
}

.info-tab-panel.active {
    display: block;
}

/* ========== メニューカード ========== */



.menu-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.menu-card-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
}

.menu-card-desc {
    font-size: 13px;
    line-height: 1.5;
}

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

/* 基本情報ブロックを少し整える */
.detail-basic {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.detail-basic a {
    color: var(--brand);
    text-decoration: none;
}

.detail-basic a:hover {
    text-decoration: underline;
}

/* ======================
   メニューカード：横スライド
   ====================== */

.menu-slider {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin: 6px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.menu-slider::-webkit-scrollbar {
    display: none;
    /* スマホでスッキリ */
}

/* 各カードをスナップさせる */
.menu-card {
    scroll-snap-align: start;
    flex: 0 0 82%;
    /* スマホでほぼ画面幅いっぱい */
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .08);
}

/* カード内レイアウトは既存のまま */
.menu-card-img {
    width: 100%;
    height: 160px;
    border-radius: 10px;
    object-fit: cover;
}

.menu-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.menu-card-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.menu-card-desc {
    font-size: 13px;
    line-height: 1.45;
}

/* 検索ドロップダウン（中身の基本） */
.search-panel {
    position: relative;
    /* dropdownの基準にする（固定は別クラスで上書き） */
}

#tkm-search-wrap .search-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 6px 8px;
    width: 100%;
    box-sizing: border-box;
}

#tkm-search-wrap .search-title {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    letter-spacing: 0.02em;
}

#tkm-search-wrap .search-panel-header .search-close-btn {
    position: relative;
    top: auto;
    right: auto;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: #111;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: auto;
}

#tkm-search-wrap .search-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: #111;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    z-index: 2150;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    overflow: hidden;
    z-index: 2100;
}

/* 検索ドロップダウン：候補が多い時はスクロール */
#tkm-search-wrap .search-dropdown {
    max-height: min(52vh, 360px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 候補ボタン（search.js が生成してる） */
#tkm-search-wrap .search-dd-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    cursor: pointer;
}

#tkm-search-wrap .search-dd-item+.search-dd-item {
    border-top: 1px solid var(--border);
}

#tkm-search-wrap .search-dd-item:hover {
    background: #f8fafc;
}

#tkm-search-wrap .search-dd-item .t {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
}

#tkm-search-wrap .search-dd-item .s {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
}

/* “候補がありません” の表示 */
#tkm-search-wrap .search-dd-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--muted);
}

/* ===== ここが重要：検索パネルの固定配置は “専用クラス” で ===== */
#tkm-search-wrap.is-follow-category {
    position: fixed;
    left: auto;
    right: 10px;
    max-width: min(92vw, 360px);
    z-index: 2100;
}


/* ドロップダウンは常に下に開く */
#tkm-search-wrap.is-follow-category .search-dropdown {
    top: calc(100% + 6px);
    bottom: auto;
    z-index: 2200;
}

/* 検索バーをカテゴリ追従させるときは、固定マージンを無効化 */
#tkm-search-wrap.is-follow-category.search-panel {
    margin-top: 0 !important;
}

/* 幅 */
@media (max-width: 640px) {
    #tkm-search-wrap input {
        width: 160px;
    }
}

.comment-hide-btn {
    margin-left: 8px;
    padding: 4px 8px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
}

.comment-hide-btn:hover {
    background: #f8fafc;
}

/* スタンプ帳：2段で横に伸びる（□□□□□□ / □□□□□□） */
.stamp-grid {
    display: grid;
    grid-auto-flow: column;
    /* 左→右に詰める */
    grid-template-rows: repeat(2, 1fr);
    /* 2段固定 */
    gap: 10px;
}

.stamp-cell {
    width: 56px;
    height: 56px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.stamp-cell.is-empty {
    background: #f7f7f7;
}

.stamp-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 640px) {
    .rally-book-head {
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        gap: 4px !important;
    }
}

/* Hide debug/status badges on production URLs (no debug=1) */
html:not(.tkm-debug) #alive-static,
html:not(.tkm-debug) #tkm-mapjs-status {
    display: none !important;
}

/* Keep visible on debug URLs */
html.tkm-debug #alive-static,
html.tkm-debug #tkm-mapjs-status {
    display: block !important;
}

/* Location prompt banner (opt-in) */
#tkm-geo-prompt {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 2147483000;
    font-size: 13px;
}

#tkm-geo-prompt .tkm-geo-actions {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    justify-content: center;
}

#tkm-geo-prompt button {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 8px;
    cursor: pointer;
}

#tkm-info-overlay {
    --tkm-actions-bg: #ffffff;
    --tkm-actions-border: #e5e7eb;
    --tkm-actions-btn-bg: #f7f8fa;
    --tkm-actions-btn-border: #d0d5dd;
    --tkm-actions-btn-text: #111827;
}

#tkm-info-actions {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid var(--tkm-actions-border);
    background: var(--tkm-actions-bg);
    justify-content: flex-end;
}

#tkm-info-actions button {
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--tkm-actions-btn-border);
    border-radius: 10px;
    background: var(--tkm-actions-btn-bg);
    color: var(--tkm-actions-btn-text);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

#tkm-info-actions button:active {
    filter: brightness(0.95);
}

#tkm-info-actions #btn-nav {
    background: #1f4fbf;
    border-color: #1f4fbf;
    color: #ffffff;
}

#tkm-info-actions #btn-nav:active {
    filter: brightness(0.92);
}

#tkm-info-actions #btn-stamp {
    border-color: #c7cdd4;
    background: #eef2f6;
}

#tkm-info-close {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

#tkm-info-close:active {
    filter: brightness(0.95);
}

/* recent comment bubble */
.leaflet-marker-icon.tkm-marker--recent-bubble-anchor {
    position: relative;
}

.tkm-recent-comment-bubble {
    position: absolute;
    top: -10px;
    right: -10px;
    padding: 3px 6px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.25);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    transform: translateZ(0);
    animation: tkmRecentBubbleFloat 1.6s ease-in-out infinite;
}

.tkm-recent-comment-bubble::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 10px;
    width: 8px;
    height: 8px;
    background: #fff;
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
    transform: rotate(45deg);
}

@keyframes tkmRecentBubbleFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}
