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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --accent: #e8c547;
  --text: #f0f0f0;
  --text-muted: #888;
  --radius: 8px;
  --gap: 1rem;
}

body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; min-height: 100vh; }

/* ── Layout ──────────────────────────────── */
header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 2rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 10; }
header h1 { font-size: 1.25rem; font-weight: 600; }
main { max-width: 1400px; margin: 0 auto; padding: 2rem; }

/* ── Grid ────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--gap); }
.grid-sm { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.grid-lg { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Card ────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color 0.15s; }
.card:hover { border-color: var(--accent); }
.card-img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--border); }
.card-body { padding: 0.75rem; }
.card-title { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Album card ──────────────────────────── */
.album-card .card-img { aspect-ratio: 4/3; }

/* ── Person card (face) ──────────────────── */
.person-card .card-img { aspect-ratio: 1; border-radius: 50%; margin: 1rem auto; width: 100px; height: 100px; display: block; }
.person-card .card-body { text-align: center; }

/* ── Photo tile ──────────────────────────── */
.photo-tile { position: relative; overflow: hidden; cursor: pointer; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .nameplate { font-size: 0.7rem; color: var(--text-muted); padding: 0.3rem 0.5rem; background: rgba(0,0,0,0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-tile .facebox-btn { position: absolute; bottom: 0.4rem; right: 0.4rem; background: rgba(0,0,0,0.6); border: none; color: var(--accent); font-size: 0.7rem; padding: 0.2rem 0.4rem; border-radius: 4px; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.photo-tile:hover .facebox-btn { opacity: 1; }
.photo-tile .admin-controls { display: flex; gap: 0.3rem; padding: 0.3rem 0.5rem; background: rgba(0,0,0,0.8); }
.photo-tile .admin-controls button { font-size: 0.7rem; padding: 0.2rem 0.4rem; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 4px; cursor: pointer; }
.photo-tile .admin-controls button:hover { border-color: var(--accent); color: var(--accent); }

/* ── Face bounding box ───────────────────── */
.face-box { position: absolute; border: 2px solid rgba(232, 197, 71, 0.8); background: rgba(232, 197, 71, 0.12); pointer-events: none; }
.face-label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.7); color: var(--accent); font-size: 0.65rem; text-align: center; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Status badge ────────────────────────── */
.badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 99px; font-weight: 600; }
.badge-ready { background: #1a3a1a; color: #6fcf6f; }
.badge-processing { background: #3a2e0a; color: var(--accent); animation: pulse 1.5s ease-in-out infinite; }
.badge-error { background: #3a1a1a; color: #cf6f6f; }
.badge-pending { background: #1a1a3a; color: #6f9fcf; }

/* ── Warning banner ──────────────────────── */
.banner { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.85rem; }
.banner-warn { background: #2e2500; border: 1px solid #5a4a00; color: #e8c547; }

/* ── Admin UI ────────────────────────────── */
.lock-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 0.4rem 0.7rem; border-radius: var(--radius); cursor: pointer; font-size: 1rem; }
.lock-btn.active { border-color: var(--accent); color: var(--accent); }
.admin-indicator { font-size: 0.75rem; color: var(--accent); }

/* ── Modal ───────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 420px; width: 90%; }
.modal h2 { margin-bottom: 1rem; }
.modal input, .modal select { width: 100%; padding: 0.6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 1rem; margin-bottom: 1rem; }
.modal input:focus, .modal select:focus { outline: none; border-color: var(--accent); }
.btn { padding: 0.6rem 1.2rem; border-radius: var(--radius); border: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* ── Toast ───────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 200; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.85rem; max-width: 320px; animation: slide-in 0.2s ease-out; }
.toast.success { border-color: #4a7a4a; }
.toast.error { border-color: #7a4a4a; }

/* ── Misc ────────────────────────────────── */
.collapsible-header { cursor: pointer; display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); user-select: none; }
.collapsible-content.hidden { display: none; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin: 0.5rem 0; }
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.5s; }
section h2 { font-size: 1.1rem; margin-bottom: 1rem; }

/* ── Animations ──────────────────────────── */
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.5 } }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ── Responsive ──────────────────────────── */
@media (max-width: 600px) {
  main { padding: 1rem; }
  header { padding: 0.75rem 1rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
