:root {
    /* Color Palette - Premium & Modern */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --error: #ef4444;

    /* Gradients */
    --grad-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --grad-surface: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(248, 250, 252, 1) 100%);

    /* Elevations */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-premium: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.05);

    /* Transitions */
    --transit: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --border-radius: 16px;
    --header-height: calc(62px + env(safe-area-inset-top, 0px));
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    overscroll-behavior: none;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    overscroll-behavior: none;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Components */
.card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transit);
    border: 1px solid var(--border);
}

.card:active {
    transform: scale(0.98);
}

.card.detailed-view {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    width: 100% !important;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 顧客枠、メモ枠などの共通スタイル（角丸ボックス化） */
.card.detailed-view .site-box,
.card.detailed-view .notes-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 0;
    width: 100%;
    box-shadow: var(--shadow-sm);
}

.card.detailed-view .site-box.main {
    border-left: 4px solid var(--error) !important;
    background-color: #fee2e2 !important;
}

.card.detailed-view .site-box.secondary {
    border-left: 4px solid var(--primary-light) !important;
    background-color: #e0e7ff !important;
}

/* 画像リストの角丸調整 */
.card.detailed-view .image-vertical-list {
    margin: 0.5rem 0 0 0 !important;
    width: 100%;
}

.card.detailed-view .list-image-item {
    border-radius: 12px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    width: 100%;
    height: auto;
}

/* メモ欄の背景色調整 */
.card.detailed-view .notes-area {
    background: #fffbeb !important;
    border: 1px solid #fef3c7 !important;
}

/* 画像追加ボタンの背景色（薄いグレー） */
.card.detailed-view .add-image-btn {
    background: #f1f5f9 !important;
    border: 1px dashed var(--border) !important;
    color: var(--text-muted) !important;
    width: 100% !important;
    padding: 0.6rem 1.2rem !important;
    border-radius: 8px !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
}

.card.detailed-view .action-bar {
    border-top: none !important;
    padding-top: 0.5rem;
    padding-right: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    /* モバイル向けに少し拡大 */
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transit);
    gap: 0.5rem;
    min-height: 48px;
    /* タッチ領域の確保 */
}

.btn-primary {
    background: var(--grad-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    box-shadow: var(--shadow-lg);
    opacity: 0.9;
}

.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--grad-primary);
    color: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Header */
header {
    height: var(--header-height);
    background: var(--surface);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

/* Sticky Controls Container */
.sticky-controls {
    position: sticky;
    top: var(--header-height);
    z-index: 40;
    background-color: var(--background);
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0.5rem 1.5rem 0;
}

.stat-card {
    background: var(--grad-primary);
    color: white;
    padding: 1.25rem;
    border-radius: var(--border-radius);
}

/* Customer List */
.customer-list {
    padding: 0 1.5rem 5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.customer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
}

.customer-info h3 {
    font-size: 1rem;
}

/* Modal / Overlay */
.overlay {
    position: absolute;
    /* 編集画面などの通常のオーバーレイ */
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    background: var(--background);
    display: none;
    z-index: 200;
}

.overlay-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    /* 半透明背景 */
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.no-scroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}

.modal {
    background: var(--background);
    /* ページの背景色と同じ */
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    /* 全画面なので丸角なし */
    padding: 0;
    /* paddingは内部要素で制御 */
    overflow-y: auto;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-overflow-scrolling: touch;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

#guide-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: var(--primary) transparent transparent;
}

/* Search Bar */
.search-container {
    padding: 5px 1.5rem 1rem;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.search-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 1rem;
}

.search-back-btn {
    position: absolute;
    right: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transit);
}

.search-back-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.search-back-btn:active {
    transform: scale(0.9);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Form Styles */
.form-section {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-section-header {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section.main {
    border-left: 4px solid var(--error);
    background-color: #fee2e2;
}

.form-section.secondary {
    border-left: 4px solid var(--primary-light);
    background-color: #e0e7ff;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 16px;
    /* iOS でのオートズーム防止 */
    transition: var(--transit);
}

/* Image Grid and Preview Styles */
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: none;
    /* ブラウザのデフォルト動作を抑制 */
}

/* Older browser fallback for aspect-ratio: 1 */
.preview-item::before {
    content: "";
    display: block;
    padding-top: 100%;
}

.preview-item.dragging {
    opacity: 0.7;
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    animation: wiggle 0.3s infinite;
}

@keyframes wiggle {
    0% {
        transform: scale(1.1) rotate(0deg);
    }

    25% {
        transform: scale(1.1) rotate(-2deg);
    }

    75% {
        transform: scale(1.1) rotate(2deg);
    }

    100% {
        transform: scale(1.1) rotate(0deg);
    }
}

.preview-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    z-index: 10;
}

/* Image List Styles */
.image-vertical-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-image-item {
    width: 100%;
    border-radius: 8px;
    height: auto;
}

/* Search Result Layout Improvements */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 0.9375rem;
}

.info-content {
    flex: 1;
    color: var(--text-main);
}

.info-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.125rem;
}

.site-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.site-box.main {
    border-left: 4px solid var(--error);
    background-color: #fee2e2 !important;
}

.site-box.secondary {
    border-left: 4px solid var(--primary-light);
    background-color: #e0e7ff !important;
}

.notes-area {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 0.5rem;
}

.card-header {
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}



@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* QR Modal Specific */
#qr-modal-overlay {
    align-items: center !important;
    /* 強制的に中央配置 */
    justify-content: center !important;
}

.qr-modal {
    max-width: 340px;
    width: 90%;
    margin: 0 auto;
    text-align: center;
    border-radius: 20px;
    /* 四隅を丸く */
    transform: none;
    /* ボトムシートのアニメーションをキャンセル */
    animation: fadeIn 0.3s ease;
}

#qrcode img {
    margin: 0 auto;
    border: 8px solid white;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Animations and Helpers */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

#server-status-indicator {
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

/* Edit View (Page Mode) */
#edit-view {
    width: 100%;
    min-height: 100vh;
    background: var(--background);
    color: var(--text-main);
}

/* Image List Styles */
.image-vertical-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-image-item {
    width: 100%;
    border-radius: 8px;
    height: auto;
}

/* Search Result Layout Improvements */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 0.9375rem;
}

.info-content {
    flex: 1;
    color: var(--text-main);
}

.info-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.125rem;
}

.site-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.site-box.main {
    border-left: 4px solid var(--error);
    background-color: #fee2e2 !important;
}

.site-box.secondary {
    border-left: 4px solid var(--primary-light);
    background-color: #e0e7ff !important;
}

.notes-area {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 0.5rem;
}

.card-header {
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}



@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* QR Modal Specific */
#qr-modal-overlay {
    align-items: center !important;
    /* 強制的に中央配置 */
    justify-content: center !important;
}

.qr-modal {
    max-width: 340px;
    width: 90%;
    margin: 0 auto;
    text-align: center;
    border-radius: 20px;
    /* 四隅を丸く */
    transform: none;
    /* ボトムシートのアニメーションをキャンセル */
    animation: fadeIn 0.3s ease;
}

#qrcode img {
    margin: 0 auto;
    border: 8px solid white;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Animations and Helpers */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

#server-status-indicator {
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

/* Edit View (Page Mode) */
#edit-view {
    width: 100%;
    min-height: 100vh;
    background: var(--background);
    animation: fadeIn 0.3s ease;
}

#edit-view header {
    justify-content: space-between;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.sync-pulse {
    animation: pulse 1.5s infinite ease-in-out;
}

/* ================================ */
/* 地図ビュー (Map View) スタイル   */
/* ================================ */

#map-view {
    position: fixed;
    inset: 0;
    background: var(--background);
    z-index: 500;
    animation: fadeIn 0.3s ease;
}

#map-container {
    width: 100%;
    /* CSSフォールバック: JSで動的に上書きされるが、初期表示用に設定 */
    height: calc(100vh - var(--header-height) - 44px);
    height: calc(100dvh - var(--header-height) - 44px); /* dvhサポートブラウザ用 */
    min-height: 300px; /* 最低限の高さを保証 */
    margin-top: var(--header-height);
    touch-action: manipulation; /* タッチ操作を最適化 */
}



#map-adjust-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-top: 1px solid var(--border);
    z-index: 1001;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.map-adjust-info {
    font-size: 0.8rem;
    color: var(--text-main);
    font-weight: 600;
}

.map-adjust-btn-group {
    display: flex;
    gap: 0.5rem;
}

.map-adjust-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-adjust-btn-save {
    background: var(--primary);
    color: white;
}

.map-adjust-btn-save:active {
    background: #4338ca;
}

.map-adjust-btn-cancel {
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.map-adjust-btn-cancel:active {
    background: #e2e8f0;
}

.map-guide-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* 長押しパルスアニメーション */
@keyframes mapPulse {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

.map-longpress-pulse {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.3);
    pointer-events: none;
    z-index: 600;
    animation: mapPulse 0.6s ease-out forwards;
}
/* Leaflet ポップアップのカスタムスタイル */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden; /* 開く瞬間の表示崩れやスクロールバーのちらつきを防止 */
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 180px;
}

.map-popup {
    padding: 12px;
    width: 200px;
    box-sizing: border-box;
}

.map-popup h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.map-popup p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.15rem 0;
}

.map-popup-btn {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--grad-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.map-popup-btn:active {
    opacity: 0.8;
}

/* 地図上の確認ダイアログ */
.map-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    animation: fadeIn 0.2s ease;
}

.map-confirm-dialog {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 300px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.map-confirm-dialog h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.map-confirm-dialog p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.map-confirm-dialog .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ================================ */
/* マーカークラスタリング スタイル   */
/* ================================ */

/* クラスターアイコンの共通スタイル */
.marker-cluster {
    background: transparent !important;
}

.marker-cluster div,
.cluster-icon-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.4), 0 0 0 4px rgba(99, 102, 241, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cluster-icon-inner span {
    position: relative;
    z-index: 1;
}

/* 小クラスター（10件未満） */
.marker-cluster-small .cluster-icon-inner {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    font-size: 13px;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35), 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* 中クラスター（10〜49件） */
.marker-cluster-medium .cluster-icon-inner {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    font-size: 15px;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4), 0 0 0 5px rgba(79, 70, 229, 0.15);
}

/* 大クラスター（50件以上） */
.marker-cluster-large .cluster-icon-inner {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    font-size: 17px;
    box-shadow: 0 5px 18px rgba(67, 56, 202, 0.45), 0 0 0 6px rgba(67, 56, 202, 0.18);
}

/* ホバー時の拡大アニメーション */
.marker-cluster:hover .cluster-icon-inner {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5), 0 0 0 6px rgba(99, 102, 241, 0.2);
}

/* クラスター分割アニメーション */
.marker-cluster-animated .marker-cluster {
    transition: all 0.3s ease-out;
}

/* Leaflet MarkerCluster デフォルトスタイルの上書き */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out !important;
}

/* スパイダー化された線のスタイル */
.leaflet-cluster-spider-leg {
    stroke: rgba(99, 102, 241, 0.4);
    stroke-width: 2;
}

/* ================================ */
/* カスタムマーカーツールチップ スタイル（吹き出し） */
/* ================================ */
.custom-marker-tooltip {
    background: rgba(15, 23, 42, 0.85) !important; /* 濃い半透明のダーク背景 */
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    pointer-events: none; /* ツールチップがクリックを邪魔しないようにする */
}

/* ツールチップの矢印部分のカラーカスタマイズ */
.leaflet-tooltip-top.custom-marker-tooltip::before {
    border-top-color: rgba(15, 23, 42, 0.85) !important;
}
.leaflet-tooltip-bottom.custom-marker-tooltip::before {
    border-bottom-color: rgba(15, 23, 42, 0.85) !important;
}
.leaflet-tooltip-left.custom-marker-tooltip::before {
    border-left-color: rgba(15, 23, 42, 0.85) !important;
}
.leaflet-tooltip-right.custom-marker-tooltip::before {
    border-right-color: rgba(15, 23, 42, 0.85) !important;
}
/* ================================ */
/* 地図タイプ切り替えコントロール     */
/* ================================ */
.map-type-control {
    position: absolute;
    top: calc(var(--header-height) + 12px);
    right: 12px;
    z-index: 1000;
    display: flex;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.map-type-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-type-btn:hover {
    color: var(--text-main);
}

.map-type-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 同期中オーバーレイの操作ブロック保障 */
#sync-overlay {
    pointer-events: auto !important;
}

/* 自車位置送信トグルスイッチ */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #f97316; /* アクティブ時はオレンジ色 */
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* 顧客名ラベルの表示・非表示制御（ズームレベル14基準） */
.custom-map-marker .customer-marker-label {
    display: none !important;
}
.map-zoom-detailed .custom-map-marker .customer-marker-label {
    display: block !important;
}

/* iOS Safari用の選択・長押しポップアップ抑止 */
*, *:before, *:after {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* フォーム入力だけは例外としてテキストの選択・コピー・入力を可能にする */
input, textarea, [contenteditable="true"] {
    -webkit-touch-callout: default !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* 全画面フォトビューアー関連スタイル (削除済み) */

/* モバイルブラウザでの全体画面崩れズーム(Viewport Zoom)防止 */
.maplibregl-popup,
.maplibregl-popup-content,
.app-header,
.map-controls-container,
.map-modal-overlay {
    touch-action: pan-x pan-y;
}

/* ポップアップの外枠（フチ）の余白削除と角丸の適用 */
.maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
}

/* ポップアップの閉じるボタン（xボタン）の位置とスタイルの最適化 */
.maplibregl-popup-close-button {
    padding: 4px 8px !important;
    color: var(--text-muted) !important;
    font-size: 16px !important;
    outline: none !important;
    border-top-right-radius: 12px !important;
}
.maplibregl-popup-close-button:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
}
