:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #161616;
    --bg-hover: #1a1a1a;
    --border: #2a2a2a;
    --border-hover: #3a3a3a;
    --gold: #c8a84e;
    --gold-light: #e0c068;
    --gold-dim: #8a7030;
    --text: #e0e0e0;
    --text-dim: #888;
    --text-bright: #fff;
    --success: #4caf50;
    --danger: #ef5350;
}

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

body {
    font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
    background: var(--bg-primary);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
    text-decoration: none;
}
.header .logo svg { width: 24px; height: 24px; }
.header .lang-toggle {
    display: flex;
    gap: 8px;
}
.header .lang-toggle button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 10px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}
.header .lang-toggle button.active {
    border-color: var(--gold);
    color: var(--gold);
}
.header .lang-toggle button:hover {
    border-color: var(--gold-dim);
    color: var(--text);
}

/* Main layout */
.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
}

/* Upload panel */
.upload-panel {
    padding: 24px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.dropzone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--gold);
    background: rgba(200, 168, 78, 0.05);
}
.dropzone svg {
    width: 48px;
    height: 48px;
    color: var(--text-dim);
}
.dropzone.dragover svg { color: var(--gold); }
.dropzone p { color: var(--text-dim); font-size: 14px; }
.dropzone .hint { font-size: 12px; color: var(--text-dim); opacity: 0.6; }

/* Preview area */
.preview-area {
    position: relative;
    display: none;
    flex-direction: column;
    gap: 12px;
}
.preview-area.active { display: flex; }
.preview-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card);
}
.preview-container img {
    width: 100%;
    display: block;
}
.preview-container canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Detected faces */
.detected-faces {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.detected-faces .label {
    font-size: 12px;
    color: var(--text-dim);
    width: 100%;
    margin-bottom: 4px;
}
.face-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    object-fit: cover;
}
.face-thumb:hover { border-color: var(--gold-dim); }
.face-thumb.selected { border-color: var(--gold); box-shadow: 0 0 8px rgba(200,168,78,0.3); }

/* Controls */
.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.btn {
    background: var(--gold);
    color: #000;
    border: none;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}
.btn:hover { background: var(--gold-light); }
.btn:disabled {
    background: var(--border);
    color: var(--text-dim);
    cursor: not-allowed;
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--gold-dim); }

.threshold-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
}
.threshold-control input[type=range] {
    width: 100px;
    accent-color: var(--gold);
}
.threshold-control .value {
    color: var(--gold);
    font-weight: 600;
    min-width: 35px;
}

/* Results panel */
.results-panel {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.results-panel h3 {
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    transition: all 0.2s;
}
.result-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}
.result-card .thumb {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.result-card .info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.result-card .username {
    color: var(--gold);
    font-weight: 600;
    font-size: 14px;
}
.result-card .username a {
    color: var(--gold);
    text-decoration: none;
}
.result-card .username a:hover { text-decoration: underline; }
.result-card .meta {
    font-size: 12px;
    color: var(--text-dim);
}
.result-card .source-link {
    font-size: 11px;
    color: var(--text-dim);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.result-card .source-link:hover { color: var(--gold-dim); }
.result-card .similarity {
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
    align-self: center;
}
.sim-high { color: var(--success) !important; }
.sim-med { color: var(--gold) !important; }
.sim-low { color: var(--text-dim) !important; }

/* Face group header */
.face-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-top: 8px;
}
.face-group-header img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 1px solid var(--gold-dim);
}
.face-group-header span {
    font-size: 13px;
    color: var(--text-dim);
}

/* Loading */
.loading {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 48px;
    flex-direction: column;
    gap: 16px;
}
.loading.active { display: flex; }
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text-dim); font-size: 13px; }

/* Empty state */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-dim);
    font-size: 14px;
    text-align: center;
    padding: 48px;
    line-height: 1.6;
}

/* Footer */
.footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-dim);
}
.footer .stats { display: flex; gap: 16px; }
.footer .stats span { color: var(--gold); font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
    .main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .upload-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 50vh;
    }
    .dropzone { padding: 32px 16px; min-height: 150px; }
    .header { padding: 12px 16px; }
    .upload-panel, .results-panel { padding: 16px; }
}
