/* ============================
   CSS Variables & Reset
   ============================ */
:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5A4BD1;
    --accent: #00CEC9;
    --accent-light: #55EFC4;
    --bg: #0F0F1A;
    --bg-card: #1A1A2E;
    --bg-card-hover: #222240;
    --bg-surface: #16162A;
    --text: #E8E8F0;
    --text-muted: #9090B0;
    --text-dim: #606080;
    --border: #2A2A4A;
    --danger: #FF6B6B;
    --success: #00B894;
    --warning: #FDCB6E;
    --match-green: #00E676;
    --match-red: #FF5252;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(108,92,231,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0,206,201,0.06) 0%, transparent 50%);
    pointer-events: none; z-index: 0;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
}

/* ============================
   Header
   ============================ */
.app-header { text-align: center; padding: 24px 0 20px; }

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 8px;
}

.logo {
    display: flex; align-items: center; justify-content: center; gap: 12px;
}

.contact-header-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 16px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: var(--radius-sm);
    color: var(--primary-light);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.contact-header-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35);
}
.contact-header-btn .material-icons-round { font-size: 16px; }

.logo-icon {
    font-size: 42px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.logo h1 {
    font-size: 32px; font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.subtitle { color: var(--text-muted); font-size: 15px; font-weight: 300; }

/* ============================
   Model Loading
   ============================ */
.model-loading {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15,15,26,0.95);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; backdrop-filter: blur(8px);
}
.model-loading.hidden { display: none; }

.loading-content { text-align: center; }
.spinner {
    width: 56px; height: 56px;
    border: 4px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content p { font-size: 18px; font-weight: 500; margin-bottom: 8px; }
.loading-sub { color: var(--text-muted); font-size: 14px !important; font-weight: 300 !important; }

/* ============================
   Step Sections
   ============================ */
.step-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    position: relative;
}

.step-badge {
    position: absolute; top: -12px; left: 24px;
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: white;
}

.step-header { margin-bottom: 20px; }
.step-header h2 {
    display: flex; align-items: center; gap: 8px;
    font-size: 18px; font-weight: 600; color: var(--text);
}
.step-header h2 .material-icons-round { color: var(--primary-light); }
.step-desc { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ============================
   Reference Face Upload
   ============================ */
.ref-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.ref-drop-zone:hover, .ref-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(0,206,201,0.05);
}
.ref-drop-zone .material-icons-round { font-size: 32px; color: var(--accent); }
.ref-drop-zone p { color: var(--text-muted); font-size: 14px; }
.ref-file-label {
    color: var(--accent); cursor: pointer; font-weight: 500;
    text-decoration: underline;
}

.ref-faces-list {
    display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px;
}

.ref-face-card {
    position: relative;
    width: 110px;
    background: var(--bg-surface);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.ref-face-card .ref-face-img {
    width: 110px; height: 110px; object-fit: cover; display: block;
}
.ref-face-card canvas {
    width: 110px; height: 110px; object-fit: cover; display: block;
}
.ref-face-card .ref-face-name {
    padding: 6px 8px;
    font-size: 11px; color: var(--text-muted);
    text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ref-face-card .ref-remove {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px;
    background: rgba(255,82,82,0.9); color: white;
    border: none; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; opacity: 0; transition: var(--transition);
}
.ref-face-card:hover .ref-remove { opacity: 1; }

.ref-face-card .ref-status {
    position: absolute; bottom: 28px; left: 0; right: 0;
    text-align: center; font-size: 10px; color: var(--accent);
    background: rgba(0,0,0,0.7); padding: 2px;
}

.ref-empty {
    display: flex; gap: 10px; align-items: center;
    padding: 12px 16px; margin-top: 12px;
    background: rgba(108,92,231,0.06);
    border: 1px solid rgba(108,92,231,0.15);
    border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 13px;
}
.ref-empty .material-icons-round { color: var(--primary-light); flex-shrink: 0; }

/* ============================
   Upload Tabs & Drop Zone
   ============================ */
.upload-tabs {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}
.tab-btn {
    flex: 1; padding: 12px;
    background: transparent; border: none;
    color: var(--text-muted); font-size: 14px; font-family: inherit;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: var(--transition);
}
.tab-btn:hover { color: var(--text); background: var(--bg-card-hover); }
.tab-btn.active { color: var(--primary-light); background: rgba(108,92,231,0.1); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 40px 24px; text-align: center; cursor: pointer;
    transition: var(--transition);
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary); background: rgba(108,92,231,0.05);
}
.drop-icon { font-size: 48px; color: var(--primary-light); margin-bottom: 8px; display: block; }
.drop-text { font-size: 16px; font-weight: 500; margin-bottom: 6px; }
.drop-sub { color: var(--text-muted); margin-bottom: 12px; }
.file-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; cursor: pointer;
    transition: var(--transition);
}
.file-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(108,92,231,0.4); }
.drop-hint { color: var(--text-dim); font-size: 12px; margin-top: 12px; }

/* Google Drive */
.gdrive-input-area { max-width: 700px; margin: 0 auto; }
.gdrive-info {
    display: flex; gap: 12px; padding: 14px;
    background: rgba(108,92,231,0.08); border: 1px solid rgba(108,92,231,0.2);
    border-radius: var(--radius-sm); margin-bottom: 16px; align-items: flex-start;
}
.gdrive-info > .material-icons-round { color: var(--primary-light); flex-shrink: 0; margin-top: 2px; }
.gdrive-info p { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.gdrive-info code {
    background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 4px; font-size: 11px;
}
.supported-links { margin: 8px 0; }
.supported-links ul { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.supported-links li code {
    background: rgba(108,92,231,0.15); border: 1px solid rgba(108,92,231,0.25);
    padding: 2px 6px; border-radius: 4px; font-size: 10px; color: var(--primary-light);
}
.gdrive-form { display: flex; flex-direction: column; gap: 10px; }
.gdrive-form textarea {
    width: 100%; height: 100px; padding: 12px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: inherit; font-size: 13px; resize: vertical;
    transition: var(--transition);
}
.gdrive-form textarea:focus { outline: none; border-color: var(--primary); }
.gdrive-form textarea::placeholder { color: var(--text-dim); }
.gdrive-load-btn {
    align-self: flex-end;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--accent), #00a89e);
    color: white; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; cursor: pointer;
    transition: var(--transition);
}
.gdrive-load-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,206,201,0.4); }
.gdrive-load-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============================
   Settings
   ============================ */
.settings-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px; margin-bottom: 20px;
}
.setting-item { display: flex; flex-direction: column; gap: 6px; }
.setting-item label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.range-wrapper { display: flex; align-items: center; gap: 10px; }
.range-wrapper input[type="range"] {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 5px; background: var(--border); border-radius: 3px; outline: none;
}
.range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    background: var(--primary); border-radius: 50%; cursor: pointer;
}
.range-wrapper span {
    font-size: 12px; color: var(--accent); font-weight: 600; min-width: 40px; text-align: right;
}
.setting-item select {
    padding: 8px 12px; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer;
}

/* ============================
   Queue
   ============================ */
.queue-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
    padding-top: 16px; border-top: 1px solid var(--border);
}
.queue-header h3 {
    display: flex; align-items: center; gap: 6px;
    font-size: 15px; font-weight: 600; color: var(--primary-light);
}
.queue-actions { display: flex; gap: 8px; }

.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; font-weight: 500; cursor: pointer;
    transition: var(--transition);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border: none;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(108,92,231,0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.btn-lg { padding: 10px 24px; font-size: 14px; }

.btn-secondary {
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

.image-queue {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px;
}
.queue-item {
    position: relative; aspect-ratio: 1;
    border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border); cursor: pointer;
    transition: var(--transition);
}
.queue-item:hover { border-color: var(--primary); transform: scale(1.03); }
.queue-item img { width: 100%; height: 100%; object-fit: cover; }
.queue-item .remove-btn {
    position: absolute; top: 4px; right: 4px;
    width: 24px; height: 24px;
    background: rgba(255,107,107,0.9); color: white;
    border: none; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; opacity: 0; transition: var(--transition);
}
.queue-item:hover .remove-btn { opacity: 1; }
.queue-item .queue-status {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,0.8));
    text-align: center; font-size: 11px;
}
.queue-item .queue-status.done { color: var(--success); }
.queue-item .queue-status.error { color: var(--danger); }
.queue-item .processing-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15,15,26,0.6);
    display: flex; align-items: center; justify-content: center;
}
.queue-item .processing-overlay .spinner { width: 28px; height: 28px; border-width: 3px; }

/* ============================
   Results
   ============================ */
.results-section {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px;
}
.results-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.results-header h3 {
    display: flex; align-items: center; gap: 8px;
    font-size: 18px; font-weight: 600; color: var(--text);
}
.results-header h3 .material-icons-round { color: var(--accent); }
.results-subtitle {
    font-size: 13px; color: var(--text-muted); margin-top: 2px;
}
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Result View Tabs */
.result-view-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.result-tab-btn {
    padding: 10px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    white-space: nowrap;
}
.result-tab-btn:hover {
    color: var(--text);
    border-color: var(--primary-light);
    background: var(--bg-card-hover);
}
.result-tab-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(108,92,231,0.3);
}
.result-view-content {
    display: none;
}
.result-view-content.active {
    display: block;
}

/* Photo Cards Grid (Original Photos) */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.photo-card {
    position: relative;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}
.photo-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.photo-card.has-matched {
    border-color: var(--match-green);
}
.photo-card.has-matched:hover {
    box-shadow: 0 8px 24px rgba(0,230,118,0.25);
}
.photo-card .photo-thumb-wrapper {
    aspect-ratio: 4/3;
    background: var(--bg);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-card .photo-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}
.photo-card:hover .photo-thumb-wrapper img {
    transform: scale(1.04);
}
.photo-card .photo-match-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}
.photo-card .photo-match-tag.matched {
    background: rgba(0, 230, 118, 0.9);
    color: #0c2010;
    box-shadow: 0 2px 8px rgba(0,230,118,0.4);
}
.photo-card .photo-match-tag.unmatched {
    background: rgba(0,0,0,0.6);
    color: var(--text-muted);
}
.photo-card .photo-details {
    padding: 10px 12px;
}
.photo-card .photo-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.photo-card .photo-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}
.photo-card .photo-actions {
    padding: 0 12px 10px;
    display: flex;
    gap: 6px;
}
.photo-card .photo-actions button {
    flex: 1;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: var(--transition);
}
.photo-card .photo-actions button:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(0,206,201,0.08);
}

.result-group-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; font-weight: 600; margin: 20px 0 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.result-group-title:first-child { margin-top: 0; }
.matched-title { color: var(--match-green); }
.matched-title .material-icons-round { color: var(--match-green); }
.unmatched-title { color: var(--text-muted); }

.faces-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 14px;
}

.face-card {
    position: relative;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden; transition: var(--transition); cursor: pointer;
}
.face-card:hover {
    border-color: var(--accent); transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,206,201,0.15);
}
.face-card.selected {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,0.3);
}
.face-card.matched { border-color: var(--match-green); }
.face-card.matched:hover { box-shadow: 0 8px 24px rgba(0,230,118,0.2); }

.face-card .face-img-wrapper {
    aspect-ratio: 1; overflow: hidden;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.face-card .face-img-wrapper canvas {
    max-width: 100%; max-height: 100%; object-fit: contain;
}

/* Match Badge */
.face-card .match-badge {
    position: absolute; top: 8px; right: 8px;
    padding: 3px 8px; border-radius: 12px;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; gap: 3px;
    z-index: 2;
}
.face-card .match-badge.match-yes {
    background: rgba(0,230,118,0.2); color: var(--match-green);
    border: 1px solid rgba(0,230,118,0.4);
}
.face-card .match-badge.match-no {
    background: rgba(255,82,82,0.15); color: var(--match-red);
    border: 1px solid rgba(255,82,82,0.3);
}
.face-card .match-badge .material-icons-round { font-size: 13px; }

/* Match ref info */
.face-card .match-ref-name {
    padding: 4px 10px;
    background: rgba(0,230,118,0.08);
    font-size: 11px; color: var(--match-green);
    text-align: center;
}

.face-card .face-info {
    padding: 8px 10px;
    display: flex; align-items: center; justify-content: space-between;
}
.face-card .face-label { font-size: 11px; color: var(--text-muted); }
.face-card .face-confidence {
    font-size: 10px; color: var(--success); font-weight: 600;
    background: rgba(0,184,148,0.1); padding: 2px 6px; border-radius: 10px;
}
.face-card .face-actions {
    padding: 0 10px 8px; display: flex; gap: 4px;
}
.face-card .face-actions button {
    flex: 1; padding: 5px;
    background: transparent; border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-muted); font-size: 11px;
    font-family: inherit; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 3px;
    transition: var(--transition);
}
.face-card .face-actions button:hover {
    border-color: var(--primary); color: var(--primary-light);
}
.face-card .face-actions button .material-icons-round { font-size: 13px; }

.face-card .select-check {
    position: absolute; top: 8px; left: 8px;
    width: 22px; height: 22px;
    background: rgba(0,0,0,0.5); border: 2px solid var(--border);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.face-card.selected .select-check { background: var(--primary); border-color: var(--primary); }
.face-card .select-check .material-icons-round { font-size: 14px; color: white; opacity: 0; }
.face-card.selected .select-check .material-icons-round { opacity: 1; }

/* ============================
   Modal
   ============================ */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10000; display: flex; align-items: center; justify-content: center;
}
.modal-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(8px);
}
.modal-content {
    position: relative; max-width: 90vw; max-height: 90vh;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
}
.modal-close {
    position: absolute; top: 12px; right: 12px;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.1); border: none; border-radius: 50%;
    color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center; z-index: 10;
    transition: var(--transition);
}
.modal-close:hover { background: var(--danger); }
.modal-body {
    padding: 24px; display: flex; align-items: center; justify-content: center;
}
.preview-img, .preview-canvas {
    max-width: 80vw; max-height: 70vh; border-radius: var(--radius-sm);
}
.modal-info { padding: 10px 24px 14px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Contact Modal Specific */
.contact-modal-card {
    max-width: 440px;
    width: 90%;
    padding: 32px 24px 24px;
    text-align: center;
}
.contact-modal-header {
    margin-bottom: 24px;
}
.contact-icon-large {
    font-size: 48px;
    color: var(--primary-light);
    margin-bottom: 8px;
    display: inline-block;
}
.contact-modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.contact-modal-header p {
    font-size: 13px;
    color: var(--text-muted);
}
.contact-links-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.contact-link-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
}
.contact-link-item:hover {
    border-color: var(--primary-light);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.2);
}
.contact-link-item .material-icons-round {
    font-size: 24px;
    color: var(--accent);
}
.contact-ig .material-icons-round {
    color: #E1306C;
}
.contact-ig:hover {
    border-color: #E1306C;
    box-shadow: 0 4px 16px rgba(225, 48, 108, 0.25);
}
.contact-fb .material-icons-round {
    color: #1877F2;
}
.contact-fb:hover {
    border-color: #1877F2;
    box-shadow: 0 4px 16px rgba(24, 119, 242, 0.25);
}
.contact-mail .material-icons-round {
    color: #EA4335;
}
.contact-mail:hover {
    border-color: #EA4335;
    box-shadow: 0 4px 16px rgba(234, 67, 53, 0.25);
}
.contact-link-text {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
}
.contact-link-text strong {
    font-size: 14px;
    color: var(--text);
}
.contact-link-text span {
    font-size: 12px;
    color: var(--text-muted);
}
.contact-link-item .link-arrow {
    font-size: 18px;
    color: var(--text-dim);
    transition: var(--transition);
}
.contact-link-item:hover .link-arrow {
    color: var(--primary-light);
    transform: translateX(3px);
}

/* ============================
   Footer (Modern Glass Card)
   ============================ */
.app-footer {
    text-align: center;
    padding: 32px 0 24px;
    margin-top: 40px;
}
.footer-card {
    background: rgba(26, 26, 46, 0.65);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: var(--radius-lg);
    padding: 24px 20px 20px;
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.footer-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
}
.footer-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.footer-avatar .material-icons-round {
    font-size: 16px;
}
.footer-author strong {
    color: var(--text);
    font-weight: 600;
}
.footer-social-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.social-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}
.social-chip:hover {
    transform: translateY(-2px);
    color: white;
}
.social-chip.chip-ig:hover {
    border-color: #E1306C;
    background: linear-gradient(135deg, rgba(225, 48, 108, 0.15), rgba(245, 96, 64, 0.15));
    box-shadow: 0 4px 16px rgba(225, 48, 108, 0.3);
    color: #FF758C;
}
.social-chip.chip-fb:hover {
    border-color: #1877F2;
    background: rgba(24, 119, 242, 0.15);
    box-shadow: 0 4px 16px rgba(24, 119, 242, 0.3);
    color: #4BA2FF;
}
.social-chip.chip-mail:hover {
    border-color: #EA4335;
    background: rgba(234, 67, 53, 0.15);
    box-shadow: 0 4px 16px rgba(234, 67, 53, 0.3);
    color: #FF6E61;
}
.social-chip.chip-web:hover {
    border-color: var(--accent);
    background: rgba(0, 206, 201, 0.15);
    box-shadow: 0 4px 16px rgba(0, 206, 201, 0.3);
    color: var(--accent-light);
}
.footer-copy {
    color: var(--text-dim);
    font-size: 11px;
    margin-top: 4px;
}

/* ============================
   Toast
   ============================ */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 11000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 18px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); color: var(--text); font-size: 13px;
    display: flex; align-items: center; gap: 8px;
    animation: toastIn 0.3s ease; max-width: 380px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.removing { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

.no-faces-msg {
    text-align: center; padding: 32px; color: var(--text-muted);
}
.no-faces-msg .material-icons-round { font-size: 40px; color: var(--text-dim); margin-bottom: 8px; display: block; }

/* ============================
   Responsive (Mobile & Tablet)
   ============================ */
@media (max-width: 768px) {
    .app-container { padding: 12px 10px 32px; }
    
    /* Header on Mobile */
    .header-top {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 6px;
    }
    .contact-header-btn {
        position: static;
        transform: none;
        padding: 6px 14px;
        font-size: 12px;
    }
    .logo-icon { font-size: 36px; }
    .logo h1 { font-size: 26px; }
    .subtitle { font-size: 13px; }

    /* Sections & Cards */
    .step-section { padding: 18px 14px; margin-bottom: 16px; border-radius: var(--radius); }
    .step-header h2 { font-size: 16px; }
    .step-badge { width: 24px; height: 24px; font-size: 11px; top: 18px; left: 14px; }
    .ref-drop-zone, .drop-zone { padding: 24px 16px; }
    .drop-icon { font-size: 40px; }

    /* Grids */
    .photos-grid { grid-template-columns: 1fr; gap: 12px; }
    .faces-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .settings-grid { grid-template-columns: 1fr; gap: 12px; }
    .queue-header, .results-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .results-actions { width: 100%; }
    .results-actions button { flex: 1; font-size: 12px; padding: 8px 12px; }
    
    /* Result tabs */
    .result-view-tabs { width: 100%; }
    .result-tab-btn { padding: 8px 12px; font-size: 12px; }

    /* Footer on Mobile */
    .app-footer { margin-top: 24px; padding: 20px 0 32px; }
    .footer-card { padding: 18px 14px; border-radius: var(--radius); gap: 12px; }
    .footer-social-chips {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        gap: 8px;
    }
    .social-chip {
        width: 100%;
        justify-content: center;
        padding: 8px 10px;
        font-size: 12px;
    }
    .footer-copy { font-size: 10px; line-height: 1.4; }

    /* Modal */
    .modal-content { max-width: 94vw; max-height: 85vh; border-radius: var(--radius); }
    .modal-body { padding: 16px; }
    .contact-modal-card { padding: 24px 16px 16px; }
    .contact-icon-large { font-size: 38px; }
    .contact-link-item { padding: 12px 14px; gap: 10px; }
}

@media (max-width: 420px) {
    .faces-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .footer-social-chips { grid-template-columns: 1fr; }
}
