/* ═══════════════════════════════════════════════════════════
   PixelVault — style.css
   Mobile-first. Vibrant. Glassy. Built for Android thumbs.
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────── */
:root {
  --bg:            #06060d;
  --bg-soft:       #0b0b17;
  --surface:       rgba(255, 255, 255, 0.055);
  --surface-2:     rgba(255, 255, 255, 0.09);
  --surface-3:     rgba(255, 255, 255, 0.14);
  --border:        rgba(255, 255, 255, 0.10);
  --border-soft:   rgba(255, 255, 255, 0.06);
  --text:          #f3f4fa;
  --text-2:        #b6b9cf;
  --muted:         #8b8fa8;
  --accent:        #7c5cff;
  --accent-2:      #ff4d9d;
  --accent-3:      #22d3ee;
  --danger:        #ff5470;
  --success:       #34d399;
  --grad:          linear-gradient(135deg, #7c5cff 0%, #ff4d9d 55%, #ff8a4c 100%);
  --grad-soft:     linear-gradient(135deg, rgba(124,92,255,.22), rgba(255,77,157,.18));
  --radius-xl:     26px;
  --radius:        18px;
  --radius-sm:     13px;
  --shadow:        0 20px 55px -22px rgba(0, 0, 0, 0.9);
  --shadow-sm:     0 8px 24px -12px rgba(0, 0, 0, 0.8);
  --safe-t:        env(safe-area-inset-top, 0px);
  --safe-b:        env(safe-area-inset-bottom, 0px);
  --safe-l:        env(safe-area-inset-left, 0px);
  --safe-r:        env(safe-area-inset-right, 0px);
  --ease:          cubic-bezier(.32, .72, 0, 1);
}

[data-theme="light"] {
  --bg:            #f3f4fb;
  --bg-soft:       #ffffff;
  --surface:       rgba(255, 255, 255, 0.78);
  --surface-2:     rgba(255, 255, 255, 0.92);
  --surface-3:     rgba(20, 18, 45, 0.06);
  --border:        rgba(20, 18, 45, 0.10);
  --border-soft:   rgba(20, 18, 45, 0.06);
  --text:          #14122b;
  --text-2:        #4b4a63;
  --muted:         #7a7a92;
  --shadow:        0 20px 50px -24px rgba(40, 30, 90, 0.35);
  --shadow-sm:     0 8px 22px -14px rgba(40, 30, 90, 0.35);
}

/* ── Reset ─────────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .4s ease, color .4s ease;
}

body.locked { overflow: hidden; }

img { max-width: 100%; display: block; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

h1, h2, h3, p { margin: 0; }

::selection { background: var(--accent); color: #fff; }

/* ── Ambient background ────────────────────────────────── */
.aurora {
  position: fixed;
  inset: -30%;
  z-index: -2;
  pointer-events: none;
  filter: blur(90px);
  opacity: .75;
  overflow: hidden;
}

.aurora::before,
.aurora::after {
  content: "";
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  will-change: transform;
}

.aurora::before {
  top: -12%;
  left: -18%;
  background: radial-gradient(circle at 30% 30%, #7c5cff 0%, transparent 62%);
  animation: drift1 22s ease-in-out infinite alternate;
}

.aurora::after {
  bottom: -18%;
  right: -20%;
  background: radial-gradient(circle at 60% 60%, #ff4d9d 0%, transparent 62%);
  animation: drift2 26s ease-in-out infinite alternate;
}

[data-theme="light"] .aurora { opacity: .5; }

@keyframes drift1 {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(14vw, 10vh, 0) scale(1.22); }
}
@keyframes drift2 {
  0%   { transform: translate3d(0, 0, 0) scale(1.1); }
  100% { transform: translate3d(-16vw, -12vh, 0) scale(0.9); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  background: linear-gradient(to bottom, var(--bg) 55%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 26px -10px rgba(124, 92, 255, .85);
}

.brand-mark svg { width: 21px; height: 21px; }

.brand-text { min-width: 0; }

.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.15;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text span {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58vw;
}

/* ── Icon buttons ──────────────────────────────────────── */
.icon-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform .18s var(--ease), background .2s ease, border-color .2s ease;
}

.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 19px; height: 19px; }

.icon-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.icon-btn.glass {
  background: rgba(12, 12, 24, .5);
  border-color: rgba(255, 255, 255, .14);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  width: 40px;
  height: 40px;
}

.icon-btn.glass.danger { color: #ff8fa3; }

#themeBtn .ico-sun  { display: none; }
#themeBtn .ico-moon { display: block; }
[data-theme="light"] #themeBtn .ico-sun  { display: block; }
[data-theme="light"] #themeBtn .ico-moon { display: none; }

/* ── Toolbar / search ──────────────────────────────────── */
.toolbar {
  padding: 2px calc(16px + var(--safe-r)) 4px calc(16px + var(--safe-l));
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color .25s ease, box-shadow .25s ease;
}

.search:focus-within {
  border-color: rgba(124, 92, 255, .6);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, .14);
}

.search-ico {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
}

.search input::placeholder { color: var(--muted); font-weight: 400; }

.search input::-webkit-search-cancel-button { display: none; }

.clear-btn {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-3);
}

.clear-btn svg { width: 12px; height: 12px; }

/* ── Chips ─────────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 12px calc(16px + var(--safe-r)) 6px calc(16px + var(--safe-l));
  scroll-snap-type: x proximity;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.1px;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform .18s var(--ease), background .22s ease, color .22s ease, border-color .22s ease;
}

.chip:active { transform: scale(.94); }

.chip .count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
}

.chip.active {
  color: #fff;
  background: var(--grad);
  border-color: transparent;
  box-shadow: 0 10px 24px -12px rgba(124, 92, 255, .9);
}

.chip.active .count {
  background: rgba(255, 255, 255, .25);
  color: #fff;
}

/* ── Gallery ───────────────────────────────────────────── */
.gallery-wrap {
  padding: 10px calc(14px + var(--safe-r)) calc(110px + var(--safe-b)) calc(14px + var(--safe-l));
}

.masonry {
  column-count: 2;
  column-gap: 10px;
}

.card {
  position: relative;
  break-inside: avoid;
  margin-bottom: 10px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transform: translateZ(0);
  transition: transform .22s var(--ease), box-shadow .22s ease;
  animation: pop .42s var(--ease) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(.94) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.card:active { transform: scale(.965); }

.card img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--surface-3);
  transition: opacity .35s ease;
}

.card img.loading { opacity: 0; }

.card-shade {
  position: absolute;
  inset: auto 0 0 0;
  height: 62%;
  background: linear-gradient(to top, rgba(4, 4, 12, .88) 0%, rgba(4, 4, 12, .35) 45%, transparent 100%);
  pointer-events: none;
}

.card-info {
  position: absolute;
  inset: auto 0 0 0;
  padding: 10px 11px 11px;
  pointer-events: none;
}

.card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.15px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .6);
}

.card-cat {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-badge {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(10, 10, 22, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .25s ease, transform .25s var(--ease);
}

.card:active .card-badge { opacity: 1; transform: scale(1); }

.card-badge svg { width: 14px; height: 14px; }

/* ── States ────────────────────────────────────────────── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 58px 24px;
  color: var(--muted);
}

.state[hidden] { display: none; }

.state-emoji { font-size: 46px; line-height: 1; }

.state h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.state p {
  font-size: 13.5px;
  max-width: 280px;
  line-height: 1.55;
}

.state.error .state-emoji { filter: grayscale(.2); }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── FAB ───────────────────────────────────────────────── */
.fab {
  position: fixed;
  right: calc(18px + var(--safe-r));
  bottom: calc(22px + var(--safe-b));
  z-index: 45;
  width: 60px;
  height: 60px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 18px 40px -12px rgba(124, 92, 255, .95), 0 0 0 1px rgba(255, 255, 255, .1) inset;
  transition: transform .2s var(--ease), box-shadow .2s ease;
}

.fab svg { width: 25px; height: 25px; }

.fab:active {
  transform: scale(.9) rotate(90deg);
  box-shadow: 0 10px 26px -12px rgba(124, 92, 255, .9);
}

.fab::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 28px;
  border: 2px solid rgba(124, 92, 255, .35);
  animation: pulse 2.6s ease-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%   { transform: scale(.9); opacity: .7; }
  70%  { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}

/* ── Overlay ───────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 3, 10, .62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}

.overlay.show { opacity: 1; visibility: visible; }

/* ── Bottom sheet ──────────────────────────────────────── */
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 60;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  transform: translate(-50%, 102%);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom: none;
  box-shadow: var(--shadow);
  transition: transform .42s var(--ease);
  will-change: transform;
}

[data-theme="dark"] .sheet {
  background: linear-gradient(180deg, #12122a 0%, #0a0a17 100%);
}

.sheet.show { transform: translate(-50%, 0); }

.grabber {
  flex: 0 0 auto;
  width: 42px;
  height: 4px;
  margin: 10px auto 2px;
  border-radius: 99px;
  background: var(--surface-3);
}

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 12px 20px;
}

.sheet-head h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.4px;
}

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(20px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}

/* ── Dropzone ──────────────────────────────────────────── */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px 18px;
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  background: var(--grad-soft);
  border: 1.6px dashed rgba(124, 92, 255, .5);
  transition: background .25s ease, border-color .25s ease, transform .2s var(--ease);
}

.dropzone:active { transform: scale(.98); }

.dropzone.dragover {
  border-color: var(--accent-2);
  background: rgba(255, 77, 157, .14);
}

.dz-ico {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 24px -12px rgba(124, 92, 255, .9);
  margin-bottom: 4px;
}

.dz-ico svg { width: 22px; height: 22px; }

.dropzone strong {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.2px;
}

.dropzone span {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Previews ──────────────────────────────────────────── */
.previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.previews:empty { display: none; }

.preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-3);
  animation: pop .3s var(--ease) both;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(8, 8, 18, .72);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.preview-remove svg { width: 10px; height: 10px; }

.preview-size {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 6px;
  color: #fff;
  background: rgba(8, 8, 18, .7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Fields ────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 3px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  outline: none;
  resize: none;
  transition: border-color .22s ease, box-shadow .22s ease, background .22s ease;
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted); font-weight: 400; }

.field input:focus,
.field textarea:focus {
  border-color: rgba(124, 92, 255, .65);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, .13);
}

/* ── Switch ────────────────────────────────────────────── */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  flex: 0 0 auto;
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background .25s ease, border-color .25s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  transition: transform .28s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--grad);
  border-color: transparent;
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

.switch-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.switch-text strong { font-size: 13.5px; font-weight: 700; letter-spacing: -.1px; }

.switch-text em {
  font-size: 11.5px;
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}

/* ── Progress ──────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
}

.progress-wrap[hidden] { display: none; }

.progress-bar {
  flex: 1 1 auto;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad);
  transition: width .25s ease;
}

.progress-text {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 52px;
  padding: 0 22px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.2px;
  text-decoration: none;
  transition: transform .18s var(--ease), opacity .2s ease, box-shadow .22s ease;
  user-select: none;
}

.btn:active { transform: scale(.96); }

.btn svg { width: 19px; height: 19px; }

.btn.primary {
  color: #fff;
  background: var(--grad);
  box-shadow: 0 14px 32px -14px rgba(124, 92, 255, .95);
}

.btn.primary:disabled {
  opacity: .42;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn.ghost {
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
}

.btn.danger {
  color: #fff;
  background: linear-gradient(135deg, #ff4d6d, #d92c56);
  box-shadow: 0 14px 30px -14px rgba(255, 77, 109, .9);
}

/* ── Lightbox ──────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: rgba(4, 4, 10, .96);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}

.lightbox.show { opacity: 1; visibility: visible; }

.lb-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
}

.lb-actions { display: flex; gap: 8px; }

.lb-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 42px;
  height: 42px;
  margin-top: -40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(14, 14, 28, .6);
  border: 1px solid rgba(255, 255, 255, .13);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .18s var(--ease), opacity .25s ease;
}

.lb-nav:active { transform: scale(.88); }
.lb-nav svg { width: 20px; height: 20px; }
.lb-nav.prev { left: calc(10px + var(--safe-l)); }
.lb-nav.next { right: calc(10px + var(--safe-r)); }
.lb-nav[hidden] { display: none; }

.lb-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0 12px;
  overflow: hidden;
}

.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 1);
  animation: lbIn .35s var(--ease) both;
}

@keyframes lbIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}

.lb-info {
  flex: 0 0 auto;
  max-height: 44dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px calc(18px + var(--safe-r)) calc(20px + var(--safe-b)) calc(18px + var(--safe-l));
  color: #fff;
  background: linear-gradient(to top, rgba(6, 6, 16, .98), rgba(6, 6, 16, .6) 70%, transparent);
}

.lb-info h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.35px;
  line-height: 1.3;
  word-break: break-word;
}

.lb-info p {
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .72);
  white-space: pre-wrap;
  word-break: break-word;
}

.lb-info p:empty { display: none; }

.lb-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 12px 0 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, .55);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .35px;
  text-transform: uppercase;
  color: #fff;
  background: var(--grad);
}

.lb-info .btn { width: 100%; }

/* ── Confirm ───────────────────────────────────────────── */
.confirm {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 4, 10, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}

.confirm.show { opacity: 1; visibility: visible; }

.confirm-card {
  width: 100%;
  max-width: 340px;
  padding: 26px 22px 20px;
  border-radius: var(--radius-xl);
  text-align: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: scale(.92);
  transition: transform .3s var(--ease);
}

.confirm.show .confirm-card { transform: scale(1); }

.confirm-emoji { font-size: 38px; margin-bottom: 8px; }

.confirm-card h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.confirm-card p {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.confirm-actions .btn { height: 48px; font-size: 14.5px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  z-index: 100;
  max-width: calc(100vw - 40px);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: rgba(18, 18, 34, .94);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translate(-50%, 24px) scale(.94);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s var(--ease), visibility .28s ease;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.toast.success { border-color: rgba(52, 211, 153, .5); }
.toast.error   { border-color: rgba(255, 84, 112, .55); }

/* ── Responsive ────────────────────────────────────────── */
@media (min-width: 520px) {
  .masonry { column-count: 3; column-gap: 12px; }
  .card { margin-bottom: 12px; }
  .brand-text span { max-width: none; }
}

@media (min-width: 820px) {
  body { font-size: 15.5px; }
  .masonry { column-count: 4; }
  .topbar { padding-top: calc(20px + var(--safe-t)); }
  .gallery-wrap { max-width: 1180px; margin: 0 auto; }
  .toolbar, .chips { max-width: 1180px; margin: 0 auto; }
  .topbar { max-width: 1180px; margin: 0 auto; }
  .fab { right: calc(50% - 590px + 18px); }
}

@media (min-width: 1080px) {
  .masonry { column-count: 5; }
}

/* ── Reduced motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}