:root {
  --font-body: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-logo: 'Dancing Script', cursive;
  --radius: 14px;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f6f5f3;
  --text: #221f1f;
  --text-muted: #75706c;
  --border: #e7e3df;
  --accent: #e0455a;
  --accent-contrast: #ffffff;
  --card-bg: #ffffff;
  --overlay-bg: rgba(255, 255, 255, 0.88);
  --overlay-text: #221f1f;
  --danger: #c0392b;
  --success: #2f7a4f;
}

html[data-theme="dark"] {
  --bg: #17151a;
  --bg-alt: #201d24;
  --text: #f3f1ee;
  --text-muted: #a79fb0;
  --border: #35313c;
  --accent: #ff5a72;
  --accent-contrast: #17151a;
  --card-bg: #201d24;
  --overlay-bg: rgba(23, 21, 26, 0.82);
  --overlay-text: #f3f1ee;
  --danger: #ff6b5e;
  --success: #63d19a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-logo);
  font-size: 34px;
  text-decoration: none;
  color: var(--text);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.flash-wrap {
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 0 20px;
}

.flash {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-weight: 600;
}
.flash-success { background: rgba(47, 122, 79, 0.12); color: var(--success); }
.flash-error { background: rgba(192, 57, 43, 0.12); color: var(--danger); }

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  min-height: 60vh;
}

.site-footer {
  text-align: center;
  padding: 30px 20px 50px;
  color: var(--text-muted);
  font-size: 13px;
}
.site-footer a { text-decoration: none; }

.center-card {
  max-width: 460px;
  margin: 60px auto;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 28px;
}

.big-heart {
  color: var(--accent);
  font-size: 42px;
  line-height: 1;
  margin-bottom: 8px;
}

.center-card h1 {
  font-size: 24px;
  margin: 0 0 12px;
}

.muted { color: var(--text-muted); }

.text-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-body);
  margin-bottom: 14px;
}

.field-label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-actions { margin-top: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 13px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
}

.btn-primary { background: var(--accent); color: var(--accent-contrast); width: 100%; }
.btn-secondary { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 9px 18px; font-size: 14px; }
.btn-small { padding: 7px 12px; font-size: 13px; border-radius: 8px; background: var(--bg-alt); border: 1px solid var(--border); color: var(--text); }
.btn-warn { background: rgba(224, 69, 90, 0.12); color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; }

/* Public gallery */
.gallery-intro { text-align: center; margin-bottom: 18px; color: var(--text-muted); }

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

.photo-card { display: flex; flex-direction: column; }

.photo-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-alt);
  aspect-ratio: 4 / 3;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-caption {
  margin: 8px 2px 0;
  font-size: 14px;
  color: var(--text-muted);
}

.zoomable-photo { cursor: zoom-in; }

.heart-wrap {
  position: absolute;
  right: 8px;
  bottom: 8px;
}

.vote-form {
  margin: 0;
}

.heart-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  max-width: 200px;
  background: var(--overlay-bg);
  color: var(--overlay-text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: normal;
  z-index: 5;
}

.heart-wrap:hover .heart-tooltip,
.heart-wrap:focus-within .heart-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.heart-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--overlay-bg);
  color: var(--overlay-text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  min-height: 44px;
  min-width: 44px;
}

.heart-icon { color: var(--text-muted); transition: color 0.15s ease, transform 0.15s ease; }
.heart-btn.is-voted .heart-icon { color: var(--accent); transform: scale(1.1); }
.heart-btn:active .heart-icon { transform: scale(0.9); }

/* Admin */
.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 22px;
}

.upload-fields {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.inline-form .text-input { margin-bottom: 0; max-width: 320px; }

.table-wrap { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th, .admin-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.admin-table tr.revoked { opacity: 0.55; }

.share-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.share-url { width: 220px; margin-bottom: 0; font-size: 12px; padding: 8px 10px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.sort-links { display: flex; gap: 14px; font-size: 14px; }
.sort-links a { text-decoration: none; color: var(--text-muted); }
.sort-links a.active { color: var(--accent); font-weight: 700; }

.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.admin-photo-card {
  position: relative;
  display: block;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--bg-alt);
  cursor: pointer;
}
.admin-photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-photo-card input[type="checkbox"] {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  z-index: 2;
}
.admin-photo-card:has(input:checked) { outline: 3px solid var(--accent); }
.admin-photo-votes {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--overlay-bg);
  color: var(--overlay-text);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* Welcome banner (admin-uploaded, shown on the public welcome page).
   No forced crop: landscape photos are limited by width, portrait photos
   by height, so the whole image always stays visible. */
.welcome-banner {
  display: block;
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  margin: 4px auto 16px;
}

/* Upload progress bar */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 14px;
}
.upload-progress-track {
  flex: 1;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
  border-radius: 999px;
}
.upload-progress-label {
  font-weight: 700;
  font-size: 13px;
  min-width: 42px;
  text-align: right;
}
.upload-summary { margin: 4px 0 14px; }
.upload-summary .flash { margin-bottom: 6px; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 11, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
  padding: 24px;
}
.lightbox.active { opacity: 1; pointer-events: auto; }
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-out;
  box-shadow: 0 10px 50px rgba(0,0,0,0.5);
}

/* Confirm modal (replaces the native browser confirm() popup) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 11, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 44px rgba(0,0,0,0.28);
}
.modal-box p { margin: 0 0 20px; font-size: 15px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { padding: 10px 18px; font-size: 14px; }

/* Admin settings page */
.admin-bar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.small-note { font-size: 13px; margin: -6px 0 12px; }
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.color-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 4px;
  cursor: pointer;
}
.settings-preview {
  display: block;
  max-width: 320px;
  max-height: 140px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 14px;
  cursor: pointer;
}
.checkbox-label input { width: 18px; height: 18px; }

@media (max-width: 720px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .logo { font-size: 28px; }
}

@media (max-width: 420px) {
  .photo-grid { grid-template-columns: 1fr; gap: 14px; }
}
