/* ========================================
   WebGIS Demo - Modern UI Styles
   ======================================== */

:root {
    /* Color Palette */
    --primary-color: #3B82F6;       /* Blue 500 */
    --primary-hover: #2563EB;       /* Blue 600 */
    --primary-active: #1D4ED8;      /* Blue 700 */
    --danger-color: #EF4444;        /* Red 500 */
    --danger-hover: #DC2626;        /* Red 600 */
    --success-color: #10B981;       /* Emerald 500 */
    --warning-color: #F59E0B;       /* Amber 500 */
    
    --text-main: #1F2937;           /* Gray 800 */
    --text-sub: #6B7280;            /* Gray 500 */
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(255, 255, 255, 0.5);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Radius */
    --radius-md: 0.5rem;    /* 8px */
    --radius-lg: 0.75rem;   /* 12px */
    --radius-full: 9999px;

    /* Alert Settings */
    --alert-opacity: 0.5; /* Default opacity multiplier */
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-main);
    background-color: #F3F4F6;
    font-size: 18px; /* Increased base font size */
}

/* Root wrappers (mode containers) */
#warnRoot,
#recordRoot {
    width: 100%;
    height: 100%;
}

/* ========================================
   MODE SELECT OVERLAY + RECORD MODE UI
   ======================================== */

.mode-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 4000;
    padding: 20px;
}

.mode-card {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 22px;
}

.mode-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 6px;
}

.mode-desc {
    font-size: 14px;
    color: var(--text-sub);
    margin-bottom: 16px;
    line-height: 1.5;
}

.mode-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.mode-btn {
    height: 56px;
    border-radius: 14px;
    border: 1px solid #D1D5DB;
    background: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.mode-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.mode-btn:active {
    transform: translateY(0);
}

.mode-footer {
    margin-top: 14px;
    display: flex;
    justify-content: flex-start;
}

.mode-check {
    font-size: 14px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.record-layout {
    --record-last-frame-color: transparent;
    --record-last-frame-glow: transparent;
    width: 100%;
    /* フォールバック */
    height: 100vh;
    /* 動的ビューポート高さ: ブラウザアドレスバー等を考慮 */
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* 記録モードは屋外での視認性重視。全体の文字サイズを少し上げる */
    font-size: 18px;
    position: relative;
}

.record-layout.last-record-action::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1500;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 10px var(--record-last-frame-color),
        inset 0 0 0 18px var(--record-last-frame-glow);
    animation: recordFrameBreath 3.2s ease-in-out infinite;
}

.record-layout.last-record-action.frame-confirmed::after {
    animation: recordFramePulse 0.82s ease-out, recordFrameBreath 3.2s ease-in-out 0.82s infinite;
}

.record-layout.last-record-action.load {
    --record-last-frame-color: rgba(59, 130, 246, 0.46);
    --record-last-frame-glow: rgba(59, 130, 246, 0.13);
}

.record-layout.last-record-action.unload {
    --record-last-frame-color: rgba(245, 158, 11, 0.50);
    --record-last-frame-glow: rgba(245, 158, 11, 0.15);
}

@keyframes recordFrameBreath {
    0%, 100% {
        opacity: 0.72;
        box-shadow:
            inset 0 0 0 10px var(--record-last-frame-color),
            inset 0 0 0 18px var(--record-last-frame-glow);
    }
    50% {
        opacity: 1;
        box-shadow:
            inset 0 0 0 13px var(--record-last-frame-color),
            inset 0 0 0 22px var(--record-last-frame-glow);
    }
}

@keyframes recordFramePulse {
    0% {
        opacity: 0.35;
        box-shadow:
            inset 0 0 0 4px var(--record-last-frame-color),
            inset 0 0 0 8px var(--record-last-frame-glow);
    }
    34% {
        opacity: 1;
        box-shadow:
            inset 0 0 0 18px var(--record-last-frame-color),
            inset 0 0 0 30px var(--record-last-frame-glow);
    }
    100% {
        opacity: 0.78;
        box-shadow:
            inset 0 0 0 10px var(--record-last-frame-color),
            inset 0 0 0 18px var(--record-last-frame-glow);
    }
}

.record-header {
    height: 64px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
}

.record-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
}

.record-header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.record-header-status .status-badge {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.record-header-status .status-badge.on {
    background: #10B981;
    color: white;
}

.record-header-status .status-badge.off {
    background: #6B7280;
    color: white;
}

.record-header-status .truck-size-status {
    background: #0F766E;
    color: white;
}

.record-main {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.record-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.record-action-btn {
    --record-action-shadow: var(--shadow-md);
    height: 120px;
    border-radius: 18px;
    border: 1px solid rgba(0,0,0,0.05);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--record-action-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.record-action-btn:active {
    transform: scale(0.98);
}

.record-action-btn.confirmed {
    animation: recordButtonConfirm 0.55s ease-out;
}

.record-action-btn.load { color: #3B82F6; }
.record-action-btn.unload { color: #F59E0B; }

.record-action-icon {
    font-size: 40px;
    line-height: 1;
}
.record-action-label { font-size: 18px; font-weight: 900; }

.record-action-btn.load .record-action-icon { font-size: 48px; }
.record-action-btn.load .record-action-label { font-size: 22px; }

.record-feedback {
    background: #fff;
    border-radius: 18px;
    border: 1px solid #D1D5DB;
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.record-feedback.confirmed {
    animation: recordFeedbackConfirm 0.65s ease-out;
}

.record-last-action {
    min-width: 0;
    color: var(--text-main);
    font-size: 17px;
    font-weight: 900;
}

.record-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    justify-content: flex-end;
}

.record-count {
    border-radius: 999px;
    padding: 6px 10px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.record-count.load { background: #2563EB; }
.record-count.unload { background: #D97706; }
.record-count.volume { background: #059669; }

@keyframes recordButtonConfirm {
    0% { box-shadow: var(--record-action-shadow); transform: scale(1); }
    35% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0.22), var(--record-action-shadow), var(--shadow-lg); transform: scale(1.025); }
    100% { box-shadow: var(--record-action-shadow); transform: scale(1); }
}

@keyframes recordFeedbackConfirm {
    0% { background: #ECFDF5; border-color: #10B981; }
    100% { background: #fff; border-color: #D1D5DB; }
}

.record-screen-flash {
    --record-flash-rgb: 59, 130, 246;
    position: fixed;
    inset: 0;
    z-index: 2800;
    pointer-events: none;
    opacity: 0;
    background:
        radial-gradient(circle at center,
            rgba(255, 255, 255, 0.96) 0%,
            rgba(var(--record-flash-rgb), 0.58) 38%,
            rgba(var(--record-flash-rgb), 0.18) 70%,
            rgba(var(--record-flash-rgb), 0) 100%);
}

.record-screen-flash.load {
    --record-flash-rgb: 59, 130, 246;
}

.record-screen-flash.unload {
    --record-flash-rgb: 245, 158, 11;
}

.record-screen-flash.active {
    animation: recordScreenFlash 0.58s ease-out;
}

@keyframes recordScreenFlash {
    0% {
        opacity: 0;
        transform: scale(0.98);
    }
    18% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.04);
    }
}

@media (prefers-reduced-motion: reduce) {
    .record-layout.last-record-action::after,
    .record-layout.last-record-action.frame-confirmed::after {
        animation: none;
    }

    .record-screen-flash.active {
        animation-duration: 0.22s;
    }
}

/* Record Mode Settings */
.record-settings {
    background: #fff;
    border-radius: 18px;
    border: 1px solid #E5E7EB;
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
}

.record-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #F3F4F6;
}

.record-setting-item:last-child {
    border-bottom: none;
}

.record-setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.record-setting-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.record-setting-desc {
    font-size: 12px;
    color: var(--text-sub);
}

/* Record Mode Minimap (Debug) */
.record-minimap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 150px;
    border-radius: 12px;
    border: 2px solid #3B82F6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
}

.record-minimap.hidden {
    display: none;
}

.track-map-modal {
    position: fixed;
    inset: 0;
    z-index: 3200;
    display: none;
    background: #fff;
}

.track-map-modal.active {
    display: block;
}

.track-map-shell {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #F9FAFB;
}

.track-map-header {
    min-height: 66px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #D1D5DB;
    background: #fff;
}

.track-map-heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.track-map-title {
    color: var(--text-main);
    font-size: 17px;
    font-weight: 900;
}

.track-map-summary {
    overflow: hidden;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-map-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.track-map-canvas {
    min-height: 0;
    width: 100%;
    height: 100%;
    background: #E5E7EB;
}

.track-point-label {
    max-width: 140px;
    padding: 4px 7px;
    border: 1px solid rgba(37, 99, 235, 0.28);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.94);
    color: #1F2937;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
    font-size: 12px;
    font-weight: 900;
    line-height: 1.25;
    white-space: nowrap;
    pointer-events: none;
}

.track-point-label.unload {
    border-color: rgba(217, 119, 6, 0.34);
}

.record-history {
    background: #fff;
    border-radius: 18px;
    border: 1px solid #E5E7EB;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.record-history-header {
    padding: 14px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #E5E7EB;
    background: #F9FAFB;
    flex-wrap: wrap;
}

.record-history-title {
    font-weight: 800;
    color: var(--text-main);
    font-size: 16px;
}

.record-history-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.record-exit .record-history-tools {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.record-exit .export-btn,
.record-exit .clear-btn {
    min-width: 0;
    width: 100%;
}

.record-history-list {
    padding: 8px 0;
}

.record-history-footer {
    padding: 12px 14px;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
    display: flex;
    justify-content: flex-end;
}

.record-history-item {
    padding: 10px 14px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.record-history-item.latest-record {
    animation: latestRecordConfirm 2.8s ease-out;
}

.record-history-item:last-child { border-bottom: none; }

.record-history-time {
    color: var(--text-main);
    font-family: monospace;
}

.record-history-meta {
    font-size: 13px;
    color: var(--text-sub);
}

@keyframes latestRecordConfirm {
    0% { background: #ECFDF5; }
    65% { background: #ECFDF5; }
    100% { background: transparent; }
}

/* ========================================
   RECORD MODE - MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 767px) {
    .record-header {
        height: auto;
        min-height: 100px;
        padding: 8px 12px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 48px;
        grid-template-areas:
            "title actions"
            "status status";
        gap: 8px;
    }

    .record-title {
        grid-area: title;
        min-width: 0;
        font-size: 18px;
    }

    .record-header-status {
        grid-area: status;
        width: 100%;
        min-width: 0;
        justify-content: flex-start;
        gap: 6px;
    }

    .record-header-status .status-badge {
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 8px;
        text-align: center;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .record-header-actions {
        grid-area: actions;
        justify-self: end;
    }

    .record-header .icon-btn {
        width: 48px;
        height: 48px;
    }

    /* Portrait: ボタン大きめ + 履歴は控えめ */
    .record-main {
        padding: 12px;
        gap: 12px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .record-actions {
        flex: 0 0 auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .record-action-btn {
        height: 112px;
        border-radius: 16px;
    }

    .record-action-icon { font-size: 38px; }
    .record-action-label { font-size: 18px; }
    .record-action-btn.load .record-action-icon { font-size: 46px; }
    .record-action-btn.load .record-action-label { font-size: 22px; }

    .record-feedback {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    .record-last-action {
        font-size: 16px;
        text-align: center;
    }

    .record-counts {
        justify-content: center;
    }

    .record-history {
        flex: 1;
        min-height: 0;
        max-height: 40dvh;  /* 履歴エリアを画面高さの40%以下に制限 */
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .record-history-header {
        flex: 0 0 auto;
        padding: 8px 12px;
    }

    .record-history-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .record-history-item {
        padding: 8px 12px;
        font-size: 14px;
    }

    .record-history-footer {
        flex: 0 0 auto;
        padding: 8px 12px;
        justify-content: stretch;
    }

    .record-history-tools {
        width: 100%;
        justify-content: space-between;
    }

    .record-history-tools .export-btn,
    .record-history-tools .clear-btn {
        flex: 1 1 auto;
        min-width: 0;
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* 横向きは端末幅に依存せず左右分割（スマホ/タブレット両対応） */
@media (orientation: landscape) {
    .record-header { height: 52px; }

    .record-header {
        min-height: 52px;
        display: flex;
        padding: 0 16px;
    }

    .record-title {
        font-size: 20px;
    }

    .record-header-status {
        width: auto;
        justify-content: center;
        gap: 8px;
    }

    .record-header-status .status-badge {
        flex: 0 1 auto;
    }

    .record-header .icon-btn {
        width: 48px;
        height: 48px;
    }

    /* ミニマップを左下に配置 */
    .record-minimap {
        right: auto;
        left: 20px;
    }

    .record-main {
        padding: 10px;
        gap: 10px;
        /* 左=履歴 / 右上=積込荷卸 / 右下=終了・クリア */
        display: grid;
        /* 要望: 左右 50:50 */
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr auto auto;
        grid-template-areas:
            "history actions"
            "history feedback"
            "history exit";
        align-items: stretch;
        overflow: hidden;
        min-height: 0;
    }

    .record-actions { grid-area: actions; }
    .record-feedback { grid-area: feedback; }
    .record-history { grid-area: history; }
    .record-exit { grid-area: exit; }

    /* 左: 履歴は中だけスクロール */
    .record-history {
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .record-history-header { flex: 0 0 auto; }

    .record-history-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        background: #fff;
    }

    /* 右上: 積込/荷卸は縦並びで押しやすく */
    .record-actions {
        /* 高さをフルに使って、2ボタンが均等に伸びる（大画面の余白対策） */
        height: 100%;
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .record-action-btn {
        /* flexで最大限伸ばす（小さい画面でも押しやすい最低サイズは確保） */
        flex: 1 1 0;
        height: auto;
        min-height: 92px;
    }

    .record-action-icon { font-size: 36px; }
    .record-action-label { font-size: 18px; }
    .record-action-btn.load .record-action-icon { font-size: 44px; }
    .record-action-btn.load .record-action-label { font-size: 22px; }

    .record-feedback {
        padding: 8px 10px;
    }

    .record-last-action {
        font-size: 15px;
    }

    .record-count {
        padding: 5px 8px;
        font-size: 12px;
    }

    /* 右下: 終了/クリアは常に見える */
    .record-exit.record-history-footer {
        border-radius: 18px;
        overflow: hidden;
        border: 1px solid #E5E7EB;
        background: #F9FAFB;
        justify-content: stretch;
    }

    .record-exit .record-history-tools {
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .record-exit .export-btn,
    .record-exit .clear-btn {
        min-width: 0;
        height: 38px;
        padding: 0 8px;
        font-size: 12px;
        line-height: 1.15;
        white-space: normal;
    }
}

/* 横向き + 低い画面（低解像度スマホ等）: さらに詰めてボタンが隠れにくくする */
@media (orientation: landscape) and (max-height: 460px) {
    .record-header { height: 44px; }

    .record-header {
        min-height: 44px;
    }

    .record-title {
        font-size: 16px;
    }

    .record-header-status .status-badge {
        padding: 3px 6px;
        font-size: 11px;
    }

    .record-header .icon-btn {
        width: 40px;
        height: 40px;
    }

    .record-main {
        padding: 8px;
        gap: 8px;
    }

    .record-side,
    .record-history {
        min-height: 0;
    }

    .record-actions {
        gap: 8px;
    }

    .record-action-btn {
        flex: 0 0 clamp(58px, 17dvh, 72px);
        height: auto;
        min-height: 0;
        border-radius: 16px;
    }

    .record-action-icon { font-size: 30px; }
    .record-action-label { font-size: 16px; }
    .record-action-btn.load .record-action-icon { font-size: 34px; }
    .record-action-btn.load .record-action-label { font-size: 18px; }

    .record-exit.record-history-footer {
        padding: 6px 10px;
    }

    .record-exit .record-history-tools {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .record-history-header,
    .record-history-footer {
        padding: 8px 10px;
    }

    .record-history-item {
        padding: 7px 10px;
        font-size: 13px;
    }

    .record-exit .export-btn,
    .record-exit .clear-btn {
        height: 30px;
        padding: 0 6px;
        font-size: 11px;
    }
}

/* 極端に低い画面（ブラウザUIで高さ350px以下）: 最小限のUIでボタンを確保 */
@media (orientation: landscape) and (max-height: 350px) {
    .record-header {
        height: 36px;
        min-height: 36px;
        padding: 0 8px;
    }

    .record-title { font-size: 14px; }

    .record-header-status {
        gap: 6px;
    }

    .record-header-status .status-badge {
        padding: 2px 5px;
        font-size: 10px;
    }

    .record-header .icon-btn {
        width: 32px;
        height: 32px;
    }

    .record-header-actions .export-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .record-main {
        padding: 6px;
        gap: 6px;
    }

    .record-actions {
        gap: 6px;
    }

    .record-action-btn {
        /* タップ可能な最低限サイズ44px〜 */
        flex: 0 0 clamp(44px, 18dvh, 64px);
        flex-direction: row;
        height: auto;
        min-height: 44px;
        gap: 8px;
        border-radius: 12px;
    }

    .record-action-icon { font-size: 22px; }
    .record-action-label {
        font-size: 14px;
        line-height: 1.1;
    }
    .record-action-btn.load .record-action-icon {
        width: 24px;
        height: 28px;
        flex: 0 0 24px;
        font-size: 0;
        background:
            radial-gradient(circle at 50% 26%, currentColor 0 5px, transparent 5.5px),
            radial-gradient(circle at 50% 72%, currentColor 0 10px, transparent 10.5px);
        background-repeat: no-repeat;
        background-size: 100% 100%;
    }
    .record-action-btn.load .record-action-label {
        font-size: 14px;
        line-height: 1.1;
    }

    .record-feedback {
        padding: 5px 8px;
        gap: 5px;
        border-radius: 12px;
    }

    .record-last-action {
        font-size: 12px;
        line-height: 1.2;
    }

    .record-counts {
        gap: 4px;
    }

    .record-count {
        padding: 3px 6px;
        font-size: 10px;
        line-height: 1.2;
    }

    .record-history {
        border-radius: 12px;
    }

    .record-history-header,
    .record-history-footer {
        padding: 6px 8px;
    }

    .record-history-title { font-size: 12px; }

    .record-history-item {
        padding: 5px 8px;
        font-size: 11px;
    }

    .record-history-meta { font-size: 10px; }

    .record-exit.record-history-footer {
        padding: 3px 8px;
        border-radius: 12px;
    }

    .record-exit .record-history-tools {
        gap: 4px;
    }

    .record-exit .export-btn,
    .record-exit .clear-btn {
        height: 24px;
        padding: 0 5px;
        font-size: 9px;
        line-height: 1;
        min-width: 0;
        white-space: nowrap;
    }
}

/* Optional: keep footer actions visible while scrolling (may be disabled if it feels intrusive) */
@media (max-width: 767px) {
    /* `record-history` has overflow:hidden for rounded corners; iOS Safari can be picky with sticky+overflow.
       We keep it non-sticky by default and only enable sticky on modern browsers. */
    @supports (position: sticky) {
        .record-history-footer {
            position: sticky;
            bottom: 0;
            z-index: 5;
        }
    }
}

/* ========================================
   LAYOUT CONTAINERS
   ======================================== */

#splitViewContainer {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

#mapContainer {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
}

/* ========================================
   MAP CONTROLS ADJUSTMENT
   ======================================== */

.maplibregl-ctrl-top-right {
    margin-top: 60px !important; /* Header height adjustment */
}

/* ========================================
   HEADER UI
   ======================================== */

#appHeader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    pointer-events: none; /* Allow clicks to pass through to map where empty */
}

#appHeader > * {
    pointer-events: auto; /* Re-enable clicks for header contents */
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 12px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-glass);
    font-size: 15px; /* Increased */
    font-weight: 500;
    color: var(--text-main);
    max-width: 200px;
}

.alert-severity-status {
    max-width: 132px;
    overflow: hidden;
    padding: 7px 10px;
    border: 1px solid rgba(5, 150, 105, 0.22);
    border-radius: var(--radius-full);
    background: rgba(240, 253, 244, 0.9);
    box-shadow: var(--shadow-sm);
    color: #047857;
    font-size: 13px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alert-severity-status.none {
    border-color: rgba(107, 114, 128, 0.25);
    background: rgba(249, 250, 251, 0.9);
    color: var(--text-sub);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    flex-shrink: 0;
}

.status-badge.locating .status-dot {
    background-color: var(--primary-color);
    animation: pulse-dot 2s infinite;
}

.status-badge.error .status-dot {
    background-color: var(--danger-color);
}

#statusText {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.distance-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 12px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-glass);
    font-weight: 700;
    color: var(--primary-color);
    font-size: 16px; /* Increased */
}

.icon-btn {
    width: 56px; /* Increased */
    height: 56px; /* Increased */
    border-radius: 50%;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: #fff;
    color: var(--primary-color);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
}

.auth-status-btn {
    min-height: 42px;
    max-width: 220px;
    padding: 0 14px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-md);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-status-btn.logged-in {
    color: var(--text-main);
    border-color: rgba(16, 185, 129, 0.35);
}

.work-type-filter-control {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(31, 41, 55, 0.12);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-md);
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 900;
}

.work-type-filter-control select {
    width: 126px;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 900;
    outline: none;
}

@media (max-width: 640px) {
    .work-type-filter-control {
        padding: 0 8px;
    }

    .work-type-filter-control span {
        display: none;
    }

    .work-type-filter-control select {
        width: 96px;
        font-size: 12px;
    }
}

@media (max-width: 767px) {
    #appHeader {
        top: env(safe-area-inset-top);
        height: auto;
        min-height: 100px;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 10px 0;
    }

    .header-left,
    .header-right {
        width: 100%;
        min-width: 0;
    }

    .header-left {
        justify-content: space-between;
    }

    .header-right {
        justify-content: flex-end;
        gap: 6px;
    }

    #appHeader .status-badge {
        min-width: 0;
        max-width: min(156px, calc(100% - 120px));
        flex: 0 1 auto;
        padding: 7px 10px;
        font-size: 13px;
    }

    .alert-severity-status {
        max-width: 112px;
        flex: 0 1 auto;
        padding: 6px 9px;
        font-size: 12px;
    }

    #appHeader .icon-btn {
        width: 48px;
        height: 48px;
        flex: 0 0 auto;
    }

    .auth-status-btn {
        min-height: 40px;
        max-width: 112px;
        padding: 0 10px;
        font-size: 12px;
        flex: 0 1 auto;
    }

    .work-type-filter-control {
        min-height: 40px;
        flex: 0 1 auto;
    }

    .maplibregl-ctrl-top-right {
        margin-top: calc(116px + env(safe-area-inset-top)) !important;
    }
}

@media (max-width: 767px) and (orientation: portrait) {
    #appHeader {
        min-height: 142px;
        align-content: flex-start;
        gap: 6px;
    }

    .header-right {
        order: 1;
        min-height: 48px;
        align-items: center;
    }

    .header-left {
        order: 2;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 6px;
    }

    #appHeader .status-badge {
        max-width: min(156px, 100%);
    }

    .alert-severity-status {
        max-width: min(112px, 100%);
    }

    .maplibregl-ctrl-top-right {
        margin-top: calc(154px + env(safe-area-inset-top)) !important;
    }
}

/* ========================================
   BOTTOM CONTROLS
   ======================================== */

#bottomControls {
    position: absolute;
    bottom: 32px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.action-btn-container {
    pointer-events: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 72px; /* Increased */
    padding: 0 48px; /* Increased */
    border-radius: var(--radius-full);
    border: none;
    font-size: 22px; /* Increased */
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.action-btn.primary {
    background-color: var(--primary-color);
}

.action-btn.primary:hover {
    background-color: var(--primary-hover);
}

.action-btn.primary:active {
    background-color: var(--primary-active);
}

.action-btn.danger {
    background-color: var(--danger-color);
}

.action-btn.danger:hover {
    background-color: var(--danger-hover);
}

.action-btn:disabled {
    background-color: #9CA3AF;
    cursor: not-allowed;
    opacity: 0.8;
}

@media (max-width: 767px) {
    #bottomControls {
        bottom: calc(18px + env(safe-area-inset-bottom));
        left: 10px;
        right: 10px;
    }

    .action-btn-container {
        width: min(100%, 280px);
    }

    .action-btn {
        width: 100%;
        height: 60px;
        padding: 0 24px;
        font-size: 18px;
        white-space: nowrap;
    }
}

/* ========================================
   FAB & COMPASS
   ======================================== */

.fab-button {
    position: absolute;
    right: 16px;
    bottom: 100px; /* Above bottom controls */
    width: 64px; /* Increased */
    height: 64px; /* Increased */
    border-radius: 50%;
    background: white;
    color: var(--text-sub);
    border: none;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.fab-button:hover {
    color: var(--primary-color);
    transform: scale(1.05);
}

@media (max-width: 767px) {
    .fab-button {
        right: 12px;
        bottom: calc(90px + env(safe-area-inset-bottom));
        width: 54px;
        height: 54px;
    }
}

.compass-widget {
    position: absolute;
    top: 140px; /* Below zoom controls */
    right: 16px;
    width: 64px;
    height: 64px;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 9;
    pointer-events: none;
}

.compass-icon {
    width: 100%;
    height: 100%;
}

@media (max-width: 767px) {
    .compass-widget {
        top: calc(184px + env(safe-area-inset-top));
        right: 12px;
        width: 54px;
        height: 54px;
    }
}

.compass-needle {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   SNOW RECORD BUTTONS
   ======================================== */

#snowRecordControls {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 24px; /* Increased gap */
    z-index: 10;
}

.record-btn {
    width: 80px; /* Increased size */
    height: 80px; /* Increased size */
    border-radius: 16px;
    border: none;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-glass);
}

.record-btn:active {
    transform: scale(0.95);
}

.record-btn.load {
    color: #3B82F6; /* Blue */
}

.record-btn.unload {
    color: #F59E0B; /* Amber */
}

.record-icon {
    font-size: 32px; /* Larger icon */
    margin-bottom: 4px;
}

.record-label {
    font-size: 15px; /* Increased */
    font-weight: 700;
}

/* ========================================
   HISTORY PANEL
   ======================================== */

.history-panel {
    position: absolute;
    top: 70px; /* Below header */
    left: 16px;
    width: 200px;
    max-height: 300px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-md);
    z-index: 9;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    padding: 10px 12px;
    font-size: 14px; /* Increased */
    font-weight: 700;
    color: var(--text-sub);
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid var(--border-glass);
}

.history-list {
    overflow-y: auto;
    padding: 8px 0;
}

.history-item {
    padding: 6px 12px;
    font-size: 14px; /* Increased */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.history-item:last-child {
    border-bottom: none;
}

.history-type {
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px; /* Increased */
}

.history-type.load {
    background: #EFF6FF;
    color: #3B82F6;
}

.history-type.unload {
    background: #FFFBEB;
    color: #F59E0B;
}

/* 自動バッジ */
.history-type.auto::after {
    content: '自動';
    font-size: 9px;
    background: #10B981;
    color: white;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    font-weight: 700;
}

.history-time {
    color: var(--text-main);
    font-family: monospace;
}

/* ========================================
   LEGEND PANEL (Bottom Left)
   ======================================== */

.legend-panel {
    position: absolute;
    bottom: 110px;
    left: 16px;
    width: 220px;
    /* 100dvh: 動的ビューポート高さ（ブラウザUI考慮） */
    max-height: calc(100dvh - 170px);
    min-height: 200px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-md);
    z-index: 9;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.legend-header {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-sub);
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.legend-title {
    flex: 1;
}

.legend-toggle-icon {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.legend-header.collapsed .legend-toggle-icon {
    transform: rotate(-90deg);
}

.legend-content {
    overflow-y: auto;
    padding: 8px 0;
    /* 100dvh対応: パネルヘッダー50px分を追加 */
    max-height: calc(100dvh - 220px);
    min-height: 150px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.legend-content.hidden {
    max-height: 0;
    min-height: 0;
    opacity: 0;
    padding: 0;
    overflow: hidden;
}

.legend-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.legend-item:last-child {
    border-bottom: none;
}

.legend-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.legend-name {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

/* ========================================
   MODAL (SETTINGS)
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: flex-end; /* Bottom sheet on mobile */
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 4200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.auth-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.auth-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 22px;
}

.auth-confirm-card {
    max-width: 380px;
}

.auth-title {
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 6px;
}

.auth-desc {
    color: var(--text-sub);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 18px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 13px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-main);
}

.auth-field input {
    height: 48px;
    border: 1px solid #D1D5DB;
    border-radius: 12px;
    padding: 0 13px;
    font-size: 16px;
}

.auth-error {
    min-height: 22px;
    color: var(--danger-color);
    font-size: 13px;
    font-weight: 700;
}

.auth-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.auth-btn {
    height: 48px;
    border-radius: 12px;
    font-weight: 900;
    cursor: pointer;
    border: 1px solid #D1D5DB;
    background: #fff;
}

.auth-btn.primary {
    color: #fff;
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.auth-btn.secondary {
    color: var(--text-main);
}

.auth-btn.danger {
    color: #fff;
    background: var(--danger-color);
    border-color: var(--danger-color);
}

.hazard-inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.hazard-mini-btn {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #D1D5DB;
    background: #fff;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.hazard-mini-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.hazard-mini-btn.danger {
    color: #fff;
    background: var(--danger-color);
    border-color: var(--danger-color);
}

.hazard-form-overlay {
    position: fixed;
    inset: 0;
    z-index: 4300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.hazard-form-overlay.active {
    opacity: 1;
    visibility: visible;
}

.hazard-form-card {
    width: min(560px, 100%);
    max-height: min(92dvh, 820px);
    background: #fff;
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hazard-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid #E5E7EB;
}

.hazard-form-header h3 {
    font-size: 20px;
    font-weight: 900;
}

.hazard-form-close {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid #E5E7EB;
    background: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.hazard-form-body {
    padding: 16px 18px;
    overflow: auto;
    display: grid;
    gap: 12px;
}

.hazard-coordinate-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: stretch;
}

.hazard-coordinates {
    padding: 10px 12px;
    border-radius: 12px;
    background: #F3F4F6;
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 700;
}

.hazard-location-btn {
    border: 1px solid #D1D5DB;
    border-radius: 12px;
    background: #fff;
    padding: 0 12px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.hazard-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 900;
}

.hazard-form-field input,
.hazard-form-field select,
.hazard-form-field textarea {
    width: 100%;
    border: 1px solid #D1D5DB;
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 16px;
    background: #fff;
}

.hazard-form-field textarea {
    resize: vertical;
    min-height: 92px;
}

.hazard-photo-section {
    display: grid;
    gap: 8px;
}

.hazard-photo-section[hidden] {
    display: none;
}

.hazard-photo-section-title {
    color: var(--text-main);
    font-size: 13px;
    font-weight: 900;
}

.hazard-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
}

.hazard-photo-thumb {
    position: relative;
    overflow: hidden;
    min-height: 92px;
    border-radius: 14px;
    border: 1px solid #E5E7EB;
    background: #F9FAFB;
}

.hazard-photo-thumb img {
    width: 100%;
    height: 92px;
    object-fit: cover;
    display: block;
}

.hazard-photo-thumb span {
    display: block;
    overflow: hidden;
    padding: 6px;
    color: var(--text-sub);
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hazard-photo-delete {
    position: absolute;
    right: 6px;
    bottom: 6px;
    min-height: 30px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.94);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

@media (max-width: 520px) {
    .hazard-coordinate-row {
        grid-template-columns: 1fr;
    }

    .hazard-location-btn {
        min-height: 42px;
    }
}

.hazard-form-error {
    min-height: 22px;
    color: var(--danger-color);
    font-size: 13px;
    font-weight: 800;
}

.hazard-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    padding: 14px 18px 18px;
    border-top: 1px solid #E5E7EB;
}

.hazard-action-btn {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #D1D5DB;
    background: #fff;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.hazard-action-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.hazard-action-btn.secondary {
    color: var(--text-main);
}

.hazard-action-btn.danger {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 設定モーダルのヘッダ内の「モード切替」は省スペースに */
.modal-header-actions .export-btn {
    padding: 8px 12px;
    font-size: 13px;
}

@media (max-width: 767px) {
    .modal-header-actions .export-btn {
        padding: 8px 10px;
        font-size: 12px;
    }
}

.modal-header h3 {
    font-size: 20px; /* Increased */
    font-weight: 700;
    color: var(--text-main);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px;
    text-align: center;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
}

.version-text {
    font-size: 12px; /* Increased */
    color: var(--text-sub);
}

/* Settings Items */
.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #F3F4F6;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-title {
    font-size: 16px; /* Increased */
    font-weight: 500;
    color: var(--text-main);
}

.setting-desc {
    font-size: 13px; /* Increased */
    color: var(--text-sub);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px; /* Increased */
    height: 34px; /* Increased */
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #E5E7EB;
    transition: .3s;
    border-radius: 34px; /* Adjusted radius */
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px; /* Increased */
    width: 26px; /* Increased */
    left: 4px; /* Adjusted */
    bottom: 4px; /* Adjusted */
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px); /* Adjusted distance */
}

/* Select Box */
.setting-select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #D1D5DB;
    background-color: #F9FAFB;
    font-size: 15px; /* Increased */
    color: var(--text-main);
    outline: none;
    cursor: pointer;
}

.setting-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.severity-alert-settings {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
}

.severity-alert-rank-list {
    display: grid;
    gap: 8px;
}

.severity-alert-rank-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 52px;
    padding: 9px 10px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #F9FAFB;
}

.severity-alert-rank-row.disabled {
    background: #F3F4F6;
    color: var(--text-sub);
}

.severity-alert-rank-info {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 9px;
}

.severity-alert-rank-swatch {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    background: var(--severity-color, #6B7280);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.severity-alert-rank-name {
    min-width: 0;
    overflow: hidden;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.severity-alert-rank-status {
    min-width: 36px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: #FFFFFF;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.setting-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-btn {
    width: 50px; /* Increased */
    height: 50px; /* Increased */
    border-radius: 50%;
    border: 1px solid #D1D5DB;
    background: white;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px; /* Increased */
    transition: all 0.2s ease;
}

.preview-btn:hover {
    background: #EFF6FF;
    border-color: var(--primary-color);
}

.preview-btn:active {
    transform: scale(0.95);
}

/* Setting Divider */
.setting-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #D1D5DB, transparent);
    margin: 16px 0;
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 8px;
}

.export-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: var(--primary-color);
    color: white;
}

.export-btn:active {
    transform: scale(0.95);
}

/* Clear Button */
.clear-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid #EF4444;
    background: transparent;
    color: #EF4444;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #EF4444;
    color: white;
}

.clear-btn:active {
    transform: scale(0.95);
}

/* ========================================
   PHOTO PANEL (Tablet/Desktop)
   ======================================== */

#photoPanel {
    display: none; /* Hidden by default */
    background: white;
    border-left: 1px solid #E5E7EB;
    z-index: 20;
    flex-direction: column;
    overflow-y: auto;
}

#photoPanelContent {
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

#photoPanelClose {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding-right: 48px; /* Space for close button */
}

#photoPanelTitle {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.4;
}

#photoPanelSeverity {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
}

#photoPanelSeverity[hidden] {
    display: none;
}

.hazard-detail-list {
    display: grid;
    gap: 6px;
    margin: 10px 0 14px;
}

.hazard-detail-list.compact {
    gap: 4px;
    margin: 6px 0 8px;
}

.hazard-detail-item {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.45;
}

.hazard-detail-list.compact .hazard-detail-item {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 6px;
    font-size: 11px;
    line-height: 1.4;
}

.hazard-detail-label {
    color: var(--text-sub);
    font-weight: 700;
}

.hazard-detail-value {
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.hazard-summary-grid {
    display: grid;
    grid-template-columns: minmax(132px, 0.95fr) minmax(0, 1.05fr);
    gap: 10px;
    margin: 8px 0 12px;
    padding: 10px 12px;
    align-items: start;
    border: 1px solid #DBEAFE;
    border-radius: var(--radius-md);
    background: #EFF6FF;
}

.hazard-summary-grid.compact {
    grid-template-columns: minmax(118px, 0.95fr) minmax(0, 1fr);
    gap: 8px;
    margin: 6px 0 10px;
    padding: 8px 9px;
}

.hazard-summary-details {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.hazard-summary-detail {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 6px;
    align-items: start;
    min-width: 0;
    font-size: 12px;
    line-height: 1.35;
}

.hazard-summary-grid.compact .hazard-summary-detail {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 5px;
    font-size: 11px;
}

.hazard-summary-label,
.hazard-summary-note-label {
    color: var(--text-sub);
    font-weight: 800;
}

.hazard-summary-value {
    min-width: 0;
    color: var(--text-main);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.hazard-summary-note {
    min-width: 0;
}

.hazard-summary-note-label {
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.25;
}

.hazard-summary-grid.compact .hazard-summary-note-label {
    font-size: 11px;
}

.hazard-summary-note-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.42;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.hazard-summary-grid.compact .hazard-summary-note-text {
    font-size: 11px;
    line-height: 1.38;
}

.hazard-photo-viewer {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: #F3F4F6;
    box-shadow: var(--shadow-sm);
    touch-action: pan-y;
}

.hazard-photo-viewer.compact {
    aspect-ratio: 16 / 10;
    border-radius: var(--radius-md);
}

.hazard-photo-viewer-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hazard-photo-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 42px;
    height: 54px;
    border: 0;
    background: rgba(17, 24, 39, 0.62);
    color: #fff;
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hazard-photo-nav.previous {
    left: -20px;
    padding-left: 16px;
    border-radius: 0 999px 999px 0;
}

.hazard-photo-nav.next {
    right: -20px;
    padding-right: 16px;
    border-radius: 999px 0 0 999px;
}

.hazard-photo-nav:active {
    background: rgba(17, 24, 39, 0.82);
}

.hazard-photo-dots {
    position: absolute;
    left: 50%;
    bottom: 8px;
    z-index: 2;
    display: flex;
    gap: 6px;
    transform: translateX(-50%);
}

.hazard-photo-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.45);
    cursor: pointer;
}

.hazard-photo-dot.active {
    background: #fff;
}

.hazard-severity-badge {
    --severity-color: #6B7280;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 30px;
    padding: 5px 12px 5px 9px;
    border: 1px solid var(--severity-color);
    border-left-width: 5px;
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
    white-space: normal;
}

.hazard-severity-badge::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--severity-color);
    flex: 0 0 auto;
}

#photoPanelDistance {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 16px;
}

.panel-image-container {
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #F3F4F6;
    margin-bottom: 16px;
}

.panel-image-container[hidden] {
    display: none;
}

#photoPanelImage {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

#photoPanelMessage {
    padding: 12px 16px;
    background: #EFF6FF;
    border-radius: var(--radius-md);
    color: var(--primary-active);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
}

@media (max-width: 767px) {
    #photoPanel {
        position: fixed;
        z-index: 3200;
        overflow: hidden;
        border-left: 0;
        background: #fff;
        box-shadow: 0 -14px 40px rgba(15, 23, 42, 0.24);
        opacity: 0;
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    body.mobile-photo-panel-open #photoPanel {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }

    #photoPanelContent {
        min-height: 0;
        height: 100%;
        padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #photoPanelClose {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        background: #fff;
        box-shadow: var(--shadow-sm);
    }

    .panel-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 10px;
        padding-right: 44px;
    }

    #photoPanelTitle {
        font-size: 17px;
        line-height: 1.32;
    }

    #photoPanelSeverity {
        gap: 6px;
    }

    #photoPanelSeverity .hazard-severity-badge {
        min-height: 28px;
        padding: 4px 10px 4px 8px;
        font-size: 12px;
    }

    #photoPanelSummary {
        margin: 0 0 10px;
    }

    #photoPanel .hazard-summary-grid {
        grid-template-columns: minmax(118px, 0.95fr) minmax(0, 1fr);
        gap: 8px;
        padding: 8px 9px;
    }

    #photoPanel .hazard-summary-detail {
        grid-template-columns: 58px minmax(0, 1fr);
        gap: 5px;
        font-size: 11px;
    }

    #photoPanel .hazard-summary-note-label {
        font-size: 11px;
    }

    #photoPanel .hazard-summary-note-text {
        font-size: 11px;
        line-height: 1.38;
    }

    #photoPanel .panel-image-container {
        margin-bottom: 10px;
        border-radius: var(--radius-md);
    }

    #photoPanel .hazard-photo-viewer {
        aspect-ratio: 16 / 10;
        border-radius: var(--radius-md);
    }

    #photoPanelActions .hazard-inline-actions {
        margin-top: 8px;
    }
}

@media (max-width: 767px) and (orientation: portrait) {
    #photoPanel {
        left: 0;
        right: 0;
        bottom: 0;
        height: min(58dvh, 520px);
        max-height: calc(100dvh - 96px);
        border-top: 1px solid #E5E7EB;
        border-radius: 18px 18px 0 0;
        transform: translate3d(0, 100%, 0);
    }
}

@media (max-width: 767px) and (orientation: landscape) {
    #photoPanel {
        top: 0;
        right: 0;
        bottom: 0;
        width: min(46vw, 360px);
        min-width: min(320px, calc(100vw - 96px));
        max-width: calc(100vw - 96px);
        border-left: 1px solid #E5E7EB;
        border-radius: 18px 0 0 18px;
        box-shadow: -14px 0 40px rgba(15, 23, 42, 0.24);
        transform: translate3d(100%, 0, 0);
    }

    #photoPanelContent {
        padding: 10px 12px;
    }

    .panel-header {
        margin-bottom: 8px;
        padding-right: 40px;
    }

    #photoPanelTitle {
        font-size: 15px;
        line-height: 1.25;
    }

    #photoPanel .hazard-summary-grid {
        margin-bottom: 8px;
    }

    #photoPanel .hazard-photo-viewer {
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 767px) and (orientation: landscape) and (max-height: 420px) {
    #photoPanel {
        width: min(52vw, 340px);
        min-width: min(300px, calc(100vw - 72px));
        max-width: calc(100vw - 72px);
    }

    #photoPanelContent {
        padding: 8px 10px;
    }

    #photoPanel .hazard-summary-note-text {
        -webkit-line-clamp: 2;
    }

    #photoPanel .hazard-photo-viewer {
        aspect-ratio: 16 / 8;
    }
}

/* Resize Handle */
#resizeHandle {
    display: none;
    width: 4px;
    background: transparent;
    cursor: col-resize;
    z-index: 30;
    transition: background 0.2s;
}

#resizeHandle:hover {
    background: var(--primary-color);
}

/* ========================================
   MAP POPUP
   ======================================== */

.maplibregl-popup-content {
    padding: 0 !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
    border: none !important;
}

.maplibregl-popup-close-button {
    background: rgba(0,0,0,0.1) !important;
    color: white !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    top: 8px !important;
    right: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    padding: 0 !important;
    z-index: 10;
}

.popup-card {
    width: 280px;
}

.popup-body {
    padding: 12px 14px;
}

.popup-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.popup-title {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.hazard-severity-badge.title {
    flex: 0 0 auto;
}

.hazard-severity-badge.compact {
    min-height: 28px;
    padding: 4px 10px 4px 8px;
    font-size: 13px;
}

.proximity-alert-banner {
    position: absolute;
    left: 50%;
    bottom: calc(104px + env(safe-area-inset-bottom));
    z-index: 14;
    max-width: calc(100vw - 28px);
    padding: 10px 16px;
    border-radius: var(--radius-full);
    background: rgba(37, 99, 235, 0.95);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 900;
    line-height: 1.25;
    opacity: 0;
    pointer-events: none;
    text-align: center;
    transform: translate(-50%, 10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.proximity-alert-banner.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ========================================
   TOAST
   ======================================== */

.toast {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(31, 41, 55, 0.95);
    color: white;
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 14px 22px;
    border-radius: var(--radius-full);
    font-size: 15px;
    line-height: 1.45;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 12000;
    box-shadow: var(--shadow-lg);
    white-space: normal;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   ALERT ANIMATION (THEMES)
   ======================================== */

@keyframes alertStripe {
    0% { opacity: calc(0.1 * var(--alert-opacity)); }
    100% { opacity: var(--alert-opacity); }
}

body.alert-active::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    
    /* Mask to create border only */
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    
    padding: 24px; /* Border width */
    animation: alertStripe 0.8s infinite alternate;
}

body.alert-active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9998;
    animation: alertStripe 0.8s infinite alternate-reverse;
    opacity: var(--alert-opacity); /* Apply opacity to overlay too */
}

/* Theme: Hazard (Default) - Black/Yellow */
body.alert-active.theme-hazard::after {
    background: repeating-linear-gradient(
        45deg,
        #F59E0B,
        #F59E0B 40px,
        #1F2937 40px,
        #1F2937 80px
    );
    box-shadow: inset 0 0 50px rgba(245, 158, 11, 0.3);
}
body.alert-active.theme-hazard::before {
    background: rgba(245, 158, 11, 0.3);
}

/* Theme: Emergency - Red Only */
body.alert-active.theme-emergency::after {
    background: rgba(239, 68, 68, 0.6); /* Semi-transparent Red */
    box-shadow: inset 0 0 80px rgba(239, 68, 68, 0.8);
}
body.alert-active.theme-emergency::before {
    background: rgba(239, 68, 68, 0.3);
}

/* Theme: Cyber - Blue/Cyan */
body.alert-active.theme-cyber::after {
    background: repeating-linear-gradient(
        45deg,
        #3B82F6,
        #3B82F6 40px,
        #06B6D4 40px,
        #06B6D4 80px
    );
    box-shadow: inset 0 0 50px rgba(59, 130, 246, 0.3);
}
body.alert-active.theme-cyber::before {
    background: rgba(59, 130, 246, 0.3);
}

/* Theme: Bio - Black/Green */
body.alert-active.theme-bio::after {
    background: repeating-linear-gradient(
        45deg,
        #10B981,
        #10B981 40px,
        #1F2937 40px,
        #1F2937 80px
    );
    box-shadow: inset 0 0 50px rgba(16, 185, 129, 0.3);
}
body.alert-active.theme-bio::before {
    background: rgba(16, 185, 129, 0.3);
}

/* ========================================
   LEGEND PANEL - MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 767px) {
    .legend-panel {
        left: 10px;
        bottom: calc(92px + env(safe-area-inset-bottom));
        width: min(190px, calc(100vw - 20px));
        max-height: min(34dvh, 260px);
        min-height: 0;
    }

    .legend-content {
        max-height: calc(min(34dvh, 260px) - 42px);
        min-height: 0;
    }

    .legend-header {
        padding: 9px 11px;
        font-size: 13px;
    }

    .legend-item {
        padding: 7px 10px;
        gap: 8px;
    }

    .legend-icon {
        width: 28px;
        height: 28px;
    }

    .legend-name {
        font-size: 13px;
    }
}

/* 極小画面（高さ650px以下）での調整 */
@media (max-height: 650px) {
    .legend-panel {
        bottom: calc(82px + env(safe-area-inset-bottom));
        max-height: 30dvh;
    }

    .legend-content {
        max-height: calc(30dvh - 42px);
    }
}

/* 超極小画面（高さ550px以下、スマホ横向き等） */
@media (max-height: 550px) {
    .legend-panel {
        bottom: calc(94px + env(safe-area-inset-bottom));
        max-height: 28dvh;
        min-height: 0;
    }

    .legend-content {
        max-height: calc(28dvh - 42px);
        min-height: 0;
    }
}

/* ========================================
   RESPONSIVE (TABLET/DESKTOP)
   ======================================== */

@media (min-width: 768px) {
    /* Split View Layout */
    #splitViewContainer {
        flex-direction: row;
    }

    #mapContainer {
        width: 50%;
    }

    #photoPanel {
        width: 50%;
        display: none; /* Controlled by JS */
        position: relative;
        border-left: 1px solid #E5E7EB;
    }

    #photoPanel[style*="display: flex"] {
        display: flex !important;
    }

    #resizeHandle {
        display: block;
    }

    /* Modal becomes centered dialog */
    .modal-overlay {
        align-items: center;
    }

    .modal-container {
        border-radius: 20px;
        transform: scale(0.95);
        opacity: 0;
    }

    .modal-overlay.active .modal-container {
        transform: scale(1);
        opacity: 1;
    }

    /* Adjust FAB position */
    .fab-button {
        bottom: 40px;
        right: 24px;
    }
    
    /* Adjust Bottom Controls */
    #bottomControls {
        bottom: 40px;
    }
}

/* ========================================
   FULLSCREEN PHOTO MODE
   ======================================== */

body.fullscreen-photo-mode #photoPanel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    z-index: 5000;
    background: black;
}

body.fullscreen-photo-mode #photoPanelContent {
    justify-content: center;
    padding: 0;
}

body.fullscreen-photo-mode .panel-image-container {
    background: black;
    border-radius: 0;
    height: 100%;
    margin: 0;
}

body.fullscreen-photo-mode #photoPanelImage {
    height: 100%;
    object-fit: contain;
}

body.fullscreen-photo-mode .hazard-photo-viewer {
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
}

body.fullscreen-photo-mode .hazard-photo-viewer-image {
    object-fit: contain;
}

body.fullscreen-photo-mode .panel-header,
body.fullscreen-photo-mode #photoPanelDistance,
body.fullscreen-photo-mode #photoPanelDetails,
body.fullscreen-photo-mode #photoPanelNote,
body.fullscreen-photo-mode #photoPanelSummary,
body.fullscreen-photo-mode #photoPanelMessage,
body.fullscreen-photo-mode #photoPanelActions {
    display: none;
}

body.fullscreen-photo-mode #photoPanelClose {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    z-index: 10001 !important; /* Above alert overlay */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.3);
}

body.fullscreen-photo-mode #photoPanelClose:hover {
    background: rgba(255,255,255,0.4);
}

/* Mini Map in Fullscreen */
body.fullscreen-photo-mode #mapContainer {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 200px !important;
    height: 200px !important;
    border-radius: 12px;
    border: 2px solid white;
    box-shadow: var(--shadow-lg);
    z-index: 5002;
    display: block !important;
}

/* Hide controls in mini map */
body.fullscreen-photo-mode #appHeader,
body.fullscreen-photo-mode #bottomControls,
body.fullscreen-photo-mode .fab-button,
body.fullscreen-photo-mode .compass-widget {
    display: none !important;
}

/* Hide snow record controls in fullscreen mode */
body.fullscreen-photo-mode #snowRecordControls {
    display: none !important;
}
