/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 32px 24px 24px 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
}

.prompt-switch {
    margin: 12px 0 18px 0;
    display: flex;
    gap: 18px;
    align-items: center;
}

.prompt-switch label {
    font-size: 1rem;
    cursor: pointer;
}

.prompt-content {
    background: #f7f7fa;
    border-radius: 8px;
    padding: 16px;
    min-height: 80px;
    font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
    font-size: 1rem;
    color: #222;
    overflow-x: auto;
}

.init-message {
    background-color: #f7f7fa;
    border-radius: 8px;
    padding: 16px;
    min-height: 80px;
    font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
    font-size: 1rem;
    color: #222;
    overflow-x: auto;
    margin-bottom: 20px;
}

.prompt-btn {
    font-size: 14px;
    letter-spacing: 2px;
    text-decoration: none;
    text-transform: uppercase;
    color: #000;
    cursor: pointer;
    border: 3px solid;
    padding: 0.25em 0.5em;
    box-shadow: 1px 1px 0px 0px, 2px 2px 0px 0px, 3px 3px 0px 0px, 4px 4px 0px 0px, 5px 5px 0px 0px;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.prompt-btn:active {
    box-shadow: 0px 0px 0px 0px;
    top: 5px;
    left: 5px;
}

/* ====================================================================
   NOXENUM WEBRTC FRONTEND STYLES
   ==================================================================== */

/* ====================================================================
   1. GLOBAL STYLES & RESET
   ==================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    /* Fallback for older browsers */
    min-height: 100dvh;
    /* Modern: dynamic viewport height */
    display: flex;
    flex-direction: column;
}

/* Hides the header during an active call on ALL devices */
body.call-active .main-header {
    display: none;
}

/* ====================================================================
   2. MAIN HEADER & NAVIGATION
   ==================================================================== */

.main-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    top: 0;
}

.header-logo .logo-img {
    height: 64px;
    margin: 8px 0;
}

.header-spacer {
    flex: 1;
}

.header-user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.login-btn {
    padding: 12px 16px;
    border-radius: 12px;
    background: #fff;
    border: 0px;
    cursor: pointer;
    font-weight: 500;
    box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
    font-size: 0.9em;
    color: #565656;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: 38px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-width: 160px;
}

.user-info {
    padding: 12px 16px;
    font-weight: 500;
}

.logout-btn {
    width: 100%;
    padding: 10px 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #d32f2f;
    font-weight: 500;
}

.firebaseui-idp-button {
    max-width: 285px !important;
    border-radius: 12px !important;
}

@media (max-width: 768px) {
    .main-header {
        padding: 0px 12px;
        height: 10vh;
        /* Fixed header height - 10% of viewport on mobile */
    }

    .header-logo .logo-img {
        height: 64px;
        padding: 8px;
    }

}

/* ====================================================================
   3. CALL INTERFACE LAYOUT
   ==================================================================== */
.call-interface {
    display: flex;
    height: 95vh;
    /* Fallback for older browsers - accounts for mobile browser UI */
    height: 100dvh;
    /* Modern: dynamic viewport height - adapts to visible area */
    flex-direction: column;
}

@media (max-width: 768px) {
    .call-interface {
        height: 90vh;
        /* Fallback for older browsers - accounts for mobile browser UI */
        height: 100svh;
        /* Modern: small viewport height - excludes browser UI */
    }

    /* When call is active and main header is hidden, use full viewport */
    body.call-active .call-interface {
        height: 100vh;
        /* Fallback: full viewport when no header interference */
        height: 100svh;
        /* Modern: full small viewport when no header interference */
    }
}

.header {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px 20px;
}

.avatar-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.footer {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

/* ====================================================================
   4. CALLER INFO & HEADER
   ==================================================================== */
.caller-info {
    text-align: center;
}

.caller-name {
    font-size: 2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.call-duration {
    font-size: 1.5rem;
    color: #7f8c8d;
    font-weight: 500;
}

/* ====================================================================
   5. AVATAR STYLES & ANIMATIONS
   ==================================================================== */
.avatar {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d3a8d5 0%, #dac8e6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: pulse var(--pulse-duration, 3s) ease-in-out infinite;
    transition: background 0.2s ease, border 0.2s ease;
}

/* Avatar States */
.avatar-idle {
    --animation-intensity: 0.3;
    --pulse-duration: 3s;
    background: linear-gradient(135deg, #d3a8d5 0%, #dac8e6 100%);
    animation: pulse var(--pulse-duration) ease-in-out infinite;
}

.avatar-listening {
    border-radius: 50%;
    background: radial-gradient(circle, #d3a8d5, #dac8e6);
    animation: breathing 2s infinite ease-in-out;
    position: relative;
}

@keyframes breathing {

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

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

/* Speaking Animation */
.avatar-speaking {
    border-radius: 50%;
    background: linear-gradient(135deg, #d3a8d5 0%, #dac8e6 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-speaking::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }

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

/* Thinking Animation */
.avatar-thinking {
    --animation-intensity: 1.0;
    --pulse-duration: 2s;
    background: linear-gradient(135deg, #d3a8d5, #dac8e6 100%);
    position: relative;
    overflow: visible;
    animation: pulse-speaking var(--pulse-duration) ease-in-out infinite;
}

.avatar-thinking::before,
.avatar-thinking::after,
.avatar-thinking .wobbly-circle {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 121% 128% 125% 124%/125% 120% 127% 125%;
    background: linear-gradient(135deg, #d3a8d5 0%, #dac8e6 100%);
    top: 0;
    left: 0;
}

.avatar-thinking::before {
    transform-origin: calc(50% - 0.8%) 50%;
    animation: wobbly-spin1 2s linear infinite;
}

.avatar-thinking::after {
    transform-origin: 50% calc(50% + 0.8%);
    animation: wobbly-spin2 2s linear infinite;
}

.avatar-thinking .wobbly-circle {
    transform-origin: calc(50% + 0.8%) 50%;
    animation: wobbly-spin3 2s linear infinite;
}

/* Avatar Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 20px 60px rgba(169, 43, 219, 0.4);
    }

    50% {
        box-shadow: 0 25px 70px rgba(59, 11, 73, 0.65)
    }

    100% {
        box-shadow: 0 20px 60px rgba(169, 43, 219, 0.4);
    }
}

@keyframes pulse-speaking {
    0% {
        box-shadow: 0 20px 60px rgba(59, 130, 246, calc(0.4 * var(--animation-intensity, 1)));
    }

    50% {
        box-shadow: 0 25px 70px rgba(37, 99, 235, calc(0.65 * var(--animation-intensity, 1)));
    }

    100% {
        box-shadow: 0 20px 60px rgba(59, 130, 246, calc(0.4 * var(--animation-intensity, 1)));
    }
}

@keyframes wobbly-spin1 {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes wobbly-spin2 {
    0% {
        transform: rotate(-144deg);
    }

    100% {
        transform: rotate(216deg);
    }
}

@keyframes wobbly-spin3 {
    0% {
        transform: rotate(216deg);
    }

    100% {
        transform: rotate(-144deg);
    }
}

/* ====================================================================
   6. CALL CONTROLS
   ==================================================================== */
.controls {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border-radius: 50px;
    padding: 20px 40px;
    display: flex;
    gap: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.mute-btn {
    background: #10b981;
    color: white;
}

.mute-btn:hover {
    background: #059669;
    transform: translateY(-2px);
}

.mute-btn.muted {
    background: #e74c3c;
}

.mute-btn.muted:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.end-call-btn {
    background: #e74c3c;
    color: white;
}

.end-call-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.transcript-btn {
    background: #34495e;
    color: white;
    position: relative;
    /* Enable absolute positioning for badge */
}

.transcript-btn:hover {
    background: #2c3e50;
    transform: translateY(-2px);
}

.message-counter {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    /* Perfect centering with CSS Grid instead of Flexbox */
    display: grid;
    place-items: center;
    /* Optimized line-height for perfect vertical centering */
    line-height: 20px;
    /* Font optimization for consistent number display */
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    /* Remove all padding hacks - Grid handles centering perfectly */
}

.mute-icon,
.end-call-icon,
.transcript-icon {
    width: 24px;
    height: 24px;
}

/* ====================================================================
   7. TRANSCRIPT INTERFACE
   ==================================================================== */
.transcript-modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    /* Fallback for older browsers */
    height: 100dvh;
    /* Modern: dynamic viewport height - adapts to visible area */
    background: rgba(44, 62, 80, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    transition: background 0.2s;
}

.transcript-content {
    background: #fff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 8px 32px rgba(44, 62, 80, 0.18);
    padding: 32px 28px 24px 28px;
    min-width: 320px;
    max-width: 95vw;
    width: 400px;
    margin-bottom: 110px;
    position: relative;
    animation: transcript-pop 0.25s cubic-bezier(.4, 1.4, .6, 1) 1;
}

.transcript-panel {
    position: fixed;
    left: 50%;
    bottom: 210px;
    transform: translateX(-50%) translateY(60px) scale(0.95);
    width: 600px;
    max-width: 90vw;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(44, 62, 80, 0.18);
    padding: 24px 20px 18px 20px;
    z-index: 100;
    border: 1px solid #e0e0e0;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(.4, 1.4, .6, 1), opacity 0.22s cubic-bezier(.4, 1.4, .6, 1);
}

.transcript-panel.show {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.transcript-content h2,
.transcript-panel h2 {
    margin-bottom: 18px;
    font-size: 1.3rem;
    color: #2c3e50;
    font-weight: 600;
}

.transcript-panel h2 {
    margin-bottom: 14px;
    font-size: 1.15rem;
}

.transcript-text {
    max-height: 260px;
    overflow-y: auto;
    font-size: 1rem;
    color: #34495e;
    line-height: 1.6;
}

.transcript-panel .transcript-text {
    max-height: 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 18px;
    font-size: 1.7rem;
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #e74c3c;
}

/* Transcript Bubbles */
.bubble {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-break: break-word;
    font-size: 1rem;
    margin-bottom: 2px;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.06);
}

.user-bubble {
    align-self: flex-end;
    background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
    color: #00796b;
    border-bottom-right-radius: 4px;
}

.bot-bubble {
    align-self: flex-start;
    background: linear-gradient(135deg, #f1f8e9 0%, #dcedc8 100%);
    color: #33691e;
    border-bottom-left-radius: 4px;
}

.bubble strong {
    color: inherit;
    font-weight: 600;
    margin-right: 6px;
}

/* Message Pills */
.message-pill {
    display: block;
    padding: 8px 16px;
    border-radius: 20px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 8px auto;
    max-width: 80%;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.08);
    animation: fadeInPill 0.3s ease-in;
}

.error-pill {
    background: #ef4444;
    color: white;
}

.info-pill {
    background: #6b7280;
    color: white;
}

@keyframes transcript-pop {
    0% {
        transform: translateY(60px) scale(0.95);
        opacity: 0;
    }

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

@keyframes fadeInPill {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* ====================================================================
   8. CONTACT SELECTION SCREEN
   ==================================================================== */
.contact-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #f5f7fa;
    text-align: center;
    padding: 20px 10px 20px;
    overflow-y: auto;
    flex: 1;
}

.contact-selection h2 {
    margin-bottom: 0;
}

/* ====================================================================
   9. PERSONA STYLES
   ==================================================================== */
.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 32px 0 0 0;
}

.persona-card {
    display: flex;
    align-items: center;
    gap: 18px;
    background: radial-gradient(circle, #DBB7C1 0%, #A86F82 100%);
    border-radius: 22px;
    padding: 18px 32px;
    cursor: pointer;
    transition: background 0.22s, transform 0.18s, box-shadow 0.18s;
    border: 2px solid transparent;
    margin-bottom: 0;
}

.persona-card:hover {
    background: #996274;
    transform: translateY(-2px) scale(1.03);
}

.persona-avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.persona-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.persona-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #DDFCFF;
    margin-bottom: 2px;
    text-transform: uppercase;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);
}

.persona-card:hover .persona-name {
    color: #fff;
}

.persona-desc {
    font-size: 1rem;
    color: #5d5d5d;
    font-weight: 500;
}

.persona-card:hover .persona-desc {
    color: #fff;
}

/* Legacy Contact Button (if still used) */
.contact-btn {
    background: linear-gradient(135deg, #b39ddb 0%, #9575cd 100%);
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 18px 38px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(44, 62, 80, 0.10);
    transition: background 0.2s, transform 0.2s;
}

.contact-btn:hover {
    background: linear-gradient(135deg, #9575cd 0%, #b39ddb 100%);
    transform: translateY(-2px) scale(1.04);
}

/* ====================================================================
   10. PERFORMANCE TOGGLE
   ==================================================================== */
.latency-toggle-container {
    margin: 90px 0 40px 0;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(44, 62, 80, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.latency-toggle-container h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.latency-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.toggle-label {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    min-width: 60px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #10b981;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 0px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transform: translateX(3px);
}

.toggle-switch input:checked+.toggle-slider {
    background: #b39ddb;
}

.toggle-switch input:checked+.toggle-slider:before {
    background: white;
    transform: translateX(27px);
}

/* ====================================================================
   11. FOOTER
   ==================================================================== */
.footer-info {
    position: relative;
    margin-top: auto;
    color: #7a7a7a;
    font-size: .875rem;
    width: 100%;
    padding: 0 0 20px 0;
}

.footer-info p {
    margin-bottom: 0;
    max-width: 420px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.privacy-link {
    color: #7c4dff;
    text-decoration: none;
    font-weight: 500;
}

.privacy-link:hover {
    text-decoration: underline;
}

/* ====================================================================
   12. CONNECT SCREEN & CHECKLIST
   ==================================================================== */
.connect-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    /* Fallback for older browsers */
    height: 100dvh;
    /* Modern: dynamic viewport height - adapts to visible area */
    background: #f5f7fa;
}

.checklist {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(44, 62, 80, 0.12);
    padding: 36px 32px 32px 32px;
    min-width: 320px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.checklist-step {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 1rem;
    color: #7f8c8d;
    font-weight: 500;
    transition: color 0.2s;
}

.checklist-step.active,
.checklist-step.checked {
    color: #2c3e50;
    font-weight: 600;
}

.checkmark {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #bdbdbd;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f7fa;
    font-size: 1.2rem;
    transition: background 0.2s, border-color 0.2s;
}

.checklist-step.active .checkmark {
    border-color: #7c4dff;
    background: #ede7f6;
}

.checklist-step.checked .checkmark {
    border-color: #43a047;
    background: #c8e6c9;
}

.checklist-step.checked .checkmark::after {
    content: '✔';
    color: #388e3c;
    font-size: 0.95rem;
}

.step-label {
    flex: 1;
}

.cancel-btn {
    margin-top: 18px;
    padding: 12px 0;
    width: 100%;
    background: #fff;
    color: #e74c3c;
    border: 2px solid #e74c3c;
    border-radius: 10px;
    font-size: 1.08rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.cancel-btn:hover {
    background: #e74c3c;
    color: #fff;
}

/* ====================================================================
   13. SPINNER & LOADING STATES
   ==================================================================== */
.spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid #b39ddb;
    border-top: 3px solid #7c4dff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* ====================================================================
   14. TOAST NOTIFICATIONS
   ==================================================================== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(calc(100% + 20px));
    transition: transform 0.3s;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #ff4757;
}

.toast.success {
    background: #2ed573;
}

.toast.warning {
    background: #ffa502;
}

/* ====================================================================
   15. MODAL SYSTEM
   ==================================================================== */

/* ---- Base Modal Infrastructure ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-sizing: border-box;
}

.modal-overlay.show {
    opacity: 1;
}

/* ---- Modal Content Base ---- */
.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 90vw;
    width: 90%;
    max-height: 90vh;
    /* Limit modal height to 90% of viewport - ensures visibility */
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin: 0;
    flex-shrink: 0;
    isolation: isolate;
    /* create a new stacking context so overlays don't blend through */
    z-index: 1001;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

/* ---- Terms Modal Specific Overrides ---- */
/* Restore original Terms Modal appearance from styles-develop.css */
.modal-overlay#terms-modal {
    background: rgba(44, 62, 80, 0.45);
    z-index: 2000;
}

.modal-overlay#terms-modal .modal-content {
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(44, 62, 80, 0.18);
    padding: 36px 32px 28px 32px;
    width: 400px;
    max-width: 95vw;
    text-align: center;
    position: relative;
    top: auto;
    margin: 0;
    transform: none;
    animation: transcript-pop 0.25s cubic-bezier(.4, 1.4, .6, 1) 1;
}

.modal-overlay#terms-modal .modal-content h2 {
    margin-bottom: 18px;
    font-size: 1.3rem;
    color: #2c3e50;
    font-weight: 600;
}

.modal-overlay#terms-modal .modal-content p {
    margin-bottom: 10px;
    color: #34495e;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* ---- Modal Structure Components ---- */
.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #e1e5e9;
    text-align: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1e293b;
}

.modal-header p {
    color: #64748b;
    font-size: 1rem;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ---- Modal Controls ---- */
.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.close-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* ---- Shared Modal Button System ---- */
.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    text-align: center;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.modal-btn-primary:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.modal-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.modal-btn-secondary:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

.modal-button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* ---- Upgrade Prompt Modal Variant ---- */
.upgrade-prompt {
    max-width: 450px;
    width: 90%;
}

.upgrade-intro {
    color: #64748b;
    font-size: 1.05rem;
    line-height: 1.6;
    text-align: center;
    margin-bottom: 8px;
}

/* Legacy modal content styling */
.modal .modal-content h2 {
    margin-bottom: 18px;
    font-size: 1.3rem;
    color: #2c3e50;
    font-weight: 600;
}

.modal .modal-content h3 {
    margin-bottom: 18px;
    font-size: 1.1rem;
    color: #394c5f;
    font-weight: 500;
}

.modal .modal-content p {
    margin-bottom: 10px;
    color: #34495e;
    font-size: 1.05rem;
    line-height: 1.6;
}

.modal-ok-btn {
    margin-top: 18px;
    padding: 12px 36px;
    background: linear-gradient(135deg, #b39ddb 0%, #9575cd 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1.08rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(44, 62, 80, 0.10);
    transition: background 0.18s, color 0.18s, transform 0.18s;
}

.modal-ok-btn:hover {
    background: linear-gradient(135deg, #9575cd 0%, #b39ddb 100%);
    color: #fff;
    transform: translateY(-2px) scale(1.04);
}

/* ---- Choice Modal Variant ---- */
.choice-modal {
    max-width: 700px;
    width: 95%;
    max-height: 85vh;
    /* Limit choice modal height to 85% of viewport - allows more content */
    overflow-y: auto;
}

.modal-overlay.show .choice-modal {
    transform: scale(1);
}

.editor>textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
    font-family: 'Courier New', Courier, monospace;
    resize: vertical;
}

.input-pw {
    width: 200px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.edit-btn {
    background: #2c2b86;
    border-radius: 999px;
    box-shadow: #7d5df0 0 10px 20px -10px;
    box-sizing: border-box;
    color: #FFFFFF;
    cursor: pointer;
    font-family: Inter, Helvetica, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", EmojiSymbols, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 24px;
    opacity: 1;
    outline: 0 solid transparent;
    padding: 6px 14px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    width: fit-content;
    word-break: break-word;
    border: 0;
}

.save-button {
    background: #2b8637;
    border-radius: 999px;
    box-shadow: #5df07d 0 10px 20px -10px;
    box-sizing: border-box;
    color: #FFFFFF;
    cursor: pointer;
    font-family: Inter, Helvetica, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", EmojiSymbols, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 24px;
    opacity: 1;
    outline: 0 solid transparent;
    padding: 6px 14px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    width: fit-content;
    word-break: break-word;
    border: 0;
}

.cancel-button {
    background: #b81d44;
    border-radius: 999px;
    box-shadow: #f05da7 0 10px 20px -10px;
    box-sizing: border-box;
    color: #FFFFFF;
    cursor: pointer;
    font-family: Inter, Helvetica, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", EmojiSymbols, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 24px;
    opacity: 1;
    outline: 0 solid transparent;
    padding: 6px 14px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    width: fit-content;
    word-break: break-word;
    border: 0;
}

/* ---- Choice Modal Components ---- */
.choice-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 8px;
}

.choice-option {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 320px;
}

.choice-option:hover {
    border-color: #8b5cf6;
    background: #faf7ff;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.15);
}

.choice-option.anonymous:hover {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.15);
}

.choice-option.authenticated:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.choice-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.choice-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.choice-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1e293b;
}

.choice-content p {
    color: #64748b;
    font-size: 0.95rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.choice-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    text-align: left;
}

.choice-content li {
    color: #475569;
    font-size: 0.9rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.choice-content li::before {
    content: '';
    width: 4px;
    height: 4px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

/* ---- Choice Modal Buttons ---- */
.choice-modal .choice-btn {
    width: 100%;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.choice-modal .anonymous-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.choice-modal .anonymous-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.choice-modal .login-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    color: white !important;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.choice-modal .login-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.choice-modal .login-btn:disabled {
    background: #94a3b8 !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---- Choice Modal States ---- */
.choice-btn .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.9rem;
    text-align: center;
}

/* ---- Modal Mobile Responsiveness ---- */
@media (max-width: 768px) {
    .choice-modal {
        max-width: 95%;
        margin: 20px;
    }

    .choice-options {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .choice-option {
        padding: 20px;
    }

    .choice-icon {
        font-size: 2rem;
        height: 50px;
        margin-bottom: 12px;
    }

    .choice-content h3 {
        font-size: 1.1rem;
    }

    .choice-content p {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    .choice-content li {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }

    .choice-btn {
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .modal-header {
        padding: 20px 20px 12px;
    }

    .modal-header h2 {
        font-size: 1.3rem;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 12px 20px 20px;
    }

    /* Shared Modal Button System Mobile */
    .modal-button-group {
        flex-direction: column;
        gap: 8px;
        margin-top: 20px;
    }

    .modal-btn {
        width: 100%;
        min-width: auto;
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    .upgrade-prompt {
        width: 95%;
        margin: 20px 10px;
    }

    /* Close Button Mobile Optimization - Touch-friendly design */
    .close-btn {
        top: 8px;
        right: 8px;
        font-size: 1.4rem;
        /* Larger for better touch target */
        padding: 8px;
        /* 1.4rem + 16px = ~42px touch target */
        min-width: 44px;
        /* Enforce Apple/Google touch standard */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ---- Metadata & Email Modal Variants ---- */
.metadata-modal {
    max-width: 600px;
    width: 95%;
}

.email-popup {
    max-width: 450px;
    width: 90%;
}

.metadata-modal .modal-body,
.email-popup .modal-body {
    padding: 24px;
}

.metadata-modal .form-group {
    margin-bottom: 20px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.metadata-modal .form-group[aria-hidden="true"] {
    opacity: 0;
    transform: translateY(-10px);
}

.metadata-modal label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.metadata-modal input,
.metadata-modal select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
    box-sizing: border-box;
}

.metadata-modal input:focus,
.metadata-modal select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.metadata-modal .required-notice {
    margin: 16px 0 8px 0;
    text-align: left;
}

.metadata-modal .required-notice small {
    color: #6b7280;
    font-size: 0.85rem;
}

.metadata-modal .button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.metadata-modal .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.metadata-modal .btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.metadata-modal .btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.metadata-modal .btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.metadata-modal .btn-secondary:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

@media (max-width: 768px) {

    .metadata-modal,
    .email-popup {
        width: 95%;
        margin: 20px 10px;
    }

    .metadata-modal .button-group {
        flex-direction: column;
        gap: 8px;
    }

    .metadata-modal .btn {
        width: 100%;
        min-width: auto;
    }

    /* Terms Modal Mobile Overrides */
    .modal-overlay#terms-modal .modal-content {
        width: 98vw;
        min-width: unset;
        padding: 18px 6vw 18px 6vw;
    }
}

/* ====================================================================
   16. LOGIN & AUTHENTICATION STYLES
   ==================================================================== */
.login-content {
    max-width: 400px;
    margin: 60px auto 0 auto;
    padding: 32px 24px;
    text-align: center;
}

.login-logo {
    width: 25px;
    margin-bottom: 25px;
}

.login-btn {
    padding: 12px 16px;
    border-radius: 12px;
    background: #fff;
    border: 0px;
    cursor: pointer;
    font-weight: 500;
    box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
    font-size: 0.9em;
    color: #565656;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: 38px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-width: 160px;
}

.user-info {
    padding: 12px 16px;
    font-weight: 500;
}

.logout-btn {
    width: 100%;
    padding: 10px 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #d32f2f;
    font-weight: 500;
}

/* ====================================================================
   17. ACCESSIBILITY & REDUCED MOTION
   ==================================================================== */
@media (prefers-reduced-motion: reduce) {

    .avatar,
    .avatar-idle,
    .avatar-listening,
    .avatar-speaking {
        animation: none !important;
    }

    .avatar {
        box-shadow: 0 20px 60px rgba(169, 43, 219, 0.4);
    }

    .avatar-listening {
        box-shadow: 0 20px 60px rgba(16, 185, 129, 0.4);
    }

    .avatar-speaking {
        box-shadow: 0 20px 60px rgba(59, 130, 246, 0.4);
    }

    .message-pill {
        animation: none;
    }

    /* Choice Modal Reduced Motion */
    .choice-option {
        transition: none;
    }

    .choice-option:hover {
        transform: none;
    }

    .choice-btn {
        transition: none;
    }

    .choice-btn:hover {
        transform: none;
    }

    .spinner {
        animation: none;
    }
}

/* ====================================================================
   18. HIGH CONTRAST MODE SUPPORT
   ==================================================================== */
@media (prefers-contrast: high) {
    .avatar-idle {
        background: linear-gradient(135deg, #9966cc 0%, #bb77dd 100%);
    }

    .avatar-listening {
        background: linear-gradient(135deg, #00aa66 0%, #00cc77 100%);
    }

    .avatar-speaking {
        background: linear-gradient(135deg, #0066ff 0%, #0077ff 100%);
    }

    .error-pill {
        background: #cc0000;
        border: 2px solid #ffffff;
    }

    .info-pill {
        background: #444444;
        border: 2px solid #ffffff;
    }
}

/* ====================================================================
   19. MOBILE RESPONSIVE STYLES
   ==================================================================== */
@media (max-width: 768px) {

    /* Call Interface Mobile */
    .header {
        padding: 20px 15px 15px;
    }

    .caller-name {
        font-size: 1.5rem;
    }

    .call-duration {
        font-size: 1.2rem;
    }

    .avatar {
        width: 140px;
        height: 140px;
    }

    .footer {
        padding: 30px 15px;
    }

    .controls {
        padding: 15px 30px;
        gap: 25px;
    }

    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 18px;
    }

    /* Transcript Mobile */
    .transcript-content {
        width: 98vw;
        min-width: unset;
        padding: 18px 6vw 18px 6vw;
        margin-bottom: 90px;
    }

    .transcript-panel {
        width: 96vw;
        padding: 14px 4vw 14px 4vw;
        bottom: 210px;
    }

    .transcript-text {
        max-height: 180px;
    }

    .message-pill {
        font-size: 0.85rem;
        padding: 6px 14px;
        max-width: 90%;
    }

    /* Contact Selection Mobile */
    .persona-card {
        padding: 12px 15px;
        gap: 10px;
        width: 90vw;
    }

    .persona-avatar {
        width: 44px;
        height: 44px;
    }

    .persona-name {
        font-size: 1.05rem;
    }

    .persona-desc {
        font-size: 0.92rem;
    }

    .latency-toggle-container {
        margin: 35px 0;
        padding: 14px 16px;
        width: 90vw;
    }

    .latency-toggle-container h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .toggle-label {
        font-size: 0.9rem;
        min-width: 50px;
    }
}