/* === Model Chip (replaces select2 dropdown) === */

#model-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.06));
    color: #c7d2fe;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    width: 240px;
    flex-shrink: 0;
    overflow: hidden;
}

#model-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
}

#model-chip:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.12));
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

#model-chip i:first-child {
    color: #a5b4fc;
    font-size: 14px;
}

/* === Model Selector Overlay === */

#model-selector-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

@media (max-width: 640px) {
    #model-selector-overlay {
        background: rgba(0, 0, 0, 0.6);
    }
}

/* === Model Selector Modal === */

#model-selector-modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 64px);
    max-width: 680px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.97), rgba(30, 41, 59, 0.95));
    backdrop-filter: blur(24px);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 20px;
    padding: 64px 24px 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(99, 102, 241, 0.06);
    animation: modelSelectorIn 0.2s ease-out;
}

@keyframes modelSelectorIn {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.ms-agi-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.ms-agi-card:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.14));
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.12);
}

.ms-agi-card.selected {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15), inset 0 0 0 1px rgba(99, 102, 241, 0.1);
}

.ms-tier-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #475569;
    margin: 28px 0 10px;
    padding: 0 4px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ms-tier-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent);
}

.ms-tier-title i {
    font-size: 11px;
    filter: saturate(0.7);
}

.ms-agi-card + .ms-tier-title {
    margin-top: 22px;
}

.ms-tier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.ms-model-card {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 72px;
}

.ms-model-card:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
}

.ms-model-card.selected {
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.14);
}

.ms-model-name {
    font-size: 13px;
    font-weight: 600;
    color: #f1f5f9;
}

.ms-model-provider {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.ms-model-meta {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 6px;
    font-size: 10px;
    color: #94a3b8;
}

.ms-model-meta span {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ms-model-card.ms-kb-focus,
.ms-agi-card.ms-kb-focus {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.ms-caps {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ms-caps-label {
    font-size: 9px;
    color: #4b5563;
    margin-right: 2px;
    letter-spacing: 0.03em;
}

.ms-caps span {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #64748b;
}

.ms-caps span[title="Vision / Images"] { color: #a78bfa; border-color: rgba(167, 139, 250, 0.15); }
.ms-caps span[title="Audio"] { color: #f472b6; border-color: rgba(244, 114, 182, 0.15); }
.ms-caps span[title="PDF / Files"] { color: #fb923c; border-color: rgba(251, 146, 60, 0.15); }
.ms-caps span[title="Reasoning / Thinking"] { color: #38bdf8; border-color: rgba(56, 189, 248, 0.15); }

.ms-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.ms-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.25);
}

@media (max-width: 640px) {
    #model-selector-modal {
        top: auto; bottom: 0; left: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        height: 93vh;
        min-height: 93vh;
        border-radius: 20px 20px 0 0;
        padding: 64px 16px 12px;
        animation: modelSelectorSlideUp 0.25s ease-out;
    }
    @keyframes modelSelectorSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    #ms-search {
        position: sticky;
        top: 0;
        z-index: 5;
    }
    .ms-tier-grid {
        grid-template-columns: 1fr;
    }
}

/* === Top Bar & Controls === */

#logo-bar {
    margin-top: -10px;
    padding-bottom: 6px;
    z-index: 2;
    flex-shrink: 0;
}

#logo-bar > img {
    position: relative;
    top: 5px;
}

#top-bar {
    z-index: 20;
    background-color: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#top-bar.initialized {
    opacity: 1;
}

.top-bar-controls {
    padding: 10px 12px 8px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Temperature slider */
/* Old slider-container removed — temperature is now in settings panel */

/* Select2 Modern Aero Theme */
.select2-container--classic .select2-selection--single {
    background-color: rgba(45, 55, 72, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 12px;
    color: #e2e8f0;
    height: 2.25rem;
    display: flex;
    align-items: center;
    transition: all 150ms ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    background-image: none !important;
}

.select2-container--classic .select2-selection--single:hover {
    background-color: rgba(45, 55, 72, 0.8);
    border-color: rgba(99, 115, 138, 0.7);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.select2-container--classic .select2-selection--single .select2-selection__rendered {
    color: #e2e8f0;
    padding-left: 12px;
    background: transparent !important;
    line-height: 2.25rem;
    font-size: 0.875rem;
}

.select2-container--classic .select2-selection--single .select2-selection__arrow {
    height: 100%;
    border: none;
    border-radius: 0 12px 12px 0;
    background: transparent !important;
    background-image: none !important;
    width: 28px;
}

.select2-container--classic .select2-selection--single .select2-selection__arrow b {
    border-color: #94a3b8 transparent transparent transparent;
    margin-top: -2px;
}

.select2-dropdown {
    border: 1px solid rgba(75, 85, 99, 0.5) !important;
    background-color: #1e293b !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    margin-top: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.select2-container--classic .select2-results {
    background-color: #1e293b !important;
}

.select2-results {
    background-color: #1e293b !important;
}

.select2-results__options {
    background-color: #1e293b !important;
}

.select2-container--classic .select2-results__option {
    background-color: #1e293b !important;
    color: #cbd5e0 !important;
    padding: 8px 12px;
    transition: background-color 150ms ease;
}

.select2-container--classic .select2-results__option--highlighted,
.select2-container--classic .select2-results__option--highlighted[aria-selected] {
    background-color: rgba(59, 130, 246, 0.3) !important;
    color: #ffffff !important;
}

.select2-container--classic .select2-results__group {
    background-color: #1e293b !important;
    color: #94a3b8;
}

.select2-container--classic .select2-search--dropdown .select2-search__field {
    background-color: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 8px;
    padding: 6px 10px;
    margin: 6px;
    width: calc(100% - 12px);
}

.select2-search--dropdown {
    padding: 4px !important;
}

.select2-selection__arrow {
    background: transparent !important;
    background-image: none !important;
}

.select2-selection__rendered {
    background: transparent !important;
}

.select2-selection__clear {
    color: #94a3b8 !important;
}

.select2-container--classic.select2-container--open .select2-selection--single {
    background-color: rgba(45, 55, 72, 0.9);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.select2-container--classic.select2-container--open .select2-dropdown {
    border-color: rgba(75, 85, 99, 0.5);
}

.select2-container--classic .select2-selection--single:focus {
    border-color: rgba(59, 130, 246, 0.5);
    outline: none;
}

.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
    background: transparent !important;
    border: none;
}

/* Model selector layout */
#model-reasoning-container > span.select2 {
    display: none !important;
}

/* Model info button */
.model-info-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 50%;
    background-color: rgba(45, 55, 72, 0.4);
    color: #94a3b8;
    cursor: pointer;
    transition: all 150ms ease;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.model-info-btn:hover {
    background-color: rgba(45, 55, 72, 0.7);
    color: #e2e8f0;
    border-color: rgba(99, 115, 138, 0.7);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.model-info-btn.active {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    color: #93c5fd;
}

/* Settings panel — glassmorphism dropdown */
.settings-panel {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    background: rgba(15, 20, 35, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 16px;
    padding: 16px 18px;
    margin-top: 8px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: settingsSlideIn 200ms ease-out;
    width: 340px;
}

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

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

/* Model info section inside settings */
.model-info-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.model-info-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.model-info-label {
    font-size: 0.75rem;
    color: #64748b;
    flex-shrink: 0;
    min-width: 65px;
}

.model-info-value {
    font-size: 0.75rem;
    color: #cbd5e0;
}

.model-info-desc {
    font-size: 0.75rem;
    color: #94a3b8;
    line-height: 1.4;
}

/* Parameter rows */
.settings-params {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.param-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: #c7d2fe;
    text-transform: capitalize;
    display: flex;
    align-items: center;
    gap: 4px;
}

.param-info-btn {
    background: none;
    border: none;
    color: #6366f1;
    opacity: 0.5;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
    line-height: 1;
    transition: opacity 0.15s;
}
.param-info-btn:hover { opacity: 1; }

.param-info-tooltip {
    font-size: 0.7rem;
    color: #94a3b8;
    background: rgba(15, 15, 30, 0.85);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    padding: 6px 8px;
    line-height: 1.4;
    margin-bottom: 2px;
}

.param-mode-toggle {
    display: flex;
    gap: 2px;
    background: rgba(30, 30, 50, 0.6);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid rgba(75, 85, 99, 0.3);
}

.param-mode-btn {
    font-size: 0.65rem;
    padding: 3px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
}

.param-mode-btn.active {
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.15);
}

.param-mode-btn:hover:not(.active) {
    color: #94a3b8;
}

.param-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.param-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(45, 55, 72, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.4);
    outline: none;
    transition: border-color 150ms ease;
}

.param-slider:hover {
    border-color: rgba(99, 115, 138, 0.7);
}

.param-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #818cf8;
    border: 2px solid rgba(99, 102, 241, 0.5);
    cursor: pointer;
    transition: all 150ms ease;
    box-shadow: 0 0 6px rgba(99, 102, 241, 0.3);
}

.param-slider::-webkit-slider-thumb:hover {
    background: #a5b4fc;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.param-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #818cf8;
    border: 2px solid rgba(99, 102, 241, 0.5);
    cursor: pointer;
}

.param-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(45, 55, 72, 0.6);
    border: none;
}

.param-number {
    width: 3.2rem;
    height: 1.75rem;
    background: rgba(30, 30, 50, 0.7);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.75rem;
    text-align: center;
    outline: none;
    transition: border-color 150ms ease;
    -moz-appearance: textfield;
}

.param-number::-webkit-inner-spin-button,
.param-number::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.param-number:focus {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* Random range inputs */
.param-range {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: #64748b;
}

.param-range-input {
    width: 2.8rem;
    height: 1.5rem;
    background: rgba(30, 30, 50, 0.7);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: 6px;
    color: #cbd5e0;
    font-size: 0.7rem;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.param-range-input::-webkit-inner-spin-button,
.param-range-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.param-range-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
}

/* Disabled state for Default mode */
.param-controls.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Dual range slider */
.param-range-slider {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
}

.param-range-slider input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    height: 6px;
    background: transparent;
    pointer-events: none;
    outline: none;
    margin: 0;
}

.param-range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid rgba(52, 211, 153, 0.5);
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
    position: relative;
    z-index: 2;
}

.param-range-slider input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid rgba(52, 211, 153, 0.5);
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
}

.param-range-slider input[type="range"]::-moz-range-track {
    height: 6px;
    background: transparent;
    border: none;
}

.param-range-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 6px;
    border-radius: 3px;
    background: rgba(45, 55, 72, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.4);
}

.param-range-fill {
    position: absolute;
    height: 6px;
    border-radius: 3px;
    background: rgba(52, 211, 153, 0.3);
    top: 0;
}

.param-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 2px;
}

@media (max-width: 1024px) {
    .settings-panel {
        position: fixed;
        top: 60px;
        bottom: auto;
        left: 16px;
        right: 16px;
        width: auto;
        z-index: 200;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        background: rgba(15, 20, 35, 0.96);
    }
}

/* Reasoning effort dropdown — matches model chip style */
#reasoning-effort {
    min-width: 110px;
    max-width: 140px;
    height: 2.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.06));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    color: #c7d2fe;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0 28px 0 12px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

#reasoning-effort:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.12));
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

#reasoning-effort:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

#reasoning-effort:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#reasoning-effort option {
    background-color: #0f172a;
    color: #e2e8f0;
    padding: 8px;
}

/* Top bar responsive */
@media (max-width: 1200px) {
}

@media (max-width: 600px) {
    #model-reasoning-container {
        width: 100%;
    }
    #model-chip {
        flex: 2;
        width: auto;
    }
    #reasoning-effort {
        flex: 1;
        min-width: 0;
        max-width: none;
        font-size: 0.75rem;
    }

    .model-info-popover {
        max-width: calc(100vw - 32px);
    }

    #logo-bar > img {
        max-width: 28%;
        top: 5px;
    }
}

/* === In-Chat Search === */

/* Trigger icon in logo bar */
.in-chat-search-trigger {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.375rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: color 150ms ease;
    position: absolute;
    top: 6px;
    right: 63px;
    z-index: 3;
}

.in-chat-search-trigger:hover {
    color: #e2e8f0;
}

@media (min-width: 1200px) {
    .in-chat-search-trigger {
        right: 10px;
    }
}

@media (max-width: 1199px) {
    .in-chat-search-trigger {
        right: 58px;
    }
    /* Hide search icon on mobile when sidebar is open (it floats above the sidebar) */
    #sidebar:not(.hidden) ~ #main-content .in-chat-search-trigger {
        display: none;
    }
}

/* Search overlay at top */
.in-chat-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background-color: rgba(17, 24, 39, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    z-index: 9998;
    animation: searchSlideDown 200ms ease-out;
}

.in-chat-search-overlay.hidden {
    display: none !important;
}

@keyframes searchSlideDown {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes searchSlideUp {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-100%); }
}

/* Desktop: overlay doesn't cover the logo — right-aligned, limited width */
@media (min-width: 1201px) {
    .in-chat-search-overlay {
        left: auto;
        width: 420px;
        border-radius: 0 0 0 12px;
    }
}

.in-chat-search-back {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    flex-shrink: 0;
    transition: color 150ms ease;
}

.in-chat-search-back:hover {
    color: #e2e8f0;
}

.in-chat-search-input {
    flex: 1;
    min-width: 0;
    background-color: rgba(45, 55, 72, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 20px;
    color: #e2e8f0;
    font-size: 0.95rem;
    padding: 8px 14px;
    outline: none;
    transition: border-color 150ms ease;
}

.in-chat-search-input:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.in-chat-search-input::placeholder {
    color: #64748b;
}

.in-chat-search-clear {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
    flex-shrink: 0;
    transition: color 150ms ease;
    margin-left: -43px;
    margin-top: 3px;
    position: relative;
    z-index: 1;
}

.in-chat-search-clear:hover {
    color: #e2e8f0;
}

.in-chat-search-clear.hidden {
    display: none !important;
}

/* Floating controls at bottom-right */
.in-chat-search-controls {
    position: fixed;
    bottom: 8.75rem;
    right: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
    animation: searchFadeIn 200ms ease-out;
}

.in-chat-search-controls.hidden {
    display: none !important;
}

@keyframes searchFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Match count pill */
.in-chat-search-count {
    background-color: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    color: #e2e8f0;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 16px;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Round FAB nav buttons */
.in-chat-search-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    color: #e2e8f0;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 150ms ease, background-color 150ms ease, border-color 150ms ease;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.in-chat-search-fab:hover:not(:disabled) {
    background-color: rgba(30, 41, 59, 0.95);
    border-color: rgba(99, 115, 138, 0.7);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.in-chat-search-fab:active:not(:disabled) {
    transform: scale(0.93);
}

.in-chat-search-fab:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Active match highlight */
.search-highlight-active {
    background: rgba(249, 115, 22, 0.6) !important;
    color: #fff !important;
    border-radius: 2px;
    font-weight: 600;
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.35);
}
