:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --ink: #171717;
  --muted: #767671;
  --hairline: #e8e6e1;
  --accent: #4f7a5f;
  --accent-soft: #e8efe9;
  --danger: #b3402f;
  --shadow-sm: 0 2px 8px rgba(23, 23, 23, 0.04);
  --shadow-md: 0 12px 32px rgba(23, 23, 23, 0.07);
  --shadow-lg: 0 24px 60px -12px rgba(23, 23, 23, 0.16);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Work Sans', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, video { max-width: 100%; display: block; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 40px 28px 100px; }
h1, h2 { font-family: 'Playfair Display', Georgia, serif; margin: 0; }
.muted { color: var(--muted); font-size: 14px; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 28px; margin-bottom: 40px; border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-size: 24px; letter-spacing: 0.01em; }
.brand .eyebrow { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 0.14em; color: var(--accent); text-transform: uppercase; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; border: none;
  padding: 12px 22px; border-radius: 999px; font-size: 14px; cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 4px; border-radius: 6px; }
.btn.danger { background: var(--danger); }

input, select {
  font: inherit; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--hairline); width: 100%; background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.card {
  border: 1px solid var(--hairline); border-radius: 18px; padding: 26px;
  margin-bottom: 20px; background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.badge {
  font-size: 10px; padding: 5px 12px; border-radius: 999px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
}
.badge.personal { background: #f3e8d9; color: #8a6a2f; }

.gallery-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; }
.gallery-card {
  border: 1px solid var(--hairline); border-radius: 18px; overflow: hidden;
  background: var(--surface); cursor: pointer; transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.gallery-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.gallery-cover {
  aspect-ratio: 4/3; background: #f1efe9; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; overflow: hidden;
}
.gallery-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.gallery-card:hover .gallery-cover img { transform: scale(1.05); }
.gallery-card-body { padding: 18px 18px 20px; }
.gallery-card-body h3 { font-family: 'Playfair Display', serif; font-size: 18px; margin: 8px 0 5px; }

.empty { color: var(--muted); text-align: center; padding: 48px 0; }

.dropzone {
  border: 2px dashed var(--hairline); border-radius: 16px; padding: 48px 24px;
  text-align: center; color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.dropzone svg { width: 32px; height: 32px; margin-bottom: 10px; color: var(--accent); }
.dropzone strong { color: var(--ink); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }

.upload-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; margin-top: 16px;
}
.upload-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; }
.upload-thumb img, .upload-thumb video { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb .ring-wrap {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
}
.upload-thumb .ring { width: 40px; height: 40px; transform: rotate(-90deg); }
.upload-thumb .ring circle { fill: none; stroke-width: 4; }
.upload-thumb .ring .bg { stroke: rgba(255,255,255,0.25); }
.upload-thumb .ring .fg { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset 0.2s; }
.upload-thumb .pct { position: absolute; color: #fff; font-size: 12px; font-weight: 600; }
.upload-thumb.error .ring-wrap { background: rgba(179,64,47,0.75); }
.upload-thumb .err-label { position: absolute; inset: 0; display:flex; align-items:center; justify-content:center; color:#fff; font-size: 11px; padding: 6px; text-align: center; }

.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-top: 16px;
}
.item-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; }
.item-tile img, .item-tile video { width: 100%; height: 100%; object-fit: cover; }
.item-tile .fav-dot {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--danger); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px;
}
.item-tile .del {
  position: absolute; top: 6px; left: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; opacity: 0; transition: opacity 0.15s;
}
.item-tile:hover .del { opacity: 1; }
.item-tile .collection-chip {
  position: absolute; bottom: 6px; left: 6px; right: 6px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 10px; padding: 3px 6px;
  border-radius: 6px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-tile.selectable { cursor: pointer; }
.item-tile .check {
  position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.85); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.item-tile.selected .check { background: var(--accent); border-color: var(--accent); }
.item-tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }

.collection-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.collection-row:last-child { border-bottom: none; }
.collection-row .fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.collection-row input, .collection-row textarea {
  border: 1px solid transparent; padding: 4px 6px; border-radius: 6px;
}
.collection-row input:hover, .collection-row textarea:hover { border-color: var(--hairline); }
.collection-row input { font-weight: 600; }
.collection-row textarea { font-size: 13px; color: var(--muted); resize: vertical; min-height: 40px; }
.collection-row .actions { display: flex; gap: 4px; }

.selection-bar {
  position: sticky; bottom: 16px; margin-top: 16px; z-index: 30;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.selection-bar .btn { padding: 8px 14px; font-size: 13px; }
.selection-bar .btn.secondary { background: rgba(255,255,255,0.15); color: #fff; }
.selection-bar select { width: auto; padding: 8px 10px; font-size: 13px; background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.2); }
.selection-bar select option { color: #111; }
.new-collection-form {
  background: var(--accent-soft); border-radius: 12px; padding: 14px; margin-top: 12px;
}
.new-collection-form input, .new-collection-form textarea { margin-top: 8px; }

.login-card { max-width: 400px; margin: 12vh auto 0; padding: 40px 36px; box-shadow: var(--shadow-lg); border: none; }
.login-card .eyebrow {
  font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 0.14em;
  color: var(--accent); text-transform: uppercase; display: block; margin-bottom: 10px;
}
.login-card h2 { font-size: 26px; }
.login-card .field { margin-top: 14px; }

/* --- Gallery detail: sidebar shell ------------------------------------ */
.gallery-shell { display: flex; align-items: flex-start; gap: 48px; }
.side-nav {
  width: 210px; flex-shrink: 0; position: sticky; top: 32px;
  display: flex; flex-direction: column;
}
.side-nav-title { font-family: 'Playfair Display', serif; font-size: 21px; margin: 12px 0 0; line-height: 1.25; }
.side-tabs { display: flex; flex-direction: column; margin-top: 28px; }
.side-tab {
  text-align: left; background: none; border: none; border-left: 2px solid transparent; cursor: pointer;
  padding: 9px 0 9px 14px; color: var(--muted); font-size: 14px;
  display: flex; align-items: center; gap: 8px; transition: color 0.15s, border-color 0.15s;
}
.side-tab:hover { color: var(--ink); }
.side-tab.active { border-left-color: var(--accent); color: var(--ink); font-weight: 600; }
.tag-new {
  font-size: 9px; background: var(--accent); color: #fff; padding: 2px 7px;
  border-radius: 999px; font-weight: 700; letter-spacing: 0.04em;
}
.tab-panels { flex: 1; min-width: 0; }

@media (max-width: 760px) {
  .gallery-shell { flex-direction: column; }
  .side-nav { width: 100%; position: static; }
  .side-tabs { flex-direction: row; overflow-x: auto; gap: 6px; }
  .side-tab { white-space: nowrap; }
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-top: 18px; }
.stat-tile { border: 1px solid var(--hairline); border-radius: 14px; padding: 16px; background: var(--surface); }
.stat-tile .num { font-family: 'Playfair Display', serif; font-size: 28px; display: block; }
.stat-tile .label { color: var(--muted); font-size: 13px; margin-top: 2px; }

.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.option-card {
  border: 2px solid var(--hairline); border-radius: 12px; padding: 14px; cursor: pointer;
  text-align: center; background: var(--surface); transition: border-color 0.15s;
}
.option-card:hover { border-color: var(--accent); }
.option-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.option-card .sample { font-size: 18px; margin-bottom: 6px; }
.option-card .label { font-size: 12px; color: var(--muted); }

.palette-swatch {
  width: 56px; height: 56px; border-radius: 50%; cursor: pointer; position: relative;
  border: 2px solid transparent; overflow: hidden; display: flex; flex-direction: column;
}
.palette-swatch span { flex: 1; display: block; }
.palette-swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.palette-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.palette-item { text-align: center; }
.palette-item .label { font-size: 11px; color: var(--muted); margin-top: 6px; max-width: 70px; }

.design-preview { margin-top: 20px; }
.design-preview .frame-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
.design-preview .frame-toggle button { padding: 6px 12px; font-size: 12px; }
.design-preview iframe {
  width: 100%; height: 640px; border: 1px solid var(--hairline); border-radius: 14px; background: #fff;
  transition: max-width 0.2s ease;
}
.design-preview.mobile iframe { max-width: 380px; }
