/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --amber:      #F5A623;
  --terracotta: #C0392B;
  --dark:       #1c1c1e;
  --mid:        #3a3a3c;
  --subtle:     #636366;
  --divider:    #e5e5ea;
  --bg:         #f2f2f7;
  --card:       #ffffff;
  --radius:     12px;
  --header-h:   56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
}

a { color: var(--terracotta); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ────────────────────────────────────────────────────────────── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--amber) 0%, var(--terracotta) 100%);
  color: #fff;
  height: var(--header-h);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

#site-header.hidden { display: none; }

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex-shrink: 0;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

nav { display: flex; gap: 16px; flex: 1; }
nav a { color: rgba(255,255,255,0.9); font-weight: 500; font-size: 0.95rem; }
nav a:hover { color: #fff; text-decoration: none; }

.btn-ghost {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-ghost:hover { background: rgba(255,255,255,0.32); }

/* ── App layout (sidebar + content) ────────────────────────────────────── */
.app-layout {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - var(--header-h));
}

/* ── Main container ────────────────────────────────────────────────────── */
#app {
  flex: 1;
  min-width: 0;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Utility classes ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 24px 0 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.empty-state {
  text-align: center;
  color: var(--subtle);
  padding: 48px 16px;
  font-size: 0.95rem;
}

.spinner {
  text-align: center;
  padding: 48px;
  color: var(--subtle);
}

.error-banner {
  background: #fff0f0;
  border: 1px solid #f5c6c6;
  color: var(--terracotta);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ── Login page ────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: #fff;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 1.9rem;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--amber), var(--terracotta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p.tagline {
  color: var(--subtle);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mid);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--amber); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--amber), var(--terracotta));
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.55; cursor: default; }

.login-note {
  font-size: 0.78rem;
  color: var(--subtle);
  text-align: center;
  margin-top: 14px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}
.link-btn:hover { opacity: 0.75; }
.link-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Event list ────────────────────────────────────────────────────────── */
.event-list { display: flex; flex-direction: column; gap: 12px; }

.event-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}
.event-item:hover { background: #f9f9fb; }
.event-item + .event-item { border-top: 1px solid var(--divider); }

.event-info { flex: 1; }
.event-name { font-weight: 600; font-size: 1rem; }
.event-date { font-size: 0.82rem; color: var(--subtle); margin-top: 2px; }
.event-arrow { color: var(--divider); font-size: 1.2rem; }

/* ── Photo grid ────────────────────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
}

.photo-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--divider);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
  transform: rotate(var(--rot-deg, 0deg));
}
.photo-thumb:hover img { transform: rotate(var(--rot-deg, 0deg)) scale(1.04); }
img.cp-photo { transform: rotate(var(--rot-deg, 0deg)); }
.photo-thumb { position: relative; }
.ev-sel-ring {
  position: absolute;
  top: 5px; left: 5px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-thumb:hover .ev-sel-ring,
.ev-selected .ev-sel-ring { opacity: 1; }
.ev-selected .ev-sel-ring {
  background: #007aff;
  border-color: #fff;
}
.ev-oor-badge {
  position: absolute;
  bottom: 5px; right: 5px;
  background: rgba(234,88,12,0.88);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  line-height: 1.4;
  pointer-events: none;
}
.ev-selected { outline: 3px solid #007aff; outline-offset: -3px; }
.ph-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.52);
  color: #fff;
  font-size: .62rem;
  padding: 3px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Photo detail ──────────────────────────────────────────────────────── */
.photo-detail-img {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 0;
  cursor: zoom-in;
  display: block;
}
#photo-img-wrap {
  margin-bottom: 20px;
}

.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.meta-label { color: var(--subtle); font-weight: 500; }
.meta-value { color: var(--dark); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--terracotta);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 20px;
  cursor: pointer;
}
.back-link:hover { opacity: 0.75; }

/* ── Comments ──────────────────────────────────────────────────────────── */
.comment-list { padding: 0; }
.comment-item {
  padding: 14px 20px;
  border-top: 1px solid var(--divider);
}
.comment-item:first-child { border-top: none; }
.comment-author { font-weight: 600; font-size: 0.88rem; color: var(--mid); margin-bottom: 4px; }
.comment-body { font-size: 0.95rem; line-height: 1.5; }

.comment-form {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--divider);
}
.comment-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  resize: none;
  min-height: 40px;
}
.comment-input:focus { border-color: var(--amber); }
.comment-submit {
  padding: 9px 18px;
  background: var(--terracotta);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
}
.comment-submit:hover { opacity: 0.88; }
.comment-submit:disabled { opacity: 0.5; cursor: default; }

/* ── Hints ─────────────────────────────────────────────────────────────── */
.hint-item {
  padding: 14px 20px;
  border-top: 1px solid var(--divider);
}
.hint-item:first-child { border-top: none; }
.hint-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hint-contributor { font-weight: 600; font-size: 0.88rem; color: var(--mid); }
.confidence-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.confidence-certain  { background: #d1f2e0; color: #1a7a42; }
.confidence-probable { background: #fdedc8; color: #8a5c00; }
.confidence-possible { background: #ebebeb; color: #555; }
.hint-text { font-size: 0.92rem; line-height: 1.5; color: var(--dark); }
.hint-meta { font-size: 0.8rem; color: var(--subtle); margin-top: 4px; }

/* ── Lightbox ──────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img {
  max-width: 94vw;
  max-height: 94vh;
  border-radius: 6px;
  object-fit: contain;
}
#lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

/* ── Page header (title + action button row) ───────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header .page-title { margin-bottom: 0; }

.event-subtitle { color: var(--subtle); font-size: .88rem; margin-top: 2px; margin-bottom: 0; }
.ev-date-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ev-date-label { font-size: .78rem; color: var(--subtle); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ev-date-input { font-size: .82rem; padding: 3px 7px; border: 1px solid var(--divider); border-radius: 6px; background: var(--card); color: var(--text); cursor: pointer; }
.ev-date-input:focus { outline: none; border-color: var(--accent); }
.event-desc-text { color: var(--subtle); font-size: .92rem; margin-bottom: 16px; }

/* ── Action / New button ───────────────────────────────────────────────── */
.btn-action {
  display: inline-block;
  padding: 7px 16px;
  background: var(--terracotta);
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.btn-action:hover { opacity: 0.88; text-decoration: none; }

/* ── Secondary / Cancel button ─────────────────────────────────────────── */
.btn-secondary {
  padding: 10px 20px;
  background: var(--divider);
  color: var(--mid);
  font-size: .95rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-secondary:hover { opacity: 0.8; }

/* ── Danger button ─────────────────────────────────────────────────────── */
.btn-danger {
  padding: 10px 20px;
  background: #fff0f0;
  color: var(--terracotta);
  border: 1.5px solid #f5c6c6;
  font-size: .95rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #ffe0e0; }

/* ── Form card ─────────────────────────────────────────────────────────── */
.form-card { padding: 24px; margin-bottom: 16px; }

/* ── Form elements ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--mid);
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--amber); }
.form-group textarea { resize: vertical; min-height: 72px; }

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { flex: 1; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.form-actions .btn-primary { flex: 1; }

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 500;
  color: var(--dark);
  margin-bottom: 0;
}
.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
#modal-body {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Inline action buttons ─────────────────────────────────────────────────── */
.row-actions { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }
.btn-icon {
  background: none;
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.78rem;
  color: var(--subtle);
  cursor: pointer;
  white-space: nowrap;
}
.btn-icon:hover { background: var(--bg); color: var(--dark); }
.btn-icon-danger { color: var(--terracotta); border-color: #f5c6c6; }
.btn-icon-danger:hover { background: #fff0f0; }
.btn-icon-success { color: #1a7a42; border-color: #b2dfcc; }
.btn-icon-success:hover { background: #e8f8f0; }

/* ── Owner action bar ──────────────────────────────────────────────────────── */
.owner-bar {
  background: #fffbf3;
  border: 1px solid #ffe4a0;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.owner-bar-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9a6700;
  margin-bottom: 12px;
}

/* ── Accepted badge ────────────────────────────────────────────────────────── */
.accepted-badge { font-size: 0.75rem; color: #1a7a42; font-weight: 600; }

/* ── Contact checkbox list ─────────────────────────────────────────────────── */
.contact-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 0.95rem;
  width: 100%;
  cursor: pointer;
}
.contact-check-item:last-child { border-bottom: none; }
.contact-check-item input { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Share list rows ───────────────────────────────────────────────────────── */
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  font-size: 0.9rem;
}
.share-row:first-child { border-top: none; }
.share-name { flex: 1; font-weight: 500; }

/* ── AI synthesis result ───────────────────────────────────────────────────── */
.ai-result {
  background: #f0f7ff;
  border: 1px solid #bcd9f5;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--dark);
  margin-top: 10px;
  white-space: pre-wrap;
}

/* ── Inline comment edit ───────────────────────────────────────────────────── */
.comment-edit-form { display: flex; flex-direction: column; gap: 8px; }
.comment-edit-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--amber);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}
.comment-edit-actions { display: flex; gap: 8px; }

/* ── Feed cards ────────────────────────────────────────────────────────── */
.feed-list { display: flex; flex-direction: column; gap: 12px; }
.feed-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
}
.feed-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.feed-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.feed-thumb-empty {
  background: var(--divider);
  border-radius: 6px;
}
.feed-card-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.feed-card-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--amber); }
.feed-card-who { font-weight: 600; font-size: 0.9rem; color: var(--dark); }
.feed-card-text { font-size: 0.88rem; color: #555; line-height: 1.4; }
.feed-card-when { font-size: 0.78rem; color: #999; margin-top: 2px; }

/* Social-style feed (renderFeed) */
.feed-social { display: flex; flex-direction: column; gap: 20px; max-width: 540px; margin: 0 auto; }
.feed-social-card {
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s;
}
.feed-social-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.feed-photo-wrap { position: relative; overflow: hidden; line-height: 0; aspect-ratio: 4 / 3; }
.feed-social-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--divider);
}
.feed-face-box {
  position: absolute;
  display: block;
  border: 2px solid orange;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  border-radius: 3px;
  pointer-events: none;
}
.feed-face-name {
  position: absolute;
  display: block;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
  max-width: 100%;
  box-sizing: border-box;
}
.feed-social-photo-empty {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--divider);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #aaa;
}
.feed-social-caption {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.feed-social-action { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--amber); }
.feed-social-who { font-size: 1rem; font-weight: 700; color: var(--dark); }
.feed-social-text { font-size: 0.9rem; color: #555; line-height: 1.45; margin-top: 2px; }
.feed-social-hint-meta { font-size: 0.82rem; color: #666; margin-top: 2px; }
.feed-social-when { font-size: 0.78rem; color: #999; margin-top: 4px; }
.feed-skeleton-card {
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  overflow: hidden;
  animation: feed-shimmer 1.4s ease-in-out infinite;
}
.feed-skeleton-card::before {
  content: '';
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--divider);
}
.feed-skeleton-card::after {
  content: '';
  display: block;
  height: 72px;
  background: linear-gradient(90deg,
    var(--divider) 25%, color-mix(in srgb, var(--divider) 40%, transparent) 50%, var(--divider) 75%);
  background-size: 200% 100%;
  animation: feed-shimmer-slide 1.4s ease-in-out infinite;
}
@keyframes feed-shimmer-slide {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--divider);
  overflow-y: auto;
  padding: 8px 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
}
#sidebar.hidden { display: none !important; }

.sb-section {
  border-bottom: 1px solid var(--divider);
  padding-bottom: 4px;
}

.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}
.sb-header:hover { color: var(--dark); }
.sb-arrow { font-size: 0.7em; }

.sb-body.collapsed { display: none; }

.sb-item {
  display: block;
  padding: 6px 14px 6px 18px;
  font-size: 0.88rem;
  color: var(--dark);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 6px;
  margin: 1px 6px;
}
.sb-item:hover { background: var(--bg); text-decoration: none; }
.sb-item.sb-active { background: var(--amber); color: #fff; }
.sb-item.sb-new { color: var(--terracotta); font-size: 0.8rem; }

.sb-nav-section { padding: 8px 0; }
.sb-nav-section .sb-item { padding-left: 14px; }

.sb-empty {
  display: block;
  padding: 2px 18px 8px;
  font-size: 0.8rem;
  color: var(--subtle);
}

/* ── Sidebar — subsections (Quick Views) ──────────────────────────────── */
.sb-sub-header {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtle);
  padding: 10px 16px 2px;
  display: block;
}
.sb-sub-item {
  display: block;
  font-size: 0.82rem;
  padding: 5px 14px 5px 28px;
  color: var(--dark);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 6px;
  margin: 1px 6px;
}
.sb-sub-item:hover { background: var(--bg); }
.sb-sub-item.sb-active { background: var(--amber); color: #fff; }

/* ── View toolbar (grid/list toggle + sort) ────────────────────────────── */
.view-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.view-toolbar select {
  font-size: 13px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: var(--dark);
}
.vt-toggle {
  display: flex;
  border: 1px solid var(--divider);
  border-radius: 6px;
  overflow: hidden;
}
.vt-toggle button {
  padding: 4px 10px;
  font-size: 14px;
  background: #fff;
  border: none;
  cursor: pointer;
  color: var(--subtle);
  line-height: 1;
}
.vt-toggle button.active { background: var(--amber); color: #fff; }
.vt-label { font-size: 13px; color: var(--subtle); margin-right: auto; }

/* ── List view rows ────────────────────────────────────────────────────── */
.list-rows { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f2f2f7;
  text-decoration: none;
  color: inherit;
}
.list-row:hover { background: #fafafa; }
.list-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--divider);
}
.list-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: #f0f0f5;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.list-info { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta  { font-size: 12px; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.list-hint  { font-size: 11px; color: var(--amber); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Map view ──────────────────────────────────────────────────────────── */
#map-container { height: 500px; border-radius: 10px; overflow: hidden; margin: 12px 0; }

/* ── Login hero (split-screen) ──────────────────────────────────────────── */
.login-hero { position:relative; flex:1; overflow:hidden; min-height:300px; }
.hero-bg-img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; object-position:center center; }
.hero-overlay { position:absolute; inset:0; z-index:2; display:flex; flex-direction:column; justify-content:flex-end; padding:48px 44px; background:linear-gradient(to bottom, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.65) 100%); color:#fff; }
.hero-brand { font-size:1rem; font-weight:700; letter-spacing:.5px; text-transform:uppercase; opacity:.75; margin-bottom:20px; }
.hero-overlay h2 { font-size:2.4rem; font-weight:800; line-height:1.2; margin-bottom:14px; text-shadow:0 2px 8px rgba(0,0,0,0.3); }
.hero-overlay > p { font-size:1.05rem; line-height:1.6; opacity:.88; max-width:360px; }
.login-panel { width:460px; flex-shrink:0; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:60px 52px; background:#fff; gap:0; }
.login-panel .login-footer { margin-top:24px; width:100%; text-align:center; }
.signup-progress { font-size:.82rem; color:var(--subtle); font-weight:600; text-transform:uppercase; letter-spacing:.5px; margin-bottom:14px; text-align:center; }

/* ── Nav icon buttons (Feed + Inbox — always visible in header) ─────────── */
.nav-icons {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.nav-icon-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.32); color: #fff; }

/* ── Hamburger button (mobile only) ─────────────────────────────────────── */
.hamburger {
  display: none;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  align-items: center;
}
.hamburger:hover { background: rgba(255,255,255,0.32); }

/* ── Account menu button (top-right, always visible) ────────────────────── */
.acct-menu-wrap { flex-shrink: 0; }
.acct-menu-btn {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}
.acct-menu-btn:hover { background: rgba(255,255,255,0.32); }

/* Dropdown is position:fixed so it's never clipped by the header */
.acct-dropdown {
  position: fixed;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.14);
  min-width: 180px;
  z-index: 9999;
  overflow: hidden;
}
.acct-dd-item {
  display: block;
  width: 100%;
  padding: 12px 18px;
  color: #222;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  background: none;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  box-sizing: border-box;
  line-height: 1.4;
  transition: background 0.12s;
}
.acct-dd-item:last-child { border-bottom: none; }
.acct-dd-item:hover { background: #f5f5f5; color: #222; }
.acct-dd-signout { color: #c0392b; }
.acct-dd-signout:hover { background: #fff0f0; color: #c0392b; }

/* ── Mobile navigation drawer ───────────────────────────────────────────── */
.mobile-menu {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 990;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
}
.mobile-menu.open { visibility: visible; opacity: 1; }

.mobile-menu-panel {
  background: var(--card);
  width: min(300px, 85vw);
  height: 100%;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.mobile-menu.open .mobile-menu-panel { transform: translateX(0); }

.mobile-menu-header {
  background: linear-gradient(135deg, var(--amber) 0%, var(--terracotta) 100%);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: var(--header-h);
}
#menu-close {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}
.mobile-nav-item {
  display: flex;
  align-items: center;
  padding: 0 20px;
  min-height: 50px;
  font-size: 0.97rem;
  color: var(--dark);
  text-decoration: none;
  border-bottom: 1px solid var(--divider);
  border-top: none;
  border-left: none;
  border-right: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.mobile-nav-item:hover { background: var(--bg); text-decoration: none; }
.mobile-signout { color: var(--terracotta); }
.mobile-menu-sep {
  height: 8px;
  background: var(--bg);
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  #sidebar { display: none !important; }
  #main-nav, .header-actions { display: none !important; }
  .nav-icons { margin-left: auto; }
  .hamburger { display: flex; }
}
@media (max-width: 820px) {
  .login-wrap { flex-direction:column; }
  .login-hero { flex:none; height:260px; min-height:unset; order:-1; }
  .hero-overlay { padding:28px 28px; }
  .hero-overlay h2 { font-size:1.6rem; margin-bottom:8px; }
  .hero-brand { display:none; }
  .login-panel { width:100%; padding:32px 24px; flex:1; justify-content:flex-start; }
  .login-card { max-width:100%; }
}
@media (max-width: 600px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .login-panel { padding:24px 20px; }
  .form-row { flex-direction: column; gap: 0; }
  .page-title { font-size: 1.3rem; }
  #app { padding: 16px 12px 40px; }
}

/* desktop-only — hidden on mobile, shown on wider screens */
.desktop-only { display: none; }
@media (min-width: 768px) { .desktop-only { display: block; } }

/* ── Load More button ───────────────────────────────────────────────────── */
.load-more-btn {
  display: block;
  width: 100%;
  margin: 8px 0 16px;
  padding: 10px;
  background: none;
  border: 1px solid var(--border, #e5e5ea);
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--accent, #007aff);
  text-align: center;
}
.load-more-btn:hover { background: #f0f0f5; }

/* ── Error retry button ─────────────────────────────────────────────────── */
.error-retry-btn {
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  color: inherit;
  cursor: pointer;
  font-size: .85em;
  padding: 2px 8px;
  margin-left: 6px;
}

/* ── Selection bar — mobile ─────────────────────────────────────────────── */
#ev-sel-bar {
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 480px) {
  #ev-sel-bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  #ev-sel-bar button { font-size: .8rem; padding: 5px 10px; }
  #ev-sel-count { width: 100%; text-align: center; }
}

/* ── Login footer ────────────────────────────────────────────────────────── */
.login-footer {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.login-footer a { color: var(--text-muted); }
.login-footer a:hover { color: var(--accent); }

/* ── Onboarding welcome (new-user empty state) ───────────────────────────── */
.onboarding-welcome {
  text-align: center;
  padding: 40px 20px;
  max-width: 520px;
  margin: 0 auto;
}
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  margin: 0 auto;
  max-width: 380px;
}
.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.onboarding-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  margin-top: 2px;
}
.onboarding-hint { font-size: .83rem; color: var(--text-muted); }

/* ── Static pages (ToS / Privacy) ───────────────────────────────────────── */
.static-page {
  max-width: 660px;
  margin: 0 auto;
  padding-bottom: 48px;
}
.static-page h2 {
  font-size: 1.05rem;
  margin: 24px 0 6px;
  color: var(--text-primary);
}
.static-page p { color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; }
.static-meta { color: var(--text-muted); font-size: .85rem; margin-bottom: 20px; }

/* ── Unassigned Faces view ────────────────────────────────────────────────── */
.uf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  padding: 4px 0 24px;
}

.uf-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e5ea);
  transition: box-shadow .15s, border-color .15s;
  text-align: center;
}
.uf-cell:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
  border-color: var(--accent, #007aff);
}

.uf-crop {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  background-color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--border, #e5e5ea);
  position: relative;
}
.uf-cell:hover .uf-crop { border-color: var(--accent, #007aff); }

/* Task 781: rotated background-image crop div inside .uf-crop circle.
   The outer .uf-crop clips via overflow:hidden + border-radius:50%.
   This inner div is sized to fill the container and receives:
     - background-size/position (crop in canonical space via faceCropGeom)
     - transform:rotate() (orientation correction)
   CSS rotation on a div rotates both the element and its background-image,
   so the face appears upright and correctly cropped for any orientation. */
.uf-crop-img {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  transform-origin: center center;
}

.uf-placeholder {
  font-size: 32px;
  color: #aaa;
}

.uf-label {
  font-size: 12px;
  color: var(--text-muted, #8e8e93);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uf-tag-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid var(--accent, #007aff);
  color: var(--accent, #007aff);
  background: transparent;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.uf-tag-btn:hover {
  background: var(--accent, #007aff);
  color: #fff;
}

@media (max-width: 600px) {
  .uf-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }
  .uf-crop { width: 80px; height: 80px; }
}

/* ── Global footer ────────────────────────────────────────────────────────── */
#site-footer {
  text-align: center;
  padding: 12px 16px;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border, #e5e5ea);
  margin-top: auto;
  flex-shrink: 0;
}
#site-footer a { color: var(--text-muted); text-decoration: none; }
#site-footer a:hover { color: var(--accent); }

/* Tab-scoped search (Library/Feed/Inbox): hide the native WebKit clear so the
   custom ✕ button (#<id>-clear) is the only clear affordance. */
input.tab-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
input.tab-search::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

/* ── Family section ───────────────────────────────────────────── */
.family-groups { display: flex; flex-direction: column; gap: 10px; }
.family-group { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.family-group-label { min-width: 70px; font-size: .8rem; font-weight: 600; color: var(--subtle); padding-top: 6px; }
.family-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.family-chip { display: flex; align-items: center; background: var(--surface); border: 1.5px solid var(--divider); border-radius: 20px; padding: 4px 10px 4px 12px; font-size: .85rem; gap: 6px; }
.family-chip-placeholder { opacity: .6; border-style: dashed; }
.family-chip-former { border-style: dashed; }
.family-chip-name { color: var(--accent); text-decoration: none; }
.family-chip-name:hover { text-decoration: underline; }
.family-chip-remove { background: none; border: none; cursor: pointer; color: var(--subtle); font-size: 1rem; padding: 0 2px; line-height: 1; }
.family-chip-remove:hover { color: var(--error); }
/* Add relative picker rows */
.ar-contact-row:hover { background: var(--hover-bg, rgba(0,0,0,.04)); }
.ar-contact-selected { background: var(--accent-light, rgba(79,142,247,.12)) !important; font-weight: 600; }
/* ── Family Tree ────────────────────────────────────────────── */
.tree-container { overflow-x: auto; padding: 16px 0; }
.tree-row { margin-bottom: 20px; }
.tree-row-label { font-size: .75rem; font-weight: 600; color: var(--subtle); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.tree-row-nodes { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.tree-row-main .tree-row-nodes { align-items: center; }
.tree-family-group, .tree-sibling-group, .tree-center-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tree-couple-sep { font-size: 1.1rem; color: var(--subtle); padding: 0 2px; }
.tree-node { background: var(--surface); border: 1.5px solid var(--divider); border-radius: 10px; padding: 10px 14px; cursor: pointer; min-width: 100px; max-width: 160px; transition: border-color .15s; }
.tree-node:hover { border-color: var(--accent); }
.tree-node-center { border-color: var(--accent); border-width: 2.5px; background: var(--accent-surface, rgba(79,142,247,.07)); }
.tree-node-placeholder { opacity: .55; border-style: dashed; }
.tree-node-name { font-size: .88rem; font-weight: 600; color: var(--text); }
.tree-node-dates { font-size: .75rem; color: var(--subtle); margin-top: 3px; }
