:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #10243e;
  --muted: #4a607d;
  --line: #dbe4f0;
  --accent: #1d5fd3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 10%, #eef4ff 0, var(--bg) 55%);
  color: var(--text);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.cover-container {
  max-width: 1500px;
  padding-left: 20px;
  padding-right: 20px;
}

h1 {
  margin: 0 0 10px;
}

.lead {
  color: var(--muted);
  margin: 0 0 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.race-cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 20px;
}

.race-cover-card {
  min-width: 0;
}

.race-cover-button {
  width: 100%;
  background: #f2f6ff;
  border: 1px solid #cdd9ef;
  border-radius: 12px;
  padding: 10px;
  text-align: left;
  color: inherit;
}

.race-cover-button:hover {
  background: #e8f0ff;
}

.race-cover-link {
  display: block;
  width: 100%;
  background: #f2f6ff;
  border: 1px solid #cdd9ef;
  border-radius: 12px;
  padding: 10px;
  text-align: left;
  color: inherit;
  text-decoration: none;
}

.race-cover-link:hover {
  background: #e8f0ff;
}

.race-cover-image {
  display: block;
  width: 100%;
  height: clamp(260px, 30vw, 420px);
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #d9e3f3;
  background: #dfe8f8;
}

.race-cover-placeholder {
  width: 100%;
  height: clamp(260px, 30vw, 420px);
  border-radius: 10px;
  border: 1px dashed #afbdd6;
  background: #eef3ff;
  color: #5c6f93;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.race-cover-title {
  margin-top: 10px;
  font-size: 22px;
  font-weight: 700;
  color: #203a60;
}

label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
  display: block;
  width: 100%;
  margin-top: 6px;
}

.source-fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.source-fieldset legend {
  font-weight: 700;
  padding: 0 6px;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-weight: 500;
}

button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.camera-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#video,
#preview {
  width: 100%;
  max-height: 380px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f1725;
}

.hidden {
  display: none;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f6f9ff;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
}

.match-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  background: #fdfefe;
  font-size: 14px;
}

/* Results page layout */
.results-page {
  background: #e6e6e6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.results-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

.results-title {
  margin: 0 0 10px;
  font-size: 50px;
  line-height: 1;
  letter-spacing: 0.2px;
}

.results-tabs {
  display: flex;
  gap: 14px;
  margin-bottom: 22px;
}

.results-tab {
  padding: 12px 22px;
  border-radius: 0;
  border: 0;
  font-size: 32px;
  color: #1b1f24;
  background: #cdcdcd;
}

.results-tab.is-active {
  color: #fff;
  background: #3a73e7;
}

.results-count {
  margin: 0 0 14px;
  font-size: 34px;
  color: #202225;
}

.results-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.results-download-all-form {
  margin: 0;
}

.results-download-all-btn {
  font-size: 17px;
  font-weight: 600;
  padding: 10px 16px;
  white-space: nowrap;
}

.results-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #1f2d3d;
}

.results-zip-status {
  margin: 8px 0 0;
  font-size: 14px;
  color: #2f4d79;
  text-align: right;
}

.results-selection-status {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: #1f2d3d;
  text-align: right;
}

.results-zip-status.is-error {
  color: #b42318;
}

.results-divider {
  border: none;
  border-top: 1px solid #bdbdbd;
  margin: 0 0 22px;
}

.results-empty {
  font-size: 28px;
}

/* ---- People gallery: dark & vibrant theme ---- */
:root {
  --su-red: #e2231a;
  --su-red-soft: rgba(226, 35, 26, 0.55);
  --people-ink: #f4f6f8;
  --people-muted: #aab2bd;
}

.people-theme {
  min-height: 100vh;
  background: #101216;
  color: var(--people-ink);
}

/* Fixed cover image behind a dark gradient overlay for legibility. */
.people-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  filter: saturate(1.05);
}

.people-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(226, 35, 26, 0.22), transparent 60%),
    linear-gradient(180deg, rgba(16, 18, 22, 0.82) 0%, rgba(16, 18, 22, 0.9) 45%, rgba(12, 13, 16, 0.96) 100%);
}

.people-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

.people-header {
  margin-bottom: 26px;
}

.people-back {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--people-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.people-back:hover {
  color: var(--su-red);
}

.people-title {
  margin: 0 0 8px;
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}

.people-count {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  color: var(--people-muted);
}

.ai-guessed {
  font-size: 0.72em;
  font-weight: 600;
  color: #7f8794;
  vertical-align: middle;
}

.people-empty {
  font-size: 22px;
  color: var(--people-muted);
}

.race-cover-people-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 18px;
  font-weight: 600;
  color: #1d5fd3;
  text-decoration: none;
}

.race-cover-people-link:hover {
  text-decoration: underline;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 22px;
}

.person-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.person-frame {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a1d23;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.person-card:hover .person-frame {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--su-red-soft);
  box-shadow: 0 0 0 1px var(--su-red-soft), 0 14px 34px rgba(226, 35, 26, 0.4);
}

.person-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #23262d;
}

.person-image.is-broken {
  min-height: 160px;
}

.person-hover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 12px 14px;
  background: linear-gradient(180deg, transparent 40%, rgba(11, 12, 15, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.person-card:hover .person-hover {
  opacity: 1;
}

.person-hover-cta {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}

.person-hover-bib {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--su-red);
  padding: 2px 10px;
  border-radius: 999px;
}

.person-meta {
  margin-top: 9px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--people-muted);
}

/* Person detail page reuses the dark theme; restyle the existing controls. */
.people-theme .results-toolbar {
  align-items: center;
}

.people-theme .results-download-all-btn {
  background: var(--su-red);
  box-shadow: 0 6px 18px rgba(226, 35, 26, 0.4);
}

.people-theme .results-download-all-btn:hover {
  filter: brightness(1.08);
}

.people-theme .results-select-all,
.people-theme .results-selection-status {
  color: var(--people-ink);
}

.people-theme .results-zip-status {
  color: #d6b7b4;
}

.people-theme .thumb-image,
.people-theme .thumb-fallback {
  border-radius: 12px;
}

.people-theme .thumb-image {
  background: #23262d;
}

.people-theme .people-count {
  margin-bottom: 0;
}

@media (max-width: 620px) {
  .people-wrap {
    padding: 28px 14px 44px;
  }

  .people-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .person-hover-cta {
    font-size: 13px;
  }

  .people-bg {
    background-attachment: scroll;
  }
}

.people-theme .thumb-match-meta {
  color: var(--people-muted);
}

.people-theme .thumb-download {
  background: var(--su-red);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px 28px;
}

.thumb-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.thumb-link {
  position: relative;
  width: 100%;
  text-decoration: none;
}

.thumb-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #182230;
  font-size: 13px;
  font-weight: 700;
}

.thumb-select-checkbox {
  width: 16px;
  height: 16px;
}

.thumb-image {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #d8d8d8;
}

.thumb-fallback {
  width: 100%;
  min-height: 220px;
  box-sizing: border-box;
  padding: 12px;
  background: #f5f5f5;
  border: 1px solid #b9b9b9;
  color: #2a2a2a;
  font-size: 16px;
  line-height: 1.35;
}

.thumb-fallback-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.thumb-fallback p {
  margin: 6px 0;
}

.thumb-fallback-note {
  margin-top: 10px;
  color: #5a5a5a;
  font-size: 14px;
}

.thumb-download {
  margin-top: 10px;
  padding: 9px 14px;
  border-radius: 6px;
  background: #2f6de6;
  color: #fff;
  text-decoration: none;
  font-size: 30px;
  line-height: 1.1;
}

.thumb-match-meta {
  margin-top: 8px;
  font-size: 22px;
  color: #3b3f46;
  text-align: center;
}

@media (max-width: 980px) {
  .race-cover-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }

  .results-wrap {
    max-width: 760px;
  }

  .results-title {
    font-size: 40px;
  }

  .results-tab {
    font-size: 24px;
    padding: 10px 14px;
  }

  .results-count {
    font-size: 24px;
    margin-bottom: 10px;
  }

  .results-download-all-btn {
    font-size: 15px;
    padding: 9px 12px;
  }

  .results-select-all {
    font-size: 14px;
  }

  .results-zip-status {
    font-size: 13px;
  }

  .results-selection-status {
    font-size: 13px;
  }

  .thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .thumb-download {
    font-size: 24px;
  }

  .thumb-match-meta {
    font-size: 17px;
  }
}

@media (max-width: 620px) {
  .cover-container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .race-cover-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .race-cover-image,
  .race-cover-placeholder {
    height: 220px;
  }

  .race-cover-title {
    font-size: 18px;
  }

  .results-wrap {
    padding: 12px 12px 28px;
  }

  .results-title {
    font-size: 32px;
  }

  .results-tabs {
    gap: 8px;
  }

  .results-tab {
    font-size: 18px;
    padding: 9px 11px;
  }

  .results-count {
    font-size: 19px;
  }

  .results-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .results-download-all-btn {
    width: 100%;
  }

  .results-zip-status {
    text-align: left;
  }

  .results-selection-status {
    text-align: left;
  }

  .results-select-all {
    font-size: 14px;
  }

  .thumb-grid {
    grid-template-columns: 1fr;
  }

  .thumb-image {
    height: 210px;
  }

  .thumb-fallback {
    min-height: 210px;
    font-size: 14px;
  }

  .thumb-fallback-note {
    font-size: 13px;
  }

  .thumb-download {
    width: 100%;
    text-align: center;
    font-size: 18px;
  }

  .thumb-match-meta {
    font-size: 15px;
  }
}
