:root {
  --ivory: #faf7f2;
  --charcoal: #2b2724;
  --secondary: #6f665e;
  --accent: #9a8157;
  --border: #e4ddd2;
  --card-bg: #ffffff;
  --danger: #a33d3d;
  --success: #4f7a4f;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ivory);
  color: var(--charcoal);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.25;
}

a { color: var(--accent); }
a:focus, button:focus, input:focus, textarea:focus, select:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.site-nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-brand {
  font-family: var(--serif);
  font-size: 1.2rem;
  text-decoration: none;
  color: var(--charcoal);
}
.site-nav nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}
.site-nav nav a { text-decoration: none; color: var(--secondary); font-size: 0.95rem; }
.site-nav nav a.active, .site-nav nav a:hover { color: var(--charcoal); }
.nav-logout-form { display: inline; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--secondary);
  cursor: pointer;
  text-decoration: none;
}
.link-button:hover { color: var(--charcoal); }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  background: #eef3ea;
  border: 1px solid #c9dbc0;
}
.flash-error { background: #f6e6e6; border-color: #e0bcbc; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  margin-bottom: 24px;
}
.card.narrow { max-width: 440px; margin: 40px auto; }

.notice { color: var(--secondary); }
.dev-hint { font-size: 0.85rem; color: var(--secondary); word-break: break-all; }

label { display: block; margin-top: 14px; margin-bottom: 4px; font-size: 0.9rem; color: var(--secondary); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=url], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--charcoal);
}
textarea { resize: vertical; min-height: 100px; }

button, .button {
  display: inline-block;
  background: var(--charcoal);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  margin-top: 16px;
}
button:hover, .button:hover { opacity: 0.9; }
button.secondary, .button.secondary {
  background: transparent;
  color: var(--charcoal);
  border: 1px solid var(--border);
}
button.danger { background: var(--danger); }

/* Home page */
.hero { text-align: center; padding: 20px 0 40px; }
.portrait-frame {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 20px;
  border: 3px solid var(--border);
  background: #fff;
}
.portrait-frame img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 { font-size: 2.2rem; margin: 0 0 6px; }
.hero .dates { color: var(--secondary); margin: 0 0 12px; }
.hero .ornament { color: var(--accent); margin: 0 8px; }
.hero .tagline { font-style: italic; color: var(--secondary); margin: 0 0 24px; }
.tribute { max-width: 640px; margin: 0 auto; text-align: left; }

.service-card {
  max-width: 480px;
  margin: 32px auto 0;
  text-align: left;
}
.service-card dl { margin: 0; }
.service-card dt { color: var(--secondary); font-size: 0.85rem; margin-top: 10px; }
.service-card dd { margin: 2px 0 0; }

/* Gallery */
.gallery-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.masonry {
  columns: 3 260px;
  column-gap: 14px;
}
.masonry figure {
  break-inside: avoid;
  margin: 0 0 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.masonry img { display: block; width: 100%; height: auto; }
.masonry figcaption { padding: 8px 10px; font-size: 0.85rem; color: var(--secondary); }
.lock-icon { color: var(--accent); }

/* Memories */
.memory {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}
.memory:last-child { border-bottom: none; }
.memory-meta { color: var(--secondary); font-size: 0.85rem; margin-bottom: 8px; }
.memory-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.memory-photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 6px; }

/* Share page */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  color: var(--secondary);
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--accent); color: var(--charcoal); }
.upload-list { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.upload-item { display: flex; gap: 12px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.upload-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.upload-item .upload-info { flex: 1; min-width: 0; }
.upload-item input[type=text] { margin-top: 4px; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-bar > span { display: block; height: 100%; background: var(--accent); width: 0%; }
.upload-item.failed .progress-bar > span { background: var(--danger); }
.upload-item.done .progress-bar > span { background: var(--success); }
.upload-remove { background: none; border: none; color: var(--secondary); cursor: pointer; font-size: 1.2rem; }
.visibility-choice { display: flex; gap: 20px; margin-top: 8px; }

/* Posts / admin tables */
table.list { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.92rem; vertical-align: middle; }
table.list th { color: var(--secondary); font-weight: 500; }
.thumb-cell img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; background: var(--border); color: var(--charcoal); }
.badge.public { background: #e6efe4; color: #3d5c3d; }
.badge.family { background: #f1e9da; color: #6b5535; }
.badge.hidden { background: #f6e6e6; color: var(--danger); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { display: inline; }
.row-actions button { margin-top: 0; padding: 4px 10px; font-size: 0.85rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--secondary); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--charcoal); border-color: var(--accent); }

/* Slideshow */
.slideshow {
  position: fixed;
  inset: 0;
  background: #0b0b0c;
  z-index: 1000;
  display: none;
}
.slideshow.open { display: block; }
.slideshow img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.slideshow img.active { opacity: 1; }
.slideshow.no-motion img { transition: none; }
.slideshow-caption {
  position: absolute;
  left: 0; right: 0; bottom: 56px;
  text-align: center;
  color: #f2f0ec;
  font-size: 0.95rem;
  padding: 0 20px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.slideshow-counter {
  position: absolute;
  top: 16px; right: 20px;
  color: #cfcac2;
  font-size: 0.85rem;
}
.slideshow-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 14px;
  transition: opacity 0.4s ease;
}
.slideshow-controls.hidden { opacity: 0; pointer-events: none; }
.slideshow-controls button {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  margin: 0;
  font-size: 1.1rem;
  cursor: pointer;
}
.slideshow-controls button:hover { background: rgba(255,255,255,0.22); }
.slideshow-close {
  position: absolute;
  top: 12px; left: 16px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: opacity 0.4s ease;
}
.slideshow-close.hidden { opacity: 0; pointer-events: none; }

.site-footer {
  text-align: center;
  color: var(--secondary);
  font-size: 0.85rem;
  padding: 24px 20px 40px;
}

@media (max-width: 640px) {
  .masonry { columns: 2 160px; }
  .hero h1 { font-size: 1.7rem; }
  .site-nav nav { gap: 12px; }
}

@media (prefers-color-scheme: dark) {
  /* Intentionally no dark theme: the site keeps a single warm, print-like look. */
}
