/* Trip Photos — hand-tuned, mobile-first, dark by default with light override */
:root {
  --bg: #0f1117; --bg2: #171a23; --card: #1d2130; --line: #2a2f42;
  --fg: #f2f4f8; --muted: #9aa3b5; --acc: #7ee2c8; --acc2: #6cb4ff;
  --danger: #ff7a8a; --radius: 18px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f6fa; --bg2: #fff; --card: #fff; --line: #e3e6ef; --fg: #1a1e2b; --muted: #5c6579; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select {
  font: inherit; color: var(--fg); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--acc2); }

/* header */
#hdr {
  position: sticky; top: 0; z-index: 5; display: none;
  align-items: center; gap: 8px; padding: calc(var(--sat) + 10px) 14px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
#gallery-count { flex: 1; font-weight: 600; font-size: 15px; }
.hdr-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--card); }

/* views */
.view { display: none; min-height: 100dvh; padding: 16px; padding-bottom: calc(var(--sab) + 96px); }
.view.active { display: block; }

/* login */
#view-login { display: none; place-items: center; }
#view-login.active { display: grid; }
.login-card { width: min(420px, 100%); text-align: center; padding: 24px; }
.logo { font-size: 64px; }
.login-card h1 { margin: 8px 0 2px; font-size: 28px; letter-spacing: -0.5px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card input { margin-bottom: 14px; text-align: center; }
.field-label {
  display: block; text-align: left; color: var(--muted);
  font-size: 13px; font-weight: 600; margin: 0 0 6px 4px;
}
#login-mint { margin-top: 12px; width: 100%; }
.err { color: var(--danger); min-height: 20px; font-size: 14px; margin: 4px 0; text-align: left; }

button.primary {
  width: 100%; padding: 14px; border-radius: 14px; font-weight: 700; font-size: 17px;
  background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #08101c;
  transition: transform .06s ease;
}
button.primary:active { transform: scale(.98); }
button.primary.busy { opacity: .7; }
.ghost {
  padding: 10px 16px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line); font-weight: 600;
}
.ghost.wide { width: 100%; }
.ghost.on { border-color: var(--acc); color: var(--acc); }
.ghost.danger { color: var(--danger); margin-top: 20px; width: 100%; }

/* cards (mint/settings) */
.card {
  max-width: 460px; margin: 24px auto; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card h2 { margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0 0 16px; }
.card label, .card .field-label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row > * { flex: 1; }
#mint-btn { margin-top: 16px; }
.code {
  font: 600 18px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg2); border: 1px dashed var(--line);
  border-radius: 12px; padding: 14px; margin: 14px 0; text-align: center;
  user-select: all; overflow-wrap: anywhere;
}
#mint-qr { display: block; margin: 0 auto 6px; width: 240px; height: 240px; border-radius: 12px; background: #fff; padding: 8px; }

/* gallery grid */
#grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px; border-radius: var(--radius); overflow: hidden;
}
.cell {
  position: relative; aspect-ratio: 1; border-radius: 6px;
  background: var(--bg2) center/cover no-repeat;
  overflow: hidden; transition: transform .1s;
}
.cell:active { transform: scale(.97); }
.cell[data-video]::after {
  content: '▶'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 22px; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.6);
}
.cell.broken::after { content: '×'; }
.cell.nothumb { background: linear-gradient(135deg, var(--card), var(--bg2)); }
.who {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; color: #fff;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
}
#empty { display: none; text-align: center; margin-top: 18vh; color: var(--muted); }
#empty .big { font-size: 56px; }

/* fab */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + 18px); z-index: 5;
  padding: 15px 28px; border-radius: 99px; font-weight: 700; font-size: 16px;
  background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #08101c;
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
.fab:active { transform: translateX(-50%) scale(.97); }
.fab.busy { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

/* lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 20; display: none;
  background: rgba(5,6,10,.94);
}
#lightbox.open { display: grid; place-items: center; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
#lb-stage { max-width: 100vw; max-height: 100dvh; padding: var(--sat) 0 var(--sab); display: grid; place-items: center; }
#lb-stage img, #lb-stage video {
  max-width: 96vw; max-height: 82dvh; border-radius: 8px; object-fit: contain;
}
.lb-meta { color: #dfe4ee; margin-top: 10px; font-size: 14px; }
.lb-del {
  position: fixed; right: 18px; bottom: calc(var(--sab) + 18px);
  padding: 10px 18px; border-radius: 99px; font-weight: 700;
  background: rgba(255,90,110,.16); color: var(--danger);
  border: 1px solid rgba(255,90,110,.4);
}
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px; z-index: 21;
  font-size: 34px; line-height: 1; color: #fff;
  background: rgba(20,24,38,.55); backdrop-filter: blur(6px);
  border-radius: 12px;
}
.lb-nav:disabled { opacity: .25; }
.lb-nav.right { right: 10px; }
.lb-nav:not(.right) { left: 10px; }
#lb-count {
  position: fixed; top: calc(var(--sat) + 12px); left: 50%; transform: translateX(-50%);
  z-index: 21; color: #dfe4ee; font-size: 13px; font-weight: 600;
  background: rgba(20,24,38,.55); padding: 4px 12px; border-radius: 99px;
}
#lb-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 23;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
#lb-bar.show { opacity: 1; }
#lb-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--acc), var(--acc2));
  transition: width .2s ease;
}
#lb-close {
  position: fixed; top: calc(var(--sat) + 8px); right: 12px; z-index: 22;
  width: 40px; height: 40px; border-radius: 12px; font-size: 17px; color: #fff;
  background: rgba(20,24,38,.55); backdrop-filter: blur(6px);
}
#lb-download {
  position: fixed; left: 18px; bottom: calc(var(--sab) + 18px); z-index: 21;
  width: 44px; height: 44px; border-radius: 99px; font-size: 18px; color: #fff;
  background: rgba(20,24,38,.55); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.18);
}
#lb-stage[data-loading]::after {
  content: ''; /* replaced by spinner below when no thumb */
}
.lb-placeholder {
  position: relative; overflow: hidden; border-radius: 8px;
  max-width: 96vw; max-height: 82dvh; aspect-ratio: auto;
  background: var(--bg2) center/cover no-repeat;
  filter: blur(18px) saturate(1.1); transform: scale(1.04);
  min-width: min(70vw, 420px); min-height: min(50dvh, 420px);
  display: grid; place-items: center;
}
.lb-full { animation: lbIn .28s ease; }
@keyframes lbIn { from { opacity: 0; } }
.lb-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: spin .8s linear infinite;
  filter: none;
}
.lb-spinner:first-child:last-child { margin: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* upload banner */
#upload-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + 78px); z-index: 6;
  display: flex; align-items: center; gap: 12px;
  background: #262c3d; color: #fff; padding: 10px 10px 10px 16px;
  border-radius: 99px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.banner-col { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
#upload-banner-text { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#upload-bar {
  height: 5px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden;
}
#upload-bar-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--acc), var(--acc2));
  transition: width .25s ease;
}
#upload-cancel {
  width: 32px; height: 32px; border-radius: 99px; font-size: 14px;
  background: rgba(255,255,255,.14); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}

/* name modal */
#name-modal {
  position: fixed; inset: 0; z-index: 25; display: none;
  background: rgba(5,6,10,.6); backdrop-filter: blur(4px);
  place-items: center; padding: 24px;
}
#name-modal.open { display: grid; animation: fade .18s ease; }
.modal-card { margin: 0; width: min(400px, 100%); }

/* toast */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--sab) + 84px); z-index: 30; opacity: 0; pointer-events: none;
  background: #262c3d; color: #fff; padding: 11px 20px; border-radius: 99px;
  font-size: 14px; font-weight: 600; transition: all .25s ease; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
