:root {
  --page-bg: #eae0d1;
  --panel-bg: #faecdc;
  --panel-bg-2: #f1e3ce;
  --maroon: #500217;
  --maroon-dark: #3a0110;
  --gold: #a6793b;
  --gold-light: #c9a15a;
  --cream: #fdf3e4;
  --ink: #2a1414;
  --ink-soft: #6b5c4f;
  --whatsapp: #1f8a5c;
  --danger: #7a1a1a;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(80, 2, 23, 0.12);
  --shadow-lg: 0 20px 60px rgba(58, 1, 16, 0.35);
  --hero-1: #4a0c1e;
  --hero-2: #370717;
  --hero-3: #2a050f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

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

h1, h2 { margin: 0; }

/* ================= Landing screen ================= */

.landing {
  min-height: 100dvh;
  min-height: 100vh;
  background: radial-gradient(120% 95% at 50% 22%, var(--hero-1) 0%, var(--hero-2) 55%, var(--hero-3) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.landing[hidden] { display: none; }

.landing-inner {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 6vh, 48px);
}

.landing-logo {
  width: min(72vw, 300px);
  height: auto;
}

.metal-tiles {
  display: flex;
  gap: clamp(10px, 3vw, 18px);
  width: 100%;
  justify-content: center;
}

.metal-tile {
  flex: 1 1 0;
  min-width: 0;
  max-width: 170px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(201, 161, 90, 0.35);
  border-radius: 14px;
  padding: clamp(16px, 4vw, 22px) 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 3vw, 16px);
}
.metal-tile:active { background: rgba(255, 255, 255, 0.08); }

.sphere {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sphere-silver {
  background: radial-gradient(circle at 32% 26%, #ffffff 0%, #e2e7ec 32%, #a9b0b8 66%, #cfd5db 100%);
  box-shadow: inset 0 -4px 8px rgba(60, 66, 74, 0.4), inset 0 3px 6px rgba(255, 255, 255, 0.7), 0 0 14px rgba(220, 225, 230, 0.45);
}
.sphere-gold {
  background: radial-gradient(circle at 32% 26%, #fff8e8 0%, #f0d9a0 28%, #c9a15a 60%, #8b6530 100%);
  box-shadow: inset 0 -4px 8px rgba(80, 50, 10, 0.4), inset 0 3px 6px rgba(255, 245, 220, 0.6), 0 0 14px rgba(201, 161, 90, 0.4);
}
.sphere-img {
  width: 48px;
  height: auto;
  flex-shrink: 0;
}

.metal-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  letter-spacing: 2.5px;
  font-size: clamp(15px, 3.6vw, 20px);
  color: #e7ce9b;
  text-transform: uppercase;
  white-space: nowrap;
}

.view-all-link {
  background: none;
  border: none;
  color: var(--gold-light);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: clamp(16px, 3.8vw, 20px);
  letter-spacing: 0.5px;
}

/* ================= Catalog screen ================= */

.catalog-screen[hidden] { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--page-bg);
  border-bottom: 1px solid rgba(80, 2, 23, 0.1);
  padding: env(safe-area-inset-top) 0 0 0;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  border: none;
  background: none;
  padding: 0;
  align-self: flex-start;
}

.brand-logo {
  height: 44px;
  width: auto;
}

/* ---------- Search ---------- */

.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--ink-soft);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  height: 52px;
  border-radius: 26px;
  border: none;
  background: #fff;
  padding: 0 46px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
#searchInput:focus { box-shadow: 0 0 0 3px rgba(166, 121, 59, 0.28); }

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--panel-bg-2);
  color: var(--maroon);
  font-size: 15px;
}

/* ---------- Metal tabs (primary axis) ---------- */

.metal-tabs {
  display: flex;
  gap: 8px;
}

.metal-tab {
  flex: 1;
  height: 42px;
  border-radius: 999px;
  border: 1.5px solid rgba(80, 2, 23, 0.18);
  background: #fff;
  color: var(--maroon);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 14px;
}
.metal-tab.active {
  background: var(--maroon);
  color: var(--cream);
  border-color: var(--maroon);
}

/* ---------- Category chip row ---------- */

.chip-row-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  height: 36px;
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: var(--maroon);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.active { background: var(--maroon); color: var(--cream); }

.show-all-btn {
  flex-shrink: 0;
  height: 36px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1.5px solid var(--gold);
  background: var(--panel-bg);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Main / grid ---------- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.status-msg { text-align: center; color: var(--ink-soft); padding: 40px 0; font-size: 16px; }
.status-msg.error { color: var(--danger); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state p { margin: 4px 0; font-size: 17px; }
.empty-sub { font-size: 14px !important; opacity: 0.8; }

.grid { column-count: 2; column-gap: 14px; }
@media (min-width: 640px) { .grid { column-count: 3; } }
@media (min-width: 900px) { .grid { column-count: 4; } }
@media (min-width: 1200px) { .grid { column-count: 5; } }

.card {
  break-inside: avoid;
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1px solid rgba(80, 2, 23, 0.06);
  transition: transform 0.12s ease;
}
.card:active { transform: scale(0.97); }
.card img { width: 100%; display: block; background: var(--panel-bg-2); }

.card-body { padding: 12px 14px 14px; }

.card-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.category-tag, .metal-tag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.category-tag { background: var(--panel-bg-2); color: var(--gold); }
.metal-tag { background: var(--maroon); color: var(--cream); }

/* ---------- Floating add button ---------- */

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--maroon);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(58, 1, 16, 0.45);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { background: var(--maroon-dark); }

/* ---------- Modals (shared) ---------- */

.modal, .viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(58, 1, 16, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.viewer { background: #0a0505; align-items: stretch; flex-direction: column; overflow-y: auto; }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--panel-bg);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 20px; margin-bottom: 20px; }
}

.small-card { text-align: center; }
.small-card h2 { font-family: 'Cormorant Garamond', serif; color: var(--maroon); font-size: 22px; margin-bottom: 6px; }
.modal-sub { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 18px; }

.modal-head-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.modal-head-row h2 { font-family: 'Cormorant Garamond', serif; color: var(--maroon); font-size: 24px; font-weight: 600; flex: 1; }

.back-btn, .close-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: #fff; color: var(--maroon); font-size: 18px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.back-btn { font-size: 24px; }

.all-categories-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.chip-with-delete {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 999px;
  overflow: hidden;
}
.chip-with-delete .chip { border-radius: 999px 0 0 999px; }
.chip-with-delete .chip.active { border-radius: 999px 0 0 999px; }
.chip-delete-x {
  height: 36px;
  width: 32px;
  border: none;
  background: var(--panel-bg-2);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  border-radius: 0 999px 999px 0;
}

/* ---------- Upload / New Design ---------- */

.upload-card { max-width: 520px; }

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin: 18px 0 8px;
}
.optional-tag { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-soft); }

.photo-pill-row { display: flex; gap: 10px; flex-wrap: wrap; }

.pill-btn {
  height: 44px; padding: 0 18px; border-radius: 999px; border: none;
  background: var(--panel-bg-2); color: var(--maroon);
  font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill-btn svg { width: 18px; height: 18px; }
.pill-btn.primary-pill { background: var(--maroon); color: var(--cream); }
.pill-btn.danger-pill { background: var(--danger); color: #fff; }

.photo-dropzone {
  display: block; width: 100%; min-height: 220px; margin-top: 14px;
  border: 1.5px dashed rgba(80, 2, 23, 0.35); border-radius: var(--radius);
  background: rgba(80, 2, 23, 0.03); padding: 0; overflow: hidden;
}

.dropzone-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 220px; color: var(--ink-soft); font-size: 14px; padding: 20px; text-align: center;
}
.dropzone-empty svg { width: 40px; height: 40px; opacity: 0.6; }

.preview-img { width: 100%; max-height: 320px; object-fit: contain; display: block; background: var(--panel-bg-2); }

.text-input {
  width: 100%; height: 50px; border-radius: 10px;
  border: 1.5px solid rgba(80, 2, 23, 0.15); background: #fff; padding: 0 14px;
  font-size: 15.5px; font-family: inherit; color: var(--ink); outline: none;
}
.text-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(166, 121, 59, 0.18); }

textarea#captionInput {
  width: 100%; border-radius: 10px; border: 1.5px solid rgba(80, 2, 23, 0.15);
  background: #fff; padding: 12px 14px; font-size: 15px; font-family: inherit;
  color: var(--ink); resize: vertical; outline: none;
}
textarea#captionInput:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(166, 121, 59, 0.18); }

.category-chooser { display: flex; flex-wrap: wrap; gap: 8px; }
.category-chooser .chip { background: var(--panel-bg-2); }
.category-chooser .chip.active { background: var(--maroon); color: var(--cream); }
.category-chooser .add-category-chip { border: 1.5px dashed var(--gold); background: transparent; color: var(--gold); }

.save-btn {
  width: 100%; height: 52px; margin-top: 24px; border-radius: 10px; border: none;
  background: var(--maroon); color: var(--cream); font-size: 15px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.save-btn:disabled { background: #c9a9ac; color: #ffe7eb; pointer-events: none; }

.btn-row-inline { display: flex; gap: 10px; margin-top: 8px; justify-content: center; }
.btn-row-inline .pill-btn { flex: 1; justify-content: center; }

/* ---------- Fullscreen viewer ---------- */

.viewer-close {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px;
  background: rgba(255, 255, 255, 0.15); color: #fff; z-index: 2;
}

.viewer-image-wrap {
  min-height: 55vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
#viewerImg { max-width: 100%; max-height: 60vh; object-fit: contain; border-radius: 10px; }

.viewer-panel {
  background: var(--panel-bg); border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
}

.viewer-title-row { display: flex; align-items: baseline; gap: 10px; }
.viewer-title-row h2 { font-family: 'Montserrat', sans-serif; font-size: 22px; font-weight: 700; color: var(--ink); flex: 1; }

.edit-link { border: none; background: none; color: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: 1px; padding: 4px; }

.viewer-title-edit-row { display: flex; gap: 8px; align-items: center; }
.viewer-title-edit-row .text-input { flex: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.icon-btn.confirm { background: var(--maroon); color: #fff; }
.icon-btn.cancel { background: #fff; color: var(--ink); }

.viewer-tags { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }

.viewer-caption { color: var(--ink-soft); font-size: 15px; line-height: 1.6; white-space: pre-wrap; margin: 0 0 20px; }

.viewer-actions { display: flex; gap: 16px; align-items: center; }

.whatsapp-btn {
  flex: 1; height: 50px; border-radius: 999px; border: 1.5px solid var(--whatsapp);
  background: transparent; color: var(--whatsapp); font-size: 14px; font-weight: 700;
  letter-spacing: 0.4px; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.whatsapp-btn svg { width: 18px; height: 18px; }
.whatsapp-btn:disabled { opacity: 0.6; pointer-events: none; }

.delete-btn {
  border: none; background: none; color: var(--danger); font-size: 13.5px;
  font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; padding: 8px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--maroon-dark); color: var(--cream);
  padding: 12px 20px; border-radius: 30px; font-size: 14.5px; z-index: 200;
  box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
}
.toast.error { background: var(--danger); }

/* ---------- Small phone tightening ---------- */

@media (max-width: 380px) {
  .metal-label { letter-spacing: 1.5px; }
  .brand-logo { height: 38px; }
  #searchInput { height: 48px; font-size: 15px; }
}

/* Belt-and-suspenders: [hidden] must always win over any class that sets
   display, regardless of selector order/specificity elsewhere in this file. */
[hidden] { display: none !important; }
