@tailwind base;
@tailwind components;
@tailwind utilities;

/*
 * VivaPro - Premium Handcrafted Design System v2
 *
 * Rejecting "SaaS Slop" in favor of strict, bespoke CSS layers.
 * Inspired by Linear's precision + organic handcrafted depth.
 * - Semantic text/surface/border hierarchy
 * - Complex overlapping box-shadows
 * - Custom cubic-bezier spring animations
 * - Distinct, human-made typography scales
 * - Organic mesh gradients and subtle textures
 * - Grid-dot decorative patterns
 */

/* ============================================
   1. Design Tokens
   ============================================ */

:root {
    /* --- Brand Palette --- */
    --color-coral: #F15D52;
    --color-coral-hover: #D54439;
    --color-coral-light: #FF9A62;

    --color-navy: #0B132B;
    --color-navy-muted: #1C2541;
    --color-navy-soft: #38485E;
    --color-navy-deep: #060A16;

    --color-cream: #FDFCF7;
    --color-white: #FFFFFF;

    /* --- Semantic Text Hierarchy (Linear-inspired) --- */
    --text-primary: #0B132B;
    --text-secondary: #38485E;
    --text-tertiary: #6B7A8D;
    --text-quaternary: #9CA8B7;

    /* --- Surface Hierarchy --- */
    --surface-base: #FDFCF7;
    --surface-raised: #FFFFFF;
    --surface-sunken: #F5F3EE;
    --surface-overlay: rgba(255, 255, 255, 0.7);

    /* --- Border Hierarchy --- */
    --border-default: rgba(11, 19, 43, 0.08);
    --border-hover: rgba(11, 19, 43, 0.15);
    --border-active: rgba(241, 93, 82, 0.4);

    /* --- Shadow Elevation Scale --- */
    --shadow-xs: 0 1px 2px rgba(11, 19, 43, 0.04);
    --shadow-sm: 0 2px 8px -2px rgba(11, 19, 43, 0.06), 0 1px 2px rgba(11, 19, 43, 0.04);
    --shadow-md: 0 8px 24px -8px rgba(11, 19, 43, 0.08), 0 2px 4px rgba(11, 19, 43, 0.03);
    --shadow-lg: 0 16px 40px -12px rgba(11, 19, 43, 0.12), 0 4px 8px rgba(11, 19, 43, 0.04);
    --shadow-luxury: 0 24px 60px -16px rgba(241, 93, 82, 0.15), 0 8px 16px rgba(11, 19, 43, 0.06);

    /* --- Radius Scale --- */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
    --radius-full: 999px;

    /* --- Typography --- */
    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Outfit', 'Playfair Display', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    /* --- Custom Easing (Buttery Smooth Spring Animations) --- */
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-organic: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Dark Mode Token Overrides --- */
.dark {
    --text-primary: #F2F0EC;
    --text-secondary: #D4D0CA;
    --text-tertiary: #B0ABA5;
    --text-quaternary: #8A857F;

    --surface-base: #0B132B;
    --surface-raised: #1C2541;
    --surface-sunken: #060A16;
    --surface-overlay: rgba(28, 37, 65, 0.7);

    --border-default: rgba(253, 252, 247, 0.06);
    --border-hover: rgba(253, 252, 247, 0.12);
    --border-active: rgba(241, 93, 82, 0.5);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
    --shadow-luxury: 0 24px 60px -16px rgba(241, 93, 82, 0.2), 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* ============================================
   2. Base Setup & Overrides
   ============================================ */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font-ui);
    background-color: var(--surface-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s var(--ease-organic), color 0.4s var(--ease-organic);
}

.dark body {
    background-color: var(--surface-base);
    color: var(--text-primary);
}

/* Typography Hierarchy */
h1,
h2,
h3,
.font-display {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

h4,
h5,
h6 {
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(56, 72, 94, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 72, 94, 0.4);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(253, 252, 247, 0.15);
}

/* ============================================
   3. Semantic Text Utilities
   ============================================ */

.text-hierarchy-primary {
    color: var(--text-primary);
}

.text-hierarchy-secondary {
    color: var(--text-secondary);
}

.text-hierarchy-tertiary {
    color: var(--text-tertiary);
}

.text-hierarchy-quaternary {
    color: var(--text-quaternary);
}

/* ============================================
   4. Buttons (Anti-Slop)
   ============================================ */

/* Base Premium Button */
.btn-premium {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    transition: all 0.4s var(--ease-spring);
    cursor: pointer;
    border: none;
    text-decoration: none;
    user-select: none;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* Primary CTA — Striking coral gradient */
.btn-primary {
    background: linear-gradient(135deg, var(--color-coral) 0%, var(--color-coral-light) 100%);
    color: var(--color-white);
    box-shadow:
        0 4px 14px 0 rgba(241, 93, 82, 0.39),
        0 1px 2px 0 rgba(241, 93, 82, 0.2) inset;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 6px 20px rgba(241, 93, 82, 0.4),
        0 2px 4px rgba(255, 255, 255, 0.3) inset;
    background: linear-gradient(135deg, var(--color-coral-hover) 0%, var(--color-coral) 100%);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 8px rgba(241, 93, 82, 0.3);
}

/* Secondary — Outline */
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-hover);
    box-shadow: var(--shadow-xs);
}

.dark .btn-secondary {
    color: var(--text-primary);
    border-color: rgba(253, 252, 247, 0.2);
}

.btn-secondary:hover {
    background: rgba(11, 19, 43, 0.03);
    border-color: rgba(11, 19, 43, 0.3);
    transform: translateY(-1px);
}

.dark .btn-secondary:hover {
    background: rgba(253, 252, 247, 0.05);
    border-color: rgba(253, 252, 247, 0.4);
}

/* Ghost Button — Minimal */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
}

.btn-ghost:hover {
    background: rgba(11, 19, 43, 0.04);
    color: var(--text-primary);
}

.dark .btn-ghost:hover {
    background: rgba(253, 252, 247, 0.04);
    color: var(--text-primary);
}

/* Danger Button */
.btn-danger {
    background: rgba(239, 68, 68, 0.08);
    color: #DC2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-full);
}

.btn-danger:hover {
    background: #DC2626;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

/* ============================================
   5. Forms & Inputs (Tactile & Precise)
   ============================================ */

.form-input-premium {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: 1rem;
    transition: all 0.3s var(--ease-out-expo);
    outline: none;
    background-color: var(--surface-raised);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.dark .form-input-premium {
    background-color: var(--color-navy-muted);
    border-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.form-input-premium:focus {
    border-color: var(--color-coral);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.02),
        0 0 0 4px rgba(241, 93, 82, 0.15);
    transform: translateY(-1px);
}

/* Premium Form Label */
.form-label-premium {
    display: block;
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    margin-bottom: 0.375rem;
}

/* Floating Label Container */
.floating-label-group {
    position: relative;
    margin-bottom: 0;
}

.floating-label-group label {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-tertiary);
    transition: all 0.3s var(--ease-spring);
    pointer-events: none;
    background: transparent;
    padding: 0 0.25rem;
}

.floating-label-group input:focus~label,
.floating-label-group input:not(:placeholder-shown)~label {
    top: 0;
    transform: translateY(-50%) scale(0.85);
    color: var(--color-coral);
    background-color: var(--surface-raised);
    border-radius: 4px;
}

.dark .floating-label-group input:focus~label,
.dark .floating-label-group input:not(:placeholder-shown)~label {
    background-color: var(--color-navy-muted);
}

/* ============================================
   6. Cards & Surfaces
   ============================================ */

/* Glass Card (Premium Frosted Surface) */
.glass-card {
    background: var(--surface-overlay);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    box-shadow:
        0 10px 30px -10px rgba(11, 19, 43, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: transform 0.4s var(--ease-spring), box-shadow 0.4s var(--ease-spring);
}

.dark .glass-card {
    background: rgba(28, 37, 65, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow:
        0 15px 35px -10px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.glass-card-hover:hover {
    transform: translateY(-6px);
    box-shadow:
        0 20px 40px -10px rgba(11, 19, 43, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: rgba(241, 93, 82, 0.2);
}

.dark .glass-card-hover:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-color: rgba(241, 93, 82, 0.3);
}

/* Feature Card (Landing page — hover accent bar) */
.feature-card {
    position: relative;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s var(--ease-spring);
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-coral), var(--color-coral-light));
    opacity: 0;
    transition: opacity 0.3s var(--ease-organic);
}

.feature-card:hover::before {
    opacity: 1;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.dark .feature-card {
    background: var(--surface-raised);
    border-color: var(--border-default);
}

/* Accent variants for feature cards */
.feature-card-indigo::before {
    background: linear-gradient(90deg, #6366F1, #818CF8);
}

.feature-card-violet::before {
    background: linear-gradient(90deg, #8B5CF6, #A78BFA);
}

.feature-card-emerald::before {
    background: linear-gradient(90deg, #10B981, #34D399);
}

/* Stat Card (Dashboard metrics) */
.stat-card {
    padding: 1.5rem 2rem;
    border-radius: var(--radius-lg);
    background: var(--surface-overlay);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-top: 3px solid var(--color-coral);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s var(--ease-organic);
}

.dark .stat-card {
    background: rgba(28, 37, 65, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
    border-top-color: var(--color-coral);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

/* Modal */
.modal-card {
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s var(--ease-spring) forwards;
}

.modal-backdrop {
    background: rgba(11, 19, 43, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dark .modal-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

/* Summary Modal Tabs */
.summary-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.summary-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-tertiary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.summary-tab:hover {
    color: var(--text-primary);
}

.summary-tab.active {
    color: var(--color-coral);
    border-bottom-color: var(--color-coral);
}

.dark .summary-tab.active {
    color: var(--color-coral-light);
    border-bottom-color: var(--color-coral-light);
}

/* Tab content panels — hidden by default, shown when active */
.summary-tab-content {
    display: none;
}

.summary-tab-content.active {
    display: block;
}

/* ============================================
   7. Sidebar Component System
   ============================================ */

.sidebar {
    width: 16rem;
    border-right: 1px solid var(--border-default);
    background: var(--surface-overlay);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
}

.sidebar-section-label {
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-quaternary);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s var(--ease-organic);
    text-decoration: none;
}

.sidebar-nav-item:hover {
    background: rgba(11, 19, 43, 0.04);
    color: var(--text-primary);
}

.dark .sidebar-nav-item:hover {
    background: rgba(253, 252, 247, 0.04);
}

.sidebar-nav-item.active {
    background: rgba(241, 93, 82, 0.08);
    color: var(--color-coral);
    font-weight: 700;
    border: 1px solid rgba(241, 93, 82, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.sidebar-nav-item.active-indigo {
    background: rgba(99, 102, 241, 0.08);
    color: #6366F1;
    font-weight: 700;
    border: 1px solid rgba(99, 102, 241, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.sidebar-user-card {
    padding: 0.75rem;
    border-top: 1px solid var(--border-default);
    background: rgba(0, 0, 0, 0.02);
}

.dark .sidebar-user-card {
    background: rgba(255, 255, 255, 0.02);
}

/* ============================================
   8. Organic Textures & Patterns
   ============================================ */

/* Mesh Glow (Organic radial gradients) */
.bg-mesh-glow {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 50%, rgba(241, 93, 82, 0.06), transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(11, 19, 43, 0.04), transparent 50%);
    filter: blur(40px);
}

.dark .bg-mesh-glow {
    background:
        radial-gradient(circle at 15% 50%, rgba(241, 93, 82, 0.1), transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(56, 72, 94, 0.15), transparent 50%);
}

/* Subtle Noise Overlay */
.subtle-noise {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Grid Dots (Linear-inspired decorative pattern) */
.bg-grid-dots {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, var(--text-quaternary) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.3;
    z-index: 0;
}

.dark .bg-grid-dots {
    opacity: 0.15;
}

/* ============================================
   9. Micro-interactions & Animations
   ============================================ */

/* Animated link underline */
.link-animated {
    position: relative;
    text-decoration: none;
    color: inherit;
}

.link-animated::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: var(--color-coral);
    transition: width 0.3s var(--ease-organic);
}

.link-animated:hover::after {
    width: 100%;
}

/* --- Keyframes --- */

@keyframes toastSlideIn {
    0% {
        transform: translateY(1rem) scale(0.95);
        opacity: 0;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes blurIn {
    from {
        opacity: 0;
        filter: blur(8px);
    }

    to {
        opacity: 1;
        filter: blur(0);
    }
}

@keyframes pulseGlow {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(241, 93, 82, 0.4);
    }

    50% {
        box-shadow: 0 0 0 12px rgba(241, 93, 82, 0);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

@keyframes shine {
    from {
        left: -100%;
    }

    to {
        left: 200%;
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Animation Utility Classes --- */

.animate-toast {
    animation: toastSlideIn 0.4s var(--ease-spring) forwards;
}

.animate-fade-slide-up {
    animation: fadeSlideUp 0.5s var(--ease-out-expo) forwards;
}

.animate-fade-slide-down {
    animation: fadeSlideDown 0.5s var(--ease-out-expo) forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s var(--ease-spring) forwards;
}

.animate-blur-in {
    animation: blurIn 0.6s var(--ease-organic) forwards;
}

.animate-pulse-glow {
    animation: pulseGlow 2s var(--ease-organic) infinite;
}

.animate-shake {
    animation: shake 0.3s var(--ease-spring);
}

.animate-count-up {
    animation: countUp 0.6s var(--ease-out-expo) forwards;
}

/* Shadow utility */
.shadow-luxury {
    box-shadow: var(--shadow-luxury);
}

/* ============================================
   10. VIVA Acronym Reveal (Landing Page)
   ============================================ */

.viva-letter {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1;
    transition: color 0.3s var(--ease-organic);
}

.viva-label {
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-tertiary);
}

/* ============================================
   11. Chat Panel (Slide-in from right)
   ============================================ */

.chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 24rem;
    max-width: 100vw;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--surface-raised);
    border-left: 1px solid var(--border-default);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.35s var(--ease-out-expo);
}

.dark .chat-panel {
    background: var(--color-navy-muted);
    border-left-color: rgba(255, 255, 255, 0.05);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
}

.chat-panel.open {
    transform: translateX(0);
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.dark .chat-panel-header {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

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

.chat-message {
    max-width: 90%;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message-content {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.chat-message.assistant .chat-message-content {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-default);
}

.dark .chat-message.assistant .chat-message-content {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.05);
}

.chat-message.user .chat-message-content {
    background: var(--color-coral);
    color: white;
    border: none;
}

/* Timestamp play buttons inside chat messages */
.chat-timestamp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    margin: 0.1rem 0.15rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--color-coral);
    background: rgba(241, 93, 82, 0.08);
    border: 1px solid rgba(241, 93, 82, 0.2);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
    vertical-align: middle;
}

.chat-timestamp-btn:hover {
    background: rgba(241, 93, 82, 0.15);
    border-color: rgba(241, 93, 82, 0.4);
    transform: scale(1.05);
}

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

.chat-timestamp-btn i {
    font-size: 0.875rem;
}

.dark .chat-timestamp-btn {
    color: var(--color-coral-light);
    background: rgba(241, 93, 82, 0.1);
    border-color: rgba(241, 93, 82, 0.25);
}

.dark .chat-timestamp-btn:hover {
    background: rgba(241, 93, 82, 0.2);
    border-color: rgba(241, 93, 82, 0.5);
}

.chat-input-container {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-default);
    flex-shrink: 0;
}

.dark .chat-input-container {
    border-top-color: rgba(255, 255, 255, 0.05);
}

/* Basic form-input (used by chat and modals) */
.form-input {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: 0.875rem;
    outline: none;
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dark .form-input {
    background: var(--color-navy-deep);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.form-input:focus {
    border-color: var(--color-coral);
    box-shadow: 0 0 0 3px rgba(241, 93, 82, 0.15);
}

/* ============================================
   12. Transcript Segments
   ============================================ */

/* Base segment card */
.transcript-segment {
    position: relative;
    padding: 1rem 2.5rem 1rem 1.25rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--color-coral);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    animation: fadeSlideIn 0.25s var(--ease-out-expo) forwards;
}

.dark .transcript-segment {
    background: rgba(28, 37, 65, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
    border-left-color: var(--color-coral);
}

.transcript-segment:hover {
    box-shadow: var(--shadow-sm);
}

/* Colored card mode (tab-only diarization) — border-left color set inline by JS */
.transcript-segment--colored {
    border-left-width: 3px;
    border-left-style: solid;
}

/* Chat bubble mode — "You" (right-aligned) */
.transcript-segment--you {
    border-left: none;
    background: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.dark .transcript-segment--you {
    background: transparent;
    border: none;
}

/* Chat bubble mode — other speaker (left-aligned) */
.transcript-segment--speaker {
    border-left: none;
    background: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.dark .transcript-segment--speaker {
    background: transparent;
    border: none;
}

/* Speaker bubbles */
.speaker-bubble {
    position: relative;
    max-width: 80%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border-radius: var(--radius-md);
    border-width: 1px;
    border-style: solid;
}

.speaker-bubble--left {
    background: var(--surface-raised);
    border-color: var(--border-default);
    border-left-width: 3px;
    border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 0.25rem;
}

.dark .speaker-bubble--left {
    background: rgba(28, 37, 65, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
}

.speaker-bubble--right {
    background: rgba(241, 93, 82, 0.06);
    border-color: rgba(241, 93, 82, 0.15);
    border-right-width: 3px;
    border-radius: var(--radius-md) var(--radius-md) 0.25rem var(--radius-md);
}

.dark .speaker-bubble--right {
    background: rgba(241, 93, 82, 0.08);
    border-color: rgba(241, 93, 82, 0.2);
}

/* Speaker labels */
.speaker-label {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-quaternary);
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

.speaker-label--right {
    text-align: right;
}

.speaker-label--left {
    text-align: left;
}

/* Speaker tag (colored mode) */
.speaker-tag {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.375rem;
}

/* Chunk number badge */
.chunk-number {
    position: absolute;
    top: 0.5rem;
    right: 0.625rem;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-quaternary);
    opacity: 0.5;
    font-family: var(--font-mono);
    line-height: 1;
}

.transcript-segment--you .chunk-number,
.transcript-segment--speaker .chunk-number {
    display: none;
}

/* Chunk text */
.chunk-text {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-primary);
    word-break: break-word;
}

/* Copy button on chunks */
.chunk-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-quaternary);
    border-radius: 0.375rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.transcript-segment:hover .chunk-copy-btn,
.speaker-bubble:hover .chunk-copy-btn {
    opacity: 1;
}

.chunk-copy-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}

.dark .chunk-copy-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* Word-level highlights (audio sync & teleprompter) */
.word-span {
    transition: color 0.15s ease, background 0.15s ease;
    border-radius: 2px;
    padding: 0 1px;
}

.word-span.word-active {
    background: rgba(241, 93, 82, 0.15);
    color: var(--color-coral);
}

.chunk-reading {
    border-left-color: var(--color-coral) !important;
    box-shadow: var(--shadow-sm);
}

.word-reading {
    background: rgba(241, 93, 82, 0.2);
    border-radius: 2px;
}

/* Audio playback word highlight */
.word-highlight {
    background: rgba(241, 93, 82, 0.25);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(241, 93, 82, 0.15);
    transition: background 0.15s ease;
}

/* Live word highlight (during recording) */
.word-live {
    background: rgba(241, 93, 82, 0.12);
    border-radius: 2px;
}

/* ============================================
   Viewer (Join Page) Layout
   ============================================ */

/* Transcript container — centered reading column */
.transcript-container-join {
    padding: 1.5rem 1rem;
}

@media (min-width: 768px) {
    .transcript-container-join {
        padding: 2rem 2rem;
    }
}

/* Center transcript cards and empty state within the scrolling container */
.transcript-container-join > .transcript-segment,
.transcript-container-join > [data-empty-state] {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   Viewer (Join Page) Controls
   ============================================ */

/* Bottom control bar */
.transcript-bottom-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--surface-raised);
    border-top: 1px solid var(--border-default);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.dark .transcript-bottom-bar {
    background: rgba(11, 19, 43, 0.8);
    border-color: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
}

.bar-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.bar-section label {
    color: var(--text-tertiary);
    font-weight: 500;
    font-size: 0.6875rem;
}

.bar-divider {
    width: 1px;
    height: 1rem;
    background: var(--border-default);
    flex-shrink: 0;
}

.dark .bar-divider {
    background: rgba(255, 255, 255, 0.1);
}

/* Auto-scroll toggle */
.auto-scroll-toggle {
    position: relative;
    display: inline-flex;
    width: 2.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    background: var(--border-default);
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.auto-scroll-toggle.active {
    background: var(--color-coral);
}

.auto-scroll-toggle .toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.auto-scroll-toggle.active .toggle-knob {
    transform: translateX(1rem);
}

/* Speed slider */
.speed-slider {
    width: 5rem;
    height: 0.375rem;
    border-radius: 9999px;
    appearance: none;
    background: var(--border-default);
    cursor: pointer;
}

.dark .speed-slider {
    background: rgba(255, 255, 255, 0.1);
}

.speed-slider::-webkit-slider-thumb {
    appearance: none;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--color-coral);
    cursor: pointer;
}

.speed-value {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    color: var(--text-tertiary);
    width: 1rem;
    text-align: center;
}

/* Chunk size controls */
.chunk-size-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0.5rem;
    padding: 0.125rem;
}

.dark .chunk-size-controls {
    background: rgba(255, 255, 255, 0.05);
}

.chunk-size-controls button {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.15s ease;
}

.chunk-size-controls button:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

.dark .chunk-size-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chunk-size-value {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-primary);
    width: 2rem;
    text-align: center;
}

/* Live badge */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-weight: 700;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.live-badge svg {
    width: 0.75rem;
    height: 0.75rem;
}

/* Recording time */
.rec-time {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.rec-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Header status indicator */
.viewer-indicator-compact {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--text-quaternary);
    flex-shrink: 0;
}

.status-dot.waiting {
    background: #f59e0b;
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.live {
    background: #10b981;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.ended {
    background: var(--text-quaternary);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Interim (in-progress) text */
.interim {
    color: var(--text-quaternary);
    font-style: italic;
}

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

/* ============================================
   13. Collapsible Side Panels
   ============================================ */

.side-panel {
    transition: width 0.3s var(--ease-out-expo), min-width 0.3s var(--ease-out-expo);
    will-change: width;
}

@media (min-width: 1024px) {
    .side-panel.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        overflow: hidden;
        border: none !important;
        padding: 0;
    }
}

/* Collapse toggle button (desktop only) */
.panel-collapse-btn {
    display: none;
}

@media (min-width: 1024px) {
    .panel-collapse-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 1.25rem;
        height: 2.5rem;
        flex-shrink: 0;
        align-self: center;
        background: var(--surface-raised);
        border: 1px solid var(--border-default);
        color: var(--text-quaternary);
        cursor: pointer;
        z-index: 30;
        transition: color 0.2s ease, background 0.2s ease;
    }

    .panel-collapse-btn:hover {
        color: var(--text-primary);
        background: var(--surface-sunken);
    }

    .dark .panel-collapse-btn {
        background: var(--color-navy-muted);
        border-color: rgba(255, 255, 255, 0.08);
    }

    .dark .panel-collapse-btn:hover {
        background: var(--color-navy-soft);
        color: var(--text-primary);
    }

    .panel-collapse-btn--left {
        border-radius: 0 0.375rem 0.375rem 0;
        margin-left: -1px;
    }

    .panel-collapse-btn--right {
        border-radius: 0.375rem 0 0 0.375rem;
        margin-right: -1px;
    }

    /* Flip chevron when panel is collapsed */
    .panel-collapse-btn .collapse-icon {
        transition: transform 0.3s var(--ease-out-expo);
    }

    .panel-collapse-btn--left.flipped .collapse-icon {
        transform: rotate(180deg);
    }

    .panel-collapse-btn--right.flipped .collapse-icon {
        transform: rotate(180deg);
    }
}

/* ============================================
   14. Responsive Helpers
   ============================================ */

.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: initial;
    }

    .show-mobile {
        display: none;
    }
}
