/* Dark cinematic theme (default) with a warm light variant. Last updated 2026-10-20 16:10 IST. */
:root {
  --bg: #0e0f13;
  --bg-raised: #16181e;
  --surface: rgba(28, 30, 38, 0.72);
  --surface-solid: #1c1e26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f2efe8;
  --muted: #9a978f;
  --accent: #e3b866;
  --accent-strong: #f0c97a;
  --accent-text: #1a1408;
  --accent-glow: rgba(227, 184, 102, 0.35);
  --like: #3ddc97;
  --nope: #ff6b6b;
  --heart: #ff5c8a;
  --warn-bg: rgba(227, 184, 102, 0.12);
  --warn-text: #f0d9a8;
  --thumb-bg: #1b1d24;
  --shimmer: rgba(255, 255, 255, 0.06);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f3ee;
    --bg-raised: #ffffff;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-solid: #ffffff;
    --border: rgba(30, 24, 12, 0.08);
    --border-strong: rgba(30, 24, 12, 0.18);
    --text: #1d1a15;
    --muted: #716b60;
    --accent: #b8862f;
    --accent-strong: #a07325;
    --accent-text: #ffffff;
    --accent-glow: rgba(184, 134, 47, 0.25);
    --warn-bg: rgba(184, 134, 47, 0.12);
    --warn-text: #6b4b10;
    --thumb-bg: #e8e3da;
    --shimmer: rgba(255, 255, 255, 0.6);
    --shadow: 0 18px 50px rgba(60, 45, 20, 0.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
/* Elements with display rules below must still disappear when given the hidden attribute. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-glow), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(120, 90, 255, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

/* ---------- Header ---------- */
.top-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px;
  padding: 14px max(20px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), #ffe3a8, var(--accent-strong), var(--accent));
  box-shadow: 0 0 18px var(--accent-glow);
  animation: brand-spin 18s linear infinite;
}
@keyframes brand-spin { to { transform: rotate(360deg); } }
.app-name { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }

.tabs {
  position: relative; display: flex; gap: 2px; padding: 4px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 999px;
}
.tab-indicator {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform 0.45s var(--ease-spring), width 0.45s var(--ease-spring);
}
.tab {
  position: relative; z-index: 1; border: 0; background: transparent; color: var(--muted);
  padding: 7px 15px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap;
  transition: color 0.25s ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-text); }
.tab-count { font-weight: 500; opacity: 0.85; }

.search-form {
  position: relative; flex: 1 1 180px; min-width: 140px; display: flex;
}
.search-icon {
  position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.search-form input {
  flex: 1; min-width: 0; padding: 10px 14px 10px 38px; font: inherit; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 999px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }

.account { display: flex; align-items: center; gap: 8px; }
.viewer-chip {
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: var(--bg-raised); border: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.primary-button, .ghost-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  text-decoration: none; white-space: nowrap;
}
.primary-button {
  border: 0; color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 6px 20px var(--accent-glow);
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 10px 28px var(--accent-glow); }
.ghost-button {
  color: var(--text); background: var(--bg-raised); border: 1px solid var(--border);
}
.ghost-button:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.ghost-button.danger { color: var(--nope); }
.ghost-button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.primary-button:active, .ghost-button:active { transform: scale(0.97); }
button:disabled, [aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ---------- Notices ---------- */
.notices { padding: 0 20px; }
.banner {
  margin-top: 14px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--border);
  animation: rise-in 0.4s var(--ease-out);
}
.share-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 10px 14px;
  border-radius: var(--radius); background: var(--bg-raised); border: 1px solid var(--border);
}
.share-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.share-bar a { color: var(--accent); word-break: break-all; font-weight: 600; }
.status-line { padding-top: 10px; color: var(--muted); font-size: 13px; min-height: 1.4em; }

/* ---------- Folder chips ---------- */
.folder-chips {
  display: flex; gap: 8px; padding: 10px 20px 4px; overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
}
.folder-chips::-webkit-scrollbar { display: none; }
.folder-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-raised); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: border-color 0.2s ease, transform 0.25s var(--ease-spring), box-shadow 0.2s ease;
  animation: rise-in 0.45s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms);
}
.folder-chip:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.folder-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.folder-chip img, .folder-chip .chip-all {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--thumb-bg);
}
.folder-chip .chip-all {
  display: grid; place-items: center; font-size: 15px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent)); color: var(--accent-text);
}
.folder-chip .chip-count { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- Grid ---------- */
main { padding: 10px 20px 120px; }
.grid-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.results-heading { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); }
.results-heading #results-text { font-size: 14px; }

.grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.tile {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; cursor: pointer; overflow: hidden;
  border-radius: 12px; background: var(--thumb-bg); content-visibility: auto; contain-intrinsic-size: 170px;
  animation: tile-in 0.55s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 24) * 28ms);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease;
}
.tile::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, var(--shimmer) 50%, transparent 70%);
  background-size: 250% 100%; animation: shimmer 1.4s linear infinite;
}
.tile.loaded::before { display: none; }
.tile img {
  position: relative; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transform: scale(1.06); transition: opacity 0.5s ease, transform 0.8s var(--ease-out);
}
.tile.loaded img { opacity: 1; transform: scale(1); }
.tile::after {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s ease;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.55));
}
@media (hover: hover) {
  .tile:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--accent-glow); z-index: 1; }
  .tile:hover::after { opacity: 1; }
  .tile:hover img { transform: scale(1.06); }
}
.tile-badge {
  position: absolute; z-index: 2; right: 8px; bottom: 8px; padding: 3px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 12px; font-weight: 600;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile-check {
  position: absolute; z-index: 3; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 50%; padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.95); background: rgba(0, 0, 0, 0.35); cursor: pointer;
  display: grid; place-items: center; color: transparent; font-size: 15px; font-weight: 800;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.3s var(--ease-spring), background 0.2s ease, color 0.2s ease;
}
.tile-check:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.55); }
.tile.selected .tile-check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.selecting .tile.selected { transform: scale(0.94); box-shadow: 0 0 0 3px var(--accent); }

.empty-state { color: var(--muted); text-align: center; padding: 70px 16px; font-size: 16px; animation: rise-in 0.5s var(--ease-out); }

/* ---------- Selection bar ---------- */
.selection-bar {
  position: fixed; z-index: 30; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); transform: translateX(-50%);
  animation: bar-in 0.45s var(--ease-spring);
}
#selection-summary { font-weight: 600; white-space: nowrap; }

/* ---------- Viewer ---------- */
.viewer {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(6, 7, 10, 0.92); color: #eee;
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
}
.viewer[open] { animation: fade-in 0.3s ease; }
.viewer::backdrop { background: rgba(0, 0, 0, 0.6); }
.viewer-stage {
  position: absolute; inset: 0 0 60px 0; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.viewer-stage img, .viewer-stage video {
  max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: zoom-in 0.4s var(--ease-out);
}
.viewer-nav, .viewer-icon {
  position: absolute; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.18); cursor: pointer;
  color: #fff; background: rgba(20, 20, 26, 0.55); border-radius: 999px; text-decoration: none;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s ease, transform 0.25s var(--ease-spring);
}
.viewer-nav { width: 54px; height: 54px; font-size: 34px; top: calc(50% - 57px); }
.viewer-nav:hover:not(:disabled), .viewer-icon:hover { background: rgba(20, 20, 26, 0.85); transform: scale(1.08); }
.viewer-nav:disabled { opacity: 0.2; cursor: default; }
.viewer-nav.prev { left: 18px; }
.viewer-nav.next { right: 18px; }
.viewer-actions { position: absolute; top: 16px; right: 16px; display: flex; gap: 10px; }
.viewer-icon { position: static; width: 44px; height: 44px; font-size: 22px; }
#viewer-like { color: var(--heart); }
#viewer-like.pop { animation: heart-pop 0.45s var(--ease-spring); }
.viewer-info {
  position: absolute; left: 0; right: 0; bottom: 0; height: 60px;
  display: flex; align-items: center; gap: 16px; padding: 0 20px; font-size: 13px; color: #b8b5ad;
  overflow: hidden; white-space: nowrap;
}
.viewer-counter { color: var(--accent); font-weight: 700; }
.viewer-name { color: #fff; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.viewer-info a { color: var(--accent); margin-left: auto; }
.viewer-error {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px; background: rgba(40, 30, 10, 0.85); color: #f0d9a8;
}

/* ---------- Swipe ---------- */
.swipe-section { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 4px; }
.pill-select {
  padding: 8px 14px; font: inherit; font-weight: 600; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 999px;
}
.card-stack {
  position: relative; width: min(440px, 100%); height: min(calc(100vh - 330px), 620px); min-height: 320px;
}
.swipe-card {
  position: absolute; inset: 0; border-radius: 22px; overflow: hidden; background: #000;
  box-shadow: var(--shadow), 0 0 0 1px var(--border); touch-action: none; user-select: none; cursor: grab;
  transition: transform 0.5s var(--ease-spring);
}
.swipe-card.top { animation: card-in 0.5s var(--ease-spring); }
.swipe-card.under { transform: scale(0.94) translateY(16px); opacity: 0.7; pointer-events: none; filter: brightness(0.7); }
.swipe-card.dragging { transition: none; cursor: grabbing; }
.swipe-card.flying { transition: transform 0.32s var(--ease-out), opacity 0.32s ease; opacity: 0; }
.swipe-card img, .swipe-card video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.stamp {
  position: absolute; top: 28px; padding: 6px 14px; border: 4px solid; border-radius: 10px;
  font-size: 30px; font-weight: 900; letter-spacing: 3px; opacity: 0; background: rgba(0, 0, 0, 0.25);
}
.stamp-like { left: 22px; color: var(--like); transform: rotate(-14deg); }
.stamp-nope { right: 22px; color: var(--nope); transform: rotate(14deg); }
.card-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 18px 16px; color: #fff; font-size: 14px; font-weight: 500;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
}
.sound-toggle {
  position: absolute; right: 14px; bottom: 14px; padding: 6px 12px; border: 0; border-radius: 999px;
  background: rgba(0, 0, 0, 0.6); color: #fff; font: inherit; font-size: 13px; cursor: pointer;
}
.swipe-buttons { display: flex; gap: 40px; }
.round-button {
  width: 66px; height: 66px; border-radius: 999px; font-size: 28px; cursor: pointer;
  background: var(--bg-raised); border: 2px solid var(--border);
  box-shadow: var(--shadow); transition: transform 0.3s var(--ease-spring), box-shadow 0.2s ease;
}
.round-button.skip { color: var(--nope); }
.round-button.like { color: var(--like); }
.round-button:hover { transform: scale(1.1); }
.round-button.skip:hover { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.15), var(--shadow); }
.round-button.like:hover { box-shadow: 0 0 0 6px rgba(61, 220, 151, 0.15), var(--shadow); }
.round-button:active { transform: scale(0.92); }
.swipe-empty { text-align: center; padding: 50px 16px; animation: rise-in 0.5s var(--ease-out); }
.swipe-empty-title { font-size: 20px; font-weight: 700; }
.swipe-hint { color: var(--muted); font-size: 13px; margin: 0; text-align: center; }

/* ---------- Find me ---------- */
.me-section { max-width: 1100px; margin: 0 auto; }
.me-hero, .me-working {
  max-width: 620px; margin: 20px auto; padding: 32px; border-radius: 22px; text-align: center;
  box-shadow: var(--shadow); animation: rise-in 0.5s var(--ease-out);
}
.me-title { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.02em; }
.me-lead { color: var(--muted); margin: 0 0 22px; }
.consent {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 14px; margin-bottom: 20px;
  border-radius: 12px; background: var(--bg-raised); border: 1px solid var(--border); font-size: 14px; cursor: pointer;
}
.consent input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.me-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-button[aria-disabled="true"] input { cursor: not-allowed; }
.me-note { color: var(--muted); font-size: 13px; margin: 18px 0 0; }
.me-error { color: var(--nope); margin: 16px 0 0; font-weight: 600; }
.me-working p { color: var(--muted); }
.spinner {
  display: inline-block; width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
.me-results { animation: rise-in 0.5s var(--ease-out); }
.me-results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.me-results-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.me-subtitle { margin: 26px 0 12px; font-size: 16px; color: var(--muted); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 40; left: 50%; top: 84px; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; font-weight: 600;
  background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  animation: toast-in 0.4s var(--ease-spring);
}

.skipped-panel { margin: 0 20px 24px; color: var(--muted); font-size: 13px; }
.skipped-panel li { word-break: break-all; }

/* ---------- Sign-in page ---------- */
.sign-in-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; overflow: hidden; }
.sign-in-page::before, .sign-in-page::after {
  content: ""; position: fixed; width: 520px; height: 520px; border-radius: 50%; filter: blur(80px); opacity: 0.45; z-index: -1;
  animation: drift 16s ease-in-out infinite alternate;
}
.sign-in-page::before { background: var(--accent); top: -160px; left: -140px; }
.sign-in-page::after { background: #6f5bff; bottom: -200px; right: -160px; animation-delay: -8s; }
.sign-in-card {
  width: min(380px, 100%); padding: 34px 30px; border-radius: 24px; box-shadow: var(--shadow);
  animation: rise-in 0.6s var(--ease-out);
}
.sign-in-card .brand { justify-content: center; margin-bottom: 6px; }
.sign-in-card form { display: flex; flex-direction: column; gap: 8px; }
.sign-in-card label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 8px; }
.sign-in-card input {
  padding: 12px 14px; font: inherit; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.sign-in-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.sign-in-card .primary-button { margin-top: 16px; padding: 12px; }
.sign-in-hint { color: var(--muted); margin: 0 0 14px; text-align: center; }
.sign-in-error { color: var(--nope); margin: 8px 0 0; font-weight: 600; text-align: center; }
.sign-in-card.shake { animation: shake 0.45s ease; }

/* ---------- Find me: tips, scanning, celebration ---------- */
.me-hero-emoji {
  font-size: 54px; line-height: 1; margin-bottom: 8px; display: inline-block; transform-origin: 70% 80%;
  animation: wave 2.4s ease-in-out infinite;
}
.photo-tips {
  list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); text-align: left;
}
.photo-tips li {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 14px;
  background: var(--bg-raised); border: 1px solid var(--border); font-size: 13px; color: var(--muted);
  animation: tip-pop 0.6s var(--ease-spring) both;
}
.photo-tips li:nth-child(1) { animation-delay: 0.05s; }
.photo-tips li:nth-child(2) { animation-delay: 0.15s; }
.photo-tips li:nth-child(3) { animation-delay: 0.25s; }
.photo-tips li:nth-child(4) { animation-delay: 0.35s; }
.photo-tips li:nth-child(5) { animation-delay: 0.45s; }
.photo-tips b { color: var(--text); font-size: 14px; }
.tip-emoji { font-size: 26px; line-height: 1; flex: none; display: inline-block; animation: bob 3s ease-in-out infinite; }
.photo-tips li:nth-child(2) .tip-emoji { animation-delay: -0.6s; }
.photo-tips li:nth-child(3) .tip-emoji { animation-delay: -1.2s; }
.photo-tips li:nth-child(4) .tip-emoji { animation-delay: -1.8s; }
.photo-tips li:nth-child(5) .tip-emoji { animation-delay: -2.4s; }
.photo-tips li:hover .tip-emoji { animation: wiggle 0.5s ease-in-out; }
.photo-tips.tips-glow li { animation: tip-glow 1.2s ease-in-out 2; }
.me-hero.shake { animation: shake 0.45s ease; }
.me-actions .file-button span { font-size: 18px; }

.me-working { overflow: hidden; }
.scan-frame {
  position: relative; width: 168px; height: 168px; margin: 6px auto 18px; border-radius: 50%;
  border: 3px solid var(--accent); box-shadow: 0 0 0 8px var(--accent-glow), 0 0 40px var(--accent-glow);
  animation: pulse-ring 1.6s ease-in-out infinite;
}
.scan-frame img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--thumb-bg); }
.scan-line {
  position: absolute; left: 8%; right: 8%; height: 3px; top: 10%; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-strong), transparent);
  box-shadow: 0 0 14px var(--accent); animation: scan 1.4s ease-in-out infinite alternate;
}
.scan-sparkle { position: absolute; font-size: 22px; animation: orbit 2.8s linear infinite; }
.scan-sparkle.s1 { top: -6px; left: 50%; }
.scan-sparkle.s2 { bottom: 0; right: -10px; animation-delay: -0.9s; }
.scan-sparkle.s3 { bottom: 4px; left: -12px; animation-delay: -1.8s; }
.scan-message { font-weight: 600; color: var(--text); min-height: 1.5em; animation: fade-in 0.4s ease; }

.me-results { position: relative; }
.emoji-burst { position: absolute; left: 50%; top: 40px; width: 0; height: 0; pointer-events: none; z-index: 5; }
.emoji-burst span {
  position: absolute; font-size: 26px; opacity: 0;
  animation: burst 1.9s var(--ease-out) forwards; animation-delay: var(--d, 0ms);
}

/* ---------- Likes on tiles, download all, progress ---------- */
.grid-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tile-like {
  position: absolute; z-index: 3; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; cursor: pointer; font-size: 18px; line-height: 1; color: #fff;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.25s var(--ease-spring), opacity 0.2s ease, background 0.2s ease;
}
.tile-like.liked { color: var(--heart); background: rgba(0, 0, 0, 0.6); }
.tile-like:hover { transform: scale(1.12); }
.tile-like.pop { animation: heart-pop 0.45s var(--ease-spring); }
@media (hover: hover) {
  .tile .tile-like:not(.liked) { opacity: 0; }
  .tile:hover .tile-like, .tile:focus-within .tile-like { opacity: 1; }
}
.selecting .tile-like { display: none; }
/* Bigger circles on touch screens so they are easy to tap. */
@media (pointer: coarse) {
  .tile-check, .tile-like { width: 36px; height: 36px; }
  .tile-check { top: 6px; left: 6px; }
}
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.size-dialog {
  width: min(460px, calc(100% - 28px)); padding: 26px; border-radius: 22px; color: var(--text);
  box-shadow: var(--shadow);
}
.size-dialog[open] { animation: rise-in 0.35s var(--ease-out); }
.size-dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); }
.size-dialog h2 { margin: 0 0 16px; font-size: 20px; }
.kind-choice { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.kind-choice label {
  display: block; cursor: pointer; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-raised);
  padding: 10px; text-align: center; transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.kind-choice input { position: absolute; opacity: 0; pointer-events: none; }
.kind-choice label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.kind-choice label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.kind-choice label.disabled { opacity: 0.4; cursor: not-allowed; }
.kind-choice span, .size-option { display: flex; flex-direction: column; gap: 3px; }
.kind-choice small, .size-option small { color: var(--muted); font-size: 12px; }
.size-buttons { display: grid; gap: 10px; }
.size-option {
  text-align: left; padding: 14px 16px; border-radius: 14px; cursor: pointer; font: inherit; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--border); transition: border-color 0.2s ease, transform 0.2s var(--ease-out);
}
.size-option:hover { border-color: var(--accent); transform: translateY(-1px); }
.size-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.size-cancel { margin-top: 14px; width: 100%; }

.download-panel {
  position: fixed; z-index: 35; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  width: min(360px, calc(100% - 32px)); max-height: 50vh; overflow: auto; padding: 12px 14px; border-radius: 18px;
  box-shadow: var(--shadow); animation: rise-in 0.35s var(--ease-out);
}
.selecting .download-panel { bottom: 88px; }
.download-panel-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 8px; }
.download-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.download-row { display: grid; gap: 6px; animation: rise-in 0.3s var(--ease-out); }
.download-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.download-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.download-cancel {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px;
}
.download-cancel:hover { color: var(--text); background: var(--bg-raised); }
.download-track { height: 6px; border-radius: 999px; background: var(--bg-raised); overflow: hidden; }
.download-fill {
  height: 100%; width: 0; border-radius: 999px; transition: width 0.25s ease;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}
.download-row.indeterminate .download-fill {
  width: 40% !important; animation: indeterminate 1.2s ease-in-out infinite;
}
.download-row.done .download-fill { background: var(--like); }
.download-row.failed .download-fill { background: var(--nope); }
.download-detail { font-size: 12px; color: var(--muted); }

/* Offline mode (served by the Worker while the Mac is off): hide what needs the Mac. */
.offline .tile-like, .offline [data-view="swipe"], .offline [data-view="liked"], .offline #viewer-like,
.offline #rescan-button, .offline .select-toggle, .offline .tile-check, .offline #me-retry, .offline #me-forget { display: none !important; }

/* ---------- Animations ---------- */
@keyframes tile-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes bar-in { from { opacity: 0; transform: translate(-50%, 30px) scale(0.95); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes heart-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.1); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-8deg); } }
@keyframes tip-pop { from { opacity: 0; transform: translateY(14px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes wiggle { 25% { transform: rotate(-14deg) scale(1.15); } 75% { transform: rotate(14deg) scale(1.15); } }
@keyframes tip-glow { 50% { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); } }
@keyframes pulse-ring { 50% { box-shadow: 0 0 0 14px var(--accent-glow), 0 0 50px var(--accent-glow); } }
@keyframes scan { from { top: 10%; } to { top: 88%; } }
@keyframes orbit { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(6px, -8px) rotate(12deg); } 100% { transform: translate(0, 0) rotate(0); } }
@keyframes burst {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4) rotate(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 260px)) scale(1.1) rotate(var(--r)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .tile img { opacity: 1; transform: none; }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  .top-bar { gap: 10px; padding: 10px 14px; }
  .brand { order: 1; }
  .account { order: 2; margin-left: auto; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 7px 6px; flex: 1 1 auto; font-size: 14px; }
  .account { gap: 6px; }
  .account .ghost-button, .viewer-chip { padding: 6px 10px; font-size: 13px; }
  .toast { top: auto; bottom: calc(90px + env(safe-area-inset-bottom)); max-width: calc(100% - 28px); text-align: center; }
  .search-form { order: 4; flex-basis: 100%; }
  .notices, main { padding-left: 14px; padding-right: 14px; }
  .folder-chips { padding-left: 14px; padding-right: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
  .tile { border-radius: 8px; }
  .viewer-nav { width: 44px; height: 44px; font-size: 28px; }
  .viewer-nav.prev { left: 8px; }
  .viewer-nav.next { right: 8px; }
  .viewer-meta { display: none; }
  .card-stack { height: calc(100svh - 380px); }
  .swipe-section > .swipe-hint { display: none; }
  .stamp { font-size: 22px; }
  .me-hero, .me-working { padding: 24px 18px; }
  .photo-tips { grid-template-columns: 1fr 1fr; gap: 8px; }
  .photo-tips li { padding: 10px; font-size: 12px; }
  .photo-tips li:last-child { grid-column: 1 / -1; }
  .me-hero-emoji { font-size: 44px; }
  .selection-bar { left: 12px; right: 12px; transform: none; justify-content: space-between; padding-left: 14px; animation: none; }
  .download-panel { right: 12px; left: 12px; width: auto; }
  .kind-choice { grid-template-columns: 1fr; }
  .grid-toolbar { flex-wrap: wrap; }
  #select-all { display: none; }
}
