:root {
  --ink: #141414;
  --ink-dim: #767676;
  --line: #e4e2de;
  --paper: #ffffff;
  --panel: #f4f3f0;
  --accent: #2f5ad6;
  --accent-ring: rgba(47, 90, 214, 0.18);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f1ee;
    --ink-dim: #a3a19b;
    --line: #2c2b28;
    --paper: #141311;
    --panel: #1d1c19;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
}

.header-row {
  max-width: 1100px;
  margin: 0 auto;
  height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.header-left { display: flex; gap: 2px; justify-self: start; }

.wordmark {
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  letter-spacing: 0.01em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}
.icon-btn[hidden] { display: none; }
.icon-btn:hover { background: var(--panel); transform: scale(1.06); }

.btn-dark {
  justify-self: end;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}
.btn-dark:hover { transform: translateY(-2px); opacity: 0.85; }
.btn-dark:active { transform: translateY(0) scale(0.98); }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.btn-outline:hover { background: var(--ink); color: var(--paper); }

.btn-full { width: 100%; padding: 14px; margin-top: 6px; }

.search-row {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0 14px;
  animation: dropIn 0.3s var(--ease);
}

#search {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  padding: 8px 2px;
  outline: none;
}
#search::placeholder { color: var(--ink-dim); }

.filter-bar {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 22px;
  overflow-x: auto;
  padding: 0 0 14px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-pill {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 4px 0;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.filter-pill:hover { color: var(--ink); }
.filter-pill.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 20px 90px; }

.empty-state {
  text-align: center;
  color: var(--ink-dim);
  padding: 100px 20px;
  animation: fadeUp 0.6s var(--ease);
}
.empty-state p { margin: 0 0 20px; font-size: 1.05rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px 20px;
}

.card {
  cursor: default;
  animation: popIn 0.5s var(--ease) both;
}

.card-img-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--panel);
  margin-bottom: 12px;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.7s var(--ease);
}

.card:hover .card-img-wrap img { transform: scale(1.08); }

.card-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  color: var(--ink);
  cursor: pointer;
  opacity: 0.9;
  font-size: 0.95rem;
  line-height: 1;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.card-delete:hover { opacity: 1; transform: scale(1.1); }

.card-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: capitalize;
}

.card-color {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-dim);
  text-transform: capitalize;
}

.card-notes {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Overlay + modal */
.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, black 45%, transparent);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: overlayIn 0.35s var(--ease);
}
.overlay:not([hidden]) { display: flex; }

.modal {
  background: var(--paper);
  padding: 30px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.35);
  animation: modalZoom 0.4s var(--ease);
}

.modal h2 {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.3s var(--ease);
}
.modal-close:hover { transform: rotate(90deg); }

.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.field-row .field { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  margin-bottom: 8px;
}

input[type="text"], input[type="url"], input[type="search"], input[type="password"], select, textarea {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  font-family: var(--sans);
  outline: none;
  transition: border-color 0.3s var(--ease);
}

input:focus, select:focus, textarea:focus { border-color: var(--ink); }

textarea { resize: vertical; }

select { cursor: pointer; }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row input { flex: 1; }

.hint { font-size: 0.76rem; color: var(--ink-dim); margin: 8px 2px 0; min-height: 1em; }

.photo-drop {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  color: var(--ink-dim);
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--panel);
  overflow: hidden;
  transition: border-color 0.3s var(--ease);
}
.photo-drop:hover { border-color: var(--ink); }
.photo-drop img { width: 100%; height: 100%; object-fit: cover; animation: popIn 0.4s var(--ease); }

.remove-photo-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.3s var(--ease);
}
.remove-photo-btn:hover { transform: scale(1.12); }

@keyframes popIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalZoom {
  from { opacity: 0; transform: scale(0.9) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 22px 14px; }
}

@media (max-width: 640px) {
  .header-row { grid-template-columns: 1fr auto 1fr; height: 58px; }
  .icon-btn { width: 34px; height: 34px; }
  .wordmark { font-size: 1.25rem; }
  .btn-dark { padding: 9px 14px; font-size: 0.72rem; }
  .container { padding: 22px 14px 70px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 18px 12px; }
  .card-title { font-size: 0.84rem; }
  .card-color, .card-notes { font-size: 0.74rem; }
  .modal { padding: 22px; max-height: 94vh; }
  .field-row { grid-template-columns: 1fr 1fr; gap: 10px; }
}

@media (max-width: 380px) {
  .grid { gap: 14px 10px; }
}
