/* AI Interviewer Custom Styles */

/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    --navy-900: #0F172A;
    --navy-800: #1E293B;
    --navy-700: #334155;
    --navy-600: #475569;
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(148, 163, 184, 0.1);
    --glass-blur: 16px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

/* ============================================
   Glass Utility Classes
   ============================================ */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
}

.glass-strong {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
}

.glass-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.glass-modal {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 24px;
    max-width: 400px;
    width: 90%;
}

/* ============================================
   Dark Form Inputs
   ============================================ */
.form-input-dark {
    width: 100%;
    padding: 10px 14px;
    background: var(--navy-900);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 8px;
    font-size: 14px;
    color: #e2e8f0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input-dark:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input-dark::placeholder {
    color: #64748b;
}

.select-dark {
    width: 100%;
    padding: 10px 14px;
    background: var(--navy-900);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 8px;
    font-size: 14px;
    color: #e2e8f0;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.select-dark:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.select-dark option {
    background: var(--navy-800);
    color: #e2e8f0;
}

/* ============================================
   Premium Button Styles
   ============================================ */
.btn-premium {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition-smooth);
    cursor: pointer;
    border: none;
}

.btn-premium:hover {
    transform: translateY(-1px);
}

.btn-premium:active {
    transform: translateY(0) scale(0.98);
}

.btn-premium-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-premium-primary:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-premium-secondary {
    background: rgba(51, 65, 85, 0.5);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-premium-secondary:hover {
    background: rgba(51, 65, 85, 0.7);
    border-color: rgba(148, 163, 184, 0.3);
}

.btn-premium-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-premium-danger:hover {
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

/* ============================================
   Status Indicators (replacing emoji)
   ============================================ */
.status-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.pending {
    background: rgba(99, 102, 241, 0.2);
    border: 2px solid rgba(99, 102, 241, 0.4);
}

.status-indicator.pending::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6366f1;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-indicator.success {
    background: rgba(16, 185, 129, 0.2);
    border: 2px solid rgba(16, 185, 129, 0.4);
}

.status-indicator.error {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid rgba(239, 68, 68, 0.4);
}

/* ============================================
   Star Rating Premium
   ============================================ */
.star-btn-premium {
    font-size: 2rem;
    color: #475569;
    transition: var(--transition-smooth);
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
}

.star-btn-premium:hover {
    transform: scale(1.2);
}

.star-btn-premium.active {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

/* ============================================
   Avatar Animation (Premium)
   ============================================ */
@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.avatar-speaking {
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 40px rgba(99, 102, 241, 0.2);
}

/* Avatar circle gradient and state overrides */
#avatar-circle {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
    transition: var(--transition-smooth);
}

#avatar-circle.bg-green-600 {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

#avatar-circle.bg-red-600 {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

#avatar-circle.bg-yellow-600 {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.3);
}

#avatar-circle.bg-indigo-600 {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

/* Avatar ring animation */
.avatar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.3);
    pointer-events: none;
}

/* ============================================
   Transcript Message Overrides
   ============================================ */
.transcript-message {
    margin-bottom: 12px;
}

.ai-message .message-content {
    color: #e2e8f0;
}

.candidate-message .message-content {
    color: #cbd5e1;
}

/* Override JS-generated transcript bubble colors */
.transcript-message .bg-indigo-100 {
    background: rgba(99, 102, 241, 0.15) !important;
}

.transcript-message .bg-gray-100 {
    background: rgba(51, 65, 85, 0.5) !important;
}

.transcript-message .text-gray-800 {
    color: #e2e8f0 !important;
}

.transcript-message .text-gray-500 {
    color: #94a3b8 !important;
}

/* ============================================
   Video Container Styles
   ============================================ */
.video-container {
    position: relative;
    background: var(--navy-800);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(51, 65, 85, 0.3);
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   Control Button Styles
   ============================================ */
.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: var(--transition-smooth);
}

.control-btn:hover {
    background: rgba(51, 65, 85, 0.6);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

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

.control-btn.active {
    background: #dc2626;
}

/* ============================================
   Loading Spinner
   ============================================ */
.loading-spinner {
    border: 3px solid rgba(51, 65, 85, 0.3);
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Scrollbar Styles
   ============================================ */
#transcript-content::-webkit-scrollbar {
    width: 6px;
}

#transcript-content::-webkit-scrollbar-track {
    background: var(--navy-900);
}

#transcript-content::-webkit-scrollbar-thumb {
    background: var(--navy-600);
    border-radius: 3px;
}

#transcript-content::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ============================================
   Audio Level Indicator
   ============================================ */
.audio-level-bar {
    height: 4px;
    background: linear-gradient(90deg, #22c55e, #84cc16, #eab308, #ef4444);
    border-radius: 2px;
    transition: width 0.1s ease;
}

/* ============================================
   Status Badge (dark themed)
   ============================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.status-badge.completed {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

/* ============================================
   Modal Styles (dark glass)
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
}

/* ============================================
   Completion Page Animations
   ============================================ */
@keyframes draw-check {
    0% { stroke-dashoffset: 100; }
    100% { stroke-dashoffset: 0; }
}

@keyframes circle-fill {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.success-circle {
    animation: circle-fill 0.6s ease-out both;
}

.success-check-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: draw-check 0.6s ease-out 0.3s both;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 767px) {
    #transcript-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        z-index: 40;
    }

    .video-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Dashboard Styles (UNTOUCHED - admin pages)
   ============================================ */
.dashboard-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 24px;
}

.dashboard-stat {
    text-align: center;
    padding: 16px;
}

.dashboard-stat .value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
}

.dashboard-stat .label {
    font-size: 14px;
    color: #6b7280;
    margin-top: 4px;
}

/* ============================================
   Table Styles (UNTOUCHED - admin pages)
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

/* ============================================
   Form Styles (UNTOUCHED - admin pages)
   ============================================ */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

/* ============================================
   Button Styles (UNTOUCHED - admin pages)
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
}

.btn-secondary {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ============================================
   Mobile-Friendly Styles
   ============================================ */

/* iOS Safari 100vh fix */
.mobile-safe-area {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

html {
    height: -webkit-fill-available;
}

/* Force interview page to use real visual viewport height (scoped via .no-pull-refresh) */
@media (max-width: 767px) {
    body:has(.no-pull-refresh) {
        overflow: hidden;
    }
    .no-pull-refresh.mobile-safe-area {
        height: 100vh;
        height: 100dvh;
        height: -webkit-fill-available;
        min-height: 0 !important;
    }
}

/* Touch optimization */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

.touch-target-lg {
    min-width: 48px;
    min-height: 48px;
}

/* Prevent text selection on interactive elements */
.no-select {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Smooth scrolling with momentum for iOS */
.scroll-momentum {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Prevent pull-to-refresh on the body */
.no-pull-refresh {
    overscroll-behavior-y: contain;
}

/* Form input sizing to prevent iOS zoom */
.mobile-input {
    font-size: 16px;
}

@media (max-width: 640px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Mobile video container styles */
.mobile-video-container {
    position: relative;
    width: 100%;
    background: var(--navy-800);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(51, 65, 85, 0.3);
}

.interview-stage {
    position: relative;
}

.interview-video-grid {
    position: relative;
}


/* ============================================
   Bottom Sheet Styles
   ============================================ */
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--navy-800);
    border-top: 1px solid rgba(51, 65, 85, 0.3);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(calc(100% - 60px));
    transition: transform 0.3s ease-out;
    z-index: 30;
    max-height: 70vh;
    padding-bottom: var(--safe-area-inset-bottom);
}

.bottom-sheet.expanded {
    transform: translateY(0);
}

.bottom-sheet.hidden-sheet {
    transform: translateY(100%);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: #4b5563;
    border-radius: 2px;
    margin: 12px auto;
}

.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}

.bottom-sheet-content {
    max-height: calc(70vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

/* ============================================
   Mobile Control Bar
   ============================================ */
.mobile-control-dock {
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.94)),
        radial-gradient(circle at top, rgba(59, 130, 246, 0.14), transparent 60%);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -12px 30px rgba(2, 6, 23, 0.45);
}

.mobile-control-dock-inner {
    width: min(100%, 540px);
    margin: 0 auto;
}

/* Mobile control buttons */
.mobile-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    width: 56px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(51, 65, 85, 0.82), rgba(30, 41, 59, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.mobile-control-btn:active {
    transform: translateY(1px) scale(0.97);
}

.mobile-control-btn.active {
    background: #dc2626;
}

.mobile-control-btn.end-call {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    width: 60px;
    height: 68px;
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(239, 68, 68, 0.28);
}

.mobile-control-btn.end-call:active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* Mobile button labels */
.mobile-btn-label {
    font-size: 10px;
    color: rgba(226, 232, 240, 0.78);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
}

/* Stacked layout on mobile: flex ratios set via Tailwind classes in HTML (flex-[3] / flex-[2]).
   No aspect-ratio overrides needed — the self-view uses an inner div for aspect ratio. */

/* Camera flip button */
.camera-flip-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
    border: none;
    line-height: 0;
}

/* Transcript preview */
.transcript-preview {
    font-size: 14px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 16px 8px;
}

/* Mobile header adjustments */
@media (max-width: 640px) {
    .mobile-header {
        padding: 8px 12px;
        padding-top: calc(8px + var(--safe-area-inset-top));
    }

    .mobile-header h1 {
        font-size: 14px;
    }
}

/* Settings modal - slides up from bottom on mobile */
@media (max-width: 640px) {
    .settings-modal-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

/* Responsive padding */
.p-mobile {
    padding: 16px;
}

@media (min-width: 640px) {
    .p-mobile {
        padding: 32px;
    }
}

/* Hide elements on mobile/desktop */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }

    .camera-flip-btn.mobile-only {
        display: flex;              /* Restore flex centering for this button */
    }

    .desktop-only {
        display: none;
    }
}

/* Mobile transcript panel */
@media (max-width: 767px) {
    #transcript-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        z-index: 40;
        border-radius: 0;
    }

    #transcript-panel.bottom-sheet-mode {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(calc(100% - 60px));
        transition: transform 0.3s ease-out;
    }

    #transcript-panel.bottom-sheet-mode.expanded {
        transform: translateY(0);
    }
}

/* Interview page mobile layout — control bar is in-flow, no padding-bottom needed */
@media (max-width: 767px) {
    .interview-stage {
        padding: 8px 8px 0;
    }

    .interview-stage-inner {
        padding: 0;
        gap: 12px;
    }

    .interview-video-grid {
        height: 100%;
        gap: 12px;
    }

    .interview-self-panel {
        flex: 1 1 auto;
        min-height: 0;
        border-radius: 24px;
        background:
            linear-gradient(180deg, rgba(15, 23, 42, 0.76), rgba(15, 23, 42, 0.92)),
            linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(14, 165, 233, 0.02));
        box-shadow: 0 18px 42px rgba(2, 6, 23, 0.34);
    }

    .interview-self-frame {
        width: auto;
        height: 100%;
        min-height: clamp(240px, 48vh, 520px);
        max-height: 100%;
        max-width: 100%;
        aspect-ratio: 3 / 4;
        border-radius: 24px;
    }

    .interview-ai-panel {
        flex: 0 0 auto;
        min-height: clamp(136px, 20vh, 188px);
        border-radius: 24px;
        align-items: stretch;
        justify-content: center;
        background:
            linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.96)),
            radial-gradient(circle at top, rgba(99, 102, 241, 0.18), transparent 62%);
        box-shadow: 0 16px 32px rgba(2, 6, 23, 0.28);
    }

    .interview-ai-panel #ai-avatar {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 16px;
        padding: 8px 10px;
        text-align: left;
    }

    .interview-ai-panel #ai-avatar > div:first-child {
        width: clamp(72px, 20vw, 104px);
        height: clamp(72px, 20vw, 104px);
        min-width: clamp(72px, 20vw, 104px);
        max-width: none;
        max-height: none;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .interview-ai-panel #ai-avatar > div:nth-child(2) {
        flex: 1 1 auto;
        padding: 0;
        min-width: 0;
    }

    .interview-ai-panel #ai-connecting-indicator,
    .interview-ai-panel #retry-ai-connection,
    .interview-ai-panel #ai-help-text {
        margin-top: 0;
        width: auto;
        max-width: none;
        text-align: left;
        padding: 0;
    }

    .interview-ai-panel .ai-text-block {
        min-width: 0;
    }

    .interview-ai-panel .ai-name,
    .interview-ai-panel .ai-status,
    .interview-ai-panel .ai-speaking,
    .interview-ai-panel .ai-connecting-text {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
    }

    .interview-ai-panel .ai-name {
        font-size: clamp(0.88rem, 2.8vw, 1rem);
        -webkit-line-clamp: 2;
    }

    .interview-ai-panel .ai-status,
    .interview-ai-panel .ai-speaking {
        font-size: clamp(0.72rem, 2.45vw, 0.88rem);
        line-height: 1.2;
        -webkit-line-clamp: 2;
    }

    .interview-ai-panel .ai-connection-row {
        align-items: flex-start;
    }

    .interview-ai-panel .ai-connecting-text {
        font-size: clamp(0.68rem, 2.2vw, 0.8rem);
        line-height: 1.2;
        -webkit-line-clamp: 2;
    }

    .mobile-control-dock {
        padding: 0 10px calc(var(--safe-area-inset-bottom) + 8px);
        border-top: none;
        background: transparent;
        box-shadow: none;
    }

    .mobile-control-dock-inner {
        padding: 10px 12px;
        border-radius: 24px;
        border: 1px solid rgba(148, 163, 184, 0.16);
        background:
            linear-gradient(180deg, rgba(15, 23, 42, 0.74), rgba(15, 23, 42, 0.94)),
            radial-gradient(circle at top, rgba(59, 130, 246, 0.14), transparent 65%);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 16px 40px rgba(2, 6, 23, 0.38);
    }

    .interview-video-area-mobile {
        flex: 1;
        padding: 8px;
    }

    body.landscape .interview-video-grid,
    .interview-video-grid.mobile-landscape {
        flex-direction: row;
    }

    body.landscape .interview-self-panel,
    .interview-video-grid.mobile-landscape .interview-self-panel {
        flex: 1.45 1 0%;
    }

    body.landscape .interview-ai-panel,
    .interview-video-grid.mobile-landscape .interview-ai-panel {
        flex: 0.85 1 0%;
        min-height: 0;
    }

    body.landscape .interview-ai-panel #ai-avatar,
    .interview-video-grid.mobile-landscape .interview-ai-panel #ai-avatar {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 10px;
    }

    body.landscape .interview-ai-panel #ai-avatar > div:first-child,
    .interview-video-grid.mobile-landscape .interview-ai-panel #ai-avatar > div:first-child {
        width: clamp(64px, 14vw, 88px);
        height: clamp(64px, 14vw, 88px);
        min-width: clamp(64px, 14vw, 88px);
    }

    body.landscape .interview-ai-panel #ai-avatar > div:nth-child(2),
    body.landscape .interview-ai-panel #ai-connecting-indicator,
    body.landscape .interview-ai-panel #retry-ai-connection,
    body.landscape .interview-ai-panel #ai-help-text,
    .interview-video-grid.mobile-landscape .interview-ai-panel #ai-avatar > div:nth-child(2),
    .interview-video-grid.mobile-landscape .interview-ai-panel #ai-connecting-indicator,
    .interview-video-grid.mobile-landscape .interview-ai-panel #retry-ai-connection,
    .interview-video-grid.mobile-landscape .interview-ai-panel #ai-help-text {
        text-align: center;
    }

    body.landscape .interview-ai-panel .ai-connection-row,
    .interview-video-grid.mobile-landscape .interview-ai-panel .ai-connection-row {
        justify-content: center;
        align-items: center;
    }

    body.landscape .interview-ai-panel .ai-name,
    .interview-video-grid.mobile-landscape .interview-ai-panel .ai-name {
        font-size: clamp(0.8rem, 1.9vw, 0.95rem);
    }

    body.landscape .interview-ai-panel .ai-status,
    body.landscape .interview-ai-panel .ai-speaking,
    body.landscape .interview-ai-panel .ai-connecting-text,
    .interview-video-grid.mobile-landscape .interview-ai-panel .ai-status,
    .interview-video-grid.mobile-landscape .interview-ai-panel .ai-speaking,
    .interview-video-grid.mobile-landscape .interview-ai-panel .ai-connecting-text {
        font-size: clamp(0.66rem, 1.6vw, 0.78rem);
    }
}

@media (max-width: 380px) {
    .interview-ai-panel #ai-avatar {
        gap: 12px;
        padding: 8px;
    }

    .interview-ai-panel #ai-avatar > div:first-child {
        width: clamp(64px, 19vw, 84px);
        height: clamp(64px, 19vw, 84px);
        min-width: clamp(64px, 19vw, 84px);
    }

    .interview-ai-panel .ai-name {
        font-size: 0.82rem;
    }

    .interview-ai-panel .ai-status,
    .interview-ai-panel .ai-speaking,
    .interview-ai-panel .ai-connecting-text {
        font-size: 0.68rem;
    }
}

/* Orientation-specific adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .interview-stage {
        padding: 6px 6px 0;
    }

    .interview-stage-inner,
    .interview-video-grid {
        gap: 8px;
    }

    .interview-self-frame {
        min-height: 0;
        width: auto;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        aspect-ratio: 3 / 4;
    }

    .mobile-control-btn {
        width: 44px;
        height: 50px;
        border-radius: 12px;
        gap: 2px;
    }

    .mobile-control-btn.end-call {
        width: 48px;
        height: 54px;
        border-radius: 14px;
    }

    .mobile-btn-label {
        font-size: 8px;
    }

    .mobile-control-dock {
        padding: 0 8px calc(var(--safe-area-inset-bottom) + 6px);
    }

    .mobile-control-dock-inner {
        padding: 8px 10px;
        border-radius: 20px;
    }
}

/* Interview page desktop/tablet layout */
@media (min-width: 768px) {
    .interview-self-frame {
        /* Landscape aspect ratio on desktop — fills the panel naturally */
        aspect-ratio: 4 / 3;
        width: 100%;
        height: auto;
        max-height: 100%;
    }

    .interview-ai-panel {
        /* Vertical centered column layout on desktop */
        justify-content: center;
        align-items: center;
    }

    .interview-ai-panel #ai-avatar {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* Double-tap camera flip hint */
.camera-flip-hint {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.camera-flip-hint.visible {
    opacity: 1;
}

/* Mobile-friendly transcript messages */
@media (max-width: 640px) {
    .transcript-message .message-content {
        font-size: 14px;
    }

    .transcript-message .text-xs {
        font-size: 11px;
    }
}

/* Active state for buttons on touch devices */
@media (hover: none) {
    .control-btn:active,
    button:active {
        opacity: 0.8;
    }
}

/* ============================================
   JS-Generated Modal Overrides (dark theme)
   ============================================ */
#connection-error-modal > div,
#ai-error-modal > div,
#preflight-error > div {
    background: rgba(30, 41, 59, 0.95) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
}

#connection-error-modal,
#ai-error-modal,
#preflight-error {
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Override text colors inside JS-generated modals */
#connection-error-modal .text-gray-800,
#ai-error-modal .text-gray-800,
#preflight-error .text-gray-800 {
    color: #f1f5f9 !important;
}

#connection-error-modal .text-gray-600,
#ai-error-modal .text-gray-600,
#preflight-error .text-gray-600 {
    color: #94a3b8 !important;
}

#connection-error-modal .text-gray-700,
#ai-error-modal .text-gray-700,
#preflight-error .text-gray-700 {
    color: #cbd5e1 !important;
}

#connection-error-modal .text-gray-500,
#ai-error-modal .text-gray-500,
#preflight-error .text-gray-500 {
    color: #64748b !important;
}

/* Override backgrounds inside JS-generated modals */
#connection-error-modal .bg-red-100,
#ai-error-modal .bg-red-100,
#preflight-error .bg-red-100 {
    background: rgba(239, 68, 68, 0.15) !important;
}

#connection-error-modal .bg-red-50,
#ai-error-modal .bg-red-50,
#preflight-error .bg-red-50 {
    background: rgba(239, 68, 68, 0.1) !important;
}

#preflight-error .bg-blue-50 {
    background: rgba(99, 102, 241, 0.1) !important;
}

#preflight-error .border-blue-200 {
    border-color: rgba(99, 102, 241, 0.2) !important;
}

#preflight-error .text-blue-800 {
    color: #93c5fd !important;
}

#preflight-error .border-red-200 {
    border-color: rgba(239, 68, 68, 0.2) !important;
}

#preflight-error .text-red-800 {
    color: #fca5a5 !important;
}

#preflight-error .text-red-700 {
    color: #fca5a5 !important;
}

/* Override button styles in JS-generated modals */
#connection-error-modal .border-gray-300,
#ai-error-modal .border-gray-300,
#preflight-error .border-gray-300 {
    border-color: rgba(148, 163, 184, 0.2) !important;
}

#connection-error-modal button.hover\:bg-gray-50:hover,
#ai-error-modal a.hover\:bg-gray-50:hover,
#preflight-error button.hover\:bg-gray-50:hover {
    background: rgba(51, 65, 85, 0.5) !important;
}
