/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: #333; background: #f0f5f9; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent, #2a7ab5); text-decoration: none; }

/* === Memorial Page === */

.memorial-hero {
  background: linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--hero-gradient-end) 100%);
  color: #fff; padding: 20px 20px 14px; text-align: center;
}
.memorial-proof {
  font-size: 11px; color: var(--accent-text); margin-top: 8px; font-weight: 500;
}
.memorial-name { font-size: 28px; font-weight: 700; letter-spacing: 0.5px; }
.memorial-dates { font-size: 14px; color: var(--accent-text); margin-top: 4px; }
.memorial-quote {
  font-size: 14px; font-style: italic; color: var(--text-on-hero);
  margin-top: 12px; line-height: 1.6; max-width: 400px;
  margin-left: auto; margin-right: auto;
}

/* Video embed */
.video-embed {
  margin: 16px 20px; border-radius: 12px; overflow: hidden;
  position: relative; padding-bottom: 56.25%; height: 0;
  background: #000;
}
.video-embed iframe {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; border: 0;
}
.video-placeholder {
  margin: 16px 20px; background: var(--hero-gradient-start);
  border-radius: 12px; height: 200px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-text); font-size: 14px;
}

/* Stats bar */
.stats-bar {
  display: flex; padding: 14px 20px; gap: 8px;
  border-bottom: 1px solid #eee; background: #fff;
}
.stat { flex: 1; text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--stat-color); }
.stat-lbl {
  font-size: 10px; color: #999; text-transform: uppercase;
  letter-spacing: 0.5px; margin-top: 2px;
}

/* Section headers */
.section-hdr {
  padding: 18px 20px 8px; font-size: 12px; font-weight: 700;
  color: #888; text-transform: uppercase; letter-spacing: 0.5px;
  background: #fff;
}

/* Memory entries */
.memories-list { background: #fff; }
.memory-entry { padding: 14px 20px; border-bottom: 1px solid #f0f0f0; }
.memory-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.memory-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--avatar-bg); display: flex;
  align-items: center; justify-content: center;
  font-size: 12px; color: var(--avatar-text); font-weight: 600;
  flex-shrink: 0;
}
.memory-author { font-size: 14px; font-weight: 600; }
.memory-date { font-size: 11px; color: #bbb; }
.memory-text { font-size: 14px; color: #444; line-height: 1.6; }
.memory-photos { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.memory-photo {
  border-radius: 8px; overflow: hidden;
  max-height: 200px; flex: 1; min-width: 120px;
}
.memory-photo img { width: 100%; height: 100%; object-fit: cover; }

.no-memories {
  padding: 40px 20px; text-align: center; color: #999;
  font-size: 14px; background: #fff;
}

/* Submission form */
.submit-form {
  padding: 20px; background: var(--accent-lighter);
  border-top: 1px solid var(--accent-light);
}
.submit-form h3 {
  font-size: 16px; font-weight: 600; margin-bottom: 12px;
  color: var(--stat-color);
}
.form-field { margin-bottom: 12px; }
.form-field label {
  display: block; font-size: 12px; font-weight: 600;
  color: #555; margin-bottom: 4px;
}
.form-input, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #ddd;
  border-radius: 8px; font-size: 14px; font-family: inherit;
  background: #fff; color: #333;
  transition: border-color 0.2s;
}
.form-input:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn-photo {
  padding: 10px 16px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 13px; color: #666; background: #fff; cursor: pointer;
  font-family: inherit; min-height: 44px;
}
.btn-photo:hover { border-color: var(--accent); color: var(--accent); }
.btn-submit {
  flex: 1; padding: 10px 16px; background: var(--accent); color: #fff;
  border-radius: 8px; font-size: 14px; font-weight: 600; border: none;
  cursor: pointer; font-family: inherit; min-height: 44px;
  transition: opacity 0.2s;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* Honeypot */
.hp-field { position: absolute; left: -9999px; }

/* File input */
.file-input { display: none; }
.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.photo-preview-item {
  width: 60px; height: 60px; border-radius: 6px; overflow: hidden;
  position: relative;
}
.photo-preview-item img { width: 100%; height: 100%; object-fit: cover; }

/* Success message */
.success-page {
  max-width: 500px; margin: 60px auto; padding: 40px 20px; text-align: center;
}
.success-page h1 {
  font-size: 24px; color: var(--stat-color); margin-bottom: 12px;
}
.success-page p { font-size: 15px; color: #666; line-height: 1.6; }
.success-page a {
  display: inline-block; margin-top: 20px; padding: 12px 28px;
  background: var(--accent); color: #fff; border-radius: 8px;
  font-weight: 600;
}

/* Error flash */
.flash-error {
  padding: 12px 16px; background: #fee2e2; color: #991b1b;
  border-radius: 8px; margin-bottom: 12px; font-size: 14px;
}

/* === Tab Bar === */

/* Hide radio inputs */
.tab-radio { position: absolute; opacity: 0; pointer-events: none; }

/* Tab panels — hidden by default */
.tab-panel { display: none; }

/* CSS-only tab switching: when a radio is checked, show its corresponding panel */
#tab-media:checked ~ .tab-panel-media,
#tab-stories:checked ~ .tab-panel-stories,
#tab-share:checked ~ .tab-panel-share {
  display: block;
}

/* Tab bar — fixed bottom */
.tab-bar {
  display: flex; border-top: 1px solid #e0e0e0; background: #fff;
  position: sticky; bottom: 0; z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-item {
  flex: 1; text-align: center; padding: 10px 4px 8px;
  font-size: 10px; color: #999; font-weight: 600;
  letter-spacing: 0.3px; position: relative; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab-icon { font-size: 20px; display: block; line-height: 1.2; }
.tab-label { display: block; margin-top: 2px; }
.tab-badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--accent, #2a7ab5); color: #fff; font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px; min-width: 16px;
}

/* Active tab styling */
#tab-media:checked ~ .tab-bar label[for="tab-media"],
#tab-stories:checked ~ .tab-bar label[for="tab-stories"],
#tab-share:checked ~ .tab-bar label[for="tab-share"] {
  color: var(--hero-gradient-start, #1a4e6e);
}
#tab-media:checked ~ .tab-bar label[for="tab-media"]::after,
#tab-stories:checked ~ .tab-bar label[for="tab-stories"]::after,
#tab-share:checked ~ .tab-bar label[for="tab-share"]::after {
  content: ''; position: absolute; top: 0; left: 20%; right: 20%;
  height: 2px; background: var(--accent, #2a7ab5); border-radius: 1px;
}

/* Tab panel content fills available space */
.tab-panel-media .stats-bar { border-bottom: none; }
.tab-panel-share .submit-form { border-top: none; }

/* Section label inside media tab */
.section-label {
  padding: 12px 16px 4px; font-size: 11px; font-weight: 700;
  color: #888; text-transform: uppercase; letter-spacing: 0.5px;
}

/* === Admin === */

.admin-header {
  padding: 20px; border-bottom: 1px solid #eee; background: #fff;
}
.admin-header h1 { font-size: 22px; font-weight: 700; }
.admin-header p { font-size: 13px; color: #888; }

.admin-nav {
  display: flex; gap: 8px; padding: 12px 20px;
  background: #fff; border-bottom: 1px solid #eee;
}
.admin-nav a {
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 600; color: #666; background: #f5f5f5;
}
.admin-nav a.active { background: var(--accent-light); color: var(--stat-color); }

.admin-card {
  margin: 12px 16px; border: 1px solid #eee; border-radius: 12px;
  overflow: hidden; background: #fff;
}
.admin-card-hero {
  background: linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--hero-gradient-end) 100%);
  color: #fff; padding: 16px 20px;
}
.admin-card-hero h2 { font-size: 18px; font-weight: 700; }
.admin-card-hero .date { font-size: 12px; color: var(--accent-text); }
.admin-card-stats { display: flex; gap: 16px; padding: 12px 20px; }
.admin-card-stat { text-align: center; }
.admin-card-stat .num { font-size: 18px; font-weight: 700; }
.admin-card-stat .lbl { font-size: 10px; color: #999; }
.admin-card-actions { display: flex; gap: 8px; padding: 0 16px 14px; }
.admin-btn {
  flex: 1; text-align: center; padding: 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.admin-btn-primary { background: var(--accent); color: #fff; }
.admin-btn-secondary { background: var(--accent-light); color: var(--stat-color); }

/* Moderation */
.moderate-entry {
  padding: 16px 20px; border-bottom: 1px solid #eee; background: #fff;
}
.moderate-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-approve {
  padding: 8px 20px; background: #dcfce7; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: #166534; border: none;
  cursor: pointer; font-family: inherit; min-height: 44px;
}
.btn-remove {
  padding: 8px 20px; background: #fee2e2; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: #991b1b; border: none;
  cursor: pointer; font-family: inherit; min-height: 44px;
}

/* Video list editor */
.video-list-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid #f0f0f0;
}
.video-list-inputs { flex: 1; }
.video-list-actions {
  display: flex; flex-direction: column; gap: 4px; padding-top: 2px;
}
.video-nav-btn {
  width: 44px; height: 32px; border: 1px solid #ddd; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 12px; color: #666;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.video-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.video-nav-btn:disabled { opacity: 0.3; cursor: default; }
.video-remove-btn:hover { border-color: #cc4444; color: #cc4444; }
.btn-add-video {
  margin-top: 8px; padding: 10px 20px; border: 1px dashed #ddd;
  border-radius: 8px; background: #fff; color: var(--accent);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  width: 100%; min-height: 44px;
}
.btn-add-video:hover { border-color: var(--accent); background: var(--accent-lighter); }

/* Edit form */
.edit-form { padding: 20px; background: #fff; }
.edit-form .form-field { margin-bottom: 16px; }
.edit-section-title {
  font-size: 11px; font-weight: 700; color: #888;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid #eee;
}
.edit-section-title:first-child { margin-top: 0; border-top: none; padding-top: 0; }

.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.theme-swatch {
  height: 56px; border-radius: 8px; position: relative;
  border: 3px solid transparent; cursor: pointer; overflow: hidden;
}
.theme-swatch.selected { border-color: #333; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333; }
.theme-swatch-name {
  position: absolute; bottom: 3px; left: 0; right: 0;
  text-align: center; font-size: 9px; font-weight: 600;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid #f0f0f0;
}
.toggle-label { font-size: 14px; font-weight: 500; }
.toggle-desc { font-size: 11px; color: #999; margin-top: 2px; }

/* QR page */
.qr-page { padding: 30px 20px; text-align: center; background: #fff; }
.qr-page h2 { font-size: 18px; font-weight: 700; color: var(--stat-color); }
.qr-page .slug { font-size: 13px; color: #888; margin-top: 4px; }
.qr-page img { margin: 20px auto; }
.qr-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.qr-actions a {
  padding: 10px 24px; border-radius: 8px; font-size: 13px; font-weight: 600;
}

/* === Utility === */

.container { max-width: 600px; margin: 0 auto; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* === Responsive === */

@media (min-width: 768px) {
  .memorial-hero { padding: 28px 24px 18px; }
  .memorial-name { font-size: 34px; }
  .tab-panel { max-width: 600px; margin: 0 auto; }
  .tab-bar { max-width: 600px; margin: 0 auto; }
  .stats-bar { max-width: 600px; margin: 0 auto; }
  .memories-list { max-width: 600px; margin: 0 auto; }
  .submit-form { max-width: 600px; margin: 0 auto; }
  .section-hdr { max-width: 600px; margin: 0 auto; }
}
