/* --- Core Styles --- */
:root {
    /* ===========================================
       DESIGN SYSTEM TOKENS
       =========================================== */

    /* --- Colors: Base Palette --- */
    --bg-color: #000000;
    --panel-bg: #09090b;
    --input-bg: #121214;
    --surface-hover: #27272a;
    --surface-active: #323238;

    /* --- Colors: Text --- */
    --text-primary: #e4e4e7;
    --text-secondary: #71717a;
    --text-muted: #52525b;

    /* --- Colors: Brand & Accent --- */
    --accent: #3bf692b0;
    --bubble-accent: #5f57afb0;
    --accent-light: #60a5fa;
    --accent-dim: rgba(59, 130, 246, 0.1);
    --accent-hover: rgba(59, 130, 246, 0.15);

    /* --- Colors: Semantic --- */
    --success: #10b981;
    --success-light: #22c55e;
    --success-dim: rgba(16, 185, 129, 0.1);
    --error: #ef4444;
    --error-light: #f87171;
    --error-dim: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.1);
    --recording: #ef4444;

    /* --- Colors: Borders --- */
    --border: #27272a;
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-medium: rgba(255, 255, 255, 0.07);
    --border-emphasis: rgba(255, 255, 255, 0.12);
    --border-focus: var(--accent);
    --border-error: var(--error);

    /* --- Glow Effects --- */
    --glow-accent: 0 0 16px rgba(59, 246, 146, 0.1);
    --glow-accent-strong: 0 0 24px rgba(59, 246, 146, 0.15);
    --glow-blue: 0 0 16px rgba(59, 130, 246, 0.1);

    /* --- Colors: External Brands --- */
    --google-blue: #4285F4;

    /* --- Typography --- */
    --font-display: 'DM Sans', sans-serif;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* --- Button Sizes --- */
    --btn-size-xs: 32px;
    --btn-size-sm: 40px;
    --btn-size-md: 44px;
    --btn-size-lg: 48px;

    /* --- Icon Sizes (for buttons) --- */
    --btn-icon-xs: 0.75rem;
    --btn-icon-sm: 0.875rem;
    --btn-icon-md: 1rem;
    --btn-icon-lg: 1.2rem;

    /* --- Border Radius --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* --- Z-Index Layers --- */
    --z-base: 0;
    --z-above: 1;
    --z-sticky: 10;
    --z-header: 50;
    --z-dropdown: 100;
    --z-overlay: 200;
    --z-drawer: 300;
    --z-modal: 500;
    --z-toast: 1000;
    --z-tooltip: 1500;
    --z-critical: 2000;
    --z-max: 9999;

    /* --- Shadows --- */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-accent: 0 4px 12px rgba(59, 130, 246, 0.2);

    /* --- Transitions --- */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
    --transition-bounce: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* --- Scrollbar Colors --- */
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);
    --scrollbar-width: 6px;
}

/* ===========================================
   SCROLLBAR STYLING
   Modern, minimal scrollbars that appear on hover/scroll
   =========================================== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
@supports (scrollbar-width: thin) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    }
}

/* ===========================================
   BUTTON SIZE SYSTEM
   =========================================== */

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
}

.btn:hover {
    color: var(--text-primary);
    border-color: var(--border-emphasis);
    box-shadow: var(--shadow-md), var(--glow-accent);
}

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

/* Button size variants */
.btn-xs {
    width: var(--btn-size-xs);
    height: var(--btn-size-xs);
    font-size: var(--btn-icon-xs);
    border-radius: var(--radius-md);
}

.btn-sm {
    width: var(--btn-size-sm);
    height: var(--btn-size-sm);
    font-size: var(--btn-icon-sm);
    border-radius: var(--radius-md);
}

.btn-md {
    width: var(--btn-size-md);
    height: var(--btn-size-md);
    font-size: var(--btn-icon-md);
    border-radius: var(--radius-lg);
}

.btn-lg {
    width: var(--btn-size-lg);
    height: var(--btn-size-lg);
    font-size: var(--btn-icon-lg);
    border-radius: var(--radius-lg);
}

/* Button color variants */
.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.btn-primary:active,
.btn-primary:focus,
.btn-primary:focus-visible {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success-light);
    color: white;
}

.btn-danger {
    background: var(--error-dim);
    color: var(--error);
    border-color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--surface-hover);
}

/* Icon button (square, icon only) */
.btn-icon {
    padding: 0;
    aspect-ratio: 1;
}

/* ===========================================
   GLOBAL RESET & BASE
   =========================================== */

* {
    box-sizing: border-box;
}

/* ===========================================
   UI CHROME TYPOGRAPHY
   Apply DM Sans to all navigational and control
   elements for a refined, cohesive look.
   Body/content text remains on the system stack.
   =========================================== */
.toolbar,
.toolbar-left,
.toolbar-right,
.toolbar-actions,
.session-name,
.session-controls,
.session-dropdown,
.dropdown-item,
.model-badge,
.response-tabs,
.response-tab-btn,
.tab-btn,
.sub-tab-btn,
.tabs-nav,
.btn,
.fab,
.bottom-sheet-content,
.bottom-sheet-btn,
.header-title,
.header-action-btn,
.speaker-chip,
.qa-input-buttons-left,
.qa-input-buttons,
.qa-model-style-indicator,
.toast-pill,
.toast-btn,
.settings-title,
.settings-header,
.controls-overlay,
.live-stats,
.action-badge,
.notification-text,
label,
select,
.icon-btn {
    font-family: var(--font-display);
}

html,
body {
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    margin: 0;
    /* Fallback for browsers that don't support dvh or have buggy implementations */
    height: 100vh;
    height: 100dvh;
    /* Use CSS custom property for JS-controlled height (iOS PWA fix) */
    height: var(--app-height, 100dvh);
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Atmospheric background — subtle radial glow for depth */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(59, 246, 146, 0.025) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 100%, rgba(59, 130, 246, 0.02) 0%, transparent 50%),
        radial-gradient(ellipse 50% 50% at 20% 80%, rgba(95, 87, 175, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===========================================
   TOOLBAR - Enhanced UX
   =========================================== */

.toolbar {
    height: 48px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.012) 100%);
    border-bottom: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    z-index: var(--z-header);
    gap: 1rem;
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Animated gradient bottom edge for toolbar */
.toolbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.5px;
    background: linear-gradient(90deg, var(--accent, #3bf692), #2563eb, #a855f7, var(--accent, #3bf692));
    background-size: 200% 100%;
    animation: toolbar-shimmer 6s linear infinite;
    opacity: 0.6;
}

@keyframes toolbar-shimmer {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* --- Toolbar Left Section --- */
.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 1;
    min-width: 0;
}

.brand {
    font-weight: 600;
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

/* --- Toolbar Divider --- */
.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    flex-shrink: 0;
}

/* --- Session Name with Dropdown --- */
.session-name-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

/* Session Name - Click to Rename */
.session-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    max-width: 225px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    background: linear-gradient(90deg, #3bf692 0%, #60a5fa 50%) text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.session-name:hover {
    background: linear-gradient(90deg, #3bf692 0%, #60a5fa 50%) text, rgba(255, 255, 255, 0.06);
    -webkit-background-clip: text, padding-box;
    background-clip: text, padding-box;
    border-color: rgba(59, 246, 146, 0.15);
    box-shadow: 0 1px 6px rgba(59, 246, 146, 0.1);
}

.session-name:active {
    transform: scale(0.98);
}

/* Session Menu Button (three dots) */
.session-menu-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.session-menu-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.session-menu-btn:active {
    transform: scale(0.92);
}

.session-name-wrapper.open .session-menu-btn {
    background: var(--surface-hover);
    color: var(--accent);
}

/* --- Session Dropdown Menu --- */
.session-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 180px;
    background: linear-gradient(180deg, rgba(24, 24, 28, 0.98) 0%, rgba(14, 14, 16, 0.98) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
}

.session-name-wrapper.open .session-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--surface-hover);
}

.dropdown-item:active {
    transform: scale(0.98);
}

.dropdown-item i {
    width: 16px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.dropdown-item .shortcut {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.dropdown-item.danger {
    color: var(--error);
}

.dropdown-item.danger i {
    color: var(--error);
}

.dropdown-item.danger:hover {
    background: var(--error-dim);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* --- Model Badge --- */
.model-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* --- Session Controls (Action Buttons) --- */
.session-controls {
    display: flex;
    gap: 2px;
    background: var(--surface-hover);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
}

/* Mobile New Session Button - hidden on desktop */
.mobile-new-session-btn {
    display: none;
}

.toolbar-icon-btn {
    width: var(--btn-size-sm);
    height: var(--btn-size-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
}

.toolbar-icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.toolbar-icon-btn:active {
    transform: scale(0.92);
}

.toolbar-icon-btn.primary {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.toolbar-icon-btn.primary:hover {
    filter: brightness(1.1);
}

/* --- Toolbar Icon Button: Loading State ------------------------------
   In-button processing indicator for async toolbar actions (e.g. New
   Session while the previous one is being persisted to Firestore).
   Replaces the icon with a rotating conic-gradient ring that picks up
   the app's accent color, plus a subtle pulsing glow. Matches the
   glassy toolbar design language.                                     */
.toolbar-icon-btn.is-loading {
    pointer-events: none;
    position: relative;
}
.toolbar-icon-btn.is-loading > i {
    opacity: 0;
    transition: opacity 0.15s ease;
}
.toolbar-icon-btn.is-loading::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(255, 255, 255, 0.95) 270deg,
        transparent 360deg
    );
    -webkit-mask: radial-gradient(circle, transparent 55%, #000 56%, #000 100%);
            mask: radial-gradient(circle, transparent 55%, #000 56%, #000 100%);
    animation: toolbar-btn-spin 0.85s linear infinite;
    pointer-events: none;
}
.toolbar-icon-btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
    animation: toolbar-btn-pulse 1.4s ease-out infinite;
    pointer-events: none;
}
/* Non-primary variant: use accent color for the ring sweep */
.toolbar-icon-btn.is-loading:not(.primary)::before {
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        var(--accent-light, #60a5fa) 270deg,
        transparent 360deg
    );
}
@keyframes toolbar-btn-spin {
    to { transform: rotate(360deg); }
}
@keyframes toolbar-btn-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(59, 130, 246, 0.45); }
    70%  { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);    }
    100% { box-shadow: 0 0 0 0   rgba(59, 130, 246, 0);    }
}

/* Mobile new-session icon button reuses the same loading treatment */
.mobile-new-session-btn.is-loading {
    pointer-events: none;
    position: relative;
}
.mobile-new-session-btn.is-loading > i {
    opacity: 0;
}
.mobile-new-session-btn.is-loading::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        var(--accent-light, #60a5fa) 270deg,
        transparent 360deg
    );
    -webkit-mask: radial-gradient(circle, transparent 55%, #000 56%, #000 100%);
            mask: radial-gradient(circle, transparent 55%, #000 56%, #000 100%);
    animation: toolbar-btn-spin 0.85s linear infinite;
}

/* --- Toolbar Right Section --- */
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* --- Live Tab Stats (Latency + Tokens/sec) --- */
.live-stats {
    display: none; /* Replaced by per-response timing badge on each card */
    gap: 10px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.live-stats span span {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Live model + response style indicator (mirrors #qaModelStyleIndicator pill) */
.live-model-style-indicator {
    flex: 0 1 auto;
    margin-right: auto;
    font-size: 0.68rem;
    color: var(--text-secondary, #a1a1aa);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid transparent;
    background:
        linear-gradient(var(--surface, #18181b), var(--surface, #18181b)) padding-box,
        linear-gradient(135deg, var(--accent, #3bf692), #2563eb) border-box;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.live-model-style-indicator:hover {
    color: var(--text-primary, #fff);
    background:
        linear-gradient(var(--surface-hover, #1f1f23), var(--surface-hover, #1f1f23)) padding-box,
        linear-gradient(135deg, var(--accent, #3bf692), #2563eb) border-box;
    box-shadow: 0 0 8px rgba(59, 246, 146, 0.12), 0 0 4px rgba(37, 99, 235, 0.1);
}

.live-indicator-chevron {
    font-size: 0.55rem;
    opacity: 0.6;
}

/* Hide latency/throughput stats on mobile to save space — keep model pill visible */
@media (max-width: 768px) {
    .live-stats {
        display: none;
    }
}

/* --- Toolbar Action Buttons --- */
.toolbar-actions {
    display: flex;
    gap: 4px;
}

.toolbar-action-btn {
    width: var(--btn-size-md);
    height: var(--btn-size-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
    position: relative;
}

.toolbar-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.04);
}

.toolbar-action-btn:active {
    transform: scale(0.92);
}

/* Action Button Badge */
.action-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--error);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Toolbar User Profile --- */
.toolbar-user-profile {
    margin-left: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    border: 2px solid transparent;
}

.toolbar-avatar:hover {
    transform: scale(1.08);
    border-color: rgba(59, 246, 146, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 246, 146, 0.12), 0 0 12px rgba(59, 246, 146, 0.15);
}

.toolbar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- User Profile Button --- */
.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-profile-btn:hover {
    background: var(--surface-hover);
}

#userAvatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: white;
    font-weight: bold;
    overflow: hidden;
}

#userAvatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Legacy Badge (for compatibility) --- */
.badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--border);
    color: var(--accent);
}

/* Toggle */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.toggle-wrapper.active {
    color: var(--success);
}

.toggle-switch {
    width: 24px;
    height: 14px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-wrapper.active .toggle-switch {
    background: var(--success);
}

.toggle-wrapper.active .toggle-switch::after {
    transform: translateX(10px);
}

.tools-btn {
    background: none;
    color: var(--accent);
    cursor: pointer;
    /* padding: 6px 10px; */
    border-radius: 8px;
    margin-left: 8px;
    margin-right: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.new-session-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.new-session-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    border-color: rgba(59, 130, 246, 0.4);
    color: var(--accent-light);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.new-session-btn:hover::before {
    width: 100px;
    height: 100px;
}

.new-session-btn:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.new-session-btn i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.new-session-btn:hover i {
    transform: rotate(90deg);
}


/* User */
#userProfileBtn {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    transition: background 0.2s;
}

#userProfileBtn:hover {
    background: var(--input-bg);
}

#userAvatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    font-weight: bold;
    overflow: hidden;
}

#userAvatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =============================================
   Shared User Popover Styles
   Used by both toolbar avatar and session panel footer.
   ============================================= */
.panel-user-popover {
    display: none;
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    max-width: 300px;
    background: var(--popover-bg, rgba(22, 22, 30, 0.92));
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 6px;
    z-index: 10010;
    flex-direction: column;
    animation: panelPopoverIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-user-popover.visible {
    display: flex;
}

@keyframes panelPopoverIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-popover-email {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
    opacity: 0.7;
}

.panel-popover-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 3px 8px;
}

.panel-popover-group {
    display: flex;
    flex-direction: column;
}

.panel-popover-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
    font-family: inherit;
}

.popover-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
    font-size: 0.82rem;
    transition: transform 0.15s ease;
}

.popover-icon-badge i { line-height: 1; }

.popover-icon-settings { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }
.popover-icon-admin { background: rgba(168, 130, 255, 0.12); color: #a882ff; }
.popover-icon-logout { background: rgba(248, 113, 113, 0.10); color: #f87171; }

.panel-popover-btn:hover { background: rgba(255, 255, 255, 0.06); }
.panel-popover-btn:hover .popover-icon-badge { transform: scale(1.08); }
.panel-popover-btn:hover .popover-icon-settings { background: rgba(96, 165, 250, 0.18); }
.panel-popover-btn:hover .popover-icon-admin { background: rgba(168, 130, 255, 0.18); }

.panel-popover-logout { color: #f87171; }
.panel-popover-logout:hover { background: rgba(248, 113, 113, 0.08); }
.panel-popover-btn:hover .popover-icon-logout { background: rgba(248, 113, 113, 0.18); }

.panel-popover-version {
    text-align: center;
    font-size: 0.62rem;
    color: var(--text-secondary);
    opacity: 0.35;
    padding: 4px 0 2px;
    letter-spacing: 0.03em;
}

/* Toolbar variant — fixed positioning at top-right */
.toolbar-popover.panel-user-popover {
    position: fixed;
    top: 56px;
    right: 12px;
    left: auto;
    bottom: auto;
    width: 260px;
    max-width: calc(100vw - 32px);
}

@media (max-width: 768px) {
    .toolbar-popover.panel-user-popover {
        width: 260px;
        max-width: calc(100vw - 24px);
    }
}

/* Intelligence Settings Popover */
/* Area-specific model override indicator */
.model-label-row {
    display: flex !important;
    align-items: center;
    gap: 6px;
}
.model-override-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
}

/* Always visible response settings button */
.response-settings-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.response-settings-btn:hover {
    background: rgba(9, 9, 11, 0.95);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.response-settings-btn i {
    font-size: 0.9rem;
}

/* Login Modal */
#loginModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: var(--z-max);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#loginModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.login-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-logo {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
}

.login-desc {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--google-blue);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s, filter 0.2s;
}

.google-btn:hover {
    filter: brightness(1.1);
    box-shadow: var(--glow-blue);
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.login-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 1rem;
    display: none;
}

/* Settings Drawer */
#settingsDrawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    background: linear-gradient(180deg, rgba(18, 18, 22, 0.98) 0%, rgba(9, 9, 11, 0.99) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10003;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    padding-top: env(safe-area-inset-top);
}

#settingsDrawer.open {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.settings-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-title i {
    color: var(--accent);
}

.tabs-nav {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 1rem;
    background: rgba(255, 255, 255, 0.02);
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 600;
    position: relative;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
}

.tab-content {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: none;
}

.tab-content.active {
    display: block;
}

/* Sub-tabs for nested sections (e.g., Config tab) */
.sub-tabs-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 1.25rem;
    background: var(--input-bg);
    padding: 4px;
    border-radius: var(--radius-md);
}

.sub-tab-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
}

.sub-tab-btn:hover {
    color: var(--text-primary);
    background: var(--border);
}

.sub-tab-btn.active {
    background: var(--accent);
    color: white;
}

.sub-tab-content {
    display: none;
}

.sub-tab-content.active {
    display: block;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1.2rem;
}

.setting-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.setting-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

input,
select,
textarea.config-text {
    background: var(--input-bg);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
    font-family: var(--font-main);
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: var(--glow-accent);
}

textarea.config-text {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.setting-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border-medium);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
}

.setting-toggle span {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Context Tab Styles */
.context-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.context-card {
    background: var(--input-bg);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border 0.2s;
}

.context-card.active {
    border-left: 3px solid var(--success);
}

.context-card.inactive {
    border-left: 3px solid var(--text-secondary);
    opacity: 0.7;
}

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.context-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.context-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.context-preview {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.context-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.context-btn {
    font-size: 0.7rem;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-medium);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.context-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.context-btn.delete:hover {
    color: var(--recording);
    border-color: var(--recording);
}

.add-context-btn {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    margin-top: 8px;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.add-context-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

/* Prompts Tab Styles (Ask Context Quick Prompts) */
.prompts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prompt-card {
    background: var(--input-bg);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    transition: border 0.2s, opacity 0.2s, box-shadow 0.2s;
}

.prompt-drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 4px 2px;
    flex-shrink: 0;
    touch-action: none;
}

.prompt-drag-handle:active {
    cursor: grabbing;
}

.prompt-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt-card.prompt-dragging {
    opacity: 0.4;
}

.prompt-card.prompt-drag-over {
    border-color: var(--accent);
    box-shadow: 0 -2px 0 0 var(--accent);
}

.prompt-drag-clone {
    position: fixed;
    z-index: 10020;
    opacity: 0.85;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    border-radius: 6px;
}

.prompt-card:hover {
    border-color: var(--accent);
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.prompt-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.prompt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.prompt-preview {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.prompt-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.prompts-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.prompts-empty i {
    font-size: 1.2rem;
    margin-bottom: 4px;
    display: block;
    opacity: 0.5;
}

.prompts-empty p {
    margin: 0;
    font-size: 0.8rem;
}

/* Context Editor */
#contextEditor {
    display: none;
    flex-direction: column;
    gap: 10px;
    animation: slideIn 0.2s ease;
}

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

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

.editor-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.file-upload-area {
    border: 1px dashed var(--border);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.file-upload-area:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.file-upload-area i {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.file-upload-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Recordings List */
.recordings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.recording-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--input-bg);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

.recording-name {
    font-weight: 500;
    color: var(--text-primary);
}

.recording-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.recording-actions {
    display: flex;
    gap: 8px;
}

.rec-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    border-radius: 4px;
}

.rec-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.delete-rec-btn:hover {
    border-color: var(--recording);
    color: var(--recording);
}

/* Layout */
.workspace {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.workspace.layout-left {
    flex-direction: row-reverse;
}

.workspace.layout-right {
    flex-direction: row;
}

.resizer {
    background: var(--border-subtle);
    z-index: var(--z-header);
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
}

.resizer:hover,
.resizer.dragging {
    background: linear-gradient(180deg, var(--accent, #3bf692), #2563eb);
}

.workspace:not(.layout-left):not(.layout-right) .resizer {
    width: 100%;
    height: 8px;
    cursor: ns-resize;
    margin-bottom: -1px;
}

.workspace.layout-left .resizer,
.workspace.layout-right .resizer {
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    margin-right: -1px;
}

/* Resizer drag handle - visible touch target for tablets */
.resizer-handle {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover, #27272a);
    border: 1px solid var(--border, #3f3f46);
    color: var(--text-secondary, #71717a);
    font-size: 0.7rem;
    transition: all 0.2s ease;
    touch-action: none;
    z-index: 1;
}

/* Horizontal layout (left/right) - vertical handle */
.workspace.layout-left .resizer-handle,
.workspace.layout-right .resizer-handle {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 44px;
    border-radius: 6px;
    cursor: ew-resize;
}

.workspace.layout-left .resizer-handle i,
.workspace.layout-right .resizer-handle i {
    transform: rotate(90deg);
}

/* Vertical layout (bottom) - horizontal handle */
.workspace:not(.layout-left):not(.layout-right) .resizer-handle {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 20px;
    border-radius: 6px;
    cursor: ns-resize;
}

/* Handle hover/active states */
.resizer:hover .resizer-handle,
.resizer.dragging .resizer-handle {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    border-color: rgba(59, 246, 146, 0.3);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.resizer.dragging .resizer-handle {
    transform: translate(-50%, -50%) scale(1.1);
}

/* Hide handle on very small screens (mobile phones) */
@media (max-width: 768px) {
    .resizer-handle {
        display: none;
    }
}

/* Show handle more prominently on touch devices */
@media (pointer: coarse) {
    .resizer-handle {
        opacity: 1;
    }

    .resizer {
        /* Larger touch target */
        min-width: 12px;
        min-height: 12px;
    }
}

/* Subtle on mouse devices, becomes visible on hover */
@media (pointer: fine) {
    .resizer-handle {
        opacity: 0.5;
    }

    .resizer:hover .resizer-handle {
        opacity: 1;
    }
}

.pane-response {
    flex: 1;
    background: linear-gradient(180deg, rgba(14, 14, 16, 1) 0%, var(--panel-bg) 100%);
    overflow: hidden;
    /* Prevent double scrollbars */
    padding: 0;
    display: flex;
    flex-direction: column;
    z-index: var(--z-above);
    position: relative;
    min-height: 0;
    /* Crucial for nested flex scrolling */
    height: 100%;
    /* Ensure it tries to fill parent */
}

/* =============================================
   Response History Cards
   ============================================= */
.response-history-container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    /* Allow container to shrink */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.response-empty-state {
    text-align: center;
    margin-top: 15%;
    color: var(--text-secondary);
    opacity: 0.6;
}

.response-empty-state i {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

.response-empty-state p {
    margin: 0 0 0.5rem 0;
}

.response-empty-state small {
    opacity: 0.7;
}

/* Response Card */
.response-card {
    background: var(--panel-bg);
    border-radius: 8px;
    margin-bottom: 2px;
    overflow: hidden;
    transition: all 0.2s ease;
    min-width: 0;
    /* Allow card to shrink */
    max-width: 100%;
}

/* Per-response timing badge — inline at top of expanded content */
.response-card-timing {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    line-height: 1;
    padding: 3px 7px;
    margin-bottom: 8px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    white-space: nowrap;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.response-card-timing.pending {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.response-card.collapsed .response-card-timing {
    display: none;
}


.response-card:not(:first-child)::before {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
    margin: 8px 20px;
}

/* Response Header */
.response-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    user-select: none;
}

.response-card-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.response-card.collapsed .response-card-header {
    border-bottom-color: transparent;
}

.response-card:not(.collapsed) .response-card-header {
    border-bottom-color: var(--border);
}

/* Collapse Icon */
.response-collapse-icon {
    color: var(--text-secondary);
    font-size: 0.7rem;
    width: 16px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.response-card.collapsed .response-collapse-icon {
    transform: rotate(-90deg);
}

/* Question/Title */
.response-card-question {
    flex: 1;
    min-width: 0;
    /* Allow proper truncation in flex container */
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.response-card-question.no-question {
    color: var(--text-secondary);
    font-style: italic;
}

/* Timestamp */
.response-card-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.7;
    flex-shrink: 0;
}

/* Actions */
.response-card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.response-card-header:hover .response-card-actions {
    opacity: 1;
}

.response-card-action {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.response-card-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.response-card-action.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Response Content */
.response-card-content {
    padding: 16px;
    max-height: none;
    /* No height limit - content should never be truncated */
    overflow: visible;
    /* Allow content to display fully */
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    opacity: 1;
    min-width: 0;
    /* Allow content to shrink */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.response-card.collapsed .response-card-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
    /* Hide content when collapsed */
}

/* Content markdown styling */
.response-card-content .markdown-body {
    font-size: inherit;
}

/* Loading state */
.response-card.loading .response-card-content::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--accent);
    animation: cursor-blink 1s infinite;
    margin-left: 2px;
    vertical-align: text-bottom;
}

@keyframes cursor-blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* Model badge in header */
.response-card-model {
    font-size: 0.6rem;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    border-radius: 4px;
    flex-shrink: 0;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .tab-content-response {
        padding: 0.5rem 0;
        /* Edge-to-edge content on mobile */
    }

    .response-history-container {
        width: 100%;
        max-width: 100%;
    }

    .markdown-body {
        max-width: 100%;
        /* Full width on mobile */
    }

    .response-card {
        border-radius: 0;
        /* Remove border-radius for edge-to-edge look */
    }

    .response-card-header {
        padding: 10px 16px;
    }

    .response-card-content {
        padding: 12px 16px;
    }

    .response-card-actions {
        opacity: 1;
        /* Always visible on touch devices */
    }

    .response-card-time {
        display: none;
        /* Hide timestamp on mobile to save space */
    }
}

.markdown-body {
    line-height: 1.6;
    font-size: 1.15rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
    /* Allow to shrink */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.markdown-body pre {
    overflow-x: auto;
    border-radius: 6px;
    background-color: var(--surface);
    padding: 1rem;
    max-width: 100%;
    /* Constrain to container width */
    box-sizing: border-box;
}

.markdown-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
}

.markdown-body h1,
.markdown-body h2 {
    color: var(--text-primary);
    margin-top: 1rem;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.3rem;
}

.cursor::after {
    font-size: 0.9rem;
}

.markdown-body.font-xs h1,
.markdown-body.font-xs h2 {
    font-size: 1.1rem;
}

.markdown-body.font-sm {
    font-size: 1.0rem;
}

.markdown-body.font-sm h1,
.markdown-body.font-sm h2 {
    font-size: 1.25rem;
}

.markdown-body.font-md {
    font-size: 1.15rem;
}

.markdown-body.font-md h1,
.markdown-body.font-md h2 {
    font-size: 1.4rem;
}

.markdown-body.font-lg {
    font-size: 1.3rem;
}

.markdown-body.font-lg h1,
.markdown-body.font-lg h2 {
    font-size: 1.6rem;
}

.markdown-body.font-xl {
    font-size: 1.5rem;
}

.markdown-body.font-xl h1,
.markdown-body.font-xl h2 {
    font-size: 1.85rem;
}

/* Font size classes applied to response container (parent inheritance) */
.response-history-container.font-xs .markdown-body {
    font-size: 0.85rem;
}

.response-history-container.font-xs .markdown-body h1,
.response-history-container.font-xs .markdown-body h2 {
    font-size: 1.1rem;
}

.response-history-container.font-sm .markdown-body {
    font-size: 1.0rem;
}

.response-history-container.font-sm .markdown-body h1,
.response-history-container.font-sm .markdown-body h2 {
    font-size: 1.25rem;
}

.response-history-container.font-md .markdown-body {
    font-size: 1.15rem;
}

.response-history-container.font-md .markdown-body h1,
.response-history-container.font-md .markdown-body h2 {
    font-size: 1.4rem;
}

.response-history-container.font-lg .markdown-body {
    font-size: 1.3rem;
}

.response-history-container.font-lg .markdown-body h1,
.response-history-container.font-lg .markdown-body h2 {
    font-size: 1.6rem;
}

.response-history-container.font-xl .markdown-body {
    font-size: 1.5rem;
}

.response-history-container.font-xl .markdown-body h1,
.response-history-container.font-xl .markdown-body h2 {
    font-size: 1.85rem;
}

/* Response Controls Container — inline toolbar inside Live tab */
.response-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.response-controls .response-settings-btn {
    position: static;
    width: 30px;
    height: 30px;
}

.font-size-controls-compact {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* Live Abort Button - Stop Generation */
.live-abort-btn {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    position: relative;
    overflow: hidden;
}

.live-abort-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.live-abort-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.live-abort-btn:hover::before {
    opacity: 1;
}

.live-abort-btn:active {
    transform: scale(0.97);
}

.live-abort-btn i {
    font-size: 0.75rem;
}

.live-abort-btn span {
    letter-spacing: 0.02em;
}

/* Generating state - show abort button with animation */
.live-abort-btn.visible {
    display: flex;
    animation: abortBtnAppear 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes abortBtnAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

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

/* Pulsing effect while generating */
.live-abort-btn.visible::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.4);
    animation: abortPulse 1.5s ease-in-out infinite;
    z-index: -1;
}

@keyframes abortPulse {

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

    50% {
        opacity: 0.1;
        transform: scale(1.08);
    }
}

/* Font Size Controls Group */
/* Font Size Controls (A+/A−) */
.font-size-btn-mobile {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    position: relative;
    overflow: hidden;
}

.font-size-btn-mobile::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.font-size-btn-mobile:active {
    transform: scale(0.9);
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent);
}

.font-size-btn-mobile:active::before {
    width: 100%;
    height: 100%;
}

/* Header Action Buttons — styled for purple header background */
.header-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: translateY(-1px);
}

.header-action-btn:active {
    transform: translateY(0) scale(0.95);
}

/* Speaker Chip - contextual action button — on purple header */
.speaker-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    margin: 0 6px 0 0;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
    height: 24px;
}

.speaker-chip:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.speaker-chip:active {
    transform: scale(0.95);
}

.speaker-chip i {
    font-size: 0.6rem;
    flex-shrink: 0;
}

.speaker-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive: icon-only on narrow panes */
.pane-input:has(.input-header) .speaker-chip span {
    display: inline;
}

/* When pane is narrow, hide text */
@container (max-width: 350px) {
    .speaker-chip span {
        display: none;
    }
}

/* Fallback for browsers without container queries */
@media (max-width: 500px) {
    .speaker-chip span {
        display: none;
    }

    .speaker-chip {
        padding: 4px 6px;
    }
}

/* Smooth Font Size Transitions */
.markdown-body,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body p,
.markdown-body li,
.markdown-body code {
    transition: font-size 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .response-controls {
        padding: 0.3rem 0.4rem;
        gap: 0.35rem;
    }

    .live-abort-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.75rem;
    }

    .live-abort-btn span {
        display: none;
        /* Icon only on mobile */
    }

    .live-abort-btn i {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .response-controls {
        padding: 0.25rem 0.4rem;
    }

    .live-abort-btn {
        padding: 0.35rem 0.6rem;
    }

    .font-size-btn-mobile {
        padding: 0.4rem 0.6rem;
        min-width: 34px;
        font-size: 0.85rem;
    }

    .header-action-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
}

.pane-input {
    background: linear-gradient(180deg, rgba(18, 18, 20, 1) 0%, var(--input-bg) 100%);
    border-color: rgba(255, 255, 255, 0.06);
    position: relative;
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
    padding: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pane-input.no-transition {
    transition: none !important;
}

/* Spring snap transition — used when drag ends and snaps to maximize/minimize/settle */
.pane-input.snap-spring {
    transition: flex-basis 0.4s cubic-bezier(0.32, 0.72, 0, 1),
        max-height 0.4s cubic-bezier(0.32, 0.72, 0, 1),
        min-height 0.4s cubic-bezier(0.32, 0.72, 0, 1),
        opacity 0.3s ease !important;
}

/* Drag snap-zone visual hint: approaching maximize */
.pane-input.drag-snap-maximize .mobile-resize-handle-bar {
    background: linear-gradient(90deg, var(--accent, #3bf692), #2563eb) !important;
    opacity: 1 !important;
    transform: scaleX(1.3) scaleY(1.2) !important;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.5), 0 0 6px rgba(59, 246, 146, 0.2) !important;
}

/* Drag snap-zone visual hint: approaching minimize */
.pane-input.drag-snap-minimize .mobile-resize-handle-bar {
    background: var(--warning, #f59e0b) !important;
    opacity: 1 !important;
    transform: scaleX(1.3) scaleY(1.2) !important;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5) !important;
}

.workspace:not(.layout-left):not(.layout-right) .pane-input {
    height: 30%;
    min-height: 100px;
    max-height: 80%;
    border-top: 1px solid var(--border-subtle);
    width: 100%;
}

.workspace:not(.layout-left):not(.layout-right) .pane-input.collapsed {
    height: 60px !important;
    min-height: 60px !important;
    flex-shrink: 0;
}

.workspace.layout-left .pane-input,
.workspace.layout-right .pane-input {
    width: 35%;
    min-width: 250px;
    max-width: 70%;
    height: 100%;
    border-top: none;
}

.workspace.layout-left .pane-input {
    border-right: 1px solid var(--border-subtle);
}

.workspace.layout-right .pane-input {
    border-left: 1px solid var(--border-subtle);
}

.workspace.layout-left .pane-input.collapsed,
.workspace.layout-right .pane-input.collapsed {
    width: 60px !important;
    min-width: 60px !important;
}

.pane-input.collapsed .input-header span,
.pane-input.collapsed .transcript-wrapper {
    display: none;
}

/* Hide header action buttons when collapsed on desktop */
.workspace.layout-left .pane-input.collapsed .header-action-btn:not(#desktopCollapseBtn),
.workspace.layout-right .pane-input.collapsed .header-action-btn:not(#desktopCollapseBtn),
.workspace.layout-left .pane-input.collapsed #speakerBtn,
.workspace.layout-right .pane-input.collapsed #speakerBtn {
    display: none;
}

/* ===========================================
   COLLAPSED MIC BUTTON - Desktop Only
   Styled to match primary mic button (#micBtn.fab-mic)
   =========================================== */
.collapsed-mic-btn {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    /* Match primary mic button gradient styling */
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    border: 2px solid rgba(59, 246, 146, 0.3);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3), 0 0 8px rgba(59, 246, 146, 0.15);
}

.collapsed-mic-btn:hover {
    background: linear-gradient(135deg, var(--accent, #3bf692), #1d4ed8);
    border-color: rgba(37, 99, 235, 0.4);
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4), 0 0 12px rgba(59, 246, 146, 0.2);
}

.collapsed-mic-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Show only when collapsed on desktop side layouts */
.workspace.layout-left .pane-input.collapsed .collapsed-mic-btn,
.workspace.layout-right .pane-input.collapsed .collapsed-mic-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Active state - Recording (Red pulsating, matches #micBtn.fab-mic.active) */
.collapsed-mic-btn.active {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: #ef4444;
    color: white;
    animation: collapsed-mic-pulse 1.5s ease-in-out infinite;
}

@keyframes collapsed-mic-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 4px 12px rgba(239, 68, 68, 0.4);
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0), 0 4px 16px rgba(239, 68, 68, 0.6);
        transform: translate(-50%, -50%) scale(1.02);
    }
}

/* Paused state - Amber (matches #micBtn.fab-mic.paused) */
.collapsed-mic-btn.paused {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
    color: white;
    animation: none;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Reconnecting state - Amber with pulse (matches #micBtn.fab-mic.reconnecting) */
.collapsed-mic-btn.reconnecting {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
    color: white;
    animation: collapsed-mic-reconnect 1.5s ease-in-out infinite;
}

@keyframes collapsed-mic-reconnect {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7), 0 4px 12px rgba(245, 158, 11, 0.4);
        opacity: 1;
    }

    50% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0), 0 4px 12px rgba(245, 158, 11, 0.6);
        opacity: 0.8;
    }
}

/* Hide the collapsed mic button on mobile */
@media (max-width: 768px) {
    .collapsed-mic-btn {
        display: none !important;
    }
}

/* ===========================================
   MOBILE TRANSCRIPT BADGE
   Vertical badge attached to left edge when transcript is collapsed
   =========================================== */
.mobile-transcript-badge {
    position: fixed;
    left: 0;
    bottom: 25%;
    transform: translateX(-100%);
    /* Start hidden off-screen */
    width: auto;
    height: auto;
    padding: 12px 7px;
    border: none;
    border-radius: 0 10px 10px 0;
    /* Rounded right corners only */
    background: linear-gradient(135deg, var(--accent, #3b82f6), #2563eb);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    cursor: pointer;
    z-index: var(--z-header);
    box-shadow: 3px 0 12px rgba(37, 99, 235, 0.4), 0 0 20px rgba(37, 99, 235, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease, visibility 0.3s, background 0.15s ease;
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
}

.transcript-badge-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    /* Read from bottom to top */
    white-space: nowrap;
    text-transform: uppercase;
}

.mobile-transcript-badge:hover {
    background: linear-gradient(135deg, var(--accent, #3b82f6), #1d4ed8);
}

.mobile-transcript-badge:active {
    transform: translateX(0) scale(0.93);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* Animated glow on transcript badge when transcription is active */
.pane-input:has(#micBtn.active) ~ .mobile-transcript-badge {
    box-shadow: 3px 0 14px rgba(59, 246, 146, 0.2), 0 0 20px rgba(37, 99, 235, 0.15);
}

.pane-input:has(#micBtn.active) ~ .mobile-transcript-badge::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 0 11px 11px 0;
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb, #a855f7, var(--accent, #3bf692));
    background-size: 300% 300%;
    animation: header-glow 4s ease-in-out infinite;
    z-index: -1;
    opacity: 0.6;
    filter: blur(6px);
}

/* Show mobile transcript badge only on mobile when transcript is collapsed */
@media (max-width: 768px) {
    .workspace .pane-input.collapsed~.mobile-transcript-badge {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
        /* Slide in from left */
        pointer-events: auto;
    }

    /* Account for iOS safe area */
    .mobile-transcript-badge {
        bottom: calc(25% + env(safe-area-inset-bottom, 0px));
    }
}

.input-header {
    padding: 0 1rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.92);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent, #3b82f6), #2563eb);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    flex-shrink: 0;
    height: 34px;
    user-select: none;
    cursor: pointer;
    position: relative;
    z-index: var(--z-sticky);
    border-bottom: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 6px 6px 0 0;
    transition: background 0.15s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.input-header:hover {
    background: linear-gradient(135deg, var(--accent, #3b82f6), #1d4ed8);
}

/* Animated glow when transcription is active — tied to mic button .active state */
.pane-input:has(#micBtn.active) .input-header {
    box-shadow: 0 0 12px rgba(59, 246, 146, 0.12), 0 0 4px rgba(37, 99, 235, 0.15);
}

.pane-input:has(#micBtn.active) .input-header::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 7px 7px 0 0;
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb, #a855f7, var(--accent, #3bf692));
    background-size: 300% 300%;
    animation: header-glow 4s ease-in-out infinite;
    z-index: -1;
    opacity: 0.5;
    filter: blur(6px);
}

@keyframes header-glow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ==========================================
   MOBILE RESIZE HANDLE
   Allows height adjustment on mobile devices
   ========================================== */

.mobile-resize-handle {
    display: none;
    /* Hidden by default, shown only on mobile */
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 28px;
    cursor: ns-resize;
    touch-action: none;
    z-index: calc(var(--z-sticky) + 1);
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
}

.mobile-resize-handle-bar {
    width: 60px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Visual feedback on touch */
.mobile-resize-handle.dragging .mobile-resize-handle-bar,
.mobile-resize-handle:active .mobile-resize-handle-bar {
    opacity: 1;
    background: linear-gradient(90deg, var(--accent, #3bf692), #2563eb);
    transform: scaleY(1.2);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4), 0 0 8px rgba(59, 246, 146, 0.15);
}

/* Hover feedback for touch devices */
.mobile-resize-handle:hover .mobile-resize-handle-bar {
    opacity: 0.9;
    transform: scaleY(1.1);
}

/* ==========================================
   MOBILE FULLSCREEN MODE
   Maximizes viewport space for chat/transcript
   ========================================== */

/* Fullscreen header - Hidden by default, shown only in fullscreen mode on mobile */
.fullscreen-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
    z-index: calc(var(--z-sticky) + 10);
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Exit fullscreen button - Prominent and easily discoverable */
.exit-fullscreen-btn {
    position: absolute;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    min-height: 44px;
    /* iOS touch target minimum */
}

.exit-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.exit-fullscreen-btn:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.15);
}

.exit-fullscreen-btn i {
    font-size: 1.1rem;
}

/* Fullscreen title - Centered, shows active tab name */
.fullscreen-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* Fullscreen entry button in toolbar - Hidden by default, shown only on mobile */
.mobile-fullscreen-entry-btn {
    display: none !important;
}

/* Hide entry button when in fullscreen mode (header button is used instead) */
body.fullscreen-mode .mobile-fullscreen-entry-btn {
    display: none !important;
}

.header-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 6px;
    margin: 0;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.header-action-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.header-action-btn.danger:hover {
    color: #ff6b6b;
    background: rgba(239, 68, 68, 0.15);
}

#mobileChevron {
    display: none;
}

#mobileMaximizeBtn {
    display: none;
}

/* Header layout containers */
.header-view-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.header-title {
    font-size: 0.72rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
    text-align: center;
    justify-self: center;
    font-weight: 600;
}

.header-title i {
    margin-right: 6px;
    color: var(--accent);
    font-size: 0.65rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Hidden on desktop */
#desktopCollapseBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background 0.2s;
}

#desktopCollapseBtn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#desktopCollapseBtn i {
    transition: transform 0.3s;
}

/* Rotate chevron when collapsed */
.pane-input.collapsed #desktopCollapseBtn i {
    transform: rotate(180deg);
}

.transcript-wrapper {
    flex-grow: 1;
    position: relative;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    container-type: size;
    container-name: transcript;
}

/* Optimized Textarea & Backdrop - Matching Line Heights is Critical */
textarea.main-input,
.highlight-backdrop {
    width: 100%;
    height: 100%;
    padding: 0.5rem 1rem;
    padding-right: 50px;
    border: none;
    margin: 0;
    box-sizing: border-box;
    font-family: var(--font-mono);
    /* Use Monospace for perfect alignment */
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    letter-spacing: normal;
}

textarea.main-input {
    background: transparent;
    color: var(--text-primary);
    resize: none;
    outline: none;
    z-index: var(--z-above);
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* Highlight Backdrop - Improved UI */
.highlight-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    z-index: var(--z-above);
    color: transparent;
    /* TEXT IS INVISIBLE - Key fix for double text */
    background: transparent;
    pointer-events: none;
    overflow-y: auto;
    scrollbar-gutter: stable;
    /* Critical: Matches textarea scrollbar behavior */
    opacity: 0;
    transition: opacity 0.2s;
}

.highlight-backdrop.active {
    opacity: 1;
}

/* New Highlighter Style - Clean gradient blocks */
.highlight-match {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.5) 0%, rgba(59, 130, 246, 0.1) 100%);
    box-shadow: inset 5px 0 0 0 var(--accent-light);
    /* Thicker, brighter bar */
    border-radius: 4px;
    color: transparent;
    /* Ensure text inside remains transparent */
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    display: inline-block;
    /* Better block formatting for mono */
    width: 100%;
    /* Extend across the line */
}

.controls-overlay {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: var(--z-sticky);
    opacity: 85%;
}

.pane-input.collapsed .controls-overlay {
    opacity: 0;
    pointer-events: none;
}

/* =============================================
   Transcript Empty State
   ============================================= */
.transcript-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: calc(var(--z-sticky) + 1);
    opacity: 0;
    overflow: hidden;
    padding: 12px 16px;
    gap: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.transcript-empty-state.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Hide controls-overlay when empty state is showing */
.controls-overlay.hidden-by-empty-state {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease;
}

/* Hide textarea placeholder when empty state is visible */
.transcript-empty-state.visible ~ .main-input::placeholder {
    color: transparent;
}

/* Hide empty state when pane is collapsed */
.pane-input.collapsed .transcript-empty-state {
    opacity: 0;
    pointer-events: none;
}

/* Compact empty state when transcript area is short */
@container transcript (max-height: 420px) {
    .empty-state-mic-hero {
        width: min(72px, 28cqh);
    }
    .empty-state-pulse-ring {
        inset: -6px;
    }
    .empty-state-heading {
        margin: 0.6rem 0 0.3rem;
        font-size: 1rem;
    }
    .empty-state-subtext {
        display: none;
    }
}

@container transcript (max-height: 320px) {
    .empty-state-mic-hero {
        width: min(56px, 25cqh);
    }
    .empty-state-pulse-ring {
        inset: -5px;
    }
    .empty-state-heading {
        margin: 0.4rem 0 0.2rem;
        font-size: 0.9rem;
    }
    .empty-state-upload-btn {
        font-size: 0.7rem;
        padding: 0.35rem 0.9rem;
    }
    .empty-state-mic-selector {
        margin-top: 0.6rem;
    }
}

/* Very compact — hide text, keep mic + upload */
@container transcript (max-height: 240px) {
    .empty-state-heading {
        display: none;
    }
}

/* Ultra compact — mic only */
@container transcript (max-height: 180px) {
    .empty-state-heading,
    .empty-state-subtext,
    .empty-state-upload-btn,
    .empty-state-mic-selector {
        display: none;
    }
    .empty-state-mic-hero {
        width: min(48px, 22cqh);
    }
}

/* Hero microphone button */
.empty-state-mic-hero {
    width: min(96px, 30cqh);
    height: auto;
    flex-shrink: 0;
    aspect-ratio: 1;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    font-size: clamp(1.2rem, 5cqh, 2.2rem);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.35), 0 0 16px rgba(59, 246, 146, 0.2);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.empty-state-mic-hero:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.45), 0 0 24px rgba(59, 246, 146, 0.3);
}

.empty-state-mic-hero:active {
    transform: scale(0.95);
}

/* Pulse ring animation */
.empty-state-pulse-ring {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(59, 246, 146, 0.3);
    animation: emptyStatePulse 2.5s ease-out infinite;
    pointer-events: none;
}

.empty-state-pulse-ring.delay {
    animation-delay: 1.25s;
}

@keyframes emptyStatePulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* ─────────────────────────────────────────────────────────────────────────
   Hero mic — "starting" state
   Fires instantly on click while toggleTranscription() does its async setup
   (mic permission, audio init, WebSocket connect). Without this, the click
   feels like nothing happens for ~1s before the active state kicks in.
   ─────────────────────────────────────────────────────────────────────── */

/* Loader ring — hidden by default, only animates while .starting is set */
.empty-state-mic-loader {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    /* Conic gradient creates a rotating "tail" effect — feels like a fast loader */
    background: conic-gradient(
        from 0deg,
        rgba(59, 246, 146, 0) 0deg,
        rgba(59, 246, 146, 0) 200deg,
        rgba(59, 246, 146, 0.85) 320deg,
        rgba(37, 99, 235, 0.95) 360deg
    );
    /* Mask creates a 3px ring (no fill in the center) */
    -webkit-mask: radial-gradient(circle, transparent calc(50% - 3px), black calc(50% - 3px));
            mask: radial-gradient(circle, transparent calc(50% - 3px), black calc(50% - 3px));
}

.empty-state-mic-hero.starting {
    cursor: progress;
    pointer-events: none; /* prevent re-clicks during async setup */
    /* Tactile click rebound — punches inward then back, kicks in synchronously */
    animation: emptyStateMicPunch 320ms cubic-bezier(0.34, 1.56, 0.64, 1) 1;
    /* Brighter glow signals "spinning up" */
    box-shadow:
        0 8px 36px rgba(37, 99, 235, 0.55),
        0 0 28px rgba(59, 246, 146, 0.45);
}

.empty-state-mic-hero.starting .fa-microphone {
    animation: emptyStateMicIconPulse 900ms ease-in-out infinite;
}

.empty-state-mic-hero.starting .empty-state-mic-loader {
    opacity: 1;
    animation: emptyStateLoaderSpin 900ms linear infinite;
}

/* While starting, suppress the calm ambient pulse rings — the loader ring
   is the focal point and the two competing animations look noisy together. */
.empty-state-mic-hero.starting .empty-state-pulse-ring {
    animation-play-state: paused;
    opacity: 0;
    transition: opacity 120ms ease-out;
}

@keyframes emptyStateMicPunch {
    0%   { transform: scale(1); }
    35%  { transform: scale(0.9); }
    70%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes emptyStateMicIconPulse {
    0%, 100% { transform: scale(1);    opacity: 1; }
    50%      { transform: scale(0.85); opacity: 0.75; }
}

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

/* Subtext fades subtly while connecting — pairs with JS swapping the text */
.transcript-empty-state.is-starting .empty-state-subtext {
    opacity: 0.7;
    transition: opacity 200ms ease-out;
}

/* Respect reduced-motion preference — no spin, just static pressed state */
@media (prefers-reduced-motion: reduce) {
    .empty-state-mic-hero.starting {
        animation: none;
        transform: scale(0.96);
    }
    .empty-state-mic-hero.starting .fa-microphone,
    .empty-state-mic-hero.starting .empty-state-mic-loader {
        animation: none;
    }
    .empty-state-mic-hero.starting .empty-state-mic-loader {
        opacity: 0.8;
    }
}

/* Heading */
.empty-state-heading {
    margin: 1.25rem 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Subtext */
.empty-state-subtext {
    margin: 0 0 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 260px;
    line-height: 1.4;
}

/* Upload button — prominent filled pill */
.empty-state-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.empty-state-upload-btn i {
    font-size: 1rem;
    color: var(--accent, #3bf692);
}

.empty-state-upload-btn:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 16px rgba(59, 246, 146, 0.12);
}

.empty-state-upload-btn:active {
    transform: scale(0.97);
}

/* Mic selector — subtle settings row below upload CTA */
/* ======================================================================
   MicPicker — Shared custom mic dropdown component (subtle + inline variants)
   ====================================================================== */
.mic-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Trigger button (shared) --- */
.mic-picker-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    padding: 6px 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
    max-width: 260px;
}

.mic-picker-trigger:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.mic-picker-trigger > i:first-child {
    font-size: 0.7rem;
    opacity: 0.7;
}

.mic-picker-label {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.mic-picker-chevron {
    font-size: 0.55rem;
    opacity: 0.5;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.mic-picker-trigger[aria-expanded="true"] .mic-picker-chevron {
    transform: rotate(180deg);
}

/* --- Dropdown menu (shared) --- */
.mic-picker-dropdown {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    max-width: 380px;
    background: rgba(22, 22, 30, 0.92);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: micPickerFadeIn 0.15s ease;
}

.mic-picker-dropdown.open { display: block; }

@keyframes micPickerFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.mic-picker-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mic-picker-option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.mic-picker-option.selected {
    color: var(--accent-color, #1aab8a);
}

.mic-picker-check {
    font-size: 0.65rem;
    width: 14px;
    flex-shrink: 0;
    opacity: 0;
}

.mic-picker-option.selected .mic-picker-check { opacity: 1; }

.mic-picker-option span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Refresh button (inline variant) --- */
.mic-picker-refresh-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.72rem;
    flex-shrink: 0;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mic-picker-refresh-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

/* --- Subtle variant (empty state) — dropdown opens upward --- */
.mic-picker-subtle {
    margin-top: 1.2rem;
    opacity: 0.55;
    transition: opacity 0.2s ease;
    justify-content: center;
}

.mic-picker-subtle:hover,
.mic-picker-subtle:focus-within {
    opacity: 0.9;
}

.mic-picker-subtle .mic-picker-trigger {
    font-size: 0.75rem;
}

.mic-picker-subtle .mic-picker-dropdown {
    bottom: calc(100% + 6px);
    top: auto;
}

/* --- Inline variant (overflow menu) — dropdown opens downward --- */
.mic-picker-inline {
    flex: 1;
    min-width: 0;
}

.mic-picker-inline .mic-picker-trigger {
    flex: 1;
    min-width: 0;
    border-radius: 6px;
    padding: 6px 8px;
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

.mic-picker-inline .mic-picker-trigger:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.08));
}

.mic-picker-inline .mic-picker-label {
    max-width: 140px;
}

.mic-picker-inline .mic-picker-dropdown {
    top: calc(100% + 6px);
    bottom: auto;
    right: 0;
    left: auto;
    transform: none;
    min-width: 300px;
    animation-name: micPickerFadeInDown;
}

/* Inherit parent z-index context when inside overflow menu */

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

/* --- Empty state mount wrapper inherits positioning context --- */
.empty-state-mic-selector {
    position: relative;
    display: flex;
    justify-content: center;
}

/* Hide mic selector at very small heights */
@media (max-height: 320px) {
    .empty-state-mic-selector { display: none; }
}

/* Session Language Selector */
.language-selector-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.session-language-select {
    padding: 6px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--surface-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-emphasis);
    border-radius: var(--radius-md);
    cursor: pointer;
    min-width: 60px;
    text-align: center;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    appearance: none;
    -webkit-appearance: none;
}

.session-language-select:hover {
    background: var(--surface-active);
    border-color: var(--accent);
    color: var(--text-primary);
}

.session-language-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2), var(--glow-accent);
}

/* Secondary FAB group - vertical on desktop, horizontal on mobile */
.fab-group-secondary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* FAB Buttons - use design system tokens */
.fab {
    width: var(--btn-size-lg);
    height: var(--btn-size-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-emphasis);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--btn-icon-lg);
    background: var(--surface-hover);
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

/* Primary FAB - larger and more prominent */
.fab.fab-primary {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    border-color: rgba(59, 246, 146, 0.3);
    font-size: 1.25rem;
}

.fab.fab-primary:hover {
    background: linear-gradient(135deg, var(--accent, #3bf692), #1d4ed8);
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: var(--shadow-md), 0 0 12px rgba(37, 99, 235, 0.3);
}

.fab:hover {
    color: var(--text-primary);
    border-color: var(--border-emphasis);
    box-shadow: var(--shadow-md), var(--glow-accent);
}

.fab:active {
    transform: scale(0.95);
}

#audioRecordBtn:hover {
    color: var(--error);
    border-color: var(--error);
}

#audioRecordBtn.recording {
    background: var(--error);
    color: white;
    animation: pulse 2s infinite;
}

/* ===========================================
   MICROPHONE BUTTON - PRIMARY ACTION
   Redesigned for prominence and clear state indication
   =========================================== */

/* Base state - Green-to-blue gradient styling */
#micBtn.fab-mic {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    border: 2px solid rgba(59, 246, 146, 0.3);
    color: white;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3), 0 0 8px rgba(59, 246, 146, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 52px;
    min-height: 52px;
}

#micBtn.fab-mic:hover {
    background: linear-gradient(135deg, var(--accent, #3bf692), #1d4ed8);
    border-color: rgba(37, 99, 235, 0.4);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4), 0 0 12px rgba(59, 246, 146, 0.2);
}

#micBtn.fab-mic:active {
    transform: scale(0.95);
}

/* Active/Recording state - Bright neon red pulsating with enhanced prominence */
#micBtn.fab-mic.active {
    background: linear-gradient(135deg, #ff0000 0%, #ff2222 100%);
    border: 2px solid #ff4444;
    color: white;
    animation: mic-pulse-recording 1.2s ease-in-out infinite;
    position: relative;
    box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.9), 0 6px 25px rgba(255, 0, 0, 0.6);
}

#micBtn.fab-mic.active::before {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    background: #ff0000;
    border: 2px solid white;
    border-radius: 50%;
    animation: recording-badge-pulse 1s ease-in-out infinite;
    z-index: 10;
    box-shadow: 0 0 6px rgba(255, 0, 0, 0.8);
}

#micBtn.fab-mic.active:hover {
    background: linear-gradient(135deg, #ff2222 0%, #ff0000 100%);
}

/* Recording badge pulse animation */
@keyframes recording-badge-pulse {

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

    50% {
        transform: scale(1.15);
        opacity: 0.85;
    }
}

/* Pulsating animation for recording state - Enhanced with larger pulse and brighter glow */
@keyframes mic-pulse-recording {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.95), 0 6px 25px rgba(255, 0, 0, 0.7), 0 0 15px rgba(255, 0, 0, 0.5);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 20px rgba(255, 0, 0, 0), 0 6px 30px rgba(255, 0, 0, 0.8), 0 0 25px rgba(255, 0, 0, 0.6);
        transform: scale(1.08);
    }
}

/* Paused state - Amber/Warning */
#micBtn.fab-mic.paused {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
    color: white;
    animation: none;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

#micBtn.fab-mic.paused:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Reconnecting state - Amber with pulse */
#micBtn.fab-mic.reconnecting {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
    color: white;
    animation: mic-pulse-reconnect 1.5s ease-in-out infinite;
}

@keyframes mic-pulse-reconnect {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7), 0 4px 15px rgba(245, 158, 11, 0.4);
        opacity: 1;
    }

    50% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0), 0 4px 15px rgba(245, 158, 11, 0.6);
        opacity: 0.8;
    }
}

/* Focus state for accessibility */
#micBtn.fab-mic:focus-visible {
    outline: 3px solid rgba(16, 185, 129, 0.5);
    outline-offset: 3px;
}

#micBtn.fab-mic.active:focus-visible {
    outline-color: rgba(239, 68, 68, 0.5);
}

/* Hide the Ask AI button - use Chat feature instead */
.fab-send-hidden {
    display: none !important;
}

#pauseTranscriptionBtn {
    color: var(--warning, #f59e0b);
    border-color: var(--warning, #f59e0b);
}

#pauseTranscriptionBtn:hover {
    background: rgba(245, 158, 11, 0.15);
}

/* Wake Lock Indicator - shows when screen sleep is prevented */
.wake-lock-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: var(--success-dim);
    color: var(--success);
    font-size: 0.75rem;
    animation: wakeLockPulse 3s ease-in-out infinite;
}

@keyframes wakeLockPulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

#audioRecordBtn.paused {
    color: var(--warning, #f59e0b);
    border-color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.1);
    animation: none;
}

#sendBtn {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    border-color: rgba(59, 246, 146, 0.3);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

#sendBtn:hover {
    background: linear-gradient(135deg, var(--accent, #3bf692), #1d4ed8);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4), 0 0 8px rgba(59, 246, 146, 0.15);
}

/* Speaker Popover */
#speakerPopover {
    position: absolute;
    right: 8px;
    top: 36px;
    width: 250px;
    background: var(--panel-bg);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-dropdown) + 1);
}

.workspace:not(.layout-left):not(.layout-right) #speakerPopover {
    top: auto;
    bottom: 100%;
    margin-bottom: 5px;
}

.workspace.layout-left #speakerPopover,
.workspace.layout-right #speakerPopover {
    top: 36px;
    bottom: auto;
    margin-top: 0;
}

#speakerPopover.visible {
    display: flex;
}

.speaker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 4px;
    border-radius: 4px;
}

.speaker-row.highlighted-speaker {
    background: rgba(59, 130, 246, 0.1);
    border-left: 2px solid var(--accent);
}

.speaker-id {
    color: var(--text-secondary);
    font-size: 0.75rem;
    width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 600;
}

.speaker-id:hover {
    color: var(--accent);
}

/* Speaker Popover Header */
.speaker-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.speaker-popover-title {
    letter-spacing: 0.03em;
}

/* AI Sparkle Button */
.speaker-ai-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: color 0.15s, background 0.15s;
    min-width: 28px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speaker-ai-btn:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.speaker-ai-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* AI Results Panel */
.speaker-ai-results {
    border-top: 1px solid var(--border-subtle);
    margin-top: 6px;
    padding-top: 6px;
}

.speaker-ai-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.speaker-ai-results-title {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

.speaker-ai-select-all {
    font-size: 0.7rem;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    padding: 2px 4px;
}

.speaker-ai-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.speaker-ai-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.speaker-ai-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.speaker-ai-old-name {
    color: var(--text-secondary);
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.speaker-ai-arrow {
    color: var(--text-secondary);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.speaker-ai-new-name {
    color: var(--accent);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.speaker-ai-apply-btn {
    width: 100%;
    margin-top: 6px;
    padding: 6px 0;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.speaker-ai-apply-btn:hover {
    opacity: 0.9;
}

.speaker-ai-apply-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.speaker-ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.speaker-ai-message {
    text-align: center;
    padding: 8px 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Response Controls - see main definition above at line ~1655 */

/* Toasts */
/* ─── Question Toast ─────────────────────────────────────── */
#questionToast,
#notificationToast {
    position: fixed;
    opacity: 0;
    pointer-events: none;
    z-index: var(--z-toast);
}

#questionToast {
    bottom: 80px;
    left: 50%;
    translate: -50% 16px;
    width: min(360px, calc(100vw - 32px));
    padding: 14px 16px 12px;
    background: rgba(24, 24, 27, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity 0.25s ease-out, translate 0.25s ease-out;
}

#questionToast.visible {
    translate: -50% 0;
    opacity: 1;
    pointer-events: auto;
}

/* Small pill label */
.toast-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin-bottom: 8px;
}
.toast-pill i { font-size: 0.6rem; }

/* Question text — clean, no box */
#detectedQuestionText {
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text-primary);
    margin: 0 0 14px;
    max-height: 120px;
    overflow-y: auto;
}

/* Action buttons — compact pill style */
.toast-actions {
    display: flex;
    gap: 8px;
}

.toast-btn {
    flex: 1;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.toast-btn:active {
    background: rgba(255, 255, 255, 0.12);
}

@media (hover: hover) {
    .toast-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(59, 246, 146, 0.25);
        color: var(--text-primary);
    }
}

.toast-btn.primary {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.toast-btn.primary i { margin-right: 4px; font-size: 0.7rem; }

.toast-btn.primary:active {
    filter: brightness(0.9);
}

@media (hover: hover) {
    .toast-btn.primary:hover {
        filter: brightness(1.1);
        color: #fff;
    }
}

#notificationToast {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--success);
    color: black;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s;
    z-index: var(--z-max); /* Must be above all modals including document manager (z-index: 2500) */
    pointer-events: none;
}

#notificationToast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

#notificationToast.warning {
    background: var(--warning, #f59e0b);
    color: black;
}

#notificationToast.error {
    background: var(--recording, #ef4444);
    color: white;
}

#notificationToast.success {
    background: var(--success);
    color: black;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

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

/* --- Mobile Overrides (Aggressive & Optimized) --- */
@media (max-width: 768px) {

    /* 1. Force Column Layout & Reset Container */
    .workspace,
    .workspace.layout-left,
    .workspace.layout-right {
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* Header/Toolbar Optimizations */
    .toolbar {
        padding: 0 0.5rem !important;
    }

    /* Stats now live inside Live tab — no toolbar-stats to manage */

    .toolbar .toggle-wrapper span {
        display: none !important;
        /* Hide 'Auto-Reply' text */
    }

    .session-name {
        max-width: 200px !important;
        /* Increased — document manager button hidden on mobile frees space */
    }

    .brand {
        font-size: 0.85rem !important;
        gap: 4px !important;
    }

    .toolbar-right {
        gap: 10px !important;
    }

    /* 3. Input Pane: Fill remaining space at bottom */
    .pane-input {
        width: 100% !important;
        height: auto !important;
        flex: 1 1 60% !important;
        order: 2;
    }

    /* 2. Response Pane: Fill remaining space above input pane */
    .pane-response {
        flex: 1 1 auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;

        /* Reset Borders for Stacked View */
        border-top: none !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;

        order: 1;
        /* Response at top */
    }

    /* Maximized State for Mobile - handled in Final Override section */

    /* Collapsed State for Mobile - handled in Final Override section */

    /* 5. Hide Resizer on Mobile */
    .resizer {
        display: none !important;
    }

    /* 6. Ensure text area is usable */
    textarea.main-input {
        font-size: 16px;
        padding: 8px 12px;
        padding-right: 10px;
    }
}

/* Upload Modal */
#uploadModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.upload-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
}

/* @keyframes pulse & slideUp defined once at top level (see line ~3911) */

/* Upload Modal */
#uploadModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.upload-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
}

/* @keyframes pulse & slideUp defined once at top level (see line ~3911) */

/* Upload Modal */
#uploadModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.upload-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
}

/* @keyframes pulse & slideUp defined once at top level (see line ~3911) */

/* Upload Modal */
#uploadModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.upload-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* @keyframes pulse & slideUp defined once at top level (see line ~3911) */

/* Upload Modal */
#uploadModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.upload-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* @keyframes pulse & slideUp defined once at top level (see line ~3911) */

/* Upload Modal */
#uploadModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.upload-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    padding: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.file-icon {
    font-size: 2rem;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 12px;
    border-radius: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* --- Mobile Layout Fixes (Final Override) --- */
@media (max-width: 768px) {

    #workspace,
    .workspace,
    .workspace.layout-left,
    .workspace.layout-right {
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* Response Pane: Fill available space at top */
    .pane-response {
        width: 100% !important;
        height: auto !important;
        flex: 1 1 auto !important;
        order: 1;
        min-height: 0 !important;
        padding: 0 !important;
    }

    /* Input Pane: Default State - normal split with response */
    .pane-input {
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        flex: 0 0 55% !important;
        order: 2;
        transition: flex-basis 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            min-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.25s ease !important;
    }

    /* Input Pane: Collapsed State - completely hidden, floating button shows instead.
       Selector must match desktop specificity (.workspace:not(...):not(...) .pane-input.collapsed) */
    .workspace:not(.layout-left):not(.layout-right) .pane-input.collapsed,
    .workspace.layout-left .pane-input.collapsed,
    .workspace.layout-right .pane-input.collapsed,
    .pane-input.collapsed {
        flex: 0 0 0px !important;
        height: 0px !important;
        min-height: 0px !important;
        max-height: 0px !important;
        overflow: hidden !important;
        padding: 0 !important;
        border: none !important;
        opacity: 0;
    }

    /* Input Pane: Maximized State - takes most of screen */
    .pane-input.maximized {
        flex: 0 0 95% !important;
        max-height: 95% !important;
    }

    /* Mobile Resize Handle - Show in regular AND maximized state (allows drag-to-minimize) */
    .pane-input:not(.collapsed) .mobile-resize-handle {
        display: flex !important;
    }

    /* Hide resize handle only when collapsed (transcript hidden) */
    .pane-input.collapsed .mobile-resize-handle {
        display: none !important;
    }

    /* Transcript wrapper - no extra padding needed since resize handle is above header */
    .pane-input:not(.collapsed):not(.maximized) .transcript-wrapper {
        padding-top: 0;
    }

    /* Ensure no padding in collapsed or maximized states */
    .pane-input.collapsed .transcript-wrapper,
    .pane-input.maximized .transcript-wrapper {
        padding-top: 0;
    }

    /* ===== MOBILE FULLSCREEN MODE ===== */

    /* Show fullscreen entry button on mobile (in toolbar) */
    .mobile-fullscreen-entry-btn {
        display: inline-flex !important;
    }

    /* Fullscreen mode active - hide main toolbar, show fullscreen header */
    body.fullscreen-mode .toolbar {
        display: none !important;
    }

    body.fullscreen-mode .fullscreen-header {
        display: flex !important;
    }

    /* Hide response tabs in fullscreen mode to maximize content area */
    body.fullscreen-mode .response-tabs {
        display: none !important;
    }

    /* Adjust workspace to account for fullscreen header */
    body.fullscreen-mode #workspace {
        margin-top: 56px !important;
        height: calc(100vh - 56px) !important;
    }

    /* Maximize available space in fullscreen mode */
    body.fullscreen-mode .pane-response {
        max-height: 100% !important;
        flex: 1 1 auto !important;
        /* Allow response pane to grow */
    }

    body.fullscreen-mode .pane-input {
        max-height: 100% !important;
    }

    /* When transcript is collapsed in fullscreen mode, response fills all space */
    body.fullscreen-mode .pane-input.collapsed {
        flex: 0 0 0px !important;
        min-height: 0px !important;
        max-height: 0px !important;
        overflow: hidden !important;
        opacity: 0;
    }

    /* When transcript is maximized in fullscreen mode */
    body.fullscreen-mode .pane-input.maximized {
        flex: 0 0 95% !important;
        max-height: 95% !important;
    }

    /* Remove top padding from tab content in fullscreen mode */
    body.fullscreen-mode .response-tab-content {
        padding-top: 0 !important;
    }

    /* Smooth transitions for fullscreen mode */
    .toolbar,
    .fullscreen-header,
    #workspace {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Rescued Mobile Styles */

    /* Mobile header - hide desktop collapse, show mobile controls */
    #desktopCollapseBtn {
        display: none !important;
    }

    /* Show mobile view controls */
    #mobileChevron {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        cursor: pointer;
        color: #fff;
        background: rgba(255, 255, 255, 0.12);
        transition: transform 0.3s, color 0.15s, background 0.15s;
        border-radius: 6px;
    }

    #mobileChevron:hover,
    #mobileChevron:active {
        color: #fff;
        background: rgba(255, 255, 255, 0.22);
    }

    /* Maximize button hidden — drag handle covers maximize/minimize */
    #mobileMaximizeBtn {
        display: none !important;
    }

    /* View controls group - tight spacing for related controls */
    .header-view-controls {
        gap: 4px;
    }

    /* Header actions - good spacing on mobile for touch targets */
    .header-actions {
        gap: 4px;
    }

    /* Slightly larger touch targets on mobile */
    .header-actions .header-action-btn {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    /* Fade out elements when collapsed */
    .pane-input .header-title,
    .pane-input .header-actions,
    .pane-input #speakerBtn {
        transition: opacity 0.2s ease;
    }

    .pane-input.collapsed .header-title,
    .pane-input.collapsed .header-actions,
    .pane-input.collapsed #speakerBtn,
    .pane-input.collapsed #speakerPopover {
        opacity: 0;
        pointer-events: none;
    }

    /* Transcript empty state — mobile adjustments */
    .empty-state-mic-hero {
        width: 80px;
        height: 80px;
        font-size: 1.8rem;
    }

    .empty-state-heading {
        font-size: 1.05rem;
    }

    .empty-state-subtext {
        font-size: 0.8rem;
        max-width: 220px;
    }

    /* When collapsed, only show view controls centered */
    .pane-input.collapsed .input-header {
        justify-content: center;
        padding: 0 8px;
    }

    .pane-input.collapsed .header-view-controls {
        gap: 8px;
    }

    .resizer {
        display: none !important;
    }

    /* Optimized controls overlay - minimal spacing to maximize content area */
    .controls-overlay {
        bottom: 0.5rem;
        right: 0.5rem;
        left: auto;
        flex-direction: row;
        align-items: flex-end;
        justify-content: flex-end;
        gap: 8px;
        transition: bottom 0.3s ease;
        z-index: var(--z-header);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Secondary group becomes horizontal row on mobile */
    .fab-group-secondary {
        flex-direction: row;
        gap: 6px;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    /* Language selector on mobile - inline with FABs */
    .language-selector-wrapper {
        margin-bottom: 0;
        margin-right: 4px;
    }

    .session-language-select {
        padding: 4px 6px;
        font-size: 0.65rem;
        min-width: 45px;
    }

    /* Smaller secondary FABs on mobile - compact for more content space */
    .fab.fab-secondary {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    /* Primary FAB - slightly smaller but still prominent */
    .fab.fab-primary {
        width: 46px;
        height: 46px;
    }

    /* Microphone button - prominent on mobile with minimum tap target */
    #micBtn.fab-mic {
        width: 52px;
        height: 52px;
        min-width: 52px;
        min-height: 52px;
        font-size: 1.25rem;
        /* Ensure it stands out from secondary buttons */
        order: 1;
    }

    /* Compact wake lock indicator on mobile */
    .wake-lock-indicator {
        width: 22px;
        height: 22px;
        font-size: 0.6rem;
    }

    .pane-input.maximized .controls-overlay {
        bottom: 1rem;
    }

    /* Maximized state - optimized padding */
    .pane-input.maximized textarea.main-input,
    .pane-input.maximized .highlight-backdrop {
        padding-bottom: 55px !important;
    }

    /* Minimal padding - aggressive to maximize content */
    textarea.main-input {
        font-size: 16px;
        padding: 8px 12px;
        padding-right: 10px;
        padding-bottom: 50px;
    }

    /* Also apply to highlight backdrop for consistency */
    .highlight-backdrop {
        padding: 8px 12px;
        padding-right: 70px;
        padding-bottom: 50px;
    }
}

/* ===================================
   QUESTION QUEUE PANEL
   =================================== */
.question-panel {
    position: fixed;
    z-index: var(--z-toast);
    pointer-events: none;
}

.question-panel.open {
    pointer-events: all;
}

/* Backdrop */
.question-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.question-panel.open .question-backdrop {
    opacity: 1;
    pointer-events: all;
}

/* Desktop: Right Drawer */
@media (min-width: 768px) {
    .question-panel {
        top: 0;
        right: 0;
        bottom: 0;
        width: 100%;
    }

    .question-container {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 320px;
        max-width: 90vw;
        background: rgba(9, 9, 11, 0.98);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-left: 1px solid var(--border-subtle);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
    }

    .question-panel.open .question-container {
        transform: translateX(0);
    }

    .drag-handle {
        display: none;
    }
}

/* Mobile: Bottom Sheet */
@media (max-width: 767px) {
    .question-panel {
        left: 0;
        right: 0;
        bottom: 0;
        top: 0;
    }

    .question-container {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 70vh;
        background: rgba(9, 9, 11, 0.98);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        padding-bottom: env(safe-area-inset-bottom);
    }

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

    .drag-handle {
        display: flex;
        justify-content: center;
        padding: 8px 0;
        cursor: grab;
        touch-action: none;
    }

    .handle-bar {
        width: 40px;
        height: 4px;
        background: var(--text-tertiary);
        border-radius: 2px;
    }
}

/* Header */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}

.question-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.question-header h3 span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

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

/* ── Reusable Modal Close Button ── */
/* Native mobile-first close button for modal headers.
   44px touch target, circular, subtle bg, tap feedback. */
.modal-close-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary, #a1a1aa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    /* Expand touch target to 44px without growing visual size */
    position: relative;
}

.modal-close-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-primary, #e4e4e7);
}

.modal-close-btn:active {
    transform: scale(0.88);
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Question List */
.question-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: rgba(0, 0, 0, 0.15);
}

/* Question Cards */
.question-card {
    background: rgba(18, 18, 20, 0.95);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--border-medium);
    border: 1px solid var(--border-medium);
    display: flex;
    gap: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.question-card.unread {
    border-left-color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
}

.question-card:hover {
    background: rgba(39, 39, 42, 0.95);
}

.question-card:active {
    transform: scale(0.98);
}

.question-indicator {
    font-size: 0.9rem;
    line-height: 1.5rem;
    flex-shrink: 0;
}

.question-content {
    flex: 1;
    min-width: 0;
}

.question-text {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    word-wrap: break-word;
    color: var(--text-primary);
    font-weight: 400;
}

.question-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.question-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.question-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(18, 18, 20, 0.95);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    flex: 1;
    min-width: 80px;
}

.question-actions button:hover {
    background: rgba(39, 39, 42, 0.95);
}

.btn-respond {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb) !important;
    color: white !important;
    border-color: transparent !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-respond:hover {
    filter: brightness(1.1);
}

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

.btn-dismiss:hover {
    background: rgba(255, 0, 0, 0.1) !important;
    border-color: rgba(255, 0, 0, 0.3) !important;
}

/* Badge */
.icon-btn {
    position: relative;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--recording);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {

    .question-container,
    .question-backdrop,
    .question-card {
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .question-card {
        border: 2px solid var(--text-primary);
    }
}

/* Question Detection Modal */
#questionDetectionModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: var(--z-critical);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#questionDetectionModal.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.upload-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.upload-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg);
    padding: 10px;
    border-radius: 8px;
}

.file-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.file-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.progress-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s;
}

/* --- Session Icon Improvements --- */

/* Toolbar Session Icon */
.session-icon {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.1rem;
    filter: drop-shadow(0 2px 4px rgba(59, 246, 146, 0.25));
    transition: transform 0.3s ease, filter 0.3s ease;
    margin-right: 4px;
}

.brand:hover .session-icon {
    transform: scale(1.12) rotate(-5deg);
    filter: drop-shadow(0 4px 10px rgba(59, 246, 146, 0.4));
}

/* Modal Session Icon */
.modal-icon-lg {
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-right: 10px;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.2));
}

/* Enhanced Session Filter Buttons */
#sessionManagerModal .toast-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

#sessionManagerModal .toast-btn:hover:not(.active) {
    background: var(--surface-hover);
    border-color: var(--text-secondary);
}

/* ===========================================
   SESSION DRAWER BUTTON
   =========================================== */
.session-drawer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md, 8px);
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.session-drawer-btn:hover {
    background: var(--surface-hover);
}

.session-drawer-btn:active {
    transform: scale(0.92);
    background: var(--surface-hover);
}

/* Hide old session manager button - replaced by drawer */
#sessionManagerBtn {
    display: none !important;
}

/* ===========================================
   SESSION PANEL - Native Mobile App Style
   =========================================== */
.session-panel-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 10000;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.4s ease;
}

.session-panel-backdrop.visible {
    display: block;
    background: rgba(0, 0, 0, 0.5);
}

/* Faster fade for closing */
.session-panel-backdrop.closing {
    transition: background 0.3s ease;
}

.session-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    will-change: transform;
    /* iOS-style spring animation */
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    touch-action: pan-y;
}

/* When visible, use spring animation */
.session-panel-backdrop.visible .session-panel {
    transform: translateX(0);
}

/* When dragging, disable transition for real-time tracking */
.session-panel.dragging {
    transition: none !important;
}

/* Closing animation - slightly faster, eased out */
.session-panel-backdrop.closing .session-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0, 1, 1);
}

/* Desktop: Panel takes partial width */
@media (min-width: 769px) {
    .session-panel {
        width: 420px;
        max-width: 90%;
        border-right: 1px solid var(--border);
    }
}

.session-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    min-height: 60px;
    flex-shrink: 0;
}

.session-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.session-panel-title i {
    font-size: 1.2rem;
}

.session-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.session-filter-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.session-filter-btn {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md, 8px);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.session-filter-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.session-filter-btn.active {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    border-color: rgba(59, 246, 146, 0.3);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.session-filter-btn i {
    font-size: 0.85rem;
}

.session-list-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.session-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    opacity: 0.6;
    text-align: center;
    flex: 1;
}

.session-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.session-empty-state p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.session-empty-state small {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Session Context Menu */
.session-context-menu {
    position: fixed;
    z-index: 10001;
    min-width: 200px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    padding: 6px;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.session-context-menu .context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.session-context-menu .context-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.8;
}

.session-context-menu .context-menu-item:hover,
.session-context-menu .context-menu-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.session-context-menu .context-menu-item.danger {
    color: #ff453a;
}

.session-context-menu .context-menu-item.danger i {
    color: #ff453a;
}

.session-context-menu .context-menu-item.danger:hover,
.session-context-menu .context-menu-item.danger:active {
    background: rgba(255, 69, 58, 0.15);
}

.session-context-menu .context-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 6px 0;
}

/* Toolbar Optimization Overrides */
.brand {
    gap: 4px !important;
}

.session-name {
    margin-right: 8px;
    position: relative;
}

.session-name::after {
    content: '';
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    height: 16px;
    width: 1px;
    background: var(--border);
}

.session-controls {
    display: flex;
    gap: 4px;
    background: var(--surface-hover);
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.badge {
    font-size: 0.6rem !important;
    padding: 2px 6px !important;
    background: transparent !important;
    border: 1px solid var(--border) !important;
    color: var(--text-secondary) !important;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Desktop toolbar spacing */
@media (min-width: 769px) {
    .toolbar-right {
        gap: 16px;
    }

    .brand {
        gap: 12px;
    }
}

/* Refined Toolbar Styles */
.session-controls {
    background: transparent;
    border: none;
    gap: 2px;
    padding: 0;
}

.session-name::after {
    display: none;
}

.toolbar-icon-btn {
    width: 32px !important;
    height: 32px !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
}

.toolbar-icon-btn.primary {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
    border-radius: 6px !important;
}

.toolbar-icon-btn:hover {
    background: var(--surface-hover) !important;
}

.toolbar-icon-btn.primary:hover {
    filter: brightness(1.1);
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb) !important;
}

/* Responsive: Hide Auto-Reply Text on Mobile */
@media (max-width: 768px) {
    .toolbar .toggle-wrapper span {
        display: none;
    }

    .session-name {
        max-width: 180px !important;
    }

    .badge {
        display: none !important;
    }
}


/* --- Final Toolbar Visibility & Overflow Fixes --- */

/* 1. Force Transparent Backgrounds & Correct Colors : Updated*/
.toolbar button:not(.primary),
.toolbar .toolbar-icon-btn:not(.primary),
.toolbar .icon-btn,
.toolbar .tools-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
}

/* 2. Hover States */
.toolbar button:not(.primary):hover,
.toolbar .toolbar-icon-btn:not(.primary):hover,
.toolbar .icon-btn:hover,
.toolbar .tools-btn:hover {
    background: var(--surface-hover) !important;
    color: var(--text-primary) !important;
}

/* 3. Ensure Icons Inherit Color */
.toolbar button i,
.toolbar .toolbar-icon-btn i,
.toolbar .icon-btn i,
.toolbar .tools-btn i {
    color: inherit !important;
}

/* 4. Specific Fix for Session Name Truncation */
.session-name {
    max-width: 225px;
    /* Default for desktop — 50% wider to show gradient text effect */
}

/* 5. Responsive Overrides to Prevent Overflow */
@media (max-width: 1024px) {

}

@media (max-width: 768px) {

    /* More space for session name now that profile is in drawer */
    .session-name {
        max-width: 180px !important;
    }

    /* Ensure Settings Toggle is visible */
    #settingsToggle {
        display: flex !important;
    }
}


/* --- Final Fixes: Badge Visibility & Icon Overflow --- */

/* 1. Fix Badge Clipping */
#questionBtn,
.icon-btn {
    overflow: visible !important;
    position: relative !important;
}

/* 2. Fix Config Icon Cut-off */
#settingsToggle {
    flex-shrink: 0 !important;
    margin-right: 0 !important;
}

/* Desktop toolbar-right spacing */
@media (min-width: 769px) {
    .toolbar-right {
        gap: 8px;
        padding-right: 4px;
    }
}

/* 3. Badge Styling & Positioning */
#questionBadge {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    background: var(--recording) !important;
    /* Red color */
    color: white !important;
    border: 1px solid var(--bg-color) !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
    font-size: 0.65rem !important;
    display: flex !important;
    /* Force flex to center content */
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    z-index: var(--z-sticky) !important;
    box-shadow: var(--shadow-md) !important;
}

/* 4. Ensure Question Button is visible if it has content */
/* Note: JS toggles display:none, but when active it must be flex */
#questionBtn[style*='display: block'],
#questionBtn[style*='display: flex'] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}


/* --- Mobile Overflow Fixes --- */

/* Desktop: Protect the Tools (Right Side) */
@media (min-width: 769px) {
    .toolbar-right {
        flex-shrink: 0;
        margin-left: auto;
    }
}

/* ===========================================
   TOOLBAR - Mobile-First Responsive Design
   =========================================== */

/* Mobile-only items: hidden on desktop, shown on mobile */
.mobile-only {
    display: none !important;
}

/* --- Tablet (1024px and below) --- */
@media (max-width: 1024px) {
    /* Hide ALL toolbar dividers on mobile */
    .toolbar-divider {
        display: none !important;
    }

    .session-name {
        max-width: 120px;
    }
}

/* === DESKTOP: Hide Mobile-Only Overflow Menu === */
.toolbar-overflow-btn,
.toolbar-overflow-menu,
.toolbar-overflow-backdrop {
    display: none !important;
}

/* --- Mobile (768px and below) --- */
@media (max-width: 768px) {

    /* Show mobile-only dropdown items */
    .mobile-only {
        display: flex !important;
    }

    .toolbar {
        height: 52px;
        padding: 0 8px;
        gap: 4px;
        justify-content: space-between;
    }

    /* Left section - session name only */
    .toolbar-left {
        flex: 0 1 auto;
        min-width: 0;
        overflow: visible;
        gap: 0;
    }

    /* Brand section — tighter spacing on mobile */
    .brand {
        gap: 0;
        min-width: 0;
        flex-shrink: 1;
    }

    .session-drawer-btn {
        width: 34px;
        height: 36px;
        font-size: 1.05rem;
    }

    /* Hide elements on mobile - they're in dropdown instead */
    .toolbar-divider,
    .session-icon,
    .model-badge,
    .session-controls {
        display: none !important;
    }

    /* Mobile New Session Button - visible on mobile only */
    /* Mobile Fullscreen Entry Button - visible on mobile only */
    .mobile-fullscreen-entry-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 36px;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.9rem;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s ease;
        margin-left: 2px;
    }

    .mobile-fullscreen-entry-btn:active {
        background: rgba(59, 130, 246, 0.2);
        color: var(--accent);
        transform: scale(0.95);
    }

    .mobile-new-session-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 36px;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.9rem;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s ease;
        margin-left: 2px;
    }

    .mobile-new-session-btn:active {
        background: rgba(59, 130, 246, 0.2);
        color: var(--accent);
        transform: scale(0.95);
    }

    /* Session name wrapper */
    .session-name-wrapper {
        display: flex !important;
        align-items: center;
        gap: 0;
        min-width: 0;
    }

    /* Session name — reclaims space freed by removed manual save button.
       More room for longer session names on mobile. */
    .session-name {
        max-width: 260px;
        min-width: 80px;
        padding: 8px 8px;
        font-size: 0.9rem;
        min-height: 40px;
        display: flex !important;
        align-items: center;
        flex-shrink: 1;
        flex-grow: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Session menu button */
    .session-menu-btn {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Right section - prevent over-shrinking to protect profile */
    .toolbar-right {
        gap: 4px;
        /* Increased from 2px for better spacing */
        flex-shrink: 0;
        /* Changed from 1 to 0 to prevent shrinking */
        min-width: fit-content;
        /* Ensure minimum space for content */
        margin-left: auto;
        /* Push to the right */
    }

    /* Hide auto-reply toggle on mobile toolbar - save space */
    .toolbar .toggle-wrapper {
        display: none !important;
    }

    /* Hide document manager (attachment) button on mobile — redundant with chat attach */
    #documentManagerBtn {
        display: none !important;
    }

    /* Action buttons - compact for mobile */
    .toolbar-actions {
        gap: 1px;
        flex-shrink: 0;
        /* Prevent action buttons from shrinking */
    }

    .toolbar-action-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
        flex-shrink: 0;
        /* Prevent individual buttons from shrinking */
    }

    /* User avatar - compact but never shrink */
    .toolbar-user-profile {
        flex-shrink: 0;
        /* Critical: prevent profile from shrinking */
        min-width: 32px;
        /* Ensure minimum touchable area */
        margin-left: 0px;
        /* Consistent spacing */
    }

    .toolbar-avatar {
        width: 32px;
        /* Increased from 28px for better visibility */
        height: 32px;
        flex-shrink: 0;
        /* Never allow avatar to shrink */
    }

    .toolbar-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        /* Ensure image fills circle properly */
    }

    /* === MOBILE OVERFLOW MENU (Only visible on mobile) === */

    /* Overflow Menu Button */
    .toolbar-overflow-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s ease;
        position: relative;
        flex-shrink: 0;
    }

    .toolbar-overflow-btn:active {
        background: var(--surface-hover);
        transform: scale(0.95);
    }

    /* Overflow Menu (Bottom Sheet) */
    .toolbar-overflow-menu {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-color);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: calc(var(--z-modal) + 1);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        max-height: 60vh;
        overflow-y: auto;
    }

    .toolbar-overflow-menu.open {
        transform: translateY(0);
    }

    .toolbar-overflow-menu-handle {
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 12px auto 8px;
    }

    .toolbar-overflow-menu-title {
        padding: 8px 20px 12px;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .toolbar-overflow-menu-items {
        padding: 0 8px 20px;
    }

    .toolbar-overflow-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
        background: transparent;
        border: none;
        width: 100%;
        text-align: left;
        color: var(--text-primary);
        font-size: 0.95rem;
        position: relative;
    }

    .toolbar-overflow-item:active {
        background: var(--surface-hover);
        transform: scale(0.98);
    }

    .toolbar-overflow-item-icon {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--surface);
        border-radius: 10px;
        color: var(--text-secondary);
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    .toolbar-overflow-item-content {
        flex: 1;
    }

    .toolbar-overflow-item-label {
        font-weight: 500;
        color: var(--text-primary);
        margin-bottom: 2px;
    }

    .toolbar-overflow-item-desc {
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    .toolbar-overflow-item-badge {
        position: absolute;
        top: 8px;
        right: 16px;
        min-width: 24px;
        height: 24px;
        padding: 0 8px;
        background: var(--error);
        color: white;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Overflow Menu Backdrop */
    .toolbar-overflow-backdrop {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: var(--z-modal);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .toolbar-overflow-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Session dropdown - bottom sheet style on mobile */
    .session-dropdown {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        max-height: 70vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 8px 8px calc(env(safe-area-inset-bottom, 24px) + 16px) 8px;
        transform: translateY(100%);
        opacity: 0;
        visibility: hidden;
        z-index: 9999;
        /* Above everything */
        overflow-y: auto;
    }

    /* Backdrop overlay for mobile dropdown */
    .session-name-wrapper.open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        animation: fadeIn 0.2s ease forwards;
    }

    @keyframes fadeIn {
        to {
            opacity: 1;
        }
    }

    .session-name-wrapper.open .session-dropdown {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    /* Larger dropdown items for touch */
    .session-dropdown .dropdown-item {
        padding: 14px 16px;
        font-size: 1rem;
    }
}

/* --- Small Mobile (480px and below) --- */
@media (max-width: 480px) {
    .toolbar {
        height: 48px;
        padding: 0 8px;
    }

    /* Session name - more space with profile in drawer */
    .session-name {
        max-width: 180px;
        min-width: 40px;
        padding: 8px 10px;
        font-size: 0.8rem;
        min-height: 36px;
    }

    /* Session menu button */
    .session-menu-btn {
        width: 36px;
        height: 36px;
    }

    /* Action buttons - slightly smaller */
    .toolbar-action-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    #userAvatar {
        width: 28px;
        height: 28px;
    }
}

/* --- Touch Target Accessibility --- */
/* Only apply to tablets and larger touch devices */
@media (hover: none) and (pointer: coarse) and (min-width: 769px) {

    .toolbar-action-btn,
    .toolbar-icon-btn,
    .session-name,
    .session-menu-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Larger dropdown items for touch */
    .dropdown-item {
        padding: 12px 16px;
        min-height: 48px;
    }
}

/* Mobile body-mounted dropdown - when appended to body to escape containing block */
@media (max-width: 768px) {
    .session-dropdown.mobile-body-mounted {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 70vh !important;
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        z-index: 10000 !important;
        background: var(--panel-bg);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 12px 12px calc(env(safe-area-inset-bottom, 24px) + 16px) 12px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
    }

    /* Backdrop when dropdown is body-mounted */
    body:has(.session-dropdown.mobile-body-mounted)::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999;
    }
}

/* ===========================================
   PULL TO REFRESH
   =========================================== */

.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 12px;
    z-index: var(--z-critical);
    pointer-events: none;
    transform: translateY(-100%);
    transition: transform var(--transition-normal);
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

.pull-to-refresh.releasing {
    transition: transform var(--transition-bounce);
}

.pull-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.pull-icon {
    font-size: 1.25rem;
    color: var(--accent);
    transition: transform var(--transition-normal);
}

.pull-to-refresh.ready .pull-icon {
    transform: rotate(180deg);
    color: var(--success);
}

.pull-to-refresh.refreshing .pull-icon {
    animation: spin 1s linear infinite;
}

.pull-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

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

    to {
        transform: rotate(360deg);
    }
}

/* Document Attachments */
.document-attachments {
    border-bottom: 1px solid var(--border-subtle);
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    max-height: 250px;
}

.document-attachments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-hover);
}

.document-attachments-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.document-attachments-clear {
    background: none;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}

.document-attachments-clear:hover {
    color: var(--error);
    border-color: var(--error);
    background: var(--error-bg);
}

.document-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    overflow-y: auto;
    flex: 1;
}

.document-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    max-width: 250px;
}

.document-attachment-icon {
    font-size: 1.25rem;
    color: var(--accent);
    flex-shrink: 0;
}

.document-attachment-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.document-attachment-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-attachment-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.document-attachment-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.document-attachment-remove:hover {
    color: var(--error);
    background: var(--error-bg);
}

.document-attachment-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* Cloud Sync Indicator */
.cloud-sync-indicator {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
    font-size: 1rem;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .cloud-sync-indicator {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* ─── Offline Indicator ─── */
.offline-indicator {
    position: fixed;
    top: 12px;
    right: 12px;
    background: var(--warning, #f59e0b);
    color: #fff;
    padding: 4px 14px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    letter-spacing: 0.02em;
    animation: offlineFadeIn 0.3s ease;
}

@keyframes offlineFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .offline-indicator {
        top: 8px;
        right: 8px;
        font-size: 0.7rem;
        padding: 3px 10px;
    }
}

/* =============================================
   Native Mobile Modal (iOS/Android feel)
   ============================================= */
.native-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10010; /* Must be above session rename modal (10001) */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.native-modal-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.native-modal-content {
    background: var(--panel-bg, #18181b);
    border: 1px solid var(--border, #27272a);
    border-radius: 16px;
    width: 100%;
    max-width: 320px;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.4);
}

.native-modal-backdrop.visible .native-modal-content {
    transform: translateY(0);
}

.native-modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.native-modal-header i {
    font-size: 2rem;
    color: var(--accent, #3b82f6);
    opacity: 0.9;
}

.native-modal-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
    text-align: center;
}

.native-modal-message {
    font-size: 0.85rem;
    color: var(--text-secondary, #a1a1aa);
    text-align: center;
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.native-modal-actions {
    display: flex;
    gap: 10px;
}

.native-modal-btn {
    flex: 1;
    padding: 14px 16px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.native-modal-btn.secondary {
    background: var(--surface-hover, #27272a);
    color: var(--text-primary, #fafafa);
}

.native-modal-btn.secondary:active {
    background: var(--surface-active, #3f3f46);
    transform: scale(0.98);
}

.native-modal-btn.primary {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.native-modal-btn.primary:active {
    filter: brightness(0.9);
    transform: scale(0.98);
}

/* Desktop: Center the modal */
@media (min-width: 769px) {
    .native-modal-backdrop {
        align-items: center;
    }

    .native-modal-content {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }

    .native-modal-backdrop.visible .native-modal-content {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ===========================================
   NATIVE MOBILE BOTTOM SHEET
   iOS/Android Action Sheet Style
   =========================================== */
.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.bottom-sheet-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet-content {
    background: linear-gradient(180deg, #1f1f23 0%, #18181b 100%);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    width: 100%;
    max-width: 100%;
    padding: 8px 20px 34px 20px;
    /* Extra bottom padding for safe area */
    padding-bottom: max(34px, env(safe-area-inset-bottom, 34px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.bottom-sheet-backdrop.visible .bottom-sheet-content {
    transform: translateY(0);
}

/* Drag handle - iOS style */
.bottom-sheet-handle {
    width: 36px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    margin: 0 auto 20px auto;
}

.bottom-sheet-header {
    text-align: center;
    margin-bottom: 24px;
}

.bottom-sheet-header i {
    font-size: 2.5rem;
    color: #f87171;
    margin-bottom: 12px;
    display: block;
}

.bottom-sheet-header h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
}

.bottom-sheet-header p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.4;
}

.bottom-sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bottom-sheet-btn {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-btn:active {
    transform: scale(0.97);
}

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

.bottom-sheet-btn.danger:active {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.bottom-sheet-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #fafafa);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.bottom-sheet-btn.secondary:active {
    background: rgba(255, 255, 255, 0.15);
}

/* Desktop: Center as modal instead of bottom sheet */
@media (min-width: 769px) {
    .bottom-sheet-backdrop {
        align-items: center;
    }

    .bottom-sheet-content {
        max-width: 360px;
        border-radius: 20px;
        padding: 20px 24px 24px 24px;
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }

    .bottom-sheet-backdrop.visible .bottom-sheet-content {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    .bottom-sheet-handle {
        display: none;
    }

    .bottom-sheet-actions {
        flex-direction: row-reverse;
        gap: 12px;
    }

    .bottom-sheet-btn {
        flex: 1;
        padding: 14px 16px;
        font-size: 0.95rem;
    }
}

/* Exit hint overlay — shown when programmatic close fails */
.exit-hint-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.2s ease-out;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.exit-hint-box {
    text-align: center;
    padding: 32px 28px;
    border-radius: 20px;
    background: var(--bg-secondary, #1e1e2e);
    color: var(--text-primary, #fff);
    max-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.exit-hint-box p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.5;
}

.exit-hint-dismiss {
    margin-top: 16px;
    padding: 10px 32px;
    border: none;
    border-radius: 12px;
    background: var(--accent, #6C63FF);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.pane-response {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* CRITICAL: Prevents flex item from expanding beyond parent */
    overflow: hidden;
    /* Contain children */
    position: relative;
    height: 100%;
}

/* ===========================================
   Response Area Tabs
   =========================================== */
/* ===========================================
   Response Area Tabs
   =========================================== */
/* Base response tabs — overridden by segmented control section below */
.response-tabs {
    display: flex;
    gap: 0;
    padding: 3px;
    margin: 6px 12px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.tab-glider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 0;
    height: calc(100% - 6px);
    background: linear-gradient(135deg, var(--accent, #3b82f6), #2563eb);
    border-radius: 8px;
    transition: transform 0.28s cubic-bezier(0.4, 0.0, 0.2, 1),
                width 0.28s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
    pointer-events: none;
    will-change: transform, width;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

.response-tab-btn {
    flex: 1;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.2s ease;
    text-align: center;
    position: relative;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}

.response-tab-btn:hover {
    color: var(--text-primary);
}

.response-tab-btn.active {
    color: #fff;
}

.tab-content-response {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal overflow - content should wrap */
    padding: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    /* Ensure it can shrink */
    min-height: 0;
    scroll-behavior: smooth;
    animation: fadeIn 0.3s ease;
    /* Text wrapping for all content */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

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

.tab-content-response.active {
    display: flex;
    height: 100%;
    /* Force full height */
}

/* Chat Placeholder */
.chat-container-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: -1.5rem -2rem;
    position: relative;
    /* Context for floating input */
    /* Counteract padding if we want full bleed, or just remove padding from this specific tab */
}

/* Override padding for chat tab to be full bleed */
#tab-content-chat {
    padding: 0;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    padding-bottom: 100px;
    /* Space for floating input */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Ensure content is behind input */
    height: 100%;
}

.chat-welcome {
    text-align: center;
    margin-top: 20%;
    color: var(--text-secondary);
}

.chat-welcome i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent);
    opacity: 0.3;
}

.chat-welcome p {
    font-size: 1.1rem;
}

.qa-input-area {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 20px));
    /* Respect iOS safe area */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    /* Transparent - no gradient, pure floating */
    background: transparent;
    pointer-events: none;
    /* Allow clicks to pass through empty areas */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    transition: all 0.2s ease-out;
}

.qa-attachment-chips {
    pointer-events: auto;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px;
}

.qa-attachment-chips[hidden] { display: none; }

.qa-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 260px;
    padding: 8px 10px 8px 8px;
    background: rgba(30, 30, 35, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    font-size: 0.82rem;
    color: var(--text-primary);
    animation: qa-chip-in 0.22s ease-out;
}

@keyframes qa-chip-in {
    from { opacity: 0; transform: translateY(6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.qa-attachment-chip .qa-chip-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

/* Image thumbnail inside chip (replaces icon background for image attachments) */
.qa-attachment-chip.has-thumbnail .qa-chip-icon {
    background: rgba(255, 255, 255, 0.06);
}

.qa-attachment-chip .qa-chip-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Clickable image chip — hint with cursor + subtle hover lift */
.qa-attachment-chip.is-previewable {
    cursor: zoom-in;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.qa-attachment-chip.is-previewable:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.qa-attachment-chip.is-previewable:focus-visible {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 2px;
}

.light-theme .qa-attachment-chip.is-previewable:hover {
    border-color: rgba(0, 0, 0, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.qa-attachment-chip.is-uploading .qa-chip-icon {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.qa-attachment-chip.is-uploading .qa-chip-icon::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from 0deg, rgba(255,255,255,0.85), transparent 70%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
            mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    animation: qa-chip-spin 0.9s linear infinite;
}

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

.qa-attachment-chip .qa-chip-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.qa-attachment-chip .qa-chip-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qa-attachment-chip .qa-chip-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.qa-attachment-chip .qa-chip-remove {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-primary);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    transition: background 0.15s ease, transform 0.15s ease;
}

.qa-attachment-chip .qa-chip-remove:hover {
    background: rgba(239, 68, 68, 0.85);
    transform: scale(1.08);
}

.qa-attachment-chip.is-uploading .qa-chip-remove {
    opacity: 0.5;
    pointer-events: none;
}

.light-theme .qa-attachment-chip {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.light-theme .qa-attachment-chip .qa-chip-remove {
    background: rgba(0, 0, 0, 0.08);
}

.qa-input-wrapper {
    pointer-events: auto;
    width: 100%;
    max-width: 800px;
    /* Optional constraint for large screens */
    display: flex;
    align-items: center;
    gap: 8px;
    /* Glassmorphism Capsule */
    background: rgba(30, 30, 35, 0.65);
    /* Semi-transparent dark */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    /* High radius for pill shape */
    padding: 6px 8px 6px 16px;
    /* Left padding for text, right for buttons */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    /* Strong lift shadow */
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.qa-input-wrapper:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6), var(--glow-blue);
    background: rgba(40, 40, 45, 0.75);
    border-color: rgba(59, 130, 246, 0.3);
    /* Slightly lighter on focus, but still transparent */
}

#qaInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 0;
    color: var(--text-primary);
    resize: none;
    min-height: 24px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
    font-size: 1rem;
}

#qaInput::placeholder {
    color: #a1a1aa;
    opacity: 0.8;
}

#qaInput:focus {
    outline: none;
}

/* Inner Buttons */
.qa-input-wrapper button.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.qa-input-wrapper button.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Specific Send Button Style */
.qa-input-wrapper #qaSendBtn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    border: 1px solid rgba(59, 246, 146, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 4px;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.qa-input-wrapper #qaSendBtn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, var(--accent, #3bf692), #1d4ed8);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4), 0 0 8px rgba(59, 246, 146, 0.15);
}

/* Legacy button removal/override if needed */

/* Help Container */
.help-container {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-primary);
}

.help-container h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    color: var(--accent);
    font-size: 1.4rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

.help-container ul {
    line-height: 1.7;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.help-container li {
    margin-bottom: 0.75rem;
}

.help-container strong {
    color: var(--text-primary);
}

/* Override for QA Header in Tab View */
.tab-content-response .qa-header {
    display: none;
    /* Hide original header container if it still exists via legacy styles */
}

/* Floating Toggle Button - DEPRECATED, replaced by qa-floating-icons */
.qa-controls-toggle {
    display: none;
}

/* Floating Controls Widget - DEPRECATED, replaced by qa-floating-icons */
.qa-floating-controls {
    position: absolute;
    top: 85px;
    /* Below new toggle position */
    right: 10px;
    /* Aligned with container edge */
    width: 280px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 100;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qa-floating-controls.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.qa-controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

/* Adjust chips layout in floating widget */
.qa-floating-controls .qa-header-chips {
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* Full Height Chat Layout - Content extends to bottom, input floats on top */
/* IMPORTANT: Only apply when chat tab is ACTIVE to not override display:none */
#tab-content-chat.active {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#tab-content-chat .qa-history-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding-top: 0;
    /* Content fills entire height including behind floating input */
}

/* Chat history scrolls to bottom edge, with padding for floating input */
#tab-content-chat .qa-history {
    padding-top: 50px;
    padding-bottom: 90px;
    /* Space for floating input capsule */
    padding-left: 10px;
    padding-right: 10px;
    height: 100%;
    overflow-y: auto;
}

/* =============================================
   CLEAN FLOATING INPUT AREA - CHAT TAB
   Two-row layout: Textarea on top, controls at bottom
   ============================================= */
#tab-content-chat .qa-input-area {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 30 !important;
    pointer-events: none !important;

    /* Fully transparent container - no visible box */
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;

    /* Edge-to-edge padding */
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
}

/* No focus styling on the transparent container */
#tab-content-chat .qa-input-area:focus-within {
    background: transparent !important;
    border: none !important;
}

/* Input wrapper - container with relative positioning for overlay controls */
#tab-content-chat .qa-input-area .qa-input-wrapper {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    background: rgba(30, 30, 35, 0.7) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    padding: 0 !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 8px 32px rgba(0, 0, 0, 0.4) !important;
    overflow: hidden !important;
    position: relative !important;
    pointer-events: auto !important;
}

#tab-content-chat .qa-input-area .qa-input-wrapper:focus-within {
    transform: none !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), var(--glow-blue) !important;
    background: rgba(40, 40, 45, 0.75) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
}

/* Textarea - full width with padding to keep last line above control bar */
#tab-content-chat .qa-input-area .qa-input-wrapper textarea#qaInput {
    display: block !important;
    width: 100% !important;
    min-height: 110px !important;
    max-height: 250px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    /* padding-bottom = control bar height (42px) + buffer to keep last line visible */
    padding: 12px 14px 54px 14px !important;
    margin: 0 !important;
    resize: none !important;
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    box-sizing: border-box !important;
    color: var(--text-primary) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* Tells browser to keep caret visible above control bar when auto-scrolling */
    scroll-padding-bottom: 54px !important;
}

#tab-content-chat .qa-input-area .qa-input-wrapper textarea#qaInput:focus {
    background: transparent !important;
    border: none !important;
    outline: none !important;
}

#tab-content-chat .qa-input-area .qa-input-wrapper textarea#qaInput::placeholder {
    color: var(--text-secondary, #a1a1aa) !important;
    opacity: 0.7 !important;
}

/* Hide suggestions dropdown */
#tab-content-chat .qa-input-area .qa-input-wrapper #qaSuggestionsDropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
}

/* Bottom toolbar - ABSOLUTELY positioned at bottom, OPAQUE background hides scrolled text */
#tab-content-chat .qa-input-area .qa-input-wrapper .qa-input-buttons-left {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: 42px !important;
    padding: 0 12px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    /* OPAQUE background to hide text scrolling behind */
    background: rgb(30, 30, 35) !important;
    box-sizing: border-box !important;
    gap: 8px !important;
    z-index: 5 !important;
}

/* Right buttons - positioned at bottom-right, same row as left buttons */
#tab-content-chat .qa-input-area .qa-input-wrapper .qa-input-buttons {
    position: absolute !important;
    bottom: 0 !important;
    right: 12px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    height: 42px !important;
    gap: 8px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    width: auto !important;
    z-index: 6 !important;
}

/* Button styling - sized for 42px control bar */
#tab-content-chat .qa-input-area .qa-input-wrapper button.icon-btn {
    width: 32px !important;
    height: 32px !important;
    border-radius: 6px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-secondary, #a1a1aa) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    font-size: 0.9rem !important;
    flex-shrink: 0 !important;
}

#tab-content-chat .qa-input-area .qa-input-wrapper button.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary, #fff) !important;
}

/* Voice mic button — listening state override (needs !important to beat generic icon-btn) */
#tab-content-chat .qa-input-area .qa-input-wrapper button.icon-btn.listening {
    color: #fff !important;
    background: rgba(239, 68, 68, 0.85) !important;
    border-radius: 50% !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35) !important;
    animation: voice-pulse 1.4s ease-in-out infinite !important;
}

#tab-content-chat .qa-input-area .qa-input-wrapper button.icon-btn.listening:hover {
    color: #fff !important;
    background: rgba(239, 68, 68, 0.95) !important;
}

/* Voice mic button — processing state override */
#tab-content-chat .qa-input-area .qa-input-wrapper button.icon-btn.processing {
    color: #fff !important;
    background: rgba(245, 158, 11, 0.7) !important;
    border-radius: 50% !important;
}

/* Send button - accent colored */
#tab-content-chat .qa-input-area .qa-input-wrapper #qaSendBtn {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb) !important;
    color: white !important;
    border: 1px solid rgba(59, 246, 146, 0.3) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
}

#tab-content-chat .qa-input-area .qa-input-wrapper #qaSendBtn:hover {
    background: linear-gradient(135deg, var(--accent, #3bf692), #1d4ed8) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4), 0 0 8px rgba(59, 246, 146, 0.15) !important;
}

/* Chat history padding for floating input (110px textarea + 36px toolbar + padding) */
#tab-content-chat .qa-history {
    padding-bottom: 180px !important;
}

/* Model + Response Style indicator in bottom toolbar — gradient-bordered pill */
#tab-content-chat .qa-model-style-indicator {
    flex: 0 1 auto;
    text-align: left;
    font-size: 0.68rem;
    color: var(--text-secondary, #a1a1aa);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    pointer-events: auto;
    padding: 4px 10px;
    line-height: 1.4;
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 20px;
    background:
        linear-gradient(var(--surface, #18181b), var(--surface, #18181b)) padding-box,
        linear-gradient(135deg, var(--accent, #3bf692), #2563eb) border-box;
}

#tab-content-chat .qa-model-style-indicator:hover {
    color: var(--text-primary, #fff);
    background:
        linear-gradient(var(--surface-hover, #1f1f23), var(--surface-hover, #1f1f23)) padding-box,
        linear-gradient(135deg, var(--accent, #3bf692), #2563eb) border-box;
    box-shadow: 0 0 8px rgba(59, 246, 146, 0.12), 0 0 4px rgba(37, 99, 235, 0.1);
}

#tab-content-chat .qa-indicator-chevron {
    font-size: 0.55rem;
    margin-left: 4px;
    opacity: 0.6;
    vertical-align: middle;
}

/* Chat Width Optimization */
#tab-content-chat .qa-message {
    max-width: 100%;
}

#tab-content-chat .qa-message.user .message-wrapper {
    max-width: 100%;
}

/* Mobile adjustments - CHAT TAB ONLY */
@media (max-width: 768px) {
    #tab-content-chat .qa-input-area {
        padding: 8px 10px !important;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #tab-content-chat .qa-input-area .qa-input-wrapper {
        border-radius: 10px !important;
    }

    #tab-content-chat .qa-input-area .qa-input-wrapper textarea#qaInput {
        /* padding-bottom = control bar (38px) + buffer to keep last line visible */
        padding: 10px 12px 50px 12px !important;
        min-height: 95px !important;
        max-height: 180px !important;
        font-size: 16px !important;
        /* Prevent iOS zoom */
        scroll-padding-bottom: 50px !important;
    }

    #tab-content-chat .qa-model-style-indicator {
        font-size: 0.58rem !important;
        line-height: 1.4 !important;
        padding: 3px 8px !important;
        letter-spacing: 0 !important;
    }

    #tab-content-chat .qa-input-area .qa-input-wrapper .qa-input-buttons-left {
        height: 38px !important;
        padding: 0 110px 0 10px !important;  /* right padding reserves space for right buttons */
    }

    #tab-content-chat .qa-input-area .qa-input-wrapper .qa-input-buttons {
        right: 10px !important;
        height: 38px !important;
    }

    #tab-content-chat .qa-input-area .qa-input-wrapper button.icon-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.85rem !important;
    }

    #tab-content-chat .qa-input-area .qa-input-wrapper #qaSendBtn {
        width: 28px !important;
        height: 28px !important;
    }

    #tab-content-chat .qa-history {
        padding-bottom: 140px !important;
    }
}

/* =========================================
   Tab Bar — iOS Segmented Control
   ========================================= */

/* Segmented control container */
.response-tabs {
    display: flex;
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 3px;
    margin: 6px 12px 8px;
    gap: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    z-index: 10;
    transition: background 0.2s ease;
}

/* Segment buttons */
.response-tab-btn {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-secondary, #71717a);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 2;
    position: relative;
    transition: color 0.2s ease;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-tap-highlight-color: transparent;
}

.response-tab-btn:hover {
    color: var(--text-primary, #e4e4e7);
}

.response-tab-btn.active {
    color: #fff;
    background: transparent;
}

/* Sliding glider */
.tab-glider {
    position: absolute;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    background: linear-gradient(135deg, var(--accent, #3b82f6), #2563eb);
    border-radius: 8px;
    z-index: 1;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.4, 0.0, 0.2, 1),
                width 0.28s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), 0 0 12px rgba(59, 246, 146, 0.12);
    will-change: transform, width;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   Smooth Resize Transitions
   ========================================= */

/* Utility class to disable all transitions during active resize drag */
.no-transition,
.no-transition * {
    transition: none !important;
}

/* Input pane (transcript): add smooth width/height transitions for resize */
.pane-input {
    transition: width var(--transition-slow), height var(--transition-slow);
    will-change: width, height;
}

/* Session panel: add smooth width transition for desktop resize */
@media (min-width: 769px) {
    .session-panel {
        transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), width var(--transition-slow);
        will-change: transform, width;
    }
}

/* Disable transitions during active dragging for immediate responsiveness */
.pane-input.no-transition,
.session-panel.dragging {
    transition: none !important;
}

/* =====================================================
   TRANSCRIPT HEADER OVERFLOW MENU
   ===================================================== */

/* Transcript overflow — hidden by default */
.transcript-overflow-backdrop,
.transcript-overflow-menu {
    display: none;
}

/* Context Popover Menu (body-level, positioned via JS) */
.transcript-overflow-menu {
    position: fixed;
    background: var(--bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border);
    z-index: calc(var(--z-modal) + 2);
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    transform-origin: top right;
    transition: opacity 0.15s ease, transform 0.15s ease;
    min-width: 240px;
    max-width: 300px;
    overflow: visible;
    max-height: 70vh;
}

.transcript-overflow-menu.open {
    display: block;
    opacity: 1;
    transform: none; /* Must be 'none', not identity — identity creates a containing block */
}

.transcript-overflow-menu-items {
    padding: 6px;
}

.transcript-overflow-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 8px;
}

/* Action rows (summary, download, clear) */
.transcript-overflow-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.transcript-overflow-item:hover {
    background: var(--surface-hover);
}

.transcript-overflow-item:active {
    background: var(--surface-hover);
    transform: scale(0.98);
}

.transcript-overflow-item-danger {
    color: var(--error);
}

.transcript-overflow-item-danger .transcript-overflow-item-icon {
    color: var(--error);
}

.transcript-overflow-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.transcript-overflow-item-content {
    flex: 1;
    min-width: 0;
}

.transcript-overflow-item-label {
    font-weight: 500;
    color: var(--text-primary);
}

.transcript-overflow-item-danger .transcript-overflow-item-label {
    color: var(--error);
}

/* Setting rows (microphone, passive intelligence) */
.transcript-overflow-setting {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
}

.transcript-overflow-setting-content {
    flex: 1;
    min-width: 0;
}

.transcript-overflow-setting-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Native select + refresh btn removed — now using shared MicPicker component */

/* Auto-detect toggle in overflow menu */
.transcript-overflow-setting .toggle-switch {
    flex-shrink: 0;
}

.transcript-overflow-setting.active .toggle-switch {
    background: var(--accent);
}

.transcript-overflow-setting.active .toggle-switch::after {
    transform: translateX(16px);
}

/* Overflow backdrop */
.transcript-overflow-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: var(--z-modal);
    pointer-events: none;
}

.transcript-overflow-backdrop.open {
    display: block;
    pointer-events: auto;
}

/* ============================================================
   UPLOAD PROCESSING MODAL — Bottom Sheet (mobile) / Card (desktop)
   ============================================================ */

#uploadModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: var(--z-critical);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#uploadModal.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Sheet container */
.upload-sheet {
    background: linear-gradient(180deg, #1f1f23 0%, #18181b 100%);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    width: 100%;
    max-width: 100%;
    padding: 8px 24px 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#uploadModal.visible .upload-sheet {
    transform: translateY(0);
}

/* iOS-style drag handle */
.upload-sheet-handle {
    width: 36px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    margin-bottom: 24px;
    flex-shrink: 0;
}

/* Animated audio waveform */
.upload-sheet-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 48px;
    margin-bottom: 20px;
}

.upload-sheet-wave span {
    display: block;
    width: 4px;
    height: 20px;
    border-radius: 2px;
    background: var(--accent);
    animation: uploadWave 1.2s ease-in-out infinite;
}

.upload-sheet-wave span:nth-child(1) { animation-delay: 0s; }
.upload-sheet-wave span:nth-child(2) { animation-delay: 0.15s; }
.upload-sheet-wave span:nth-child(3) { animation-delay: 0.3s; }
.upload-sheet-wave span:nth-child(4) { animation-delay: 0.45s; }
.upload-sheet-wave span:nth-child(5) { animation-delay: 0.6s; }

@keyframes uploadWave {
    0%, 100% { transform: scaleY(0.35); opacity: 0.5; }
    50% { transform: scaleY(1); opacity: 1; }
}

/* File name */
.upload-sheet-fname {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    padding: 0 8px;
}

/* Status text */
.upload-sheet-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    transition: color 0.3s ease;
    letter-spacing: 0.02em;
}

/* Progress track */
.upload-sheet-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 24px;
}

.upload-sheet-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
    position: relative;
    box-shadow: 0 0 12px rgba(59, 246, 146, 0.4);
}

/* Shimmer effect on progress bar */
.upload-sheet-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.25) 50%,
        transparent 100%
    );
    animation: uploadShimmer 1.8s ease-in-out infinite;
}

@keyframes uploadShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Cancel button */
.upload-sheet-cancel {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.upload-sheet-cancel:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.12);
}

/* Desktop: Centered card instead of bottom sheet */
@media (min-width: 769px) {
    #uploadModal {
        align-items: center;
    }

    .upload-sheet {
        max-width: 360px;
        border-radius: 20px;
        padding: 24px 28px 28px;
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
                    opacity 0.3s ease;
    }

    #uploadModal.visible .upload-sheet {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    .upload-sheet-handle {
        display: none;
    }

    .upload-sheet-cancel {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .upload-sheet-wave span {
        animation: none;
        opacity: 0.6;
    }
    .upload-sheet-fill::after {
        animation: none;
    }
}

/* ─── Performance: Pause animations on hidden elements ───
   Prevents GPU compositing work for off-screen/invisible elements.
   The browser still animates elements with display:none or visibility:hidden,
   wasting compositor cycles. These rules stop that. */
[style*="display: none"] *,
[style*="display:none"] *,
.hidden *,
[hidden] * {
    animation-play-state: paused !important;
}

/* Bottom sheets / modals that are off-screen (translateY(100%)) */
.qa-bottom-sheet:not(.visible) *,
.modal:not(.visible) *,
#settingsDrawer:not(.open) *,
#contextEditor:not(.visible) *,
#authCheckModal:not(.visible) *,
#fullscreenHeader:not(.visible) * {
    animation-play-state: paused !important;
}

/* Tab content that is not active */
.tab-content-response:not(.active) * {
    animation-play-state: paused !important;
}