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

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    text-align: center;
    flex-shrink: 0;
}

h1 {
    color: #333;
    font-size: 2em;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.config-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.results-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.card h2 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #555;
}

input[type="text"], input[type="file"] {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-group input {
    flex: 1;
    margin: 10px 0;
}

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.button-group button {
    margin: 0;
}

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

.cache-row p {
    flex: 1;
    margin: 0;
}

input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

button {
    padding: 10px 20px;
    margin: 5px 0;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-inline {
    padding: 8px 16px;
    margin: 0;
    font-size: 13px;
    white-space: nowrap;
}

.btn-primary {
    background: #4CAF50;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 15px;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: #45a049;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

.btn-warning:hover {
    background: #f57c00;
}

button:not(.btn-primary):not(.btn-secondary):not(.btn-warning):not(.btn-inline) {
    background: #667eea;
    color: white;
    width: 100%;
}

button:not(.btn-primary):not(.btn-secondary):not(.btn-warning):not(.btn-inline):hover {
    background: #5568d3;
}

.btn-inline:not(.btn-secondary):not(.btn-warning) {
    background: #667eea;
    color: white;
}

.btn-inline:not(.btn-secondary):not(.btn-warning):hover {
    background: #5568d3;
}

.status {
    margin-top: 10px;
    padding: 8px;
    border-radius: 5px;
    font-size: 13px;
}

.status.success {
    background: #d4edda;
    color: #155724;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s;
    width: 0%;
}

#progress-text {
    text-align: center;
    font-weight: bold;
    color: #555;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
    flex-shrink: 0;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    overflow-y: auto;
    padding: 20px 0;
    flex: 1;
}

.result-card {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.result-card img {
    max-width: 100%;
    border-radius: 5px;
    margin-bottom: 10px;
}

.result-card .filename {
    font-weight: bold;
    margin: 10px 0;
    word-break: break-word;
}

.result-card .similarity {
    color: #4CAF50;
    font-size: 1.2em;
    font-weight: bold;
}

#ref-list {
    display: none;
}

small {
    display: block;
    color: #666;
    margin-top: 5px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}
