:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.hidden {
    display: none !important;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.glass-panel.micro {
    border-radius: 12px;
}

/* Auth Profile UI */
.auth-container {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 100;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    padding: 8px 16px 8px 8px;
    border-radius: 40px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.4s ease;
}

.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}

.user-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Join Screen */
#join-screen {
    padding: 40px;
    width: 90%;
    max-width: 480px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

#join-screen h1 {
    font-weight: 600;
    font-size: 2.5rem;
    margin-bottom: 8px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#join-screen p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

button,
a.primary-btn,
a.secondary-btn {
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.primary-btn {
    background: var(--accent);
    color: white;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.secondary-btn {
    background: transparent;
    color: var(--text-secondary);
    width: 100%;
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.primary-btn.sm,
.secondary-btn.sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    width: auto;
}

/* Pill variant — used in the auth profile so Logout matches My Recordings */
.primary-btn.sm.pill,
.secondary-btn.sm.pill {
    border-radius: 999px;
    padding: 6px 16px;
}
.secondary-btn.sm.pill {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
}
.secondary-btn.sm.pill:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Settings Modal */
#settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 32px;
    width: 90%;
    max-width: 480px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    animation: zoomIn 0.3s ease;
}

#settings-modal h2 {
    font-size: 1.6rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.setting-group label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.setting-group select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.setting-group select:focus {
    border-color: var(--accent);
}

.setting-group select option {
    background: #1e1b4b;
    /* Opaque baseline color for dropdown menus */
    color: white;
}

/* Call Screen */
#call-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
    transition: padding 0.3s ease;
}

/* Slim header: floats over content, doesn't push video down */
.header {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 6px 16px;
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    z-index: 20;
    transition: opacity 0.35s ease, transform 0.35s ease;
    white-space: nowrap;
}

.header ion-icon {
    font-size: 1rem;
    vertical-align: middle;
    margin-right: 2px;
}

.header .duration-text { margin-left: 0 !important; opacity: 1 !important; font-size: 0.82rem !important; }
.header #room-display { font-weight: 500; color: var(--text-primary); }
.header #participant-count { display: inline-flex; align-items: center; }

/* Auto-hide chrome on mouse idle during a call */
body.is-idle .header,
body.is-idle .controls,
body.is-idle #auth-container {
    opacity: 0;
    transform: translate(var(--idle-tx, 0), var(--idle-ty, 8px));
    pointer-events: none;
}
body.is-idle .header { --idle-tx: -50%; --idle-ty: -8px; }
body.is-idle.in-call { cursor: none; }

/* Active speaker accent ring */
.video-container.is-speaking {
    box-shadow: 0 0 0 2px var(--accent), 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Tile name label (bottom-left glass pill) */
.video-label {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 24px);
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}
.video-label .mic-off-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: var(--danger);
}
.video-label .mic-off-icon svg { width: 14px; height: 14px; }

/* Custom hover tooltip for control buttons.
   Replaces the slow, browser-native title= popup with our design language. */
.control-btn[data-tip] {
    position: relative;
}
.control-btn[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 5px 10px;
    background: rgba(15, 23, 42, 0.92);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 50;
}
.control-btn[data-tip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
body.is-idle .control-btn[data-tip]::after { opacity: 0 !important; }

.header ion-icon {
    font-size: 1.2rem;
    vertical-align: middle;
    margin-right: 4px;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    gap: 20px;
    min-height: 0;
    /* Ensures flexbox can shrink child to fit viewport safely */
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Video Grid */
/* Video Grid Layout Container */
.video-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px;
    align-items: stretch;
    align-content: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    transition: padding 0.3s ease, gap 0.3s ease;
    overflow-y: auto;
}

/* For 1–2 person layouts, tiles fill the full available height instead
   of being capped by a 16:9 aspect ratio. Tracks crop with object-fit:
   cover, so this just removes dead vertical space. Layouts 3+ keep the
   aspect ratio so wrapping rows fit on screen. */
.video-grid.layout-1 .video-container,
.video-grid.layout-2 .video-container {
    aspect-ratio: auto;
    height: 100%;
    min-height: 0;
}

/* When idle, the video goes truly edge-to-edge: paddings and gaps collapse,
   tile corners straighten out, the surrounding chrome disappears. */
body.is-idle #call-screen { padding: 0; }
body.is-idle .video-grid { padding: 0; gap: 0; }
body.is-idle .video-container { border-radius: 0; box-shadow: none; }
body.is-idle .video-container.is-speaking {
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* Dynamic Width Sizing based on JS total visible count */
.video-grid.layout-1 .video-container {
    width: 90%;
    max-width: 1000px;
}

.video-grid.layout-2 .video-container {
    width: calc(50% - 10px);
}

.video-grid.layout-3 .video-container {
    width: calc(50% - 10px);
}

.video-grid.layout-4 .video-container {
    width: calc(50% - 10px);
}

.video-grid.layout-5 .video-container,
.video-grid.layout-6 .video-container,
.video-grid.layout-9 .video-container {
    width: calc(33.33% - 12px);
}

.video-grid.layout-7 .video-container,
.video-grid.layout-8 .video-container {
    width: calc(25% - 14px);
}

/* === Layout Mode: Gallery === */
/* Forces equal-sized tiles regardless of participant count */
.video-grid.mode-gallery .video-container {
    width: calc(50% - 10px) !important;
    max-width: none;
}

/* === Layout Mode: Stacked (top/bottom) === */
/* Each tile gets full width; height splits evenly across all visible tiles.
   flex-direction: column makes flex-grow distribute height. */
.video-grid.mode-stacked {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    align-content: stretch;
}
.video-grid.mode-stacked .video-container {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 0 !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
}

/* === Layout Mode: Sidebar === */
/* One large focused video + small thumbnails */
.video-grid.mode-sidebar {
    flex-wrap: nowrap;
    align-items: stretch;
}

.video-grid.mode-sidebar .sidebar-main {
    flex: 1 1 70%;
    width: 70% !important;
    max-width: none;
    order: -1;
}

.video-grid.mode-sidebar .sidebar-thumb {
    flex: 0 0 auto;
    width: 200px !important;
    height: 112px;
    min-height: auto;
    align-self: flex-start;
}

/* === Layout Mode: Focus === */
/* Only the focused video is visible */
.video-grid.mode-focus .focus-visible {
    width: 95% !important;
    max-width: 1200px;
}

.video-grid.mode-focus .focus-hidden {
    display: none !important;
}

/* === Layout Toast Notification === */
#layout-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    color: white;
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: 1px solid rgba(124, 58, 237, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999;
}

#layout-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Active state for layout button */
#toggle-layout-btn.active {
    background: rgba(124, 58, 237, 0.3);
    border-color: var(--primary-color);
}

/* Spotlight Layout for Screen Sharing / pinned video.
   The spotlit tile takes a full row up top; other tiles sit as a row of
   fixed-size thumbnails below. Width rules use flex-basis with !important
   to defeat any layout-N width rules that may also match. */
.video-grid.spotlight {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    align-content: flex-start;
}

.video-grid.spotlight .video-container {
    flex: 0 0 256px !important;
    width: 256px !important;
    max-width: 256px !important;
    height: 144px !important;
    aspect-ratio: auto !important;
    min-height: 0 !important;
}

.video-grid.spotlight .video-container.spotlight-active {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 70vh !important;
    order: -1;
    margin-bottom: 8px;
}

.summary-text p {
    margin-bottom: 12px;
}

.summary-text ul,
.summary-text ol {
    margin-left: 20px;
    margin-bottom: 12px;
    padding-left: 10px;
}

.summary-text li {
    margin-bottom: 6px;
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 100px;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: zoomIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    transition: width 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.video-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
}

.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.avatar-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.avatar-overlay img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    object-fit: cover;
}

.avatar-overlay .avatar-name {
    font-size: 1.4rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

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

/* Specific styling if someone is sharing screen to scale down rather than crop */
video.screenshare {
    object-fit: contain;
}

/* Prevent ultra-wide monitor horizontal cropping when pinning a webcam */
.video-container.spotlight-active video {
    object-fit: contain;
}

/* AI Sidebar */
#ai-sidebar {
    width: 350px;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease, opacity 0.3s ease;
    transform-origin: right;
    overflow: hidden;
}

#ai-sidebar.hidden {
    width: 0;
    opacity: 0;
    border: none;
    padding: 0;
    margin: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding: 16px;
}

.tab-btn {
    background: none;
    padding: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-radius: 6px;
    letter-spacing: 1px;
}

.tab-btn.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    font-weight: 600;
}

.icon-btn {
    background: none;
    color: var(--text-secondary);
    padding: 4px;
    font-size: 1.2rem;
}

.icon-btn:hover {
    color: white;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sidebar-content.hidden {
    display: none;
}

.transcript-line {
    margin-bottom: 12px;
}

.transcript-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    display: block;
}

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

.transcript-placeholder,
.summary-placeholder {
    color: var(--text-secondary);
    text-align: center;
    margin-top: 50%;
    font-style: italic;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
}

.primary-btn.sm {
    padding: 10px 16px;
    font-size: 0.9rem;
    width: 100%;
}

.primary-btn.sm.disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

/* Controls */
.controls {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    z-index: 20;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.control-btn svg {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    flex-shrink: 0;
    display: block;
    pointer-events: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.control-btn.active {
    background: rgba(255, 255, 255, 0.2);
}

.control-btn.off {
    background: var(--danger);
}

.control-btn.danger {
    background: var(--danger);
}

.control-btn.danger:hover {
    background: var(--danger-hover);
}

.control-btn.recording {
    background: var(--danger);
    animation: pulseRecord 1.5s infinite;
}

/* Animations */
@keyframes pulseRecord {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

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

/* Dashboard / Gallery View */
#dashboard-screen {
    width: 90%;
    max-width: 800px;
    height: 80vh;
    padding: 32px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.dashboard-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.recordings-gallery {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    overflow-y: auto;
    padding-right: 8px;
    /* Room for scrollbar */
}

.recording-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.recording-card.processing {
    background: rgba(255, 165, 0, 0.05);
    border-color: rgba(255, 165, 0, 0.3);
}

.recording-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.1);
}

.recording-card .room-id {
    font-weight: 600;
    font-size: 1.1rem;
    color: white;
    margin-bottom: 4px;
}

.recording-card .date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex: 1;
    /* Pushes the button to the bottom */
}

@media (max-width: 600px) {

    /* Mobile-only Flex wrapping overrides */
    .video-grid.layout-2 .video-container,
    .video-grid.layout-3 .video-container,
    .video-grid.layout-4 .video-container {
        width: 100%;
    }

    #dashboard-screen {
        padding: 20px;
        height: 90vh;
    }

    .recordings-gallery {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 8px 12px;
        gap: 12px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .controls::-webkit-scrollbar {
        display: none;
    }

    .control-btn {
        flex: 0 0 auto;
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .control-btn svg {
        width: 22px;
        height: 22px;
        min-width: 22px;
        min-height: 22px;
    }

    /* Mobile: full-width chat overlay */
    #chat-overlay {
        left: 10px;
        right: 10px;
        width: auto;
        bottom: 80px;
    }

    /* Mobile: smaller video corners */
    .video-container {
        border-radius: 12px;
    }

    /* Mobile: responsive header */
    .header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 16px;
    }

    /* Mobile: gallery mode stacks to single column */
    .video-grid.mode-gallery .video-container {
        width: 100% !important;
    }

    /* Mobile: sidebar becomes vertical */
    .video-grid.mode-sidebar {
        flex-wrap: wrap;
    }
    .video-grid.mode-sidebar .sidebar-main {
        width: 100% !important;
        flex: 1 1 100%;
    }
    .video-grid.mode-sidebar .sidebar-thumb {
        width: calc(50% - 8px) !important;
        height: auto;
    }
}

/* Extra-small screens */
@media (max-width: 400px) {
    .control-btn {
        width: 40px;
        height: 40px;
    }
    .control-btn svg {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
    }
    .controls {
        gap: 8px;
        padding: 6px 8px;
    }
    .header {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* Chat Overlay */
#chat-overlay {
    position: absolute;
    bottom: 90px;
    left: 20px;
    width: 320px;
    height: 400px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

#chat-overlay.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-placeholder {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.85rem;
    margin-top: 20px;
}

.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.chat-msg .sender-name {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.chat-msg.local {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.remote {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--glass-border);
}

.chat-input-area {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 14px;
    color: white;
    font-size: 0.9rem;
    outline: none;
}

#chat-input::placeholder {
    color: var(--text-secondary);
}

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

#send-chat-btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* ============================================================
   Booking Page configuration modal
   ============================================================ */
.booking-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    z-index: 1000;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}
.booking-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.booking-modal-header h2 { margin: 0; color: white; }
.booking-modal .setting-group { margin-bottom: 22px; }
.booking-modal .setting-group label {
    display: block;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.booking-modal input[type=text],
.booking-modal input[type=number],
.booking-modal select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9em;
}
.booking-modal input[type=number] { width: 60px; }
.booking-modal select {
    width: 100%;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 32px;
}
.booking-modal select option {
    background: #1e1b4b;
    color: white;
}

.booking-status {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
}
.booking-url-row { display: flex; gap: 8px; }
.booking-url-row input[type=text] { flex: 1; }
.booking-url-display {
    margin-top: 6px;
    font-size: 0.9em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.booking-url-display a { color: var(--accent); text-decoration: none; }
.booking-url-display a:hover { text-decoration: underline; }

.booking-hours-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.booking-hour-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.booking-event-types-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.booking-event-type-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
}
.booking-event-type-main { flex: 1; min-width: 0; }
.booking-event-type-name { font-weight: 500; }
.booking-event-type-slug {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Themed in-page dialog (replaces window.prompt / window.confirm)
   ============================================================ */
.app-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.15s ease;
    padding: 16px;
}
.app-dialog {
    width: 100%;
    max-width: 420px;
    padding: 24px 26px;
    color: var(--text-primary);
    animation: zoomIn 0.18s ease;
}
.app-dialog-wide { max-width: 520px; }
.app-dialog h2 {
    margin: 0 0 12px;
    font-size: 1.2rem;
    font-weight: 600;
}
.app-dialog-message {
    margin: 0 0 18px;
    color: var(--text-secondary);
    line-height: 1.45;
    font-size: 0.95rem;
}
.app-dialog-field { margin-bottom: 14px; }
.app-dialog-field label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.app-dialog-field input,
.app-dialog-field textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease;
}
.app-dialog-field input:focus,
.app-dialog-field textarea:focus { border-color: var(--accent); }
.app-dialog-field textarea { resize: vertical; min-height: 70px; }
.app-dialog-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}
.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}
/* Reused danger color for destructive confirms */
.danger-btn {
    background: var(--danger);
    color: white;
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.15s ease;
}
.danger-btn:hover { background: var(--danger-hover); transform: translateY(-1px); }

/* === Booking modal: section header with inline action button === */
.booking-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.booking-section-head label { margin: 0 !important; }

/* === Question editor rows inside the event-type dialog === */
.qe-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}
.qe-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.qe-row input[type=text] {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
}
.qe-row label {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: none !important;
    letter-spacing: 0 !important;
    margin: 0 !important;
    white-space: nowrap;
}
.qe-row .qe-remove {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1;
}
.qe-row .qe-remove:hover { color: var(--danger); border-color: var(--danger); }
.qe-add-btn {
    background: transparent;
    border: 1px dashed var(--glass-border);
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    width: 100%;
}
.qe-add-btn:hover { color: var(--text-primary); border-color: var(--accent); }

/* Inline "+ Add event type" tile shown at the end of the event-type list */
.booking-event-type-add {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.18);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 4px;
}
.booking-event-type-add:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: rgba(99,102,241,0.06);
}
.booking-event-type-add-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
}
