:root {
  --paper: #fbf8f3;
  --paper2: #f2ece2;
  --ink: #111;
  --muted: #6f675c;
  --gold: #9a8467;
  --gold-2: #b07b52;
  --line: #e2d8c8;
  --danger: #b0524d;
  --serif: 'Cormorant Garamond', 'legitima', serif;
  --jp: 'Zen Old Mincho', 'ten-mincho-text', 'Hiragino Mincho ProN', serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--jp);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }

.eyebrow {
  font-family: var(--serif);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gold);
  margin: 0 0 8px;
}
.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(154, 132, 103, 0.15); }
.btn {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #fff;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  letter-spacing: 0.08em;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--ghost { background: transparent; color: var(--gold); }
.btn--ghost:hover { background: var(--paper2); }

/* ---------- gate ---------- */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fff 0, transparent 60%),
    var(--paper);
}
.gate__card {
  width: min(420px, 100%);
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 44px 28px 36px;
  box-shadow: 0 20px 60px rgba(60, 40, 10, 0.06);
}
.gate__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 40px;
  letter-spacing: 0.06em;
  margin: 0;
  line-height: 1.1;
}
.gate__date { font-family: var(--serif); letter-spacing: 0.2em; color: var(--muted); margin: 8px 0 22px; }
.gate__lead { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.gate__form { display: grid; gap: 12px; }
.gate__form .input { text-align: center; letter-spacing: 0.3em; font-size: 20px; }
.gate__error { color: var(--danger); font-size: 13px; margin: 14px 0 0; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--sat)) 16px 10px;
  background: rgba(251, 248, 243, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top__brand { display: flex; flex-direction: column; line-height: 1.2; }
.top__names { font-family: var(--serif); font-size: 22px; letter-spacing: 0.08em; }
.top__sub { font-family: var(--serif); font-size: 12px; letter-spacing: 0.18em; color: var(--gold); margin-top: 3px; }
.top__meta { font-family: var(--serif); font-size: 13px; letter-spacing: 0.1em; color: var(--muted); white-space: nowrap; }

/* ---------- main ---------- */
.main { padding: 0 0 calc(110px + var(--sab)); max-width: 1400px; margin: 0 auto; }
.hint { text-align: center; font-size: 12.5px; color: var(--muted); margin: 18px 16px 12px; line-height: 1.9; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0 2px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px; padding: 0 4px; } }
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  background: var(--paper2);
  overflow: hidden;
  display: block;
  width: 100%;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.tile img.is-loaded { opacity: 1; }
.tile__badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  pointer-events: none;
}
.tile__mine {
  position: absolute;
  left: 6px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}
.tile--processing::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
.tile--failed { background: #f3e3e2; }
.tile--failed::after { content: '×'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--danger); font-size: 26px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; line-height: 2; }
.sentinel { height: 1px; }
.loading { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--sab));
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 14px 24px 14px 20px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.fab__plus { font-size: 18px; line-height: 1; }
.fab:active { transform: translateX(-50%) scale(0.97); }

/* ---------- uploads panel ---------- */
.uploads {
  margin: 12px 12px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.uploads__head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.uploads__close { border: 0; background: none; font-size: 20px; color: var(--muted); padding: 0 4px; }
.uploads__list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.uprow { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.uprow__thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--paper2); }
.uprow__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uprow__bar { height: 4px; background: var(--paper2); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.uprow__bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s linear; }
.uprow__status { color: var(--muted); white-space: nowrap; }
.uprow--done .uprow__status { color: var(--gold); }
.uprow--error .uprow__status { color: var(--danger); }
.uprow__retry { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; margin-left: 6px; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 15, 8, 0.45);
  display: grid;
  place-items: end center;
  padding: 16px;
}
@media (min-width: 640px) { .modal { place-items: center; } }
.modal__card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 24px 22px calc(20px + var(--sab));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}
.modal__title { font-size: 18px; font-weight: 500; margin: 0 0 6px; }
.modal__lead { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }
.modal__summary { font-size: 12.5px; color: var(--muted); margin: 4px 0 14px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- lightbox ---------- */
.lb {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0b0a09;
  color: #fff;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.lb__stage { position: absolute; inset: 0; display: grid; place-items: center; }
.lb__stage img, .lb__stage video {
  max-width: 100vw;
  max-height: 100dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #000;
}
.lb__stage video { width: 100vw; max-height: 100dvh; }
.lb__stage .lb__msg { text-align: center; padding: 24px; font-size: 14px; line-height: 2; color: #ddd; }
.lb__stage .lb__msg a { color: #fff; }
.lb__close, .lb__nav {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.lb__close { top: calc(12px + var(--sat)); right: 12px; }
.lb__nav { top: 50%; transform: translateY(-50%); font-size: 34px; }
.lb__nav--prev { left: 10px; }
.lb__nav--next { right: 10px; }
@media (max-width: 639px) { .lb__nav { display: none; } }
.lb__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 40px 16px calc(14px + var(--sab));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.lb__bar > * { pointer-events: auto; }
.lb__info { min-width: 0; font-size: 12.5px; line-height: 1.6; }
.lb__info strong { display: block; font-weight: 500; font-size: 14px; }
.lb__info span { color: #cfc8bd; font-family: var(--serif); letter-spacing: 0.06em; }
.lb__info p { margin: 2px 0 0; color: #eee; }
.lb__actions { display: flex; gap: 8px; flex-shrink: 0; }
.lb__btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  text-decoration: none;
  letter-spacing: 0.08em;
}
.lb__btn--danger { border-color: rgba(255, 120, 110, 0.7); color: #ffb3ad; }
.lb__btn--confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
.lb__counter {
  position: absolute;
  top: calc(22px + var(--sat));
  left: 0; right: 0;
  text-align: center;
  font-family: var(--serif);
  letter-spacing: 0.15em;
  font-size: 13px;
  color: #cfc8bd;
  pointer-events: none;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--sab));
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(17, 17, 17, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast--error { background: var(--danger); }

/* ---------- uploads notice ---------- */
.uploads__notice {
  background: #fff6e8;
  border: 1px solid #efd9b3;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0 4px;
  font-size: 12.5px;
  line-height: 1.7;
}
.uploads__notice ul { margin: 4px 0 6px; padding-left: 18px; }
.uploads__notice-title { margin: 0; font-weight: 500; color: #8a5a1a; }
.uploads__notice-body { margin: 4px 0 0; }
.uploads__notice-body strong { color: var(--danger); }
.uploads__notice-ok { color: var(--muted); }
.lb__hint { margin: 2px 0 0; font-size: 11.5px; color: #b8b0a3; }

/* ---------- admin (mobile first) ---------- */
.admin-body { background: var(--paper); }
.admin { padding: 12px 12px calc(120px + var(--sab)); max-width: 1100px; margin: 0 auto; }
.top__actions { display: flex; gap: 6px; align-items: center; }
.top__link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
}
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card--wide { grid-column: 1 / -1; }
.card__label { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.card__value { font-family: var(--serif); font-size: 28px; line-height: 1.1; margin-top: 4px; }
.card__sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.meter { height: 8px; background: var(--paper2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--gold); width: 0; transition: width 0.3s ease; }
.meter i.is-warn { background: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.actions--grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .actions--grid { grid-template-columns: 1fr 1fr; } }
.btn--block { display: block; width: 100%; text-align: center; text-decoration: none; padding: 13px 16px; }
.btn--sm { padding: 9px 14px; font-size: 13.5px; }
.btn--danger { background: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: #963f3a; border-color: #963f3a; }
.hint--left { text-align: left; margin: 4px 2px 12px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--muted);
}
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip--action { color: var(--gold); border-color: var(--gold); }
.grid--admin .tile { cursor: pointer; }
.tile--select .tile__check {
  position: absolute;
  top: 6px; left: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.tile--select.is-selected .tile__check { background: var(--gold); border-color: #fff; }
.tile--select.is-selected .tile__check::after {
  content: '';
  position: absolute;
  left: 6px; top: 2px;
  width: 6px; height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.tile--select.is-selected img { opacity: 0.55; }
.tile--select.is-selected::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--gold); z-index: 1; pointer-events: none; }
.tile__open {
  position: absolute;
  top: 4px; right: 4px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 14px;
  text-decoration: none;
  z-index: 2;
}
.selbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + var(--sab));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
}
.selbar__info { display: flex; flex-direction: column; line-height: 1.3; font-size: 12px; color: var(--muted); min-width: 60px; }
.selbar__info strong { font-size: 15px; color: var(--ink); font-weight: 500; }
.selbar__btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
