/* Modern Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: #000000;
    color: #ffffff;
    line-height: 1.5;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Mobile Controls */
.mobile-*-controls, .video-pair-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.mobile-btn {
    flex: 1 1 60px;
    min-width: 60px;
    height: 40px;
    font-size: 12px;
    padding: 0 8px;
    gap: 4px;
}

.settings-full-width {
    flex: 1 1 100% !important;
    min-width: 100px;
}

.mobile-settings-row {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.mobile-media-btn {
    width: 20px !important;
    height: 20px !important;
}

.mobile-media-btn svg {
    width: 12px !important;
    height: 12px !important;
}

/* Desktop Controls */
.desktop-*-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: 12px 0;
}

/* Video Pair on Mobile */
.video-pair-container {
    display: flex !important;
    gap: 12px;
    justify-content: space-around;
    flex: 1;
}

.video-card.mobile {
    flex: 1;
    max-width: 150px;
    min-width: 120px;
    aspect-ratio: 1;
}

/* Messages Container - UPDATED: iOS scrolling fix (remove hidden, add height) */
.messages-container {
    flex: 1;
    min-height: 0;
    position: relative;
    height: 100%;  /* Explicit for iOS flex scrolling */
}

/* Messages List - ENHANCED: iOS momentum + overscroll fix */
.messages-list {
    height: 100%;
    max-height: 100vh;  /* Fallback for safe areas on iOS */
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch !important;  /* Force iOS momentum */
    overscroll-behavior: contain;  /* Prevent parent bounce on iOS */
    transform: translateZ(0);  /* Hardware acceleration for smooth iOS scroll */
    -webkit-transform: translateZ(0);  /* iOS specific */
}

/* FIXED: iOS-compatible scrolling for messages */
.messages-container {
    flex: 1;
    min-height: 0;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.messages-list {
    flex: 1;
    height: 100%;
    padding: 24px;
    overflow-y: scroll;  /* Changed from 'auto' to 'scroll' for iOS */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;  /* iOS momentum scrolling */
    overscroll-behavior-y: contain;  /* Prevent iOS bounce interfering */
    transform: translate3d(0, 0, 0);  /* Force GPU acceleration */
    -webkit-transform: translate3d(0, 0, 0);
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    .messages-list {
        height: 100%;
        min-height: 100%;
        max-height: none;  /* Remove max-height on iOS */
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

.messages-list::-webkit-scrollbar {
    width: 4px;
}

.messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* iOS-Specific Scrolling Fix (Media Query) */
@supports (-webkit-touch-callout: none) {  /* Targets iOS Safari */
    .messages-list {
        -webkit-overflow-scrolling: touch !important;
        height: 100vh;  /* Full viewport for iOS safe areas */
        padding-bottom: env(safe-area-inset-bottom);  /* Extra padding for notch */
    }
    
    /* Ensure no clipping on iOS flex children */
    .messages-container {
        -webkit-mask: linear-gradient(transparent, black);  /* Fade if needed, but optional */
    }
}

/* App Container */
.app-container {
    height: 100vh;
    height: 100svh; /* Safe area viewport height */
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Setup Screen Styles */
.setup-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    visibility: visible;
    transition: all 0.5s ease;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.setup-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.setup-container {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 32px;
    max-width: 480px;
    width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.setup-header {
    text-align: center;
    margin-bottom: 32px;
}

.setup-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 8px;
}

.setup-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    font-weight: 400;
}

.setup-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.setup-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.optional {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

.section-desc {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: -8px;
}

/* Mode Selection */
.mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.mode-option {
    cursor: pointer;
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.4s ease;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.mode-option:active .mode-card::before {
    width: 200px;
    height: 200px;
}

.mode-option input[type="radio"]:checked + .mode-card {
    background: rgba(255, 255, 255, 0.15);
    border-color: #ffffff;
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
}

.mode-card svg {
    color: rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
}

.mode-option input[type="radio"]:checked + .mode-card svg {
    color: #ffffff;
}

.mode-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.mode-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

/* Topics Input */
.topics-input-container {
    position: relative;
}

.topic-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 14px 16px;
    color: #ffffff;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
}

.topic-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.topic-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    align-items: flex-start;
    align-content: flex-start;
}

.topic-tag {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #ffffff;
    animation: tagIn 0.3s ease;
}

@keyframes tagIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.topic-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    margin: 0;
    transition: color 0.2s ease;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topic-remove:hover {
    color: #ef4444;
}

.topics-placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    font-style: italic;
    display: flex;
    align-items: center;
    min-height: 40px;
}

/* Setup Footer */
.setup-footer {
    margin-top: 32px;
    text-align: center;
}

.start-chat-btn {
    width: 100%;
    height: 52px;
    background: #ffffff;
    color: #000000;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.2);
}

.start-chat-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    transition: all 0.4s ease;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.start-chat-btn:active::before {
    width: 300px;
    height: 300px;
}

.start-chat-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 255, 255, 0.3);
}

.start-chat-btn svg {
    flex-shrink: 0;
}

.setup-note {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
    max-width: 320px;
    margin: 0 auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .setup-screen {
        padding: 16px;
        align-items: flex-start;
        justify-content: flex-start;
        padding-top: 40px;
    }
    
    .setup-container {
        padding: 24px;
        border-radius: 20px;
        max-width: none;
        width: 100%;
    }
    
    .setup-logo {
        font-size: 1.5rem;
        gap: 10px;
    }
    
    .setup-subtitle {
        font-size: 15px;
    }
    
    .mode-options {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .mode-card {
        padding: 16px;
        flex-direction: row;
        text-align: left;
        gap: 12px;
    }
    
    .mode-card svg {
        width: 24px;
        height: 24px;
    }
    
    .mode-title {
        font-size: 15px;
    }
    
    .mode-desc {
        font-size: 12px;
    }
    
    .topic-input {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    .start-chat-btn {
        height: 48px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .setup-container {
        padding: 20px;
    }
    
    .setup-header {
        margin-bottom: 24px;
    }
    
    .setup-content {
        gap: 20px;
    }
    
    .setup-section {
        gap: 12px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .mode-card {
        padding: 14px;
        gap: 10px;
    }
    
    .setup-footer {
        margin-top: 24px;
    }
}

/* Initially hide main app */
.app-container.setup-mode {
    display: none;
}

/* Text-only mode styles */
.text-mode-header {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
}

.text-mode-header h3 {
    font-size: 16px;
    color: #ffffff;
    margin-bottom: 4px;
}

.text-mode-header p {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

.user-topics {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.user-topics h4 {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.topics-display {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.topic-pill {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 12px;
    color: #ffffff;
}

.no-topics {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.settings-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: auto;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}


/* Header */
.header {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px; /* space between image and text */
  font-size: 1.5rem; /* adjust text size */
  font-weight: bold;
}

.logo-img {
  height: 46px; /* adjust to your liking */
  width: auto;
}


.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Mobile Text Mode Styles */
.mobile-text-header {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    margin-bottom: 12px;
}

.text-mode-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}

.text-mode-indicator svg {
    color: rgba(255, 255, 255, 0.8);
}

/* Mobile Controls */
.mobile-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    margin-top: auto;
    padding-top: 8px;
}

.mobile-controls .control-btn {
    flex: 1;
    min-width: 80px;
    height: 40px;
    font-size: 12px;
    gap: 4px;
}

.mobile-controls .settings-btn.mobile {
    flex: 0 0 auto;
    min-width: 80px;
    height: 40px;
    padding: 0 12px;
    font-size: 11px;
    gap: 4px;
}

/* Mobile Video Card Adjustments */
.video-card.mobile {
    min-height: 140px;
    aspect-ratio: 1;
}

.video-card.mobile .video-container {
    height: calc(100% - 28px);
}

.video-card.mobile .media-controls {
    height: 28px;
}

.video-card.mobile .media-btn {
    width: 20px;
    height: 20px;
}

.video-card.mobile .video-label {
    font-size: 10px;
    padding: 3px 6px;
    top: 6px;
    left: 6px;
}

.video-card.mobile .placeholder-avatar {
    width: 32px;
    height: 32px;
}

.video-card.mobile .video-placeholder {
    font-size: 11px;
    gap: 6px;
}

/* Hide shortcuts and topics on mobile for both modes */
@media (max-width: 768px) {
    .shortcuts-info,
    .user-topics {
        display: none !important;
    }
    
    /* Ensure mobile controls are visible */
    .mobile-controls {
        display: flex !important;
    }
    
    /* Hide desktop video controls on mobile */
    .video-controls:not(.mobile-controls) {
        display: none;
    }
    
    /* Adjust video sidebar for mobile */
    .video-sidebar {
        flex-direction: row;
        padding: 10px 12px;
        gap: 10px;
        max-height: 180px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        align-items: center;
        justify-content: space-between;
    }
    
    /* Video cards in mobile layout */
    .video-sidebar .video-card {
        flex: 0 0 140px;
        min-width: 140px;
    }
    
    /* Mobile text mode specific adjustments */
    .video-sidebar .mobile-text-header {
        flex: 1;
        margin-bottom: 0;
        margin-right: 12px;
    }
    
    .video-sidebar .mobile-controls {
        flex: 0 0 auto;
        width: 20%;
        margin-top: 0;
        padding-top: 0;
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    .mobile-controls .control-btn {
        height: 36px;
        font-size: 11px;
        padding: 0 8px;
    }
    
    .mobile-controls .settings-btn.mobile {
        min-width: 60px;
        height: 36px;
        font-size: 10px;
    }
    
    .text-mode-indicator {
        font-size: 13px;
        gap: 6px;
    }
    
    .text-mode-indicator svg {
        width: 20px;
        height: 20px;
    }
    
    .video-card.mobile {
        flex: 0 0 120px;
        min-width: 120px;
        min-height: 120px;
    }
}

/* Extra small mobile */
@media (max-width: 360px) {
    .mobile-controls .control-btn,
    .mobile-controls .settings-btn.mobile {
        min-width: 60px;
        height: 32px;
        font-size: 10px;
        padding: 0 6px;
    }
    
    .video-card.mobile {
        flex: 0 0 100px;
        min-width: 100px;
        min-height: 100px;
    }
    
    .mobile-controls {
        gap: 6px;
    }
}

/* Low Quality Toggle (REWORKED: Fixed, Amazing UI/UX with Clean Bolt Icon) */
.quality-option {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px 20px;
    margin-top: 12px;  /* Space from mode options */
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);  /* Smooth iOS-like */
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: 52px;  /* Touch-friendly */
}

.quality-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.quality-option:active {
    transform: translateY(0) scale(0.98);  /* Subtle press */
}

/* Ripple Effect on Tap/Hover (Amazing Feedback) */
.quality-option::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: none;  /* Instant start */
    z-index: 0;
    pointer-events: none;
}

.quality-option:active::before {
    animation: ripple 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ripple {
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

.quality-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    z-index: 1;  /* Above ripple */
}

.quality-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;  /* Fully hide, but accessible */
    width: 0;
    height: 0;
}

.quality-toggle input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

/* Toggle Content (Icon + Switch + Text) */
.toggle-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.icon-speed {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.6);  /* Default muted */
    transition: all 0.3s ease;
}

.icon-speed path {
    transition: stroke 0.3s ease;  /* Inherit from icon */
}

.quality-toggle:hover .icon-speed {
    color: rgba(255, 255, 255, 0.8);
    transform: scale(1.05);  /* Subtle hover energy */
}

/* Switch Background and Knob */
.toggle-switch {
    position: relative;
    flex-shrink: 0;
    width: 48px;  /* Standard size */
    height: 28px;
    background: rgba(255, 255, 255, 0.1);  /* Off state */
    border-radius: 14px;  /* Pill */
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #ffffff;  /* White knob */
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Enabled State: Green Theme (Amazing Glow + Slide) */
.quality-toggle input[type="checkbox"]:checked + .toggle-content .toggle-switch {
    background: rgba(16, 185, 129, 0.4);  /* Green tint */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 8px rgba(16, 185, 129, 0.3);
}

.quality-toggle input[type="checkbox"]:checked + .toggle-content .toggle-switch::before {
    left: 23px;  /* Slide to right */
    background: #10b981;  /* Solid green */
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);  /* Glow */
}

.quality-toggle input[type="checkbox"]:checked + .toggle-content .icon-speed {
    color: #10b981;  /* Green bolt */
    animation: boltPulse 0.6s ease-out;  /* Subtle "strike" pulse */
}

@keyframes boltPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.quality-toggle input[type="checkbox"]:checked + .toggle-content .toggle-text {
    color: #10b981;  /* Green text */
    font-weight: 600;  /* Bold for emphasis */
}

/* Disabled State: Gray Out + Hint */
.quality-toggle input[type="checkbox"]:disabled + .toggle-content {
    opacity: 0.5;
    cursor: not-allowed;
}

.quality-toggle input[type="checkbox"]:disabled + .toggle-content .toggle-switch {
    background: rgba(255, 255, 255, 0.05);
}

.quality-toggle input[type="checkbox"]:disabled + .toggle-content .toggle-switch::before {
    background: rgba(255, 255, 255, 0.5);
}

.quality-toggle input[type="checkbox"]:disabled + .toggle-content .toggle-text::after {
    content: ' (Disabled in Text Mode)';  /* Clear hint */
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85em;
    font-style: italic;
    margin-left: 4px;
}

/* Text Styling */
.toggle-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
    line-height: 1.4;
}

/* Focus/Accessibility (High Contrast Ring) */
.quality-toggle:focus-within {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.5);  /* Green ring */
}

@media (prefers-reduced-motion: reduce) {
    .quality-toggle,
    .toggle-switch,
    .toggle-switch::before,
    .icon-speed {
        animation: none;
        transition: background-color 0.2s ease, color 0.2s ease;  /* Minimal */
    }
    
    .quality-option::before {
        display: none;
    }
}

/* Responsive (Mobile-First: Stacks, Larger Touch) */
@media (max-width: 768px) {
    .quality-option {
        padding: 14px 16px;
        gap: 12px;
        flex-direction: row;  /* Horizontal, but wrap if needed */
        min-height: 48px;
    }
    
    .quality-toggle {
        gap: 10px;
        padding: 4px;
    }
    
    .icon-speed {
        width: 18px;
        height: 18px;
    }
    
    .toggle-switch {
        width: 44px;  /* Smaller but touch-friendly (min 44px) */
        height: 24px;
    }
    
    .toggle-switch::before {
        width: 18px;
        height: 18px;
        top: 3px;
        left: 3px;
    }
    
    .quality-toggle input:checked + .toggle-content .toggle-switch::before {
        left: 21px;  /* Adjusted slide */
    }
    
    .toggle-text {
        font-size: 13px;
        max-width: 150px;  /* Prevent overflow */
    }
    
    .quality-option:hover {
        transform: none;  /* No lift on touch devices */
    }
}

@media (max-width: 480px) {
    .quality-option {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .toggle-text {
        font-size: 12px;
        text-align: center;  /* Center if wrapped */
        max-width: none;
    }
    
    .icon-speed {
        width: 16px;
        height: 16px;
    }
}

/* Landscape: Tight Space Adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .quality-option {
        padding: 10px 12px;
        gap: 8px;
        margin-top: 8px;
    }
    
    .toggle-text {
        font-size: 12px;
        white-space: normal;  /* Allow wrap */
    }
}
/* Messages (ENHANCED: Amazing animations and low-quality specific style) */
.messages-list {
    height: 100%;
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.messages-list::-webkit-scrollbar {
    width: 4px;
}

.messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages */
.message {
    display: flex;
    margin-bottom: 16px;
    animation: messageIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);  /* Bouncy entry for amazing feel */
    position: relative;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.you {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.you .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);  /* Deeper shadow */
    transition: all 0.3s ease;
}

.message-bubble:hover {
    transform: translateY(-1px);  /* Subtle lift on hover */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.message.you .message-bubble {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);  /* Gradient for premium */
    color: #000000;
    border-bottom-right-radius: 6px;
}

.message.partner .message-bubble {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.you .message-sender {
    color: rgba(0, 0, 0, 0.7);  /* Darker for user */
}

.message.system {
    justify-content: center;
    margin: 24px 0;
    animation-duration: 0.6s;  /* Slower for emphasis */
}

.message.system .message-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 16px;  /* Softer corners */
    padding: 12px 20px;  /* More padding */
    font-size: 14px;
    font-style: italic;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    position: relative;
    max-width: 90%;  /* Responsive width */
    text-align: center;
}

/* NEW: Specific Style for Low Quality System Message (Amazing: Icon + Glow) */
.low-quality-message .message-bubble {
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.15));  /* Green gradient */
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);  /* Glow + inner shine */
    animation: lowQualityIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);  /* Custom bouncy entry */
    position: relative;
    overflow: hidden;
}

.low-quality-message .message-bubble::before {  /* NEW: Lightning icon background */
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAABEklEQVR4nOXUO0vDUBiA4ergJP4BEZ10EJwdRXTSSdFBod7BoXhBEFE6iA4FBxEvILh4wc3f+MiBTyghxYaeRfzgkASa5w05obXavxks4BMfmMuNj+IL97jFU+7AQ0IDv8FLTnwR7214C4+58EG8FfDrdJ0rcBGvpx2/TOc58Cm8luDNdOwV7+/w5E2c4wx7mMVY+n3VQD0CrRL8FCc4RCNWio1XCTx3ie8HvoWdKoG7ingdG1UC0xG4ii/pN3wz3dN1ICJ9GMFMQEcd8PVY1Ta6JHhcgq9hF8M94Wni9RTxtOZrOQYHBXw1fTkYyBVoFPC0sZNZ8LbAD76CpVrOwXbgy7GxQ7kDExFJePd/C39+vgEgnDTNbPjcUgAAAABJRU5ErkJggg==");  /* Inline SVG for icon */
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.8;
    z-index: 1;
}

.low-quality-message .message-content {  /* Shift text right for icon */
    padding-left: 30px;  /* Space for icon */
}

@keyframes lowQualityIn {
    0% { 
        opacity: 0; 
        transform: translateY(15px) scale(0.9); 
        box-shadow: 0 2px 10px rgba(16, 185, 129, 0.1);
    }
    50% { 
        transform: translateY(-2px) scale(1.02); 
        box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2);
    }
}

.low-quality-message .message-bubble:hover {
    transform: translateY(-2px) scale(1.01);  /* Enhanced hover */
    box-shadow: 0 6px 30px rgba(16, 185, 129, 0.3);
}

/* General System Message Hover (Subtle Enhancement) */
.message.system .message-bubble:hover {
    background: rgba(255, 255, 255, 0.12);  /* Lighter on hover */
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Fade Out for Auto-Remove (From Your JS) */
.message.system.fading {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Desktop-only elements - ensure they show on desktop */
@media (min-width: 769px) {
    .mobile-controls {
        display: none;
    }
    
    .mobile-text-header {
        display: none;
    }
    
    .video-controls:not(.mobile-controls) {
        display: flex;
    }
    
    .shortcuts-info,
    .user-topics {
        display: block;
    }
}

.user-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.connection-dot.connecting {
    background: #f59e0b;
    animation: pulse 2s infinite;
}

.connection-dot.disconnected {
    background: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

/* Main Interface */
.main-interface {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

/* Video Sidebar */
.video-sidebar {
    width: 320px;
    background: rgba(18, 18, 18, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
    flex-shrink: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.video-card {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 4/3;
    transition: all 0.3s ease;
    min-height: 180px;
}

.video-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.video-container {
    width: 100%;
    height: calc(100% - 40px);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000000;
    border-radius: 16px 16px 0 0;
    display: block;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    z-index: 2;
}

.video-placeholder.active {
    display: flex;
}

.placeholder-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

.video-label {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 3;
}

/* Media Controls */
.media-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 0 0 16px 16px;
    z-index: 3;
}

.media-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.media-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.media-btn.muted {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.media-btn.muted:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Video Controls */
.video-controls {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 8px;
    height: -webkit-fill-available;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    align-items: center;
}

.control-btn {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.control-btn:active::before {
    width: 100px;
    height: 100px;
}

.control-btn.primary {
    background: #ffffff;
    color: #000000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.control-btn.primary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.control-btn svg {
    flex-shrink: 0;
}

/* Shortcuts Info */
.shortcuts-info {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
}

.shortcuts-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.shortcuts-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.9);
}

.shortcut span {
    color: rgba(255, 255, 255, 0.6);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #000000;
    position: relative;
}

/* Status Banner */
.status-banner {
    background: rgba(16, 185, 129, 0.15);
    border-bottom: 1px solid rgba(16, 185, 129, 0.3);
    padding: 12px 24px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.status-banner.waiting {
    background: rgba(245, 158, 11, 0.15);
    border-bottom-color: rgba(245, 158, 11, 0.3);
}

.status-banner.error {
    background: rgba(239, 68, 68, 0.15);
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.status-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-icon {
    color: #10b981;
    flex-shrink: 0;
}

.status-banner.waiting .status-icon {
    color: #f59e0b;
    animation: spin 2s linear infinite;
}

.status-banner.error .status-icon {
    color: #ef4444;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#statusMessage {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

/* Messages Container */
.messages-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.messages-list {
    height: 100%;
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.messages-list::-webkit-scrollbar {
    width: 4px;
}

.messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages */
.message {
    display: flex;
    margin-bottom: 16px;
    animation: messageIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.you {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.you .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.message.you .message-bubble {
    background: #ffffff;
    color: #000000;
    border-bottom-right-radius: 6px;
}

.message.partner .message-bubble {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.you .message-sender {
    color: rgba(255, 255, 255, 0.8);
}

.message.system {
    justify-content: center;
    margin: 24px 0;
}

.message.system .message-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 13px;
    font-style: italic;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Message Input */
.message-input-container {
    padding: 20px 24px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.input-wrapper {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 12px 60px 12px 20px;
    transition: all 0.3s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 15px;
    line-height: 1.4;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.message-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.send-button {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #ffffff;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.send-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.send-button:active {
    transform: translateY(-50%) scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Confirmation Dialog */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-content {
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.confirm-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.confirm-content p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.confirm-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.confirm-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.confirm-btn.stop {
    background: #ef4444;
    color: #ffffff;
}

.confirm-btn.stop:hover {
    background: #dc2626;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) {
    .video-sidebar {
        width: 280px;
        padding: 16px;
        gap: 12px;
    }
    
    .control-btn {
        height: 44px;
        font-size: 13px;
    }
    
    .messages-list {
        padding: 20px;
    }
    
    .message-input-container {
        padding: 16px 20px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .shortcuts-info {
        display: none;
    }
}

/* Mobile Portrait (up to 768px) */
@media (max-width: 768px) {
    .header {
        height: 56px;
        padding: 0 16px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .header-info {
        gap: 12px;
    }
    
    .user-count {
        font-size: 12px;
        padding: 3px 6px;
    }
    
    .status-indicator {
        font-size: 13px;
    }
    
    .main-interface {
        flex-direction: column;
    }
    
    .video-sidebar {
        width: 100%;
        flex-direction: row;
        display: flex;
        padding: 12px 16px;
        height: auto;
        max-height: 220px;
        gap: 20px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        align-content: center;
        justify-content: center;
        align-items: center;
    }
    
    .video-card {
        flex: 0 0 160px;
        min-width: 160px;
        aspect-ratio: 1;
        min-height: 160px;
    }
    
    .video-card:hover {
        transform: none;
    }
    
    .video-container {
        height: calc(100% - 32px);
    }
    
    .video-label {
        top: 8px;
        left: 8px;
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .placeholder-avatar {
        width: 36px;
        height: 36px;
    }
    
    .video-placeholder {
        font-size: 12px;
        gap: 8px;
    }
    
    .media-controls {
        height: 32px;
    }
    
    .media-btn {
        width: 24px;
        height: 24px;
        border-radius: 6px;
    }
    
    .media-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .video-controls {
        flex-direction: column;
        gap: 8px;
        width: auto;
        height: -webkit-fill-available;
        flex-shrink: 0;
        margin-top: 0;
        padding-top: 0;
        align-self: center;
    }
    
    .control-btn {
        height: 40px;
        font-size: 12px;
        min-width: 80px;
        padding: 0 12px;
        gap: 6px;
    }
    
    .control-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .shortcuts-info {
        display: none;
    }
    
    .status-banner {
        padding: 10px 16px;
    }
    
    .status-content {
        gap: 10px;
    }
    
    #statusMessage {
        font-size: 13px;
    }
    
    .messages-list {
        padding: 16px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .message-input-container {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 16px));
    }
    
    .input-wrapper {
        padding: 10px 50px 10px 16px;
        min-height: 44px;
    }
    
    .message-input {
        font-size: 14px;
    }
    
    .send-button {
        width: 32px;
        height: 32px;
        right: 6px;
    }
    
    .send-button svg {
        width: 16px;
        height: 16px;
    }
    
    .confirm-content {
        padding: 20px;
        max-width: 320px;
    }
    
    .confirm-content h3 {
        font-size: 16px;
    }
    
    .confirm-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .confirm-btn {
        width: 100%;
    }
}

/* Small Mobile (up to 480px) */
@media (max-width: 480px) {
    .header {
        height: 52px;
        padding: 0 12px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .header-info {
        gap: 8px;
    }
    
    .user-count {
        font-size: 11px;
        padding: 2px 4px;
    }
    
    .user-count svg {
        width: 12px;
        height: 12px;
    }
    
    .status-indicator {
        font-size: 12px;
        gap: 6px;
    }
    
    .connection-dot {
        width: 6px;
        height: 6px;
    }
    
    .video-sidebar {
        padding: 10px 12px;
        gap: 10px;
        max-height: 200px;
    }
    
    .video-card {
        flex: 0 0 140px;
        min-width: 140px;
        min-height: 140px;
        border-radius: 12px;
    }
    
    .video-container {
        border-radius: 12px 12px 0 0;
    }
    
    video {
        border-radius: 12px 12px 0 0;
    }
    
    .video-label {
        top: 6px;
        left: 6px;
        padding: 3px 6px;
        font-size: 10px;
        border-radius: 6px;
    }
    
    .placeholder-avatar {
        width: 32px;
        height: 32px;
    }
    
    .video-placeholder {
        font-size: 11px;
        gap: 6px;
    }
    
    .media-controls {
        height: 28px;
        border-radius: 0 0 12px 12px;
    }
    
    .media-btn {
        width: 20px;
        height: 20px;
        border-radius: 4px;
    }
    
    .media-btn svg {
        width: 10px;
        height: 10px;
    }
    
    .video-controls {
        width: 160px;
        gap: 6px;
    }
    
    .control-btn {
        height: 36px;
        font-size: 11px;
        min-width: 70px;
        padding: 0 8px;
        gap: 4px;
        border-radius: 10px;
    }
    
    .control-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .status-banner {
        padding: 8px 12px;
    }
    
    #statusMessage {
        font-size: 12px;
    }
    
    .messages-list {
        padding: 12px;
    }
    
    .message {
        margin-bottom: 12px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .message-bubble {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 16px;
    }
    
    .message-sender {
        font-size: 11px;
    }
    
    .message.system .message-bubble {
        padding: 6px 12px;
        font-size: 12px;
        border-radius: 10px;
    }
    
    .message-input-container {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 12px));
    }
    
    .input-wrapper {
        padding: 8px 42px 8px 14px;
        min-height: 40px;
        border-radius: 20px;
    }
    
    .message-input {
        font-size: 13px;
        min-height: 20px;
    }
    
    .send-button {
        width: 28px;
        height: 28px;
        right: 5px;
    }
    
    .send-button svg {
        width: 14px;
        height: 14px;
    }
    
    .confirm-content {
        padding: 16px;
        max-width: 280px;
    }
    
    .confirm-content h3 {
        font-size: 15px;
    }
    
    .confirm-content p {
        font-size: 13px;
    }
}

/* Extra Small Mobile (up to 360px) */
@media (max-width: 360px) {
    .video-sidebar {
        padding: 8px 10px;
        gap: 8px;
        max-height: 180px;
    }
    
    .video-card {
        flex: 0 0 120px;
        min-width: 120px;
        min-height: 120px;
    }
    
    .video-controls {
        width: 140px;
    }
    
    .control-btn {
        height: 32px;
        font-size: 10px;
        min-width: 60px;
        padding: 0 6px;
    }
    
    .messages-list {
        padding: 10px;
    }
    
    .message-input-container {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 10px));
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        height: 48px;
    }
    
    .video-sidebar {
        height: 140px;
        max-height: 140px;
        padding: 8px 12px;
    }
    
    .video-card {
        flex: 0 0 120px;
        min-width: 120px;
        min-height: 120px;
    }
    
    .video-controls {
        width: 140px;
    }
    
    .control-btn {
        height: 32px;
        font-size: 11px;
    }
    
    .messages-list {
        padding: 12px;
    }
    
    .message-input-container {
        padding: 10px 16px;
    }
    
    .input-wrapper {
        min-height: 36px;
        padding: 6px 36px 6px 12px;
    }
    
    .send-button {
        width: 24px;
        height: 24px;
        right: 4px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .app-container {
        height: -webkit-fill-available;
    }
    
    .message-input {
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    .control-btn,
    .send-button,
    .media-btn,
    .confirm-btn {
        -webkit-appearance: none;
    }
}

/* Android specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
    .message-input {
        background-color: transparent;
    }
    
    .video-card {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .connection-dot {
        border: 0.5px solid rgba(255, 255, 255, 0.1);
    }
    
    .video-card {
        border-width: 0.5px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .control-btn::before {
        display: none;
    }
}

.mobile-note {
    display: none;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .mobile-note {
        display: inline;
    }
}

.control-btn:focus-visible,
.send-button:focus-visible,
.message-input:focus-visible,
.media-btn:focus-visible,
.confirm-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Touch interactions */
@media (hover: none) and (pointer: coarse) {
    .control-btn:hover,
    .media-btn:hover,
    .send-button:hover,
    .video-card:hover {
        background: initial;
        transform: none;
        box-shadow: initial;
        border-color: initial;
    }
    
    .send-button:hover {
        transform: translateY(-50%);
    }
}

/* Performance optimizations */
.video-card,
.control-btn,
.message-bubble,
.send-button,
.media-btn,
.confirm-content {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}



/* Safe area adjustments for notch devices */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .video-sidebar {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .messages-list {
        padding-left: max(24px, env(safe-area-inset-left));
        padding-right: max(24px, env(safe-area-inset-right));
    }
    
    .message-input-container {
        padding-left: max(24px, env(safe-area-inset-left));
        padding-right: max(24px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    @media (max-width: 768px) {
        .header {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
        }
        
        .video-sidebar {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
        }
        
        .messages-list {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
        }
        
        .message-input-container {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
            padding-bottom: max(16px, env(safe-area-inset-bottom));
        }
    }
}