:root {
  --bg: #1c1a17;
  --surface: #26231f;
  --surface-raised: #2e2a25;
  --border: #3a352e;
  --gold: #c9a227;
  --gold-soft: #e4c55e;
  --ivy: #5a7052;
  --ivy-soft: #7c9573;
  --steel: #4f6b78;
  --steel-soft: #7a97a3;
  --text: #f2efe9;
  --text-muted: #a39c8f;
  --danger: #b3401f;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .brand {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: inherit; }

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.login-card .brand {
  font-size: 2.1rem;
  color: var(--gold-soft);
  margin-bottom: 4px;
}
.login-card .tagline {
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 28px;
  font-size: 0.95rem;
}
.login-form input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 14px;
}
.login-form button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  background: var(--gold);
  color: #1c1a17;
}
.login-form .error {
  color: #e08a6a;
  font-size: 0.9rem;
  margin: -6px 0 12px;
}

/* ---------- App shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(28, 26, 23, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
}
.topbar-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.topbar .brand {
  font-size: 1.35rem;
  color: var(--gold-soft);
  margin: 0;
}
.topbar .icon-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip.active {
  background: var(--gold);
  color: #1c1a17;
  border-color: var(--gold);
  font-weight: 600;
}
.chip.vibe.active {
  background: var(--ivy);
  color: #f2efe9;
  border-color: var(--ivy);
}
.chip.surface.active {
  background: var(--steel);
  color: #f2efe9;
  border-color: var(--steel);
}

.vibe-row { margin-top: 8px; }

/* ---------- Gallery ---------- */
.gallery-wrap {
  padding: 16px;
  padding-bottom: 100px;
}
.gallery {
  columns: 1;
  column-gap: 12px;
}
@media (min-width: 480px) {
  .gallery { columns: 2; }
}
@media (min-width: 768px) {
  .gallery { columns: 3; }
}
@media (min-width: 1100px) {
  .gallery { columns: 4; }
}

.card {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.card.just-saved {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.35);
}
.card img {
  display: block;
  width: 100%;
  height: auto;
}
.card .tag-strip {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.mini-tag {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(28, 26, 23, 0.78);
  color: var(--gold-soft);
  backdrop-filter: blur(2px);
}
.mini-tag.surface {
  color: var(--steel-soft);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 24px;
}
.empty-state h2 { color: var(--text); margin-bottom: 8px; }
.empty-state a { color: var(--gold-soft); font-weight: 600; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: #1c1a17;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  z-index: 20;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.92);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 65vh;
  border-radius: var(--radius);
  object-fit: contain;
  touch-action: pan-y;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(28, 26, 23, 0.6);
  border: 1px solid var(--border);
  color: var(--gold-soft);
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.lightbox-nav:disabled {
  opacity: 0.2;
  pointer-events: none;
}
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }
.lightbox-meta {
  width: 100%;
  max-width: 480px;
  margin-top: 16px;
  text-align: center;
}
.lightbox-meta .tags {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.lightbox-meta .notes {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.lightbox-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.lightbox-actions button,
.lightbox-actions a {
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-close { background: var(--surface-raised); color: var(--text); }
.btn-edit { background: var(--steel); color: #f2efe9; }
.btn-delete { background: var(--danger); color: #fff; }

/* ---------- Upload page ---------- */
.upload-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}
.upload-wrap h1 {
  color: var(--gold-soft);
  font-size: 1.5rem;
}
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.drop-zone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 20px;
  background: var(--surface);
}
.drop-zone strong { color: var(--gold-soft); }
.drop-zone input { display: none; }

.field-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 20px 0 8px;
}

.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pill {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.pill.selected.gender { background: var(--gold); color: #1c1a17; border-color: var(--gold); font-weight: 600; }
.pill.selected.vibe { background: var(--ivy); color: #f2efe9; border-color: var(--ivy); font-weight: 600; }
.pill.selected.surface { background: var(--steel); color: #f2efe9; border-color: var(--steel); font-weight: 600; }

.custom-vibe-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.custom-vibe-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.custom-vibe-row button {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
}

textarea.notes-input {
  width: 100%;
  min-height: 70px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}

.preview-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.preview-list img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.submit-btn {
  width: 100%;
  padding: 15px;
  margin-top: 24px;
  border-radius: var(--radius);
  background: var(--gold);
  color: #1c1a17;
  font-weight: 700;
  font-size: 1rem;
}
.submit-btn:disabled {
  opacity: 0.5;
}

.status-msg {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}
.status-msg.success { color: var(--ivy-soft); }
.status-msg.error { color: #e08a6a; }
