:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f1b16;
  --muted: #7a7064;
  --line: #ebe4d9;
  --accent: #a1324a;
  --accent-soft: #f6e6e9;
  --gold: #b8935a;
  --radius: 14px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(31, 27, 22, .06), 0 8px 24px rgba(31, 27, 22, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
input { font: inherit; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 999px; padding: 10px 18px; font-weight: 500; text-decoration: none; background: none; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #3a332b; }
.btn-ghost { border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { border-color: #d6ccbd; }
.btn-danger { color: var(--accent); border-color: #ecd0d6; background: #fff; }
.btn-block { width: 100%; padding: 13px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #f3e7dc 0%, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 400px; text-align: center; }
.login-mark, .brand-mark { color: var(--gold); }
.login-mark { font-size: 22px; letter-spacing: 6px; }
.couple { font-family: var(--serif); font-weight: 500; font-size: clamp(38px, 7vw, 56px); line-height: 1.05; margin: 10px 0 8px; letter-spacing: -.5px; }
.login-sub { color: var(--muted); margin: 0 0 32px; }
.login form { text-align: left; background: var(--surface); padding: 24px; border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 14px; }
.login input, .field input, .field select { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fdfbf8; color: var(--ink); font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s; }
.login input:focus, .field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184, 147, 90, .15); }
.form-error { color: var(--accent); font-size: 13px; min-height: 18px; margin: 0 0 10px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(250, 247, 242, .85); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-family: var(--serif); font-size: 21px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.user-menu { position: relative; }
.user-pill { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-weight: 500; font-size: 14px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.menu-head { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.menu button:hover { background: var(--bg); }

/* ---------- Layout ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 20px 120px; }
.hero { text-align: center; padding: 36px 0 22px; }
.hero .couple { font-size: clamp(34px, 5vw, 50px); margin: 0 0 4px; }
.hero-sub { color: var(--muted); margin: 0; }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: inline-flex; background: #f1ebe2; padding: 4px; border-radius: 999px; gap: 2px; overflow-x: auto; max-width: 100%; }
.tab { border: 0; background: none; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; transition: background .15s, color .15s; }
.tab .n { font-weight: 400; opacity: .75; margin-left: 4px; font-variant-numeric: tabular-nums; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.tools { display: flex; gap: 8px; align-items: center; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; outline: 0; background: none; padding: 8px 0; width: 160px; color: var(--ink); }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.view-toggle button { border: 0; background: none; padding: 8px 12px; color: var(--muted); display: grid; place-items: center; }
.view-toggle button.active { background: var(--ink); color: #fff; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); transition: all .15s; }
.chip .n { opacity: .6; margin-left: 4px; }
.chip.active { border-color: var(--ink); color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--ink); }

.staff-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; color: var(--muted); }
.staff-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #efe8de; cursor: zoom-in; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s, transform .5s; }
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.03); }
.tile::after { content: ""; position: absolute; inset: 0; border-radius: 10px; pointer-events: none; transition: box-shadow .15s; }
.tile.mine::after { box-shadow: inset 0 0 0 3px var(--accent); }
.heart-btn { position: absolute; right: 8px; bottom: 8px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); color: #8a8076; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); opacity: 0; transform: scale(.9); transition: opacity .15s, transform .15s, background .15s, color .15s; }
.tile:hover .heart-btn, .tile.mine .heart-btn { opacity: 1; transform: none; }
.tile.mine .heart-btn { background: var(--accent); color: #fff; }
.heart-btn svg { width: 19px; height: 19px; }
.heart-btn.pop { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }
.badge { position: absolute; left: 8px; top: 8px; background: rgba(31, 27, 22, .72); color: #fff; font-size: 11.5px; font-weight: 500; padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px); display: flex; gap: 4px; align-items: center; }
.badge .h { color: #ff9fb1; }
.name-tag { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 11.5px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (hover: none) { .heart-btn { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .wrap { padding: 0 10px 110px; }
  .topbar-inner { padding: 8px 12px; }
  .hero { padding: 22px 0 14px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .tile, .tile::after { border-radius: 6px; }
  .heart-btn { width: 30px; height: 30px; right: 5px; bottom: 5px; }
  .heart-btn svg { width: 15px; height: 15px; }
  .badge { left: 5px; top: 5px; font-size: 10.5px; padding: 2px 6px; }
  .toolbar { gap: 8px; }
  .tools { width: 100%; }
  .search { flex: 1; } .search input { width: 100%; }
  .user-pill #user-name { display: none; }
  .user-pill { padding: 3px 8px 3px 3px; }
  .name-tag { display: none; }
  .staff-actions { padding: 10px 12px; font-size: 13px; }
  .staff-btns { width: 100%; }
  .staff-btns .btn { flex: 1; padding: 8px 10px; font-size: 13px; }
}

/* ---------- List (photographer) ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 44px 56px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.4fr) auto; align-items: center; gap: 14px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row.head { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fcfaf7; }
.row .idx { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.row img { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; background: #efe8de; cursor: zoom-in; display: block; }
.row .fname { font-weight: 500; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.row .muted { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font-size: 13px; }
.dl:hover { border-color: var(--ink); }
@media (max-width: 760px) {
  .row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; padding: 8px 10px; }
  .row .idx, .row .folder-col, .row.head { display: none; }
  .row .pick-col { grid-column: 2; grid-row: 2; font-size: 12px; margin-top: -6px; }
  .row img { width: 48px; height: 48px; grid-row: span 2; }
  .row .dl-col { grid-row: span 2; grid-column: 3; grid-row-start: 1; }
}

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty .big { font-family: var(--serif); font-size: 28px; color: var(--ink); margin-bottom: 6px; }

/* ---------- FAB ---------- */
.fab { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 15; display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 999px; border: 0; background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 10px 30px rgba(31, 27, 22, .25); }
.fab .heart { color: #ff9fb1; }
.fab-label { opacity: .75; font-weight: 400; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #0f0d0b; color: #fff; display: flex; flex-direction: column; }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.lb-info { display: flex; gap: 12px; font-size: 13px; opacity: .8; font-variant-numeric: tabular-nums; }
.lb-top-btns { display: flex; gap: 4px; }
.lb-icon { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center; text-decoration: none; }
.lb-icon:hover { background: rgba(255, 255, 255, .16); }
.lb-icon.dark { background: var(--bg); color: var(--ink); }
.lb-stage { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; }
.lb-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .2s; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center; z-index: 2; }
.lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }
.lb-spinner { position: absolute; width: 30px; height: 30px; border: 2px solid rgba(255, 255, 255, .2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; opacity: 0; transition: opacity .2s; pointer-events: none; }
.lb-spinner.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.lb-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.lb-pickers { font-size: 13px; opacity: .75; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pick { flex: none; display: inline-flex; gap: 8px; align-items: center; border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 600; background: #fff; color: var(--ink); transition: background .15s, color .15s; }
.lb-pick.on { background: var(--accent); color: #fff; }
@media (max-width: 640px) { .lb-nav { display: none; } .lb-bottom { flex-direction: column-reverse; align-items: stretch; } .lb-pick { justify-content: center; } .lb-pickers { text-align: center; } }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(31, 27, 22, .4); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.modal { width: 100%; max-width: 560px; max-height: 90dvh; overflow: auto; background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font-family: var(--serif); font-weight: 600; font-size: 26px; margin: 0; }
.field { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
.member { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.member .meta { flex: 1; min-width: 0; }
.member .meta b { font-weight: 600; }
.member .meta small { display: block; color: var(--muted); }
.role-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); margin-left: 6px; font-weight: 500; }
.add-member { margin-top: 18px; padding-top: 6px; }
.add-member h3 { font-size: 14px; margin: 0 0 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 500px) { .two { grid-template-columns: 1fr; } }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; top: 18px; transform: translate(-50%, -150%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 100; transition: transform .25s ease; box-shadow: var(--shadow); max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); }
