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

:root {
    --bg:        #eef2f6;
    --card:      #ffffff;
    --accent:    #0d9488;   /* teal */
    --accent-dk: #0f766e;
    --text:      #1f2937;
    --muted:     #6b7280;
    --line:      #e5e7eb;
    --radius:    14px;
    --shadow:    0 6px 24px rgba(15, 23, 42, 0.08);
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: linear-gradient(160deg, #e6f0ef 0%, #eef2f6 60%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 14px;
}

/* ===== Card container ===== */
.container {
    width: 100%;
    max-width: 520px;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 28px 24px 32px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* ===== Header ===== */
.app-header { text-align: center; margin-bottom: 22px; }

.app-title {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--accent-dk);
}

.app-subtitle {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.45;
}

/* ===== Upload buttons ===== */
.upload-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.upload-btn {
    flex: 1;
    text-align: center;
    background: #fff;
    border: 2px solid var(--accent);
    color: var(--accent-dk);
    border-radius: var(--radius);
    padding: 14px 10px;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    -webkit-appearance: none;
    appearance: none;
}
.upload-btn:hover  { background: #ecfdf9; }
.upload-btn:active { transform: translateY(1px); }

/* ===== Cropped preview ===== */
.photo-container { text-align: center; }
.photo-container img {
    max-width: 70%;
    max-height: 240px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin: 4px auto 14px;
    display: block;
}

/* ===== Detection summary (HSV result highlight) ===== */
.detection-summary {
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 18px;
}
.detection-summary .ds-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-dk);
    font-weight: 700;
    margin-bottom: 8px;
}
.ds-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px 5px 8px;
    font-size: 0.85rem;
    font-weight: 600;
}
.ds-swatch {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
    flex: 0 0 auto;
}

/* ===== Result form ===== */
.result-area { display: flex; flex-direction: column; }
.result-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 14px;
}

.selection-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.selection-container label {
    flex: 0 0 5em;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}
.selection-container input,
.selection-container select {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 16px; /* prevents iOS zoom */
    color: var(--text);
    text-align: center;
    text-align-last: center;
    -webkit-appearance: none;
    appearance: none;
}
.selection-container input:focus,
.selection-container select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* ===== Primary button ===== */
.match-btn-wrapper { margin-top: 18px; }
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 15px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}
.btn-primary:hover  { background: var(--accent-dk); }
.btn-primary:active { transform: translateY(1px); }

/* ===== Modal ===== */
.modal {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 1000;
}
.modal[hidden] { display: none; }
.modal-card {
    background: #fff;
    width: 100%;
    max-width: 760px;
    max-height: 86vh;
    border-radius: 16px;
    padding: 22px;
    position: relative;
    display: flex;
    flex-direction: column;
}
.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    font-size: 20px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { overflow-y: auto; margin-top: 8px; }

.candidate-list { display: flex; flex-direction: column; gap: 16px; }
.candidate-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    background: #fafafa;
}
.candidate-card img {
    max-width: 100%;
    max-height: 46vh;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    margin: 0 auto 12px;
}
.candidate-card h3 {
    color: var(--accent-dk);
    margin-bottom: 10px;
    text-align: center;
}
.candidate-card p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 6px;
    color: var(--text);
}
.candidate-card p strong { color: var(--muted); }

/* ===== Small screens ===== */
@media (max-width: 480px) {
    .container { padding: 22px 16px 26px; }
    .selection-container label { flex: 0 0 4.2em; font-size: 0.85rem; }
    .photo-container img { max-width: 85%; }
}
