*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #007bff;
    --brand: #28a745;
    --surface: #ffffff;
    --text: #1a1a2e;
    --muted: #6c757d;
    --border: #e9ecef;
    --shadow-up: 0 -6px 30px rgba(0, 0, 0, 0.12);
    --sheet-peek: 175px; /* must match SHEET_PEEK constant in app.js */
    --radius-lg: 22px;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, 'Helvetica Neue', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── フルスクリーンマップ ── */
#map {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* ── 凡例（左下に浮かぶ） ── */
.map-legend {
    position: fixed;
    bottom: calc(var(--sheet-peek) + 12px);
    left: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 14px;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    font-size: 11px;
    font-weight: 600;
    z-index: 500;
    pointer-events: none;
    display: none;
    max-width: 155px;
    color: #333;
}
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 11px;
}
.legend-item:last-child { margin-bottom: 0; }
.legend-line { width: 20px; height: 4px; margin-right: 8px; border-radius: 2px; flex-shrink: 0; }

/* ── フローティングGPSボタン ── */
.fab-container {
    position: fixed;
    right: 16px;
    bottom: calc(var(--sheet-peek) + 16px);
    z-index: 500;
    transition: opacity 0.25s, transform 0.25s;
}
.fab-container.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}
.fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s;
}
.fab:active { transform: scale(0.88); }

/* ── ボトムシート ── */
.bottom-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-up);
    /* 折りたたみ時: 上端 SHEET_PEEK px だけ表示 */
    transform: translateY(calc(100% - var(--sheet-peek)));
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-height: 88vh;
    will-change: transform;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* iPhone X+ ホームインジケーター対応 */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-sheet.expanded {
    transform: translateY(0);
}
.bottom-sheet.dragging {
    transition: none;
}

/* ── シートハンドルエリア（常時表示） ── */
.sheet-handle-area {
    flex-shrink: 0;
    padding: 10px 16px 12px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.sheet-drag-bar {
    width: 36px;
    height: 4px;
    background: #dce0e8;
    border-radius: 2px;
    margin: 0 auto 12px;
}
.sheet-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.sheet-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--brand) 0%, #20c997 100%);
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.28);
}
.sheet-title-group { flex: 1; min-width: 0; }
.sheet-sub {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
    margin-bottom: 1px;
}
.sheet-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sheet-expand-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #f1f3f5;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.sheet-expand-btn:active { background: #e2e6ea; }
.bottom-sheet.expanded .sheet-expand-btn {
    transform: rotate(180deg);
    background: #e9ecef;
}

/* ── モード切り替え ── */
.mode-switch {
    display: flex;
    background: #f1f3f5;
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
}
.mode-switch label {
    flex: 1;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mode-switch input[type="radio"] { display: none; }
.mode-switch span {
    display: block;
    padding: 9px 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    border-radius: 8px;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}
.mode-switch input[type="radio"]:checked + span {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ── シートコンテンツ（展開時にスクロール可） ── */
.sheet-content {
    flex: 1;
    min-height: 0;
    padding: 16px 16px 28px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── セクション ── */
.section { margin-bottom: 16px; }
.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── 入力グループ ── */
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group input {
    flex: 1;
    height: 48px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    min-width: 0;
    background: #f8f9fa;
    color: var(--text);
    appearance: none;
}
.input-group input:focus {
    border-color: var(--primary);
    background: white;
}
.input-group input::placeholder { color: #adb5bd; }

/* ── セレクト ── */
select {
    width: 100%;
    height: 48px;
    padding: 0 40px 0 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: #f8f9fa;
    outline: none;
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

/* ── アイコンボタン ── */
.btn-icon {
    width: 48px;
    height: 48px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: #f8f9fa;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    color: var(--text);
}
.btn-icon:active { background: #e9ecef; }

/* ── 経路生成ボタン（メインCTA） ── */
.btn-generate {
    display: block;
    width: 100%;
    height: 56px;
    background: linear-gradient(135deg, var(--brand) 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 4px;
    box-shadow: 0 4px 18px rgba(40, 167, 69, 0.38);
    letter-spacing: 0.2px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s, box-shadow 0.12s;
}
.btn-generate:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.25);
}
.btn-generate:disabled {
    background: linear-gradient(135deg, #adb5bd, #868e96);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ── フィルターチップ ── */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: #f8f9fa;
    color: #adb5bd;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.filter-chip.active {
    background: var(--text);
    color: white;
    border-color: var(--text);
}
.filter-chip:active { opacity: 0.75; }

/* ── 検索候補ドロップダウン ── */
.search-suggestions {
    margin-top: 4px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    z-index: 10;
}
.suggestion-item {
    display: flex;
    flex-direction: column;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:active { background: #f0f4ff; }
.suggestion-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}
.suggestion-addr {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 2px;
}
.suggestion-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}
.suggestion-badge.local { background: #e8f5e9; color: #28a745; }
.suggestion-badge.osm   { background: #e3f2fd; color: #1976d2; }

/* ── ヒントテキスト ── */
.hint-text {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 6px;
    padding-left: 2px;
}

/* =============================================
   POI 絵文字マーカー
   ============================================= */

/* Leaflet DivIcon デフォルトスタイルをリセット */
.poi-icon-wrapper {
    background: none !important;
    border: none !important;
}

/* 絵文字マーカー（色背景あり・ズームレスポンシブ） */
.poi-emoji-marker {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    border: 2px solid rgba(255, 255, 255, 0.88);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    /* ズームに応じてスケール（JS が zoom イベント + rAF で連続更新） */
    transform: scale(var(--poi-scale, 1));
    transform-origin: center center;
    /* transition なし：JS 連続更新が滑らかさを担うため不要 */
}
.poi-emoji-marker:hover,
.poi-emoji-marker:active {
    transform: scale(calc(var(--poi-scale, 1) * 1.25));
    transition: transform 0.12s ease;
}

/* =============================================
   POI ポップアップ
   ============================================= */

/* Leaflet ポップアップ外枠をリセット（POIポップアップのみ） */
.poi-leaflet-popup .leaflet-popup-content-wrapper {
    padding: 0 !important;
    border-radius: 18px !important;
    overflow: hidden;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22) !important;
}
.poi-leaflet-popup .leaflet-popup-content {
    margin: 0 !important;
    width: 230px !important;
    line-height: 1.4;
}
.poi-leaflet-popup .leaflet-popup-tip {
    box-shadow: none;
}
/* 閉じるボタンを白にして視認性を上げる（POIポップアップのみ） */
.poi-leaflet-popup .leaflet-popup-close-button {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 20px !important;
    top: 6px !important;
    right: 8px !important;
    font-weight: 300 !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.poi-leaflet-popup .leaflet-popup-close-button:hover {
    color: white !important;
    background: rgba(255,255,255,0.2) !important;
    border-radius: 50%;
}

/* ポップアップ本体 */
.poi-popup-header {
    padding: 18px 16px 14px;
    text-align: center;
}
.poi-popup-emoji {
    font-size: 36px;
    display: block;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}
.poi-popup-body {
    padding: 12px 14px 16px;
    background: white;
}
.poi-popup-name {
    font-size: 15px;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 10px;
    line-height: 1.35;
    font-family: -apple-system, 'Helvetica Neue', 'Hiragino Kaku Gothic ProN', sans-serif;
}
.poi-popup-tags {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.poi-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1.5px solid;
    letter-spacing: 0.2px;
    font-family: -apple-system, 'Helvetica Neue', 'Hiragino Kaku Gothic ProN', sans-serif;
}
/* カスタムタグ（グレー） */
.poi-tag-custom {
    background: #f1f3f5 !important;
    color: #495057 !important;
    border-color: #dee2e6 !important;
    font-weight: 600;
}

/* 写真ありヘッダー */
.poi-popup-photo-wrap {
    position: relative;
    height: 120px;
    overflow: hidden;
}
.poi-popup-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.poi-popup-photo-badge {
    position: absolute;
    bottom: 8px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* 営業時間 */
.poi-popup-info {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    color: #444;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 8px;
}
.poi-info-icon { font-size: 13px; flex-shrink: 0; margin-top: 3px; }
.hours-list { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.hours-row {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-size: 11.5px;
    line-height: 1.6;
}
.hours-day { color: #6c757d; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.hours-time { color: #444; }
/* 本日の行 */
.hours-today .hours-day { color: #1a1a2e; font-weight: 700; }
.hours-today .hours-time { color: #1a1a2e; font-weight: 700; }
/* 他の曜日アコーディオン */
details.hours-other { margin-top: 3px; }
details.hours-other > summary {
    list-style: none;
    font-size: 11px;
    color: #adb5bd;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 1px 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
details.hours-other > summary::after { content: ' ▾'; font-size: 10px; }
details.hours-other[open] > summary::after { content: ' ▴'; }
details.hours-other > summary::-webkit-details-marker { display: none; }
details.hours-other[open] > summary { color: #6c757d; margin-bottom: 2px; }

/* 詳細説明 */
.poi-popup-desc {
    font-size: 12px;
    color: #555;
    line-height: 1.5;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Powered by Google */
.poi-popup-powered {
    font-size: 10px;
    color: #adb5bd;
    text-align: right;
    margin-top: 6px;
}


/* =============================================
   凡例 絵文字版
   ============================================= */
.legend-emoji {
    font-size: 14px;
    margin-right: 7px;
    line-height: 1;
    display: inline-block;
    width: 18px;
    text-align: center;
}
