:root {
  --bg: #faf7f2;
  --fg: #2b2420;
  --accent: #c8783c;
  --accent-dark: #a85f2b;
  --card-bg: #ffffff;
  --border: #e6ddd0;
  --muted: #8a7f70;
}

* { box-sizing: border-box; }

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

header {
  padding: 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

header h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar span {
  font-size: 0.85rem;
  color: var(--muted);
}

.topbar a, .topbar button {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.9rem;
  background: none;
  border: none;
  white-space: nowrap;
  cursor: pointer;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.status-bar {
  text-align: center;
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: var(--muted);
}

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.fav-btn.active {
  background: var(--accent);
  color: white;
}

.card .fname {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 4px 8px 8px;
  text-align: center;
}

/* login page */
.login-box {
  max-width: 360px;
  margin: 80px auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
}

.login-box h1 { font-size: 1.3rem; margin-top: 0; }
.login-box p { color: var(--muted); font-size: 0.9rem; }

.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 12px;
}

.login-box button {
  width: 100%;
  padding: 10px 12px;
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.login-box button:hover { background: var(--accent-dark); }

.msg { margin-top: 14px; font-size: 0.9rem; min-height: 1.2em; }
.msg.error { color: #b23a3a; }
.msg.ok { color: #2f8a4b; }

/* keuze page */
table.tally {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table.tally th, table.tally td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

table.tally img {
  width: 70px;
  height: 93px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

table.tally tr.chosen { background: #fbf0e4; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}

.count-badge {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  font-weight: 600;
  text-align: center;
}

.voter-names {
  font-size: 0.78rem;
  color: var(--muted);
}

/* lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.94);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.lightbox.open {
  display: flex;
}

.lb-imgwrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 70px 90px;
  box-sizing: border-box;
}

.lb-imgwrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 1002;
  padding: 8px;
}

.lb-nav {
  position: absolute;
  top: 0;
  bottom: 90px;
  width: 60px;
  background: rgba(0,0,0,0);
  border: none;
  color: white;
  font-size: 3rem;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-nav:hover { background: rgba(255,255,255,0.08); }

.lb-prev { left: 0; justify-content: flex-start; padding-left: 8px; }
.lb-next { right: 0; justify-content: flex-end; padding-right: 8px; }

.lb-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.lb-fav {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-fav.active {
  background: var(--accent);
}

.lb-counter {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  position: absolute;
  right: 16px;
}

@media (max-width: 640px) {
  .lb-imgwrap { padding: 50px 12px 100px; }
  .lb-nav { width: 44px; font-size: 2.2rem; }
  .lb-close { font-size: 1.8rem; }
}
