/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a25;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #a855f7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: var(--primary);
    top: -200px;
    left: -200px;
    animation-delay: 0s;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--secondary);
    bottom: -150px;
    right: -150px;
    animation-delay: 7s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: var(--success);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 14s;
}

@keyframes float {

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

    33% {
        transform: translate(30px, -30px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Sections */
.setup-phase,
.monitoring-phase {
    animation: fadeIn 0.5s ease;
}

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

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

.hidden {
    display: none !important;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.alert-count {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Alert Form */
.add-alert-form {
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.text-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.number-input {
    width: 100px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    color: var(--text-primary);
    text-align: center;
}

.number-input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    font-size: 10px;
    margin-left: 4px;
    cursor: help;
}

/* Global Settings */
.global-settings {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1rem;
}

.global-settings h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    margin-left: 0.5rem;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--primary);
}

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

.toggle-switch:has(input:focus) .toggle-slider {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 20px;
    height: 20px;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--danger);
}

.btn-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-gradient:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Alert List */
.alert-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.alert-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.2s;
}

.alert-item:hover {
    border-color: var(--primary);
}

.alert-item.disabled {
    opacity: 0.5;
}

.alert-item-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
}

.alert-text {
    flex: 1;
    font-weight: 500;
}

.alert-actions {
    display: flex;
    gap: 0.5rem;
    min-width: 80px;
    justify-content: flex-end;
}

.alert-config {
    display: flex;
    gap: 1rem;
    padding-left: 2.5rem;
    flex-wrap: wrap;
}

.alert-config-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-config-item label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.alert-config-item input {
    width: 70px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.875rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

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

.icon-btn.danger:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.2);
}

.icon-btn.toggle:hover {
    color: var(--success);
}

/* Upload Section */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.drop-zone p {
    color: var(--text-secondary);
}

.video-preview-container {
    text-align: center;
}

.video-wrapper {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.video-wrapper video {
    width: 100%;
    max-height: 300px;
    display: block;
}

/* Start Section */
.start-section {
    text-align: center;
    padding: 2rem 0;
}

/* Monitoring Phase */
.monitoring-phase {
    animation: fadeIn 0.3s ease;
}

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

.monitoring-stats {
    display: flex;
    gap: 2rem;
}

.stat {
    color: var(--text-secondary);
}

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

.monitoring-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .monitoring-layout {
        grid-template-columns: 1fr;
    }
}

/* Video Player Section */
.video-player-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.video-container {
    position: relative;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

#monitoring-video {
    width: 100%;
    display: block;
    max-height: 70vh;
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Alert Popup */
.alert-popup {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--danger);
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 250px;
    animation: alertPop 0.3s ease;
    z-index: 100;
}

@keyframes alertPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

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

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

.popup-icon {
    background: var(--danger);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.popup-score {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

.popup-text {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.popup-crop img {
    width: 100%;
    border-radius: var(--radius-sm);
}

/* Video Controls */
.video-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

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

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

.embed-progress {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 0.3rem 0.5rem;
}

.embed-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    flex-shrink: 0;
    animation: embed-pulse 1s ease-in-out infinite;
}

@keyframes embed-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

#time-display {
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-width: 100px;
    text-align: right;
}

/* Alert Timeline */
.alert-timeline-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

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

.timeline-header h3 {
    color: var(--text-primary);
}

.timeline-items {
    flex: 1;
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 0.5rem;
}

.timeline-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.timeline-item.active {
    background: rgba(99, 102, 241, 0.2);
    border-left: 3px solid var(--primary);
}

.timeline-time {
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 60px;
}

.timeline-content {
    flex: 1;
}

.timeline-alert {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.timeline-score {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.timeline-crop {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.timeline-crop img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* Alert Summary */
.alert-summary {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

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

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.summary-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.summary-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.summary-item-time {
    color: var(--primary);
    font-weight: 600;
    min-width: 80px;
}

.summary-item-content {
    flex: 1;
}

.summary-item-text {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.summary-item-score {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.summary-item-crop {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.summary-item-crop img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loader */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader p {
    color: var(--text-primary);
    margin-top: 1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 3000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.5rem;
    margin-top: 0.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--primary);
}

/* Similarity Graph Section */
.graph-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    margin-top: 2rem;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.graph-header h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
}

.model-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.model-name {
    color: var(--primary);
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

.graph-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.graph-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

#similarity-graph {
    width: 100%;
    height: 100%;
    display: block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* RTSP Section */
.rtsp-section {
    margin-top: 2rem;
}

.full-width {
    flex: 1;
}

.status-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    position: relative;
}

.status-indicator.active {
    background: var(--danger);
    box-shadow: 0 0 10px var(--danger);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.7;
    }
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    margin-left: auto;
}

.video-feed-container {
    width: 100%;
    margin-top: 1rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
}

.video-feed-container img {
    width: 100%;
    display: block;
}

/* ---- Realtime FAISS search results --------------------------------------- */
.search-section .form-row {
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.search-results {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.9rem;
}

.search-result-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 120ms ease, border-color 120ms ease;
}

.search-result-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.25);
}

.search-result-card .thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #111;
}

.search-result-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.search-result-card .score-pill {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.85);
    color: #fff;
    letter-spacing: 0.02em;
}

.search-result-card .meta {
    padding: 0.55rem 0.7rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
}

.search-result-card .meta .row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.search-result-card .meta .row.sub {
    font-size: 0.7rem;
    opacity: 0.7;
}

.search-result-card .src {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #93c5fd;
}

.search-result-card .when {
    opacity: 0.85;
}

.search-result-card .vec {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 600;
}

.search-result-card .obj {
    color: #fbbf24;
    text-transform: capitalize;
}
/* ============================================================
   Face Recognition Section
   ============================================================ */

/* Enroll row */
.face-enroll-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.face-enroll-row .text-input { flex: 1; min-width: 120px; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.face-pick-label { cursor: pointer; user-select: none; }

/* Thumbnail preview shown after selecting a photo */
.face-thumb-wrap {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}
.face-thumb-wrap img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: block;
}
.face-thumb-clear {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--danger);
    border: none;
    color: #fff;
    font-size: 10px;
    line-height: 15px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

/* Gallery — 100×100 cards */
.face-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    min-height: 36px;
}
.face-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.4rem;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    position: relative;
    width: 108px;
}
.face-card:hover { border-color: var(--danger); background: rgba(239,68,68,0.06); }
.face-card.selected { border-color: var(--primary); background: rgba(99,102,241,0.12); }
.face-card img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: block;
}
.face-card .face-name {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
    width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Remove overlay on hover */
.face-card .face-del-overlay {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-sm);
    background: rgba(239,68,68,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}
.face-card:hover .face-del-overlay { opacity: 1; }
.face-del-overlay span {
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.03em;
}

/* "Searching as NAME ×" badge */
.face-search-selected {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.6rem;
    white-space: nowrap;
}
.face-search-selected strong { color: var(--text-primary); }
.face-photo-clear-inline {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 0 0 2px;
}
.face-photo-clear-inline:hover { color: var(--danger); }

/* Person filter row in Search section */
.face-filter-row {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.4rem 0;
}
.face-filter-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.face-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
}
.face-filter-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}
.face-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.6rem 0.2rem 0.35rem;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: border-color 0.15s, background 0.15s;
}
.face-chip img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.face-chip:hover { border-color: var(--primary); color: var(--text-primary); background: rgba(99,102,241,0.08); }
.face-chip.active { border-color: var(--primary); background: rgba(99,102,241,0.18); color: var(--text-primary); }

/* Source remove row */
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.75rem 0 0.5rem;
}
.source-remove-row {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.4rem 0;
}
.source-select {
    flex: 1;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

/* Translation preview */
.translation-preview {
    margin-top: 6px;
    padding: 7px 12px;
    background: rgba(99, 102, 241, 0.07);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.translation-label {
    color: var(--primary);
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.translation-text {
    color: var(--text-primary);
    flex: 1;
}

.translation-loading {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.78rem;
}
.source-select:focus { outline: none; border-color: var(--primary); }
