:root {
  --paper: #f5f2ea;
  --surface: #fffdf7;
  --ink: #221f1b;
  --muted: #837c6f;
  --line: #e3ddcd;
  --accent: #8e2f3c;
  --accent-dark: #6e222d;
  --gold: #a8863c;
  --ok-bg: #e8efdd;
  --ok-ink: #45602a;
  --err-bg: #f4dfdc;
  --err-ink: #8a2f26;
  --radius: 10px;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, .brand, .candidate-card .name {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.01em;
}
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 21px; margin-bottom: 14px; }
h2::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  background: var(--gold);
  margin-top: 6px;
  border-radius: 2px;
}

.container { max-width: 980px; margin: 0 auto; padding: 28px 18px 72px; }
.container.narrow { max-width: 460px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar .brand { font-size: 20px; color: var(--ink); }
.topbar .brand:hover { text-decoration: none; }
.topbar form { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-top: 22px;
}

.subtitle { color: var(--muted); margin-top: 6px; }

label { display: block; font-weight: 600; font-size: 13.5px; margin: 15px 0 5px; letter-spacing: 0.02em; }
input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbc4b2;
  border-radius: 7px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type="file"] { margin-top: 4px; font-size: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; margin-top: 15px; }
.checkbox-row label { margin: 0; font-weight: 500; }
.checkbox-row input { accent-color: var(--accent); width: 17px; height: 17px; }

.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 11px 22px;
  font-size: 15.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: transparent; color: var(--ink); border-color: #c4bca8; }
.btn.secondary:hover { background: #eeeade; }
.btn.danger { background: transparent; color: var(--err-ink); border-color: #d8b3ae; }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn.block { width: 100%; margin-top: 20px; }
.btn.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.alert { border-radius: 7px; padding: 11px 15px; margin-top: 15px; font-size: 15px; }
.alert.error { background: var(--err-bg); color: var(--err-ink); }
.alert.success { background: var(--ok-bg); color: var(--ok-ink); }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid;
}
.badge.DRAFT { color: #6c6659; border-color: #c9c2af; background: #edeadf; }
.badge.OPEN { color: var(--ok-ink); border-color: #b5c99a; background: var(--ok-bg); }
.badge.CLOSED { color: var(--err-ink); border-color: #d8b3ae; background: var(--err-bg); }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 15px; }
th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ------ grille candidats (vote) ------ */
.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 22px;
}
.candidate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  text-align: center;
  position: relative;
}
.candidate-card:hover { border-color: #b9ac8d; }
.candidate-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.candidate-card.selected::after {
  content: "✓";
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  line-height: 26px;
}
.candidate-card img, .candidate-card .placeholder {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #e9e4d6;
}
.candidate-card .placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: #b6ad97;
}
.candidate-card .info { padding: 11px 9px 14px; }
.candidate-card .name { font-size: 16px; }
.candidate-card .slogan { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 3px; }

.vote-footer {
  position: sticky;
  bottom: 14px;
  margin-top: 26px;
  text-align: center;
}
.vote-footer .btn { box-shadow: 0 8px 24px rgba(34, 31, 27, 0.25); padding: 14px 30px; }

/* ------ admin candidats ------ */
.admin-candidate {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  margin-top: 12px;
  background: #fff;
}
.admin-candidate img, .admin-candidate .placeholder {
  width: 68px; height: 90px; object-fit: cover; border-radius: 6px; background: #e9e4d6;
  display: flex; align-items: center; justify-content: center; font-size: 24px; color: #b6ad97;
  flex-shrink: 0;
}
.admin-candidate .grow { flex: 1; }
.admin-candidate summary { cursor: pointer; font-size: 14px; color: var(--accent); margin-top: 6px; }

.qr-box { text-align: center; padding: 10px; }
.qr-box img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 8px; }

.results-bar {
  background: #ebe6d8;
  border-radius: 6px;
  height: 24px;
  overflow: hidden;
  margin-top: 4px;
}
.results-bar .fill {
  background: var(--accent);
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s;
  min-width: 2px;
}

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt { margin-top: 18px; }
.muted { color: var(--muted); font-size: 14px; }

.contest-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 2px; border-bottom: 1px solid var(--line);
}
.contest-list-item:last-child { border-bottom: none; }
.contest-list-item .title-link { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--ink); }

.center { text-align: center; }
.hero-mark {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 24px;
  color: var(--gold);
}

/* ------ champ photo + caméra ------ */
.photo-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.photo-thumb { width: 52px; height: 68px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.cam-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(24, 21, 17, 0.75);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.cam-modal.show { display: flex; }
.cam-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  max-width: 560px; width: 100%;
  text-align: center;
}
.cam-box video, .cam-box .cam-preview {
  width: 100%; max-height: 60vh; object-fit: contain;
  border-radius: 8px; background: #171410;
}
.cam-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* ------ panneau présentateur ------ */
.presenter-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.presenter-note { margin-top: 10px; }

@media (max-width: 560px) {
  .candidate-grid { grid-template-columns: repeat(2, 1fr); gap: 11px; }
  h1 { font-size: 24px; }
  .card { padding: 18px; }
}
