html, body, #react-entry-point {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

/* Fullscreen loader override for Dark Mode.
   We target the Dash loading components specifically rather than any div with a spinner,
   to avoid 'background strobe' when multiple fast callbacks fire. */

.dash-loading-callback,
._dash-loading-callback,
.dash-spinner-container {
    background-color: rgba(17, 17, 17, 0.7) !important;
}

/* Ensure the spinner itself doesn't have a white background */
.dash-spinner {
    background-color: transparent !important;
}

/* Suppress loading overlay flicker on graphs that update from clientside
   callbacks (hover, playback).  These fire at ~25 fps so even a brief
   loading-overlay flash produces a visible strobe effect. */
#speed-graph[data-dash-is-loading="true"] > ._dash-loading-callback,
#mini-track-map[data-dash-is-loading="true"] > ._dash-loading-callback,
#gg-diagram[data-dash-is-loading="true"] > ._dash-loading-callback,
#speed-graph .dash-spinner,
#mini-track-map .dash-spinner,
#gg-diagram .dash-spinner,
/* Also catch any child of these graphs that might be marked as loading */
#speed-graph [data-dash-is-loading="true"],
#mini-track-map [data-dash-is-loading="true"],
#gg-diagram [data-dash-is-loading="true"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Also prevent the parent loading wrapper from showing overlay bg */
#speed-graph > div[data-dash-is-loading],
#mini-track-map > div[data-dash-is-loading],
#gg-diagram > div[data-dash-is-loading],
[data-dash-is-loading="true"] {
    background-color: transparent !important;
}

/* Re-enable background for actual dcc.Loading wrappers that aren't the ones we suppressed above */
div:has(> .dash-spinner):not(#speed-graph-container):not(#mini-map-container) {
    background-color: rgba(17, 17, 17, 0.5);
}

/* Mobile-first guided layout. Desktop styles above remain unchanged. */
@media (max-width: 768px) {
    html, body, #react-entry-point {
        height: auto !important;
        min-height: 100%;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        background: #08090b;
    }

    .container-fluid {
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        background: #08090b;
    }

    .mobile-companion {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.65rem;
        align-items: center;
        position: sticky;
        top: 0;
        z-index: 1050;
        padding: calc(0.62rem + env(safe-area-inset-top, 0px)) 0.85rem 0.62rem;
        margin: 0;
        border: 0;
        border-bottom: 1px solid #2b2b2b;
        border-radius: 0;
        background: rgba(10, 10, 12, 0.96);
        backdrop-filter: blur(14px);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    }

    .mobile-companion > .experience-mode-control,
    .mobile-companion > .comparison-shortcuts {
        display: none !important;
    }

    .mobile-companion-title {
        min-width: 0;
    }

    .mobile-brand {
        font-size: 0.95rem;
        line-height: 1.05;
    }

    .mobile-session-summary {
        font-size: 0.78rem;
        line-height: 1.2;
        color: #d6d6d6;
        max-width: 58vw;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .mobile-action-buttons {
        grid-template-columns: repeat(2, minmax(62px, 1fr));
        gap: 0.42rem;
        min-width: 132px;
    }

    .mobile-action-buttons .btn {
        min-height: 40px;
        padding: 0.36rem 0.55rem;
        font-size: 0.82rem;
        font-weight: 800;
    }

    .sidebar-col,
    .content-col {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        border-right: none !important;
    }

    .sidebar-panel,
    .sidebar-col > div {
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .sidebar-panel {
        padding: 0.85rem !important;
        background: #08090b !important;
        border-bottom: 1px solid #262626;
    }

    .sidebar-header h2,
    .sidebar-header p,
    .sidebar-header hr,
    .sidebar-footer {
        display: none !important;
    }

    .experience-mode-wrap,
    .sidebar-control-field,
    .sidebar-driver-selector,
    .shortcut-wrap,
    .sidebar-leaderboard {
        margin-bottom: 0.7rem !important;
        padding: 0.72rem !important;
        border: 1px solid #2a2a2a;
        border-radius: 8px;
        background: #121417;
    }

    .sidebar-controls {
        display: block !important;
        padding-right: 0 !important;
        margin-bottom: 0 !important;
        overflow: visible !important;
    }

    .sidebar-control-field,
    .sidebar-driver-selector {
        min-width: 0;
    }

    .sidebar-control-label,
    .sidebar-driver-selector label {
        display: block;
        font-size: 0.86rem !important;
        line-height: 1.2;
        margin-bottom: 0.42rem !important;
        color: #e4e4e4;
        font-weight: 700;
    }

    .experience-mode-wrap .sidebar-control-label {
        color: #e4e4e4 !important;
        font-size: 0.86rem !important;
    }

    .experience-mode-control {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.42rem;
    }

    .experience-mode-input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .experience-mode-label {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 38px;
        padding: 0.3rem 0.38rem;
        text-align: center;
        font-size: 0.8rem;
    }

    .sidebar-controls .Select-control,
    .sidebar-controls .Select-placeholder,
    .sidebar-controls .Select-value,
    .sidebar-controls .Select-input {
        min-height: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 0.95rem !important;
    }

    .sidebar-controls .Select-menu-outer {
        font-size: 0.95rem !important;
        z-index: 1200;
    }

    .sidebar-driver-selector > div {
        align-items: stretch !important;
        gap: 0.45rem;
    }

    .sidebar-driver-selector button {
        min-width: 44px;
        padding: 0 0.65rem !important;
        font-size: 1rem !important;
    }

    .teammate-label {
        display: none !important;
    }

    .comparison-shortcuts {
        margin-bottom: 0 !important;
    }

    .comparison-shortcuts .btn,
    .sidebar-latest-btn,
    .sidebar-update-btn,
    .sidebar-leaderboard-btn {
        min-height: 42px;
        font-size: 0.86rem;
    }

    .sidebar-latest-btn,
    .sidebar-update-btn,
    .sidebar-leaderboard-btn {
        margin: 0 0 0.7rem !important;
    }

    .sidebar-divider {
        display: none;
    }

    .sidebar-leaderboard-title {
        font-size: 0.98rem !important;
        margin: 0 0 0.55rem !important;
        color: #f2f2f2;
    }

    .sidebar-leaderboard {
        max-height: 220px;
        overflow-y: auto;
    }

    .content-col {
        padding-bottom: 1rem !important;
    }

    .content-col > div {
        padding: 0.85rem !important;
    }

    #main-title {
        display: none;
    }

    .dashboard-action-row {
        display: block;
        margin: 0 0 0.75rem;
    }

    .loading-status-banner {
        min-height: 44px;
        padding: 0.58rem 0.68rem;
        font-size: 0.74rem;
        line-height: 1.18;
        border-radius: 8px;
        background: #121417;
    }

    .tab-content span[style*="F1 data"] {
        display: block;
        max-width: 100%;
        padding: 0 0.35rem;
        font-size: clamp(0.48rem, 2.6vw, 0.62rem) !important;
        line-height: 1.15 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .export-actions,
    .export-status {
        display: none !important;
    }

    .tab-container,
    div[class*="tab-container"] {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        margin: 0 -0.15rem 0.75rem;
        padding-bottom: 0.2rem;
    }

    .tab-parent {
        gap: 0.35rem;
    }

    .tab {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 104px;
        padding: 0.58rem 0.62rem !important;
        border: 1px solid #2d2d2d !important;
        border-radius: 8px !important;
        margin-right: 0.35rem !important;
        font-size: 0.82rem !important;
        font-weight: 700;
    }

    .tab--selected {
        border-color: #ff4444 !important;
    }

    .tab-label-with-tip .help-tip {
        display: none !important;
    }

    .telemetry-controls-panel,
    .trackmap-controls-panel,
    .telemetry-sidecar,
    #ai-response-output {
        border-radius: 8px !important;
        border: 1px solid #2a2a2a !important;
        background: #121417 !important;
    }

    .telemetry-controls-panel {
        padding: 0.72rem !important;
    }

    .telemetry-controls-panel .row {
        row-gap: 0.35rem;
    }

    .telemetry-controls-panel .col-12,
    .telemetry-controls-panel [class*="col-"] {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 0.35rem;
    }

    .telemetry-controls-panel input,
    .telemetry-controls-panel .btn,
    .trackmap-controls-panel .btn,
    .trackmap-controls-panel input {
        min-height: 40px;
        font-size: 0.86rem !important;
    }

    .trackmap-controls-panel {
        padding: 0.72rem !important;
        align-items: flex-start !important;
        flex-direction: column;
        gap: 0.45rem;
    }

    .js-plotly-plot .modebar {
        display: none !important;
    }

    #speed-graph,
    [id="2d-dominance-graph"],
    #grid-pace-graph {
        height: min(58vh, 520px) !important;
    }

    #strategy-graph,
    #deg-graph,
    #race-gaps-graph,
    #pit-stops-graph {
        height: min(46vh, 420px) !important;
    }

    #mini-track-map {
        height: 180px !important;
    }

    #gg-diagram {
        height: 220px !important;
    }

    .telemetry-sidecar {
        padding: 0.72rem !important;
        margin-top: 0.75rem !important;
    }

    #ai-question-input {
        min-height: 44px;
        font-size: 0.94rem !important;
    }

    #ai-ask-button {
        min-height: 44px;
    }

    .feedback-fab {
        position: static !important;
        display: block !important;
        width: calc(100% - 1.7rem);
        margin: 0.85rem;
        border-radius: 8px;
        opacity: 1;
    }
}

/* Tabs: horizontal scroll on narrow screens instead of truncation */
.tab-container,
div[class*="tab-container"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tab-container::-webkit-scrollbar {
    height: 3px;
}

.tab-container::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* Prevent tabs from wrapping — keep them in a single row */
.tab-parent {
    flex-wrap: nowrap !important;
    white-space: nowrap;
}

/* Smooth transitions for interactive elements */
.btn {
    transition: all 0.2s ease-in-out;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 0, 0, 0.3);
}

/* Tab hover effects */
.tab {
    transition: background-color 0.2s ease;
}

/* Leaderboard row hover */
#leaderboard-container > div:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Dropdown styling for better contrast */
.Select-control {
    transition: border-color 0.2s ease;
}

/* AI input focus glow */
#ai-question-input:focus {
    border-color: #ff0000 !important;
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.2) !important;
}

/* Notes textarea focus */
#session-notes:focus {
    border-color: #ff0000 !important;
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.2) !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: #111;
}
::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Inline loading spinners for dropdowns — keep them small and unobtrusive */
.dash-spinner:not(.dash-spinner--fullscreen) {
    min-height: 0 !important;
    padding: 0 !important;
}

.feedback-fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1100;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    opacity: 0.8;
}

.feedback-fab:hover {
    opacity: 1;
}

.modal-content {
    background-color: #101010;
    border: 1px solid #333;
}

.modal-header,
.modal-footer {
    border-color: #262626;
}

.modal-title,
.modal-body label {
    color: #f2f2f2;
}

#feedback-review-panel .card {
    background: linear-gradient(180deg, #171717 0%, #121212 100%);
    border: 1px solid #2d2d2d;
}

#feedback-review-panel .card-title,
#feedback-review-panel .card-text,
#feedback-review-panel .list-group-item {
    color: #e3e3e3;
}

.tab--disabled,
.tab[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .feedback-fab {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        width: auto;
        border-radius: 999px;
        padding: 0.5rem 0.85rem;
        font-size: 0.8rem;
        opacity: 0.92;
    }
}

/* Live Telemetry Dashboard Styling */
.live-dashboard-container {
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 5px 8px;
    margin-bottom: 6px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border-left: 3px solid #ff0000;
    transition: opacity 0.3s ease;
}

.live-driver-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px 0;
}

.live-driver-name {
    font-weight: 900;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0;
    flex: 0 0 46px;
}

.live-stats {
    display: flex;
    gap: 7px;
    flex: 1;
    justify-content: flex-end;
}

.stat-item {
    color: #888;
    font-size: 0.55rem;
    text-align: right;
    min-width: 45px;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 2px;
    justify-content: flex-end;
}

.stat-val {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    line-height: 1;
    display: inline-block;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Fixed widths to prevent jitter */
#live-d1-speed, #live-d2-speed { min-width: 32px; }
#live-d1-gear, #live-d2-gear { min-width: 12px; }
#live-d1-rpm, #live-d2-rpm { min-width: 44px; }

.stat-item small {
    font-size: 0.5rem;
    color: #555;
    font-weight: 700;
    text-transform: uppercase;
}

.live-delta-row {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1px 0;
    border-top: 1px solid #2a2a2a;
    border-bottom: 1px solid #2a2a2a;
    margin: 2px 0;
    background: rgba(255, 255, 255, 0.01);
}

.delta-label {
    font-size: 0.55rem;
    color: #777;
    margin-right: 6px;
    font-weight: 800;
    text-transform: uppercase;
}

.delta-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.82rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0;
}

/* Row color accents */
.d1-row { border-bottom: 1px solid rgba(255,255,255,0.05); }
.d2-row { border-top: 1px solid rgba(255,255,255,0.05); }

.experience-mode-wrap {
    margin-top: 0.55rem;
}

.experience-mode-control {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.experience-mode-label {
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.18rem 0.42rem;
    background: #171717;
    color: #bbb;
    cursor: pointer;
}

.experience-mode-input:checked + .experience-mode-label,
.experience-mode-label:has(input:checked) {
    color: #fff;
    border-color: #ff4444;
    background: #2a1414;
}

.comparison-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.7rem;
}

.comparison-shortcuts .btn {
    min-height: 30px;
    font-size: 0.72rem;
    padding: 0.22rem 0.35rem;
}

.comparison-shortcuts .btn-outline-secondary,
.export-actions .btn-outline-secondary {
    background: #263238;
    border-color: #546e7a;
    color: #f1f7fa;
}

.comparison-shortcuts .btn-outline-secondary:hover,
.comparison-shortcuts .btn-outline-secondary:focus,
.export-actions .btn-outline-secondary:hover,
.export-actions .btn-outline-secondary:focus {
    background: #37474f;
    border-color: #78909c;
    color: #fff;
}

#main-title {
    margin-top: 0.35rem !important;
    margin-bottom: 0.25rem !important;
    font-size: 1.35rem;
}

.dashboard-action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.55rem;
    margin: 0.15rem 0 0.25rem;
}

.loading-status-banner {
    flex: 1 1 auto;
    min-height: 28px;
    display: flex;
    align-items: center;
    padding: 0.22rem 0.5rem;
    border: 1px solid #333;
    border-radius: 6px;
    color: #cfcfcf;
    background: #151515;
    font-size: 0.82rem;
}

.status-loading,
.status-queued {
    border-color: #0d6efd;
    color: #d9e9ff;
}

.status-ready {
    border-color: #198754;
    color: #d8f6e4;
}

.status-error {
    border-color: #dc3545;
    color: #ffd9dd;
}

.export-actions {
    display: flex;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.export-status {
    min-height: 0;
    color: #aaa;
    font-size: 0.78rem;
    text-align: right;
    margin-top: -0.35rem;
    margin-bottom: 0;
}

.glossary-term {
    color: #f3f3f3;
    text-decoration: underline dotted #777;
    text-underline-offset: 0.16rem;
    cursor: help;
}

.label-with-tip {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-left: 0.28rem;
    border-radius: 50%;
    border: 1px solid #607d8b;
    background: #1b2a30;
    color: #eaf7fb;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
    cursor: help;
    vertical-align: middle;
}

.tab-label-with-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
}

.tab-label-with-tip .help-tip {
    width: 14px;
    height: 14px;
    margin-left: 0.16rem;
    font-size: 0.6rem;
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
}

.btn .help-tip {
    width: 14px;
    height: 14px;
    margin-left: 0.34rem;
    font-size: 0.62rem;
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.18);
    color: #fff;
}

.app-mode-engineer .help-tip,
.app-mode-intermediate .tip-beginner-only {
    display: none !important;
}

.app-mode-beginner .sidebar-footer > div {
    display: none;
}

.mobile-companion {
    display: none;
}

.mobile-brand {
    color: #ff4444;
    font-weight: 800;
    font-size: 0.9rem;
}

.mobile-session-summary {
    color: #ccc;
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.replay-focus-active .sidebar-col {
    display: none !important;
}

.replay-focus-active .content-col {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

.replay-focus-active #main-title,
.replay-focus-active .dashboard-action-row {
    display: none !important;
}

.replay-focus-active #speed-graph {
    height: 76vh !important;
}

.replay-focus-active .telemetry-sidecar {
    background: #101010 !important;
}

.btn:focus-visible,
.Select-control:focus-within,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #f5c542 !important;
    outline-offset: 2px;
}

/* Visual refresh: keep the dense dashboard workflow, but give controls and charts clearer hierarchy. */
:root {
    --surface-0: #07090d;
    --surface-1: #0d1218;
    --surface-2: #131a22;
    --surface-3: #1a242e;
    --line-soft: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text-main: #f4f7fa;
    --text-muted: #9ca9b6;
    --f1-red: #f43f46;
    --f1-red-deep: #a80f1f;
    --teal-accent: #22d3c5;
    --amber-accent: #f6c343;
    --control-radius: 8px;
}

html,
body,
.container-fluid {
    background:
        linear-gradient(135deg, rgba(244, 63, 70, 0.08), transparent 34%),
        linear-gradient(180deg, #080a0e 0%, #0c1118 48%, #090b10 100%) !important;
    color: var(--text-main);
    font-family: Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

.app-root {
    color: var(--text-main);
}

.sidebar-col {
    border-right: 1px solid var(--line-strong) !important;
    box-shadow: 18px 0 36px rgba(0, 0, 0, 0.28);
}

.sidebar-panel,
.sidebar-col > div {
    background:
        linear-gradient(180deg, rgba(244, 63, 70, 0.08) 0%, rgba(13, 18, 24, 0.98) 18%, rgba(8, 10, 14, 0.98) 100%) !important;
}

.sidebar-header h2 {
    color: #ffffff;
    letter-spacing: 0;
    line-height: 1.05;
}

.sidebar-header h2::after {
    content: "";
    display: block;
    width: 52px;
    height: 3px;
    margin-top: 0.42rem;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--f1-red), var(--teal-accent));
}

.sidebar-control-label,
.sidebar-driver-selector label,
.telemetry-sidecar-label {
    color: #c9d3dc !important;
    font-weight: 700;
}

.sidebar-control-field,
.sidebar-driver-selector,
.shortcut-wrap,
.experience-mode-wrap {
    border-radius: var(--control-radius);
}

.Select-control,
.Select-menu-outer {
    border-color: var(--line-strong) !important;
    border-radius: var(--control-radius) !important;
    background: #f6f8fb !important;
    box-shadow: none !important;
}

.form-control,
.form-select {
    border-color: var(--line-strong) !important;
    border-radius: var(--control-radius) !important;
    background: #111821 !important;
    color: var(--text-main) !important;
    box-shadow: none !important;
}

.Select-control:hover,
.Select.is-focused > .Select-control,
.form-control:focus,
.form-select:focus {
    border-color: var(--teal-accent) !important;
    box-shadow: 0 0 0 2px rgba(34, 211, 197, 0.18) !important;
}

.Select-menu-outer {
    overflow: hidden;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.36) !important;
}

.btn {
    border-radius: var(--control-radius);
    font-weight: 800;
    letter-spacing: 0;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.btn-danger,
.btn-success {
    border-color: transparent !important;
    background: linear-gradient(180deg, #ff4b52 0%, var(--f1-red-deep) 100%) !important;
    color: #fff !important;
    box-shadow: 0 8px 18px rgba(168, 15, 31, 0.28);
}

.btn-success {
    background: linear-gradient(180deg, #28d07f 0%, #158a57 100%) !important;
    box-shadow: 0 8px 18px rgba(21, 138, 87, 0.24);
}

.btn-info {
    background: linear-gradient(180deg, #34d5e6 0%, #0e7c8c 100%) !important;
    border-color: transparent !important;
    color: #051013 !important;
}

.btn-secondary,
.btn-outline-secondary {
    background: #1a2630 !important;
    border-color: #41505e !important;
    color: #edf5fa !important;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.32);
}

.experience-mode-label {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    color: #d5dde5;
    font-weight: 800;
}

.experience-mode-input:checked + .experience-mode-label,
.experience-mode-label:has(input:checked) {
    background: linear-gradient(180deg, rgba(244, 63, 70, 0.28), rgba(244, 63, 70, 0.12));
    border-color: rgba(244, 63, 70, 0.9);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#main-title {
    color: #ffffff;
    font-weight: 900;
    letter-spacing: 0;
}

.dashboard-action-row,
.telemetry-controls-panel,
.trackmap-controls-panel,
.telemetry-sidecar,
#ai-response-output {
    background: rgba(13, 18, 24, 0.92) !important;
    border: 1px solid var(--line-soft) !important;
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
}

.loading-status-banner {
    background: rgba(15, 21, 28, 0.9);
    border-color: var(--line-soft);
    color: #dbe4ec;
}

.status-loading,
.status-queued {
    border-color: rgba(34, 211, 197, 0.65);
    color: #dffdfa;
}

.status-ready {
    border-color: rgba(40, 208, 127, 0.6);
    color: #ddf8e9;
}

.tab-container,
div[class*="tab-container"] {
    border-bottom: 1px solid var(--line-soft);
}

.tab {
    background: #111821 !important;
    border: 1px solid var(--line-soft) !important;
    color: #c8d2dc !important;
    font-weight: 850;
}

.tab:hover {
    background: #172332 !important;
    color: #ffffff !important;
}

.tab--selected {
    background: linear-gradient(180deg, #f44a52 0%, #a80f1f 100%) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 24px rgba(168, 15, 31, 0.28);
}

.tab--disabled,
.tab[disabled] {
    background: #101318 !important;
    color: #6f7b86 !important;
}

.js-plotly-plot {
    border-radius: var(--control-radius);
}

.js-plotly-plot .plotly .modebar {
    opacity: 0.28;
    transition: opacity 0.16s ease;
}

.js-plotly-plot:hover .plotly .modebar {
    opacity: 1;
}

.live-dashboard-container {
    background: rgba(9, 14, 20, 0.94);
    border-color: var(--line-strong);
    border-left-color: var(--teal-accent);
}

#leaderboard-container > div {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

#leaderboard-container strong {
    text-shadow: 0 0 16px currentColor;
}

.feedback-fab {
    background: linear-gradient(180deg, #ff4b52 0%, #a80f1f 100%) !important;
    border-color: transparent !important;
}

.modal-content {
    background: #0d1218;
    border-color: var(--line-strong);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.58);
}

.phone-disclaimer-modal .modal-content {
    border-top: 3px solid var(--f1-red);
}

.phone-disclaimer-modal .modal-title {
    font-weight: 900;
}

.phone-disclaimer-modal .modal-body {
    color: #edf3f7;
    line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }

    .btn:hover {
        transform: none;
    }
}

@media (max-width: 768px) {
    .mobile-companion {
        background: rgba(8, 12, 17, 0.96) !important;
        border-bottom-color: var(--line-strong) !important;
    }

    .mobile-brand {
        color: #ffffff;
    }

    .mobile-brand::before {
        content: "";
        display: inline-block;
        width: 8px;
        height: 8px;
        margin-right: 0.42rem;
        border-radius: 50%;
        background: var(--f1-red);
        box-shadow: 0 0 16px rgba(244, 63, 70, 0.75);
        vertical-align: 0.08rem;
    }

    .sidebar-panel {
        background: #080c11 !important;
    }
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 768px) {
    .replay-focus-active .content-col {
        padding-bottom: 0.5rem !important;
    }

    .replay-focus-active #speed-graph {
        height: 62vh !important;
    }

    .mobile-companion {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: 0.65rem !important;
        align-items: center !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1050 !important;
        padding: calc(0.62rem + env(safe-area-inset-top, 0px)) 0.85rem 0.62rem !important;
        margin: 0 !important;
        border: 0 !important;
        border-bottom: 1px solid #2b2b2b !important;
        border-radius: 0 !important;
        background: rgba(10, 10, 12, 0.96) !important;
        backdrop-filter: blur(14px);
    }

    .mobile-companion > .experience-mode-control,
    .mobile-companion > .comparison-shortcuts {
        display: none !important;
    }

    .mobile-session-summary {
        max-width: 58vw;
        font-size: 0.68rem;
        line-height: 1.12;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: normal;
        overflow-wrap: anywhere;
    }

    #main-title {
        max-width: 100%;
        overflow: visible;
        white-space: normal;
        overflow-wrap: anywhere;
        text-wrap: balance;
        font-size: clamp(0.86rem, 4.4vw, 1.08rem) !important;
        line-height: 1.12 !important;
        margin: 0.1rem 0 0.25rem !important;
    }

    .mobile-action-buttons {
        grid-template-columns: repeat(2, minmax(62px, 1fr));
        gap: 0.42rem;
        min-width: 132px;
    }

    .experience-mode-control {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.42rem;
    }

    .experience-mode-input {
        position: absolute !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .experience-mode-label {
        display: flex !important;
        justify-content: center;
        align-items: center;
        min-height: 38px;
        text-align: center;
    }

    .tab-container,
    div[class*="tab-container"] {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
    }

    .tab {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 104px !important;
    }

    .feedback-fab {
        position: static !important;
        display: none !important;
        width: calc(100% - 1.7rem) !important;
        margin: 0.85rem !important;
        border-radius: 8px !important;
        opacity: 1 !important;
    }

    /* Guided mobile flow: hide desktop training aids and only reveal the current step. */
    .help-tip,
    .experience-mode-wrap {
        display: none !important;
    }

    .mobile-action-buttons,
    #mobile-open-feedback-modal-btn,
    #mobile-update-dashboard-btn,
    #mobile-share-btn {
        display: none !important;
    }

    .mobile-flow-loaded .mobile-action-buttons {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(58px, 1fr)) !important;
        min-width: 204px;
    }

    .mobile-flow-loaded .mobile-action-buttons .btn {
        min-height: 38px;
        padding: 0.32rem 0.35rem;
        font-size: 0.76rem;
    }

    .mobile-flow-loaded #mobile-open-feedback-modal-btn,
    .mobile-flow-loaded #mobile-share-btn {
        display: block !important;
    }

    .sidebar-leaderboard-title,
    .sidebar-leaderboard-btn,
    .sidebar-leaderboard {
        display: none !important;
    }

    .mobile-flow-needs-session .sidebar-driver-selector,
    .mobile-flow-needs-session .shortcut-wrap,
    .mobile-flow-needs-session .sidebar-update-btn,
    .mobile-flow-needs-session .content-col,
    .mobile-flow-needs-drivers .sidebar-update-btn,
    .mobile-flow-needs-drivers .content-col,
    .mobile-flow-ready .content-col {
        display: none !important;
    }

    .mobile-flow-needs-drivers .sidebar-latest-btn,
    .mobile-flow-ready .sidebar-latest-btn,
    .mobile-flow-loaded .sidebar-latest-btn,
    .mobile-flow-loaded .sidebar-update-btn {
        display: none !important;
    }

    .mobile-flow-ready .sidebar-update-btn {
        display: block !important;
    }

    .mobile-flow-ready .sidebar-update-btn::before {
        content: "Load Comparison";
        display: inline;
    }

    .mobile-flow-ready .sidebar-update-btn {
        color: transparent !important;
        position: relative;
    }

    .mobile-flow-ready .sidebar-update-btn::before {
        color: #fff;
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-flow-ready.mobile-load-pending .sidebar-update-btn::before {
        content: "Loading...";
        padding-left: 1rem;
    }

    .mobile-flow-ready.mobile-load-pending .sidebar-update-btn::after {
        content: "";
        position: absolute;
        left: calc(50% - 3.6rem);
        top: 50%;
        width: 14px;
        height: 14px;
        margin-top: -7px;
        border: 2px solid rgba(255, 255, 255, 0.35);
        border-top-color: #fff;
        border-radius: 999px;
        animation: mobile-load-spin 0.8s linear infinite;
    }

    @keyframes mobile-load-spin {
        to {
            transform: rotate(360deg);
        }
    }

    .telemetry-controls-panel .row:first-child,
    #replay-focus-btn {
        display: none !important;
    }

    .mobile-flow-loaded:not(.mobile-setup-open) .sidebar-col {
        display: none !important;
    }

    .mobile-flow-loaded.mobile-setup-open .sidebar-col {
        display: block !important;
    }

    .mobile-flow-loaded .mobile-action-buttons {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(58px, 1fr)) !important;
        min-width: 204px;
    }

    .mobile-flow-loaded .mobile-action-buttons .btn {
        min-height: 38px;
        padding: 0.32rem 0.35rem;
        font-size: 0.76rem;
    }

    .mobile-flow-loaded #mobile-open-feedback-modal-btn,
    .mobile-flow-loaded #mobile-edit-selection-btn,
    .mobile-flow-loaded #mobile-share-btn {
        display: block !important;
    }

    .mobile-flow-loaded #mobile-update-dashboard-btn {
        display: none !important;
    }

    .telemetry-controls-panel .form-check,
    .trackmap-controls-panel .form-check {
        display: inline-flex !important;
        align-items: center !important;
        min-height: 0 !important;
        margin: 0 0.8rem 0.25rem 0 !important;
        padding-left: 0 !important;
        gap: 0.35rem;
    }

    .telemetry-controls-panel input[type="radio"],
    .trackmap-controls-panel input[type="radio"] {
        position: static !important;
        width: 14px !important;
        height: 14px !important;
        min-width: 14px !important;
        min-height: 14px !important;
        max-width: 14px !important;
        max-height: 14px !important;
        margin: 0 !important;
        transform: none !important;
        opacity: 1 !important;
        appearance: auto !important;
        -webkit-appearance: radio !important;
    }

    .telemetry-controls-panel .form-check-label,
    .trackmap-controls-panel .form-check-label {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.2 !important;
        font-size: 0.82rem !important;
    }

    .mobile-flow-loaded .dashboard-action-row {
        display: none !important;
    }

    .mobile-flow-loaded .content-col > div {
        padding: 0.45rem !important;
    }

    .mobile-flow-loaded .telemetry-controls-panel {
        padding: 0.45rem !important;
        margin-bottom: 0.35rem !important;
    }

    .mobile-flow-loaded .telemetry-controls-panel .row:nth-child(2) {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.4rem;
    }

    .mobile-flow-loaded .telemetry-controls-panel .row:nth-child(2) > [class*="col-"] {
        width: auto !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .mobile-flow-loaded #lap-playback-time-label {
        grid-column: 1 / -1;
        font-size: 0.72rem !important;
        text-align: center;
    }

    .mobile-flow-loaded .telemetry-visual-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) 132px;
        gap: 0.42rem;
        margin: 0 !important;
        width: 100% !important;
        min-height: 555px;
        max-height: 610px;
        height: clamp(555px, 70dvh, 610px);
        align-items: stretch;
    }

    .mobile-flow-loaded .telemetry-visual-grid > [class*="col-"] {
        width: auto !important;
        max-width: none !important;
        flex: none !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .mobile-flow-loaded #speed-graph,
    .mobile-flow-loaded #speed-graph > div,
    .mobile-flow-loaded #speed-graph .js-plotly-plot,
    .mobile-flow-loaded #speed-graph .plot-container,
    .mobile-flow-loaded #speed-graph .svg-container {
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
    }

    .mobile-flow-loaded .telemetry-sidecar {
        height: 132px !important;
        min-height: 0 !important;
        min-width: 0 !important;
        display: grid !important;
        grid-template-columns: minmax(0, 0.92fr) minmax(0, 0.9fr) minmax(0, 1.18fr);
        grid-template-rows: minmax(0, 1fr);
        gap: 0.28rem;
        padding: 0.26rem !important;
        margin-top: 0 !important;
        overflow: hidden !important;
    }

    .mobile-flow-loaded .telemetry-sidecar-label,
    .mobile-flow-loaded .telemetry-sidecar > hr {
        display: none !important;
    }

    .mobile-flow-loaded .live-dashboard-container {
        display: block !important;
        grid-column: 1;
        align-self: stretch;
        min-height: 0;
        overflow: hidden;
        padding: 0.26rem !important;
        margin-bottom: 0 !important;
    }

    .mobile-flow-loaded .live-driver-row {
        justify-content: space-between;
        align-items: center;
        min-height: 28px;
        gap: 0.22rem;
    }

    .mobile-flow-loaded .live-driver-name {
        flex: none;
        font-size: 0.66rem;
        text-align: left;
    }

    .mobile-flow-loaded .live-stats {
        display: flex !important;
        flex: 1;
        gap: 0.18rem;
        justify-content: flex-end;
        min-width: 0;
    }

    .mobile-flow-loaded .stat-item {
        min-width: 0;
        font-size: 0;
        gap: 0;
        align-items: center;
        flex-direction: column;
        line-height: 1;
    }

    .mobile-flow-loaded .stat-item small {
        display: block !important;
        font-size: 0.34rem;
        line-height: 1;
        color: #777;
        margin-top: 1px;
    }

    .mobile-flow-loaded .stat-val,
    .mobile-flow-loaded .delta-value {
        font-size: 0.64rem;
        min-width: 0 !important;
    }

    .mobile-flow-loaded .live-delta-row {
        flex-direction: column;
        gap: 0.1rem;
        padding: 0.35rem 0;
    }

    .mobile-flow-loaded .delta-label {
        margin-right: 0;
        font-size: 0.5rem;
    }

    .mobile-flow-loaded #mini-track-map,
    .mobile-flow-loaded #gg-diagram {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        min-width: 0 !important;
    }

    .mobile-flow-loaded #mini-track-map {
        grid-column: 2;
    }

    .mobile-flow-loaded #gg-diagram {
        grid-column: 3;
        position: relative;
    }

    .mobile-flow-loaded #gg-diagram::before {
        content: "G-Force";
        position: absolute;
        top: 2px;
        left: 0;
        right: 0;
        z-index: 2;
        color: #aaa;
        font-size: 0.52rem;
        font-weight: 800;
        line-height: 1;
        text-align: center;
        pointer-events: none;
    }

    .mobile-flow-loaded #gg-diagram .svg-container,
    .mobile-flow-loaded #gg-diagram .main-svg {
        width: 100% !important;
        height: 100% !important;
    }

    .mobile-flow-loaded .telemetry-sidecar > *,
    .mobile-flow-loaded .telemetry-sidecar .dash-graph,
    .mobile-flow-loaded .telemetry-sidecar .js-plotly-plot {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}
