/* Hermes Voice Client — Videocall Dark Theme */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: #161633;
    --accent-primary: #6366f1;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #6366f1, #06b6d4);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --danger: #ef4444;
    --success: #22c55e;
    --border: rgba(99, 102, 241, 0.15);
    --glow: rgba(99, 102, 241, 0.25);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --pip-size: 120px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
}
.screen.active {
    display: flex;
}

/* ── Connect Screen ──────────────────────────────── */
#connect-screen {
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
}

.logo-container {
    text-align: center;
}

.logo-ring {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem;
    animation: pulse-glow 3s ease-in-out infinite;
}

.logo-svg {
    width: 100%;
    height: 100%;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.6)); }
}

.app-title {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 300;
    margin-top: 0.5rem;
}

/* Mode selector */
.mode-selector {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 9999px;
    padding: 4px;
    border: 1px solid var(--border);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.mode-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

/* Hermes toggle (home PC delegation) */
.hermes-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.hermes-toggle:hover { opacity: 1; }
.hermes-toggle.hidden { display: none; }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    user-select: none;
}
.hermes-toggle input:checked ~ .toggle-slider + .toggle-label,
.hermes-toggle:has(input:checked) .toggle-label {
    color: var(--accent-primary);
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 22px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.25s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform 0.25s, background 0.25s;
}
.toggle-switch input:checked + .toggle-slider {
    background: rgba(99, 102, 241, 0.3);
    border-color: var(--accent-primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: var(--accent-primary);
}

.connect-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 9999px;
    color: white;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}
.connect-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}
.connect-button:active {
    transform: scale(0.98);
}

/* ── Session Screen ──────────────────────────────── */
#session-screen {
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

/* Video area — fills full screen, portrait selfie crop */
.video-area {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    overflow: hidden;
}

/* PiP mode — small round avatar at top of fullscreen chat */
.video-area.pip {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    bottom: auto;
    right: auto;
    width: var(--pip-size);
    height: var(--pip-size);
    border-radius: 50%;
    overflow: hidden;
    z-index: 25;
    border: 2px solid var(--accent-primary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 12px var(--glow);
}

.video-area.pip #avatar-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.video-area.pip .avatar-placeholder {
    width: 100%;
    height: 100%;
}

.video-area.pip .avatar-placeholder .avatar-icon svg {
    width: 36px;
    height: 36px;
}

.video-area.pip .avatar-rings {
    display: none;
}

.video-area.pip .visualizer-overlay,
.video-area.pip .agent-status-overlay {
    display: none;
}

/* Avatar placeholder */
.avatar-placeholder {
    position: relative;
    width: 240px;
    height: 240px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-rings {
    position: absolute;
    inset: 0;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--border);
}
.ring-1 {
    inset: 0;
    animation: ring-rotate 12s linear infinite;
}
.ring-2 {
    inset: 20px;
    animation: ring-rotate 8s linear infinite reverse;
    border-color: rgba(6, 182, 212, 0.15);
}
.ring-3 {
    inset: 40px;
    animation: ring-rotate 6s linear infinite;
    border-style: dashed;
}

@keyframes ring-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.avatar-icon {
    color: var(--text-secondary);
    z-index: 1;
}

#avatar-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

#avatar-video.visible {
    display: block;
}

/* Speaking animation */
.video-area.speaking .ring-1 {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 20px var(--glow);
}
.video-area.speaking .ring-2 {
    border-color: rgba(6, 182, 212, 0.4);
}
.video-area.pip.speaking {
    border-color: var(--accent-secondary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 20px rgba(6, 182, 212, 0.4);
}

/* Agent status overlay */
.agent-status-overlay {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    transition: opacity 0.3s;
    pointer-events: none;
}

.agent-status {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(10, 10, 26, 0.85);
    padding: 0.4rem 1.1rem;
    border-radius: 9999px;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.agent-status.listening { color: var(--accent-secondary); border-color: rgba(6,182,212,0.3); }
.agent-status.speaking  { color: var(--accent-primary);   border-color: rgba(99,102,241,0.4); }
.agent-status.thinking  { color: var(--text-secondary); }
.agent-status.working   {
    color: #f59e0b;
    border-color: rgba(245,158,11,0.35);
    animation: workingPulse 1.6s ease-in-out infinite;
}
@keyframes workingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* Transcript links */
.transcript-entry a {
    color: var(--accent-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.transcript-entry a:hover { opacity: 0.8; }

/* Documents panel */
.docs-panel {
    position: absolute;
    bottom: 5rem;
    right: 1rem;
    width: 280px;
    max-height: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    backdrop-filter: blur(16px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: opacity 0.2s, transform 0.2s;
}
.docs-panel.hidden { display: none; }
.docs-panel-header {
    padding: 0.6rem 0.9rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.docs-panel-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem 0;
}
.docs-panel-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
}
.docs-panel-item:hover { background: rgba(99,102,241,0.08); }
.docs-panel-item svg { flex-shrink: 0; opacity: 0.6; }
.docs-panel-empty {
    padding: 1rem 0.9rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}
.docs-btn-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Visualizer overlay */
.visualizer-overlay {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 300px;
    height: 40px;
    z-index: 10;
    opacity: 0.6;
}

#visualizer-canvas {
    width: 100%;
    height: 100%;
}

/* ── Transcript Panel ────────────────────────────── */
.transcript-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72vh;
    max-height: 72vh;
    background: var(--bg-secondary);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 44px rgba(0, 0, 0, 0.5);
    z-index: 15;
    display: flex;
    flex-direction: column;
    transform: translateY(105%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.transcript-panel.open {
    transform: translateY(0);
}

.transcript-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.1rem 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
/* drag handle */
.transcript-header::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
}

.transcript-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.transcript-close-btn:hover {
    background: rgba(99, 102, 241, 0.15);
}

.transcript-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    scroll-behavior: smooth;
    min-height: 0;
}

.transcript {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.transcript-entry {
    max-width: 80%;
    padding: 0.6rem 0.85rem;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: fade-in 0.25s ease;
}

.transcript-entry.user {
    align-self: flex-end;
    background: var(--accent-gradient);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.transcript-entry.agent {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 5px;
}
.transcript-entry.agent a { color: var(--accent-secondary); }

.transcript-entry.pending {
    opacity: 0.65;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Text input inside transcript panel */
.text-input-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.7rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

#text-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 9999px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
#text-input:focus {
    border-color: var(--accent-primary);
}
#text-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.send-btn:hover {
    transform: scale(1.08);
}
.send-btn:active {
    transform: scale(0.95);
}

/* ── Floating Controls ───────────────────────────── */
.controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding: 1.25rem;
    z-index: 18;
    background: linear-gradient(transparent, rgba(10, 10, 26, 0.85));
    transition: opacity 0.3s;
}

/* When transcript is open, controls move up */
.controls.chat-open {
    bottom: calc(72vh + 6px);
    background: none;
    padding: 0.5rem;
}

.control-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(22, 22, 51, 0.8);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(12px);
}
.control-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary);
}
.control-btn:active {
    transform: scale(0.92);
}

.control-btn.disconnect {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.control-btn.disconnect:hover {
    background: #dc2626;
}

.control-btn.muted {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: var(--danger);
}

.control-btn.active-chat {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

/* ── Connecting Overlay ──────────────────────────── */
.connecting-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    z-index: 100;
    backdrop-filter: blur(8px);
}
.connecting-overlay.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Audio-only mode ─────────────────────────────── */
.video-area.audio-only {
    background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.06) 0%, var(--bg-primary) 70%);
}

.video-area.audio-only .visualizer-overlay {
    bottom: 50%;
    transform: translate(-50%, 50%);
    width: 80%;
    max-width: 400px;
    height: 80px;
    opacity: 1;
}

.video-area.audio-only .avatar-placeholder {
    display: none;
}

.video-area.audio-only .agent-status-overlay {
    top: 50%;
    transform: translate(-50%, -80px);
}

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Safe area for mobile (notch) */
@supports(padding: env(safe-area-inset-bottom)) {
    .controls {
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }
    .text-input-container {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
}

/* Responsive */
@media (min-width: 768px) {
    .avatar-placeholder {
        width: 300px;
        height: 300px;
    }
    :root {
        --pip-size: 160px;
    }
}

@media (min-width: 1024px) {
    #session-screen {
        max-width: 900px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    :root {
        --pip-size: 180px;
    }
    .transcript-panel {
        height: 50%;
    }
    .controls.chat-open {
        bottom: 50%;
    }
    .video-area.pip {
        bottom: calc(50% + 70px);
    }
}

/* ── Reactions Float-Up ──────────────────────────── */
.reaction-float {
    position: absolute;
    bottom: 80px;
    z-index: 12;
    pointer-events: none;
    animation: float-up-wobble 2.5s ease-out forwards;
    will-change: transform, opacity;
}

@keyframes float-up-wobble {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 1;
    }
    20% {
        transform: translateY(-60px) translateX(10px) scale(1.2);
        opacity: 1;
    }
    50% {
        transform: translateY(-180px) translateX(-8px) scale(1);
        opacity: 0.9;
    }
    80% {
        transform: translateY(-300px) translateX(5px) scale(0.9);
        opacity: 0.5;
    }
    100% {
        transform: translateY(-400px) translateX(0) scale(0.7);
        opacity: 0;
    }
}

/* ── Photo Overlay ───────────────────────────────── */
.photo-overlay {
    position: absolute;
    inset: 0;
    z-index: 11;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 26, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

.photo-overlay.visible {
    opacity: 1;
}

.photo-overlay img {
    max-width: 80%;
    max-height: 60%;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    object-fit: contain;
}

.photo-overlay .photo-caption {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: rgba(10, 10, 26, 0.6);
    padding: 0.5rem 1.5rem;
    border-radius: 9999px;
    backdrop-filter: blur(8px);
}

/* ── Settings Button ───────────────────────────────── */
.settings-btn {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.settings-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px var(--glow);
}

/* ── Settings Panel ────────────────────────────────── */
.settings-panel {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.settings-panel.hidden {
    display: none;
}

.settings-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.settings-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.settings-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: color 0.2s;
}

.settings-close-btn:hover {
    color: var(--text-primary);
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.settings-select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: auto;
    transition: border-color 0.2s;
}

.settings-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--glow);
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    line-height: 1.4;
}

.settings-save-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: white;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

.settings-save-btn:hover {
    opacity: 0.9;
}

.settings-save-btn:active {
    transform: scale(0.98);
}

/* ── Photo Slideshow Overlay (Teams screen-share style) ──── */
.slideshow-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: #0a0a14;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.slideshow-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.slideshow-overlay.hidden {
    display: none;
}

/* Photo fills most of the screen */
.slideshow-photo-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.slideshow-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0;
    transition: opacity 0.35s ease;
}

.slideshow-img.loading {
    opacity: 0.3;
}

/* "Screen sharing" badge (top left) */
.slideshow-screen-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: rgba(99, 102, 241, 0.85);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
    backdrop-filter: blur(6px);
}

/* Bottom info + navigation bar */
.slideshow-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: rgba(10, 10, 26, 0.95);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.slideshow-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.slideshow-date {
    font-size: 0.78rem;
    color: var(--accent-secondary);
    font-weight: 500;
}

.slideshow-location {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.slideshow-summary {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
    margin: 0;
}

.slideshow-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.slideshow-counter {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-width: 3rem;
    text-align: center;
}

.slideshow-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, opacity 0.15s;
}

.slideshow-nav-btn:hover {
    background: rgba(99, 102, 241, 0.25);
}

.slideshow-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.slideshow-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    margin-left: 0.4rem;
}

.slideshow-close-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Avatar PiP during slideshow (bottom right) */
.slideshow-pip {
    position: absolute;
    bottom: 5rem;
    right: 1rem;
    width: 140px;
    height: 140px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--accent-primary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    z-index: 51;
}

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

.slideshow-pip-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.2rem 0.5rem;
    background: rgba(10, 10, 26, 0.7);
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-align: center;
    backdrop-filter: blur(4px);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .slideshow-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
        padding: 0.75rem 1rem;
    }

    .slideshow-summary {
        max-width: 100%;
        white-space: normal;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .slideshow-pip {
        width: 100px;
        height: 100px;
        bottom: 7rem;
    }
}

/* ── Self-View Camera PiP ──────────────────────────── */
.self-view {
    position: absolute;
    bottom: 80px;
    right: 12px;
    width: 75px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    z-index: 14;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.self-view.hidden { display: none; }

.self-view video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.control-btn.active-cam {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

/* Adjust self-view when chat is open */
.controls.chat-open ~ .self-view,
.video-area.pip ~ .self-view {
    bottom: auto;
    top: 12px;
    right: 12px;
    width: 60px;
    height: 80px;
}

/* ── Camera swap (click PiP to swap with avatar) ─── */
.video-area.camera-swapped #avatar-video {
    position: absolute !important;
    bottom: 80px;
    left: 12px;
    right: auto;
    width: 75px;
    height: 100px;
    border-radius: 12px;
    object-fit: cover;
    z-index: 14;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.video-area.camera-swapped .self-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 5;
    cursor: pointer;
}

.video-area.camera-swapped .self-view video {
    border-radius: 0;
}

/* ── Link / Preview Card ────────────────────────── */
.link-card {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    min-width: 260px;
    max-width: min(90vw, 440px);
}

.link-card.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: all;
}

.link-card.hidden { display: none; }

.link-card-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 15, 35, 0.92);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 14px;
    padding: 10px 14px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99,102,241,0.15);
}

.link-card-label {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-card-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--accent-gradient);
    color: #fff;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.link-card-btn:hover { opacity: 0.85; }

.link-card-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.9rem;
    line-height: 1;
    flex-shrink: 0;
}
.link-card-close:hover { color: var(--text-primary); }

/* ── Thought Bubbles (Gedankenblasen) ───────────────────────── */
.thought-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(220, 230, 255, 0.65), rgba(99, 102, 241, 0.25));
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 11;
    animation: thought-float 2.5s ease-out forwards;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

@keyframes thought-float {
    0%   { transform: scale(0.3) translateY(0);                          opacity: 0; }
    15%  { transform: scale(1) translateY(-10px);                        opacity: 0.9; }
    50%  { transform: scale(1.1) translateY(-60px) translateX(15px);     opacity: 0.7; }
    100% { transform: scale(0.6) translateY(-130px) translateX(-10px);   opacity: 0; }
}

/* ── Idea Flash (Glühbirne) ─────────────────────────────────── */
.idea-flash {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    z-index: 12;
    pointer-events: none;
    animation: idea-pop 1.2s ease-out forwards;
    filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.7));
}

@keyframes idea-pop {
    0%   { transform: translateX(-50%) scale(0) rotate(-20deg); opacity: 0; }
    20%  { transform: translateX(-50%) scale(1.3) rotate(5deg);  opacity: 1; }
    40%  { transform: translateX(-50%) scale(1) rotate(0deg);    opacity: 1; }
    70%  { transform: translateX(-50%) scale(1.1) translateY(-15px); opacity: 0.8; }
    100% { transform: translateX(-50%) scale(0.5) translateY(-40px); opacity: 0; }
}

/* ── Cowork Pipeline ────────────────────────────────────────── */
.cowork-pipeline {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 13;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}
.cowork-pipeline.hidden { display: none; }

.pipeline-stages {
    display: flex;
    align-items: center;
    background: rgba(14, 14, 36, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 9999px;
    padding: 0.4rem 0.8rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}
.pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem 0.45rem;
    opacity: 0.3;
    transition: all 0.35s ease;
}
.pipeline-stage span:last-child {
    font-size: 0.52rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}
.pipeline-stage .stage-icon { font-size: 1rem; line-height: 1; transition: transform 0.3s; }
.pipeline-stage.active  { opacity: 1; }
.pipeline-stage.active .stage-icon { animation: stage-pulse 1.5s ease-in-out infinite; }
.pipeline-stage.completed { opacity: 0.65; }
@keyframes stage-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }

.pipeline-connector {
    width: 14px; height: 2px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 2px;
    transition: background 0.4s;
    flex-shrink: 0;
}
.pipeline-connector.filled { background: linear-gradient(90deg, #6366f1, #06b6d4); }

.cowork-deploy-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 220px;
    height: 42px;
    border-radius: 9999px;
    background: rgba(14, 14, 36, 0.92);
    border: 1px solid rgba(99, 102, 241, 0.25);
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.4s;
}
.cowork-deploy-btn.hidden { display: none; }
.deploy-wave {
    position: absolute; left: 0; top: 0; height: 100%; width: 0%;
    background: linear-gradient(90deg, rgba(99,102,241,0.3), rgba(6,182,212,0.3));
    transition: width 0.8s ease; border-radius: 9999px;
}
.deploy-wave::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
    animation: wave-shimmer 2s ease-in-out infinite;
}
@keyframes wave-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }
.deploy-label {
    position: relative; z-index: 1;
    font-family: var(--font); font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary); letter-spacing: 0.03em;
}
.cowork-deploy-btn.ready { border-color: rgba(34,197,94,0.5); box-shadow: 0 4px 20px rgba(34,197,94,0.2); }
.cowork-deploy-btn.ready .deploy-wave { width: 100% !important; background: linear-gradient(90deg, rgba(34,197,94,0.3), rgba(6,182,212,0.3)); }
.cowork-deploy-btn.ready .deploy-label { color: #22c55e; font-weight: 600; }
.cowork-deploy-btn.ready:hover { transform: scale(1.05); }
