:root {
  --bg: #f5eee0;
  --card: #f9f3e8;
  --ink: #3a352c;
  --muted: #8a7f6a;
  --green-deep: #33453a;
  --green-mid: #5c7a5f;
  --accent: #b08d57;
  --accent-light: #c9a668;
  --accent-ink: #f9f3e8;
  --border: #e7dcc8;
  --danger: #b5486a;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: 3rem;
  overflow-x: hidden;
}

.topbar {
  padding: 2rem 1.25rem 1.25rem;
  text-align: center;
  position: relative;
}

.topbar-flourish {
  width: 54px;
  height: auto;
  margin: 0 auto 0.5rem;
  display: block;
  opacity: 0.9;
}

.topbar h1 {
  margin: 0 0 0.15rem;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 2rem;
  color: var(--green-deep);
}

.topbar-date {
  margin: 0 0 0.5rem;
  font-family: 'Parisienne', cursive;
  font-size: 1.3rem;
  color: var(--accent);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.15rem;
}

.ornament-divider {
  max-width: 720px;
  margin: 0.25rem auto;
  padding: 0 1rem;
}

.ornament-divider svg { display: block; width: 100%; height: 16px; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.notice {
  background: #efe4cf;
  border-color: var(--accent-light);
  color: var(--green-deep);
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.1rem;
}

.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border: none;
}

.upload-button .icon { font-size: 1.3rem; }
.upload-button:active { opacity: 0.85; }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.75rem 0 0;
  text-align: center;
}

.upload-summary {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-deep);
}

.upload-summary .progress-track {
  margin-top: 0.35rem;
}

.upload-list {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.upload-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.upload-item .name {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.upload-item .status { color: var(--muted); white-space: nowrap; }
.upload-item.error .status { color: var(--danger); }

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}

.upload-item.error .progress-fill { background: var(--danger); }

.retry-btn {
  margin-top: 0.4rem;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: none;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.gallery-header h2 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--green-deep);
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
}

.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }

@media (max-width: 400px) {
  .gallery-actions .btn { padding: 0.45rem 0.7rem; font-size: 0.78rem; }
}

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

@media (min-width: 480px) {
  .gallery { grid-template-columns: repeat(4, 1fr); }
}

.load-more {
  display: flex;
  width: 100%;
  margin-top: 0.9rem;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--border);
  cursor: pointer;
}

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

.tile .fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 1.6rem;
}

.tile .badge {
  position: absolute;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 6px;
}

.tile .badge-kind { right: 4px; }
.tile .badge-size { left: 4px; }

.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }

.tile .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile .select-checkbox {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 1.1rem;
  height: 1.1rem;
}

.lightbox-info {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8rem;
  text-align: center;
  margin: 0;
  max-width: 90vw;
  overflow-wrap: break-word;
}

.lightbox-actions {
  display: flex;
  gap: 0.6rem;
  align-self: center;
}

.bulk-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 1rem;
  width: calc(100% - 2rem);
  max-width: 420px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.bulk-bar .btn { padding: 0.4rem 0.8rem; white-space: nowrap; }
.bulk-bar .btn.secondary { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.bulk-bar span { white-space: nowrap; font-size: 0.8rem; }

.footer {
  max-width: 720px;
  margin: 1.5rem auto 0;
  padding: 0 1rem 2rem;
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.4rem;
}

.admin-login {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 260px;
  margin: 0.75rem auto 0;
}

.admin-login input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.hint.error { color: var(--danger); }

.admin-controls {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.site-toggle input { width: 1rem; height: 1rem; accent-color: var(--accent); }

.admin-closed-banner {
  text-align: center;
  font-weight: 600;
}

.admin-storage {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-storage.low {
  color: var(--danger);
  font-weight: 600;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(14, 22, 16, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  gap: 1rem;
}

.lightbox-content {
  max-width: 100%;
  max-height: 78vh;
  display: flex;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 8px;
  margin: auto;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 2;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.lightbox-nav:disabled { opacity: 0.25; cursor: default; }
.lightbox-nav-prev { left: 0.5rem; }
.lightbox-nav-next { right: 0.5rem; }

@media (min-width: 480px) {
  .lightbox-nav-prev { left: 1rem; }
  .lightbox-nav-next { right: 1rem; }
}
