html, body {
            overscroll-behavior: none;
            font-family: 'Inter', sans-serif;
            color: #E5E7EB; /* Light gray text for better contrast on dark overlay */
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        .video-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: #000;
            z-index: 1;
            overflow: hidden; /* Hide parts of video that go off-screen when zoomed */
        }
        #videoPlayer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: contain; /* Maintain aspect ratio */
            transform-origin: center center;
        }
        #overlayCanvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: contain;
            transform-origin: center center;
            z-index: 10;
            cursor: crosshair;
        }
        
        /* Overlays */
        .ui-overlay {
            position: absolute;
            z-index: 20;
            background-color: rgba(17, 24, 39, 0.8); /* Dark semi-transparent background */
            border-radius: 0.5rem;
            padding: 0.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        #top-display-overlay {
            display: none;
            top: 3.6rem;
            left: 50%;
            transform: translateX(-50%);
            align-items: center;
            background-color: rgba(17, 24, 39, 0.8);
            z-index: 30;
        }

        body.video-loaded #top-display-overlay {
            display: flex;
        }

        #tables-column {
            top: 6rem;
            right: 1rem;
            background-color: rgba(17, 24, 39, 0.8);
            /* width: 280px; */ /* Fixed width */
            max-height: calc(100vh - 7rem);
            overflow-y: auto;
            transition: opacity 0.3s, transform 0.3s;
        }
        #tables-column.hidden {
            opacity: 0;
            transform: translateX(20px);
            pointer-events: none;
        }

        #mobile-tables-column {
            display: none;
        }

        #shortcuts-overlay {
            top: 5rem;
            left: 1rem;
            background-color: rgba(17, 24, 39, 0.8);
            transition: opacity 0.3s, transform 0.3s;
        }
        

        #controls-overlay {
            bottom: 1rem;
            left: 50%;
            transform: translateX(-50%);
            width: 95%;
            max-width: 800px;
            background-color: rgba(17, 24, 39, 0.8);
            transition: opacity 0.3s, transform 0.3s;
        }
        #controls-overlay.hidden {
            opacity: 0;
            transform: translate(-50%, 20px);
            pointer-events: none;
        }

        /* Buttons and Controls */
        .controls-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
            gap: 0.4rem;
        }
        .button-primary, .button-secondary, .button-danger, .button-warning {
            color: white;
            padding: 0.4rem 0.6rem;
            border-radius: 0.375rem;
            font-weight: 500;
            transition: background-color 0.2s;
            border: 1px solid rgba(255, 255, 255, 0.1);
            cursor: pointer;
            font-size: 0.75rem;
        }
        .button-primary { background-color: #4F46E5; }
        .button-primary:hover { background-color: #4338CA; }
        .button-secondary { background-color: #4B5563; }
        .button-secondary:hover { background-color: #374151; }
        .button-danger { background-color: #DC2626; }
        .button-danger:hover { background-color: #B91C1C; }
        .button-warning { background-color: #F59E0B; }
        .button-warning:hover { background-color: #D97706; }

        /* Time Displays and Tables */
        .time-display { font-size: 1rem; font-weight: 600; color: #FFF; }
        .lap-time-table { width: 100%; margin-top: 0.5rem; border-collapse: collapse; }
        .lap-time-table th, .lap-time-table td { 
            border: 1px solid #374151; 
            padding: 0.2rem 0.4rem; 
            text-align: left; 
            font-size: 0.75rem;
        }
        .lap-time-table th { background-color: #1F2937; }
        #strokeCountDisplay { color: #FFF; font-size: 0.75rem; }
        h2 { color: #818CF8; font-size: 0.75rem; } /* Indigo-300 for titles */

        /* File Selector */
        #file-selector-container {
            position: relative;
            z-index: 100;
            background-color: #1F2937;
            color: #D1D5DB;
            margin-top: auto !important;
            margin-bottom: auto !important;
        }
        /* Speed Controls */
        .speed-btn {
            background-color: #4B5563; /* Same as button-secondary */
            color: white;
            padding: 0.2rem 0.5rem;
            border-radius: 0.375rem;
            font-size: 0.7rem;
            font-weight: 500;
            border: 1px solid rgba(255, 255, 255, 0.1);
            transition: background-color 0.2s;
        }

        .speed-btn:hover {
            background-color: #374151;
        }

        .speed-btn.active-speed {
            background-color: #4F46E5; /* Same as button-primary */
            cursor: default;
        }

        body.video-loaded footer {
            display: none !important;
        }

        body.video-loaded #cancel-warning-banner {
            display: none !important;
        }

        #mobileMenuOpenBtn, #mobileLeftDrawer, #mobileLeftDrawerOverlay {
            display: none;
        }

/* ================================================================== */
/* Mobile Pro Layout (max-width: 1200px)               */
/* ================================================================== */
@media (max-width: 1200px) {
    /* --- Base Layout --- */
    #main-content {
        display: none !important;
    }
    body.video-loaded #main-content {
        display: flex !important;
        flex-direction: column;
        height: 100vh;
        width: 100%;
        overflow: hidden;
    }
    .video-container {
        position: relative;
        width: 100%;
        height: 100vh; /* Full height */
    }
    #videoPlayer, #overlayCanvas {
        object-position: center center;
    }
    /* スマホ版では、画面を広く使うため常にヘッダーを非表示にする */
    #nav-header {
        display: none !important;
    }

    /* スマホ用左ドロワー（サイドナビゲーション） */
    #mobileMenuOpenBtn {
        display: block !important;
    }
    body.page-measure:not(.video-loaded) #mobileMenuOpenBtn {
        display: none !important;
    }
    #mobileLeftDrawer {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 16rem !important; /* w-64 */
        background-color: rgba(3, 7, 18, 0.98) !important; /* bg-gray-950/98 */
        border-right: 1px solid #1f2937 !important; /* border-gray-800 */
        z-index: 9999 !important; /* 最前面 */
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        padding: 1.5rem !important;
    }
    #mobileLeftDrawer.open {
        transform: translateX(0) !important;
    }
    #mobileLeftDrawerOverlay {
        display: none;
        position: fixed !important;
        inset: 0 !important;
        background-color: rgba(0, 0, 0, 0.6) !important;
        z-index: 9998 !important; /* ドロワーの背面 */
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }
    #mobileLeftDrawerOverlay.open {
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    /* 動画ロード後は操作の邪魔にならないようメニューボタンを少し透過 */
    body.video-loaded #mobileMenuOpenBtn {
        opacity: 0.4;
        background-color: rgba(17, 24, 39, 0.4);
    }
    body.video-loaded #mobileMenuOpenBtn:hover {
        opacity: 0.9;
        background-color: rgba(17, 24, 39, 0.9);
    }
    /* タイム・倍速コントロールを再生ボタン（.playback-controls）のすぐ上に配置 */
    body.video-loaded #top-display-overlay {
        display: flex !important;
        position: absolute !important;
        top: auto !important;
        bottom: 68px !important;
        left: 15px !important;
        transform: none !important;
        z-index: 30 !important;
        margin: 0 !important;
        background-color: rgba(17, 24, 39, 0.85) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
        pointer-events: auto !important;
    }

    /* --- UI Switching --- */
    #controls-overlay, #shortcuts-overlay, #tables-column {
        display: none !important;
    }

    #mobile-tables-column {
        display: block;
    }
    body.video-loaded #mobile-controls-overlay { 
        display: block !important; 
    }

    /* --- Mobile Controls Root --- */
    #mobile-controls-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: transparent;
        pointer-events: none;
    }

    /* パネルが開いている間は、背後のフローティング操作ボタンを隠して誤タップを防ぐ */
    #main-content:has(#right-panel.open) .playback-controls,
    #main-content:has(#right-panel.open) .record-buttons,
    #main-content:has(#right-panel.open) .panel-tab,
    #main-content:has(#right-panel.open) #top-display-overlay,
    #main-content:has(#bottom-panel.open) .playback-controls,
    #main-content:has(#bottom-panel.open) .record-buttons,
    #main-content:has(#bottom-panel.open) .panel-tab,
    #main-content:has(#bottom-panel.open) #top-display-overlay {
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.2s ease;
    }

    /* --- New Control Buttons --- */
    .playback-controls, .record-buttons, .panel-tab {
        pointer-events: auto;
        position: absolute;
        background-color: rgba(23, 23, 23, 0.85);
        border-radius: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 0 15px rgba(0,0,0,0.5);
        transition: opacity 0.2s ease;
    }

    .playback-controls {
        bottom: 15px;
        left: 15px;
        padding: 0.25rem;
    }

    .control-btn {
        background: none;
        border: none;
        color: white;
        font-size: 1.35rem;
        margin: 0 0.25rem;
        padding: 0.375rem;
        line-height: 1;
    }
    
    .play-pause-btn {
        background-color: #4F46E5;
        border-radius: 50%;
        width: 38px;
        height: 38px;
    }

    .frame-controls {
        display: flex;
        align-items: center;
    }

    .record-buttons {
        bottom: 50px;
        right: 10px;
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.4rem 0.25rem;
    }

    .record-btn {
        background: none;
        border: none;
        color: white;
        font-size: 0.75rem;
        background-color: rgba(60, 60, 60, 0.9);
        border-radius: 50%;
        width: 45px;
        height: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* --- Collapsible Panels & Tabs --- */
    .panel-tab {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        padding: 0.75rem 0.375rem;
        font-size: 0.9rem;
        cursor: pointer;
        z-index: 99;
    }

    .panel-close-btn {
        position: absolute;
        top: 1rem;
        right: 1rem;
        background-color: #374151 !important;
        border: none;
        color: white;
        font-size: 2rem;
        line-height: 1;
        cursor: pointer;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border-radius: 50%;
        z-index: 100;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        transition: background-color 0.2s;
    }
    .panel-close-btn:hover {
        background-color: #4B5563 !important;
    }

    .right-tab {
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        border-top-left-radius: 1.5rem;
        border-bottom-left-radius: 1.5rem;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .bottom-tab {
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        writing-mode: horizontal-tb;
        border-top-left-radius: 1.5rem;
        border-top-right-radius: 1.5rem;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        padding: 0.75rem 2.25rem;
    }

    .collapsible-panel {
        position: absolute;
        background-color: #111827 !important; /* 完全不透明に変更 */
        transition: transform 0.3s ease-in-out;
        z-index: 99 !important;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5), 0 5px 25px rgba(0, 0, 0, 0.5);
    }

    #right-panel {
        top: 0;
        right: 0;
        width: 100% !important; /* スマホでは全画面ドロワー */
        max-width: 360px; /* タブレット以上では最大360px */
        height: 100%;
        transform: translateX(100%);
        padding: 4rem 1.25rem 1.25rem 1.25rem !important; /* 閉じるボタンと被らないように余白を追加 */
        overflow-y: auto;
    }
    #right-panel.open {
        transform: translateX(0);
    }

    #bottom-panel {
        bottom: 0;
        left: 0;
        width: 100%;
        transform: translateY(100%);
        border-top: 1px solid #374151;
        padding-top: 3.5rem !important; /* 閉じるボタンと被らないように余白を追加 */
    }
    #bottom-panel.open {
        transform: translateY(0);
    }
    
    .panel-content {
        padding: 1.25rem;
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .panel-btn {
        width: 100% !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 0.5rem !important;
        background-color: #374151 !important;
        color: white;
        text-align: center;
        cursor: pointer;
        transition: background-color 0.2s;
    }
    .panel-btn:hover {
        background-color: #4B5563 !important;
    }

    /* 下部パネル内のFPS設定項目 */
    .fps-settings {
        display: flex !important;
        gap: 0.5rem !important;
        grid-column: span 2 !important; /* 横幅を広めに取る */
        margin-top: 0.25rem;
    }
    .fps-settings input {
        flex: 1 !important;
        background-color: #1F2937 !important;
        border: 1px solid #374151 !important;
        color: white !important;
        padding: 0.5rem !important;
        border-radius: 0.5rem !important;
        font-size: 0.85rem !important;
        width: auto !important;
    }
    .fps-settings button {
        background-color: #4F46E5 !important;
        color: white !important;
        border: none !important;
        padding: 0.5rem 1rem !important;
        border-radius: 0.5rem !important;
        font-size: 0.85rem !important;
        font-weight: 600 !important;
        cursor: pointer;
    }
}

/* ================================================================== */
/* Disabled Button & Tooltip Styles                                   */
/* ================================================================== */
button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-container .tooltip-text {
    visibility: hidden;
    width: 180px;
    background-color: #1f2937;
    color: #f3f4f6;
    text-align: center;
    border-radius: 6px;
    padding: 6px 10px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    margin-left: -90px;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 10px;
    border: 1px solid #374151;
    pointer-events: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ================================================================== */
/* Paid/Premium Feature Styles                                        */
/* ================================================================== */
.nav-btn-active {
    background-color: #374151 !important;
    color: #FFFFFF !important;
}

/* Onboarding tab active state */
.tab-active {
    border-color: #6366F1 !important;
    color: #818CF8 !important;
}

/* View transitions */
#dashboard-container, #settings-container, #onboarding-container, #main-content {
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom scrollbar for database lists */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #111827;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #4B5563;
}

/* Readonly overlay helpers */
.readonly-active .tempo-input,
.readonly-active .lap-input {
    border-color: transparent !important;
    background: transparent !important;
    pointer-events: none !important;
}

.readonly-active .delete-row-btn,
.readonly-active .add-row-btn {
    display: none !important;
}

/* アコーディオンのトランジション用 */
tr[id^="accordion-"] {
    transition: all 0.3s ease-in-out;
}
tr[id^="accordion-"].hidden {
    display: none;
}
tr[id^="row-"].bg-indigo-950\/20 {
    background-color: rgba(49, 46, 129, 0.2) !important;
}

/* Hide tooltip for enabled buttons */
.tooltip-container button:not(:disabled) + .tooltip-text {
    display: none !important;
}

