/* ============================================================================
   APEX-MIND Web — Premium Racing Telemetry Platform
   A world-class motorsport analysis interface
   ============================================================================ */


/* ---------------------------------------------------------------------------
   1. DESIGN TOKENS
   --------------------------------------------------------------------------- */

:root {
    /* Backgrounds — deep space hierarchy */
    --bg-base:        #080812;
    --bg-primary:     #0b0f1a;
    --bg-secondary:   #0f1724;
    --bg-card:        #141c2e;
    --bg-input:       #0d1320;
    --bg-elevated:    #1a2540;

    /* Text hierarchy */
    --text-primary:   #e8ecf4;
    --text-secondary: #8892a8;
    --text-muted:     #4e5a70;
    --text-bright:    #ffffff;

    /* Racing accent palette */
    --accent:         #ff6b35;
    --accent-hover:   #ff8c5a;
    --accent-deep:    #cc4a1a;
    --cyan:           #00d4ff;
    --cyan-dim:       #0099bb;
    --green:          #00e676;
    --green-dim:      #00a854;
    --red:            #ff3d3d;
    --yellow:         #ffd740;

    /* Surfaces & borders */
    --border:         rgba(255, 255, 255, 0.06);
    --border-hover:   rgba(255, 107, 53, 0.4);
    --glass:          rgba(20, 28, 46, 0.8);
    --glass-border:   rgba(255, 255, 255, 0.08);

    /* Shadows & glows */
    --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md:      0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg:      0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-accent:  0 4px 24px rgba(255, 107, 53, 0.2);
    --shadow-cyan:    0 4px 24px rgba(0, 212, 255, 0.15);
    --glow-accent:    0 0 20px rgba(255, 107, 53, 0.3);
    --glow-cyan:      0 0 20px rgba(0, 212, 255, 0.25);
    --glow-green:     0 0 16px rgba(0, 230, 118, 0.2);

    /* Radii */
    --radius:         12px;
    --radius-sm:      8px;
    --radius-xs:      6px;
    --radius-full:    9999px;

    /* Typography */
    --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:      'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Timing */
    --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast:  150ms;
    --duration:       250ms;
    --duration-slow:  400ms;
}


/* ---------------------------------------------------------------------------
   2. RESET & BASE
   --------------------------------------------------------------------------- */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.65;
    overflow-x: hidden;
}


/* ---------------------------------------------------------------------------
   3. RACING LIVERY STRIPE + BACKGROUND
   --------------------------------------------------------------------------- */

/* Top racing stripe — 3px gradient bar like a livery stripe */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--accent) 0%,
        var(--cyan) 40%,
        var(--accent) 70%,
        var(--cyan) 100%
    );
    background-size: 200% 100%;
    animation: stripeShift 8s linear infinite;
    z-index: 9999;
}

@keyframes stripeShift {
    0%   { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* Carbon-fiber background texture */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(255, 107, 53, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.008) 2px,
            rgba(255, 255, 255, 0.008) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.005) 2px,
            rgba(255, 255, 255, 0.005) 4px
        );
    pointer-events: none;
    z-index: 0;
}


/* ---------------------------------------------------------------------------
   4. TYPOGRAPHY
   --------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

a {
    color: inherit;
    text-decoration: none;
}

.text-sm   { font-size: 0.85rem; }
.text-xs   { font-size: 0.75rem; }
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }


/* ---------------------------------------------------------------------------
   5. NAVBAR
   --------------------------------------------------------------------------- */

.navbar {
    position: sticky;
    top: 3px; /* below the racing stripe */
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: rgba(15, 23, 36, 0.85);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--glass-border);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-bright);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.navbar-brand .logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
    color: var(--text-bright);
    transition: transform var(--duration) var(--ease-spring),
                box-shadow var(--duration) var(--ease-out);
}

.navbar-brand:hover .logo {
    transform: scale(1.08) rotate(-2deg);
    box-shadow: var(--glow-accent);
}

.navbar-links {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.navbar-links a {
    position: relative;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-xs);
    transition: color var(--duration-fast), background var(--duration-fast);
}

.navbar-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.navbar-links a.active {
    color: var(--accent);
}

.navbar-links a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0.9rem;
    right: 0.9rem;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 2px 2px 0 0;
}


/* ---------------------------------------------------------------------------
   6. LAYOUT
   --------------------------------------------------------------------------- */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
    position: relative;
    z-index: 1;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
    background: linear-gradient(135deg, var(--text-bright) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}


/* ---------------------------------------------------------------------------
   7. CARDS & GLASSMORPHISM
   --------------------------------------------------------------------------- */

.card {
    background: var(--glass);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: border-color var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out),
                transform var(--duration) var(--ease-out);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md),
                inset 0 1px 0 rgba(255, 107, 53, 0.06);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

/* Glass utility class */
.glass {
    background: var(--glass);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border: 1px solid var(--glass-border);
}


/* ---------------------------------------------------------------------------
   8. UPLOAD ZONE
   --------------------------------------------------------------------------- */

.upload-zone {
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 4.5rem 2rem;
    text-align: center;
    cursor: pointer;
    background: linear-gradient(
        180deg,
        rgba(20, 28, 46, 0.6) 0%,
        rgba(15, 23, 36, 0.8) 100%
    );
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--duration-slow) var(--ease-out);
    overflow: hidden;
}

/* Animated dashed border via pseudo-element */
.upload-zone::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(
        from var(--border-angle, 0deg),
        transparent 0%,
        var(--accent) 12%,
        transparent 24%,
        transparent 50%,
        var(--cyan) 62%,
        transparent 74%,
        transparent 100%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-out);
    animation: borderRotate 4s linear infinite;
}

.upload-zone:hover::before,
.upload-zone.dragover::before {
    opacity: 1;
}

.upload-zone:hover {
    border-color: transparent;
    background: linear-gradient(
        180deg,
        rgba(255, 107, 53, 0.06) 0%,
        rgba(15, 23, 36, 0.9) 100%
    );
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-zone.dragover {
    border-color: transparent;
    background: linear-gradient(
        180deg,
        rgba(255, 107, 53, 0.1) 0%,
        rgba(0, 212, 255, 0.05) 100%
    );
    box-shadow: var(--glow-accent),
                var(--shadow-lg);
}

.upload-zone.uploading {
    border-color: transparent;
    background: linear-gradient(
        180deg,
        rgba(0, 212, 255, 0.06) 0%,
        rgba(15, 23, 36, 0.9) 100%
    );
    pointer-events: none;
}

.upload-zone .icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    display: block;
    animation: float 3s ease-in-out infinite;
}

.upload-zone .label {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-zone .hint {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.upload-zone input[type="file"] {
    display: none;
}


/* ---------------------------------------------------------------------------
   9. PROGRESS BAR
   --------------------------------------------------------------------------- */

.progress-bar {
    width: 80%;
    max-width: 400px;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 1.5rem auto 0;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    border-radius: var(--radius-full);
    transition: width 0.3s var(--ease-out);
    width: 0%;
    position: relative;
    box-shadow: 0 0 12px rgba(255, 107, 53, 0.4);
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 107, 53, 0.3); }
    50%      { box-shadow: 0 0 18px rgba(0, 212, 255, 0.5); }
}


/* ---------------------------------------------------------------------------
   10. BUTTONS
   --------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: all var(--duration) var(--ease-out);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
    color: var(--text-bright);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    border-radius: var(--radius-xs);
}


/* ---------------------------------------------------------------------------
   11. SESSION LIST & SESSION CARDS
   --------------------------------------------------------------------------- */

.session-list {
    display: grid;
    gap: 0.75rem;
}

.session-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: var(--glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-left: 3px solid;
    border-image: linear-gradient(to bottom, var(--accent), var(--cyan)) 1;
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: all var(--duration) var(--ease-out);
    animation: slideUp var(--duration-slow) var(--ease-out) backwards;
    animation-delay: calc(var(--delay, 0) * 80ms);
}

.session-card:hover {
    border-image: linear-gradient(to bottom, var(--accent-hover), var(--cyan)) 1;
    transform: translateY(-2px) translateX(2px);
    box-shadow: var(--shadow-md),
                inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.session-card .info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.session-card .info .meta {
    color: var(--text-secondary);
    font-size: 0.83rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.session-card .info .meta span::before {
    content: '';
    display: none;
}

.session-card .info .meta span + span::before {
    content: '\00b7';
    display: inline;
    margin-right: 0.6rem;
    color: var(--text-muted);
}

.session-card .stats {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.stat {
    text-align: center;
}

.stat .value {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.stat .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.15rem;
}


/* ---------------------------------------------------------------------------
   12. STATUS BADGES
   --------------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 1px solid transparent;
}

.badge-parsed    { background: rgba(0, 230, 118, 0.1);  color: var(--green);  border-color: rgba(0, 230, 118, 0.2); }
.badge-done      { background: rgba(0, 230, 118, 0.1);  color: var(--green);  border-color: rgba(0, 230, 118, 0.2); }
.badge-uploaded  { background: rgba(255, 215, 64, 0.1); color: var(--yellow); border-color: rgba(255, 215, 64, 0.2); }
.badge-error     { background: rgba(255, 61, 61, 0.1);  color: var(--red);    border-color: rgba(255, 61, 61, 0.2); }

.badge-analyzing,
.badge-parsing {
    background: rgba(0, 212, 255, 0.1);
    color: var(--cyan);
    border-color: rgba(0, 212, 255, 0.2);
    animation: glow 2s ease-in-out infinite;
}


/* ---------------------------------------------------------------------------
   13. KPI CARDS
   --------------------------------------------------------------------------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-top: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--accent), var(--cyan)) 1;
    border-image-slice: 1 0 0 0;
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    transition: transform var(--duration) var(--ease-spring),
                box-shadow var(--duration) var(--ease-out);
}

.kpi-card:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-md);
}

.kpi-card .value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 24px rgba(0, 212, 255, 0.3);
    line-height: 1.2;
}

.kpi-card .label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.35rem;
    font-weight: 500;
}


/* ---------------------------------------------------------------------------
   14. ANALYSIS PAGE LAYOUT
   --------------------------------------------------------------------------- */

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.25rem;
    margin-top: 1.25rem;
}

/* Report-focused mode: report dominates, chat slides out */
.analysis-layout-full {
    grid-template-columns: 1fr;
}

.analysis-layout-full .chat-panel {
    position: fixed;
    right: -420px;
    top: 63px;
    bottom: 0;
    width: 400px;
    z-index: 500;
    border-radius: 0;
    border-right: none;
    transition: right var(--duration-slow) var(--ease-out);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
}

.analysis-layout-full .chat-panel.open {
    right: 0;
}

.viz-frame {
    width: 100%;
    min-height: 600px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    transition: border-color var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out);
}

.viz-frame:hover {
    border-color: rgba(0, 212, 255, 0.2);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.06);
}

/* Analysis progress stepper */
.analysis-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
}

.analysis-progress .step {
    display: flex;
    align-items: center;
    gap: 0;
}

.analysis-progress .step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all var(--duration) var(--ease-out);
    position: relative;
}

.analysis-progress .step-dot.active {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: var(--glow-cyan);
    animation: glow 2s ease-in-out infinite;
}

.analysis-progress .step-dot.done {
    background: var(--green);
    border-color: var(--green);
    color: var(--text-bright);
}

.analysis-progress .step-line {
    width: 60px;
    height: 2px;
    background: var(--glass-border);
    transition: background var(--duration) var(--ease-out);
}

.analysis-progress .step-line.done {
    background: linear-gradient(90deg, var(--green), var(--cyan));
}

.analysis-progress .step-label {
    position: absolute;
    top: 100%;
    margin-top: 0.4rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ---------------------------------------------------------------------------
   15. CHAT PANEL
   --------------------------------------------------------------------------- */

.chat-panel {
    display: flex;
    flex-direction: column;
    height: 650px;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-msg {
    max-width: 88%;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    line-height: 1.55;
    animation: slideUp var(--duration) var(--ease-out);
    word-break: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
    color: var(--text-bright);
    border-bottom-right-radius: 3px;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

.chat-msg.system {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text-secondary);
    border-bottom-left-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-msg.thinking {
    align-self: flex-start;
    background: rgba(0, 212, 255, 0.06);
    color: var(--cyan-dim);
    font-style: italic;
    border: 1px solid transparent;
    border-bottom-left-radius: 3px;
    position: relative;
    overflow: hidden;
}

/* Animated gradient border for thinking state */
.chat-msg.thinking::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(
        var(--think-angle, 0deg),
        var(--cyan),
        transparent 40%,
        transparent 60%,
        var(--accent)
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: thinkRotate 3s linear infinite;
}

@keyframes thinkRotate {
    to { --think-angle: 360deg; }
}

@property --think-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.chat-input-area {
    display: flex;
    gap: 0;
    padding: 0.75rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.15);
}

.chat-input {
    flex: 1;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-full) 0 0 var(--radius-full);
    border: 1px solid var(--glass-border);
    border-right: none;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--duration-fast);
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

/* Integrated send button */
.chat-input-area .btn {
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
    padding: 0.7rem 1.1rem;
    min-width: unset;
}


/* ---------------------------------------------------------------------------
   16. LAP TABLE
   --------------------------------------------------------------------------- */

.lap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.lap-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.lap-table th {
    text-align: left;
    padding: 0.7rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--glass-border);
    background: var(--bg-card);
}

.lap-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    transition: background var(--duration-fast);
}

/* Alternating row opacity */
.lap-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.lap-table tbody tr:hover td {
    background: rgba(255, 107, 53, 0.06);
}

/* Best lap row */
.lap-table tr.best {
    position: relative;
}

.lap-table tr.best td {
    color: var(--green);
    font-weight: 600;
    background: rgba(0, 230, 118, 0.04);
    box-shadow: inset 3px 0 0 var(--green);
}

.lap-table tr.best td:first-child {
    border-left: 3px solid var(--green);
    box-shadow: var(--glow-green);
}

.lap-table tr.best:hover td {
    background: rgba(0, 230, 118, 0.08);
}


/* ---------------------------------------------------------------------------
   17. LOGIN
   --------------------------------------------------------------------------- */

.login-container {
    max-width: 420px;
    margin: 6rem auto;
    animation: slideUp var(--duration-slow) var(--ease-out);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.form-group input {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--duration-fast),
                box-shadow var(--duration-fast);
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}


/* ---------------------------------------------------------------------------
   18. FOOTER
   --------------------------------------------------------------------------- */

.footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 3rem;
    position: relative;
    z-index: 1;
}

.footer a {
    color: var(--text-secondary);
    transition: color var(--duration-fast);
}

.footer a:hover {
    color: var(--accent);
}


/* ---------------------------------------------------------------------------
   19. SCROLLBAR
   --------------------------------------------------------------------------- */

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 53, 0.25);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 53, 0.45);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 107, 53, 0.25) transparent;
}


/* ---------------------------------------------------------------------------
   20. KEYFRAME ANIMATIONS
   --------------------------------------------------------------------------- */

/* Gentle floating for upload icon */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* Skeleton loading shimmer */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-elevated) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* Rotating border for animated borders */
@keyframes borderRotate {
    0%   { --border-angle: 0deg; }
    100% { --border-angle: 360deg; }
}

@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Staggered card entrance */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulsing glow for active elements */
@keyframes glow {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

/* Fade in (legacy compat) */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Pulse (legacy compat) */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* Scale-in entrance */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* ---------------------------------------------------------------------------
   21. RESPONSIVE DESIGN
   --------------------------------------------------------------------------- */

/* Tablet */
@media (max-width: 1024px) {
    .analysis-grid {
        grid-template-columns: 1fr;
    }

    .chat-panel {
        height: 500px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        padding: 1.5rem;
    }

    .viz-frame {
        min-height: 450px;
    }
}

/* Mobile */
@media (max-width: 640px) {
    html {
        font-size: 15px;
    }

    .navbar {
        padding: 0 1rem;
        height: 54px;
    }

    .navbar-brand span {
        font-size: 1rem;
    }

    .navbar-links {
        gap: 0.15rem;
    }

    .navbar-links a {
        font-size: 0.82rem;
        padding: 0.4rem 0.6rem;
    }

    .container {
        padding: 1.25rem 1rem 2rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .page-subtitle {
        font-size: 0.88rem;
        margin-bottom: 1.5rem;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .kpi-card {
        padding: 1rem 0.75rem;
    }

    .kpi-card .value {
        font-size: 1.4rem;
    }

    .session-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }

    .session-card .stats {
        justify-content: flex-start;
    }

    .upload-zone {
        padding: 3rem 1.5rem;
    }

    .upload-zone .icon {
        font-size: 2.5rem;
    }

    .upload-zone .label {
        font-size: 1.05rem;
    }

    .analysis-grid {
        gap: 1rem;
    }

    .chat-panel {
        height: 450px;
    }

    .chat-msg {
        max-width: 92%;
    }

    .viz-frame {
        min-height: 350px;
    }

    .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .navbar-brand .logo {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
}


/* ---------------------------------------------------------------------------
   22. UTILITY CLASSES
   --------------------------------------------------------------------------- */

/* Visibility */
.hidden { display: none !important; }

/* Colors */
.text-accent  { color: var(--accent); }
.text-cyan    { color: var(--cyan); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* Glow effects */
.glow-accent {
    box-shadow: var(--glow-accent);
}

.glow-cyan {
    box-shadow: var(--glow-cyan);
}

/* Spacing */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Flex */
.flex { display: flex; }
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Animations */
.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.fade-in {
    animation: fadeIn 0.3s var(--ease-out);
}

/* Staggered entrance with custom delay */
.stagger-in {
    animation: slideUp var(--duration-slow) var(--ease-out) backwards;
    animation-delay: calc(var(--delay, 0) * 80ms);
}
