/* Photos' visual language: a dark, cinematic gallery by default — the way a
 * photo grid should look — with a light mode for anyone who prefers it.
 * Every color is a token so the two stay in one place. */
:root {
  --bg: #0b0b0d;
  --bg-elev: #17171b;
  --bg-elev-2: #222226;
  --text: #f2f2f3;
  --muted: #9a9aa2;
  --accent: #6ea8ff;
  --accent-2: #a78bfa;
  --danger: #f87171;
  --ok: #34d399;
  --border: #2a2a2f;
  --shadow: 0 12px 32px rgba(0,0,0,.45);
  --radius: 14px;
  --radius-sm: 8px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7f9;
    --bg-elev: #ffffff;
    --bg-elev-2: #eeeef1;
    --text: #17171b;
    --muted: #6b6b76;
    --border: #e3e3e8;
    --shadow: 0 8px 24px rgba(20,20,30,.08);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button { font-family: inherit; }
a { color: inherit; }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- header */
header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
header.top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
header.top .brand .mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
header.top .spacer { flex: 1; }
header.top .who { color: var(--muted); font-size: 13px; margin-right: 4px; display: none; }
@media (min-width: 640px) { header.top .who { display: inline; } }

.iconbtn {
  border: none; background: var(--bg-elev-2); color: var(--text);
  width: 38px; height: 38px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; transition: transform .12s ease, background .12s ease;
}
.iconbtn:hover { background: var(--border); }
.iconbtn:active { transform: scale(.94); }
.iconbtn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

/* --------------------------------------------------------------- tabs --- */
nav.tabs {
  position: sticky; top: 60px; z-index: 19;
  display: flex; gap: 4px; padding: 8px 12px;
  overflow-x: auto; scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: none; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
nav.tabs button.active { background: var(--bg-elev-2); color: var(--text); }

/* -------------------------------------------------------------- main --- */
main { flex: 1; padding: 8px 12px 100px; max-width: 1400px; width: 100%; margin: 0 auto; }

.section-heading {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  margin: 20px 6px 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 4px;
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; } }

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elev-2);
  cursor: pointer;
  border: 2px solid transparent;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 26px;
}
.tile .badge {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  display: flex; align-items: center; gap: 3px;
}
.tile .fav {
  position: absolute; left: 4px; top: 4px; font-size: 13px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.6));
}
.tile.selected { border-color: var(--accent); }
.tile.selected::after {
  content: "✓"; position: absolute; inset: 0;
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 700;
}
.tile.uploading::after {
  content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.45);
}
.tile .progress {
  position: absolute; left: 8px; right: 8px; bottom: 8px; height: 3px;
  background: rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; z-index: 2;
}
.tile .progress > i { display: block; height: 100%; background: var(--accent); width: 0%; }

.empty {
  text-align: center; color: var(--muted); padding: 80px 20px;
}
.empty .big { font-size: 44px; margin-bottom: 12px; }
.empty h2 { color: var(--text); margin: 0 0 6px; }
.empty p { margin: 0 0 18px; }
.empty button {
  border: none; padding: 11px 22px; border-radius: 999px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 14.5px;
}

/* --------------------------------------------------------- albums grid --- */
.albums-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.album-card {
  border-radius: var(--radius); overflow: hidden; background: var(--bg-elev);
  border: 1px solid var(--border); cursor: pointer; box-shadow: var(--shadow);
}
.album-card .cover { aspect-ratio: 1.3; background: var(--bg-elev-2); position: relative; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.album-card .meta { padding: 10px 12px; }
.album-card .meta h3 { margin: 0 0 2px; font-size: 14.5px; }
.album-card .meta p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------- upload fab --- */
.fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 30;
  width: 58px; height: 58px; border-radius: 999px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 26px; box-shadow: var(--shadow); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(.94); }

/* ------------------------------------------------------- upload queue --- */
.upload-tray {
  position: fixed; left: 12px; right: 12px; bottom: 92px; z-index: 25;
  max-width: 420px; margin: 0 auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 14px; font-size: 13.5px;
}
.upload-tray .row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.upload-tray .row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-tray .row .pct { color: var(--muted); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- zip tray */
#zip-tray {
  position: fixed; left: 12px; right: 12px; bottom: 92px; z-index: 25;
  max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px;
}
.zip-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; font-size: 13.5px;
}
.zip-card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.zip-card .head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.zip-card .head .count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.zip-card .bar { height: 5px; border-radius: 5px; background: var(--bg-elev-2); overflow: hidden; }
.zip-card .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0%; transition: width .2s ease; }

/* ------------------------------------------------------------ lightbox --- */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.94);
  display: flex; flex-direction: column;
}
.lightbox .lb-top {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px; color: #fff;
}
.lightbox .lb-top .spacer { flex: 1; }
.lightbox .lb-top .info { font-size: 12.5px; color: rgba(255,255,255,.7); }
.lightbox .lb-stage {
  flex: 1; display: flex; align-items: center; justify-content: center; position: relative;
  overflow: hidden; touch-action: pan-y;
}
.lightbox .lb-stage img, .lightbox .lb-stage video {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
.lightbox .nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.35); color: #fff; border: none; width: 42px; height: 42px;
  border-radius: 999px; font-size: 18px; cursor: pointer; display: none;
}
@media (min-width: 720px) { .lightbox .nav-btn { display: flex; align-items: center; justify-content: center; } }
.lightbox .nav-btn.prev { left: 12px; }
.lightbox .nav-btn.next { right: 12px; }
.lightbox .lb-bar {
  display: flex; justify-content: center; gap: 22px; padding: 14px 12px 22px; color: #fff;
}
.lightbox .lb-bar button {
  background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; opacity: .9;
}
.lightbox .lb-bar button.on { color: #ff6b81; }

/* -------------------------------------------------------------- sheet --- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg-elev); width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0; padding: 8px 6px 20px;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--radius); margin-bottom: 40px; }
}
.sheet .grabber { width: 36px; height: 4px; background: var(--border); border-radius: 4px; margin: 6px auto 10px; }
.sheet button.item, .sheet label.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: none; background: none; color: var(--text); font-size: 15px;
  padding: 13px 14px; border-radius: var(--radius-sm); cursor: pointer;
}
.sheet button.item:hover, .sheet label.item:hover { background: var(--bg-elev-2); }
.sheet button.item.danger { color: var(--danger); }
.sheet input[type=text] {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font-size: 15px; margin: 4px 0 10px;
}

/* -------------------------------------------------------------- toast --- */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; z-index: 80;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ----------------------------------------------------------- sign-in --- */
.gate {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 20px;
}
.gate .mark {
  width: 64px; height: 64px; border-radius: 20px; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.gate h1 { margin: 0 0 8px; }
.gate p { color: var(--muted); margin: 0 0 20px; max-width: 320px; }
.gate a.btn {
  text-decoration: none; padding: 12px 26px; border-radius: 999px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
