:root {
  color-scheme: light dark;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1d2521;
  --muted: #617069;
  --line: #d8ded9;
  --accent: #0d766e;
  --accent-strong: #095c55;
  --race-lime: #d7ff00;
  --race-black: #050605;
  --race-panel: #111311;
  --race-line: #272b25;
  --warn: #a44816;
  --shadow: 0 12px 30px rgba(21, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.runner-view {
  background: var(--race-black);
  color: #f7f9f1;
}

a {
  color: inherit;
  text-decoration: none;
}

.back-link,
.secondary-link {
  color: var(--accent-strong);
  display: inline-block;
  font-weight: 700;
}

.back-link {
  margin-bottom: 12px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

body.runner-view .topbar {
  display: none;
}

.brand {
  font-weight: 800;
}

nav {
  display: flex;
  gap: 8px;
}

nav a,
button,
input,
select {
  border-radius: 6px;
  font: inherit;
}

nav a {
  color: var(--muted);
  padding: 8px 10px;
}

nav a:hover {
  background: #eef3ef;
  color: var(--ink);
}

.app-shell {
  margin: 0 auto;
  max-width: 1120px;
  padding: 34px 20px 56px;
}

body.runner-view .app-shell {
  max-width: none;
  min-height: 100vh;
  padding: 0 0 34px;
}

.page-head {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 24px;
}

h1 {
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: 0;
  line-height: 1;
  margin: 0 0 10px;
}

.subtle {
  color: var(--muted);
  margin: 0;
}

.bib-form,
.group-form,
.admin-token,
.admin-tools {
  align-items: center;
  display: flex;
  gap: 8px;
}

.admin-tools {
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

input {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 40px;
  padding: 0 12px;
}

select {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 40px;
  padding: 0 32px 0 12px;
}

button {
  background: var(--accent);
  border: 0;
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-strong);
}

.button-link {
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  justify-content: center;
  margin-top: 22px;
  min-height: 40px;
  padding: 10px 14px;
}

.button-link:hover {
  background: var(--accent-strong);
}

.secondary-button-link,
.disabled-button {
  border-radius: 6px;
  display: inline-flex;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
}

.secondary-button-link {
  background: #e7ece8;
  color: var(--ink);
}

.secondary-button-link:hover {
  background: #d9e2dd;
}

.disabled-button {
  background: #f1f3f1;
  color: #8d9993;
}

button.secondary {
  background: #e7ece8;
  color: var(--ink);
}

button.warning {
  background: var(--warn);
}

.empty,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.notice {
  border-left: 4px solid var(--accent);
}

body.runner-view .empty,
body.runner-view .notice {
  background: var(--race-panel);
  border: 1px solid var(--race-line);
  border-left: 4px solid var(--race-lime);
  border-radius: 0;
  box-shadow: none;
  color: #f7f9f1;
  margin: 16px;
}

.runner-hero {
  background: #050605;
  border-bottom: 1px solid var(--race-line);
  margin: 0;
}

.runner-logo {
  display: block;
  height: auto;
  width: 100%;
}

.runner-title {
  align-items: baseline;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 14px 16px 16px;
}

.runner-title span {
  color: #aeb5a8;
  font-size: 14px;
  text-transform: uppercase;
}

.runner-title strong {
  color: var(--race-lime);
  font-size: clamp(22px, 8vw, 36px);
  letter-spacing: 0;
  line-height: 1;
}

.photo-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

body.runner-view .photo-grid {
  gap: 2px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 2px;
}

.photo-detail {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 240px;
}

body.runner-view .photo-detail {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.photo-stage {
  background: #111814;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.runner-view .photo-stage {
  background: #000;
  border-radius: 0;
  box-shadow: none;
}

.photo-stage img {
  display: block;
  max-height: 74vh;
  object-fit: contain;
  width: 100%;
}

body.runner-view .photo-stage img {
  max-height: none;
  min-height: 0;
}

.photo-side {
  align-self: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

body.runner-view .photo-side {
  background: var(--race-black);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
}

body.runner-view .button-link,
body.runner-view .secondary-button-link {
  background: var(--race-lime);
  color: #050605;
  font-weight: 800;
}

body.runner-view .button-link:hover,
body.runner-view .secondary-button-link:hover {
  background: #ecff5c;
}

body.runner-view .disabled-button {
  background: #171a16;
  border: 1px solid #30352e;
  color: #686f63;
}

.photo-side .secondary-link {
  margin-top: 14px;
}

.photo-nav {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.photo-card,
.review-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.runner-view .photo-card {
  background: #000;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.photo-card img,
.review-image {
  aspect-ratio: 4 / 3;
  background: #dbe2dd;
  display: block;
  object-fit: cover;
  width: 100%;
}

body.runner-view .photo-card img {
  aspect-ratio: 1 / 1;
}

.photo-meta,
.review-body {
  padding: 12px;
}

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

.remove-match-button {
  min-height: 34px;
  padding: 0 10px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  background: #edf5f2;
  border: 1px solid #cfe0da;
  border-radius: 999px;
  color: #245f58;
  font-size: 12px;
  padding: 4px 8px;
}

.review-list {
  display: grid;
  gap: 16px;
}

.review-item {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
}

.candidate-list {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.candidate-list span {
  background: #f1f3f1;
  border-radius: 6px;
  padding: 5px 7px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-section {
  margin-top: 24px;
}

.admin-section h2 {
  font-size: 22px;
  letter-spacing: 0;
  margin: 0 0 12px;
}

.admin-photo-grid {
  margin-top: 0;
}

@media (max-width: 720px) {
  .topbar,
  .page-head,
  .review-item,
  .photo-detail {
    display: block;
  }

  nav {
    margin-top: 8px;
  }

  .bib-form,
  .group-form,
  .admin-token,
  .admin-tools {
    align-items: stretch;
    flex-direction: column;
    margin-top: 16px;
  }

  .photo-side {
    margin-top: 14px;
  }

  body.runner-view .photo-side {
    margin-top: 0;
  }
}

@media (min-width: 760px) {
  body.runner-view .runner-logo {
    max-height: 220px;
    object-fit: cover;
  }

  body.runner-view .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 4px;
  }

  body.runner-view .photo-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  body.runner-view .photo-stage img {
    max-height: calc(100vh - 220px);
    min-height: auto;
  }
}
