:root {
  --bg: #0f0f14;
  --bg-2: #1a1a23;
  --bg-3: #252531;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --primary: #6366f1;
  --primary-h: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --favorite: #ec4899;
  --border: #303040;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.music-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 1.5rem; max-width: 1400px; margin: 0 auto; }
.music-sidebar { background: var(--bg-2); border-radius: var(--radius); padding: 1rem; max-height: 70vh; overflow-y: auto; }
.music-sidebar h3 { margin-bottom: .8rem; font-size: .95rem; color: var(--muted); }
.music-sidebar ul { list-style: none; }
.music-sidebar li { padding: .5rem .7rem; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.music-sidebar li:hover { background: var(--bg-3); }
.music-sidebar li.active { background: var(--primary); color: white; }
.music-main h2 { margin-bottom: 1rem; }
.track-table { width: 100%; border-collapse: collapse; }
.track-table th { text-align: left; padding: .6rem .8rem; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--border); }
.track-table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.track-table tr { cursor: pointer; }
.track-table tr:hover { background: var(--bg-2); }
.track-table tr.playing { background: rgba(99, 102, 241, .2); color: var(--primary); font-weight: 600; }
.player { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-2); border-top: 1px solid var(--border); padding: .8rem 1.5rem; display: flex; gap: 1.5rem; align-items: center; z-index: 100; }
.player-info { flex-shrink: 0; min-width: 250px; }
.player-title { font-weight: 600; font-size: .95rem; }
.player-artist { color: var(--muted); font-size: .85rem; }
.player audio { flex: 1; }
@media (max-width: 700px) {
  .music-wrap { grid-template-columns: 1fr; }
  .player { flex-direction: column; gap: .5rem; padding: .6rem; }
  .player audio { width: 100%; }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  background: var(--bg);
  color: var(--fg);
  overscroll-behavior: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font: inherit; }

.quota { font-size: .8rem; color: var(--muted); margin-right: 1rem; }
.upload-zone {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}
#upload-status {
  color: var(--muted);
  font-size: .9rem;
}
#drop-zone {
  position: fixed;
  inset: 0;
  background: rgba(99, 102, 241, .85);
  z-index: 1000;
  display: grid;
  place-items: center;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.album-filter-banner {
  background: var(--bg-2);
  border-left: 3px solid var(--primary);
  padding: .8rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.album-filter-banner a { font-size: .85rem; margin-left: .5rem; }

.drop-message {
  text-align: center;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  border: 4px dashed white;
  padding: 4rem 6rem;
  border-radius: 24px;
}
.drop-icon { font-size: 4rem; margin-bottom: 1rem; }

#upload-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  z-index: 999;
  box-shadow: var(--shadow);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.2rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .logo { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: .5rem; flex: 1; margin-left: 1rem; }
.topbar nav a {
  color: var(--muted);
  padding: .4rem .8rem;
  border-radius: 8px;
  font-weight: 500;
}
.topbar nav a:hover { background: var(--bg-3); color: var(--fg); }
.topbar .user { display: flex; gap: .8rem; align-items: center; font-size: .9rem; color: var(--muted); }

main { padding: 1rem; }

.flash {
  padding: .8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  background: var(--bg-2);
  border-left: 4px solid var(--primary);
}
.flash-error { border-left-color: var(--danger); }



.muted { color: var(--muted); }
.btn-primary {
  background: var(--primary);
  color: white;
  padding: .7rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost { padding: .7rem 1.4rem; border-radius: 10px; color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: center;
}
.login-form {
  background: var(--bg-2);
  padding: 2rem;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(380px, 92vw);
  box-shadow: var(--shadow);
}
.login-form h1 { font-size: 1.6rem; }
.login-form input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: .8rem 1rem;
  border-radius: 10px;
  outline: none;
}
.login-form input:focus { border-color: var(--primary); }
.login-form button {
  background: var(--primary);
  color: white;
  padding: .9rem;
  border-radius: 10px;
  font-weight: 600;
}

/* ---------- Tinder ---------- */
.tinder-wrap {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}
.stack {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  margin-top: .5rem;
}
.card {
  position: absolute;
  inset: 0;
  background: var(--bg-2);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: grab;
  touch-action: none;
  transition: transform .25s ease, opacity .25s ease;
  will-change: transform;
}
.card.dragging { transition: none; cursor: grabbing; }
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.card-meta {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 1.2rem 1rem .9rem;
  background: linear-gradient(to top, rgba(0,0,0,.85), transparent);
  font-size: .85rem;
  color: white;
}
.card-meta .filename { font-weight: 600; margin-bottom: 2px; }
.card-meta .when { color: rgba(255,255,255,.75); font-size: .8rem; }

.badge {
  position: absolute;
  top: 1.4rem;
  padding: .35rem .7rem;
  font-size: 1.4rem;
  font-weight: 800;
  border: 3px solid;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity .1s;
}
.badge-keep { right: 1.4rem; color: var(--success); border-color: var(--success); transform: rotate(15deg); }
.badge-delete { left: 1.4rem; color: var(--danger); border-color: var(--danger); transform: rotate(-15deg); }
.badge-fav { top: 1rem; left: 50%; transform: translateX(-50%); color: var(--favorite); border-color: var(--favorite); }
.badge-arc { bottom: 1rem; left: 50%; top: auto; transform: translateX(-50%); color: var(--muted); border-color: var(--muted); }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  background: var(--bg-3);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.empty h2 { margin-bottom: .8rem; }
.empty p { color: var(--muted); margin-bottom: 1.5rem; }

.actions {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
}
.act {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 2px solid var(--border);
  font-size: 1.6rem;
  display: grid;
  place-items: center;
  transition: transform .15s, border-color .15s;
}
.act:hover { transform: scale(1.08); }
.act:active { transform: scale(.92); }
.act-delete:hover { border-color: var(--danger); }
.act-archive:hover { border-color: var(--muted); }
.act-favorite:hover { border-color: var(--favorite); }
.act-keep:hover { border-color: var(--success); }

.hint { color: var(--muted); font-size: .8rem; text-align: center; }
.hint kbd {
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-family: ui-monospace, monospace;
  font-size: .75rem;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 1rem;
}
.modal-card {
  background: var(--bg-2);
  padding: 1.5rem;
  border-radius: var(--radius);
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: .8rem;
}
.modal-card h3 { margin-bottom: .3rem; }
.modal-card label { font-size: .85rem; color: var(--muted); }
.modal-card input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: .7rem .9rem;
  border-radius: 10px;
  outline: none;
  width: 100%;
}
.modal-card input:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: .8rem; justify-content: flex-end; margin-top: .5rem; }

/* ---------- Browse ---------- */
.browse-wrap { max-width: 1400px; margin: 0 auto; }
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chip {
  padding: .45rem 1rem;
  border-radius: 100px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: white; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .4rem;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-2);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s;
}
.thumb:hover img { transform: scale(1.05); }
.thumb-badge {
  position: absolute;
  top: 6px; right: 6px;
  font-size: 1rem;
}
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.95);
  z-index: 200;
  display: grid;
  place-items: center;
}
.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 1rem; right: 1rem;
  font-size: 2rem;
  color: white;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.lightbox-meta {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7);
  padding: .8rem 1.2rem;
  border-radius: 10px;
  font-size: .9rem;
}

/* ---------- Stats ---------- */
.stats-wrap { max-width: 900px; margin: 0 auto; }
.stats-wrap h1 { margin-bottom: 1.2rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-2);
  border: 2px solid;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.stat-num { font-size: 2.5rem; font-weight: 800; }
.stat-label { color: var(--muted); margin-top: .3rem; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .topbar { padding: .6rem .8rem; gap: .6rem; }
  .topbar nav a { padding: .3rem .6rem; font-size: .9rem; }
  .topbar .user span { display: none; }
  main { padding: .6rem; }
  .act { width: 56px; height: 56px; font-size: 1.4rem; }
}
.lightbox-close { z-index: 201; cursor: pointer; }

.modal[hidden] { display: none !important; }
/* === PhotoCloud v2 additions === */

/* Albums grid */
.albums-wrap { max-width: 1200px; margin: 0 auto; }
.albums-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.albums-header h1 { font-size: 1.6rem; }

.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.album-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: transform .15s, border-color .15s;
}
.album-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}
.album-icon { font-size: 3rem; margin-bottom: .5rem; }
.album-name { font-weight: 600; margin-bottom: .3rem; font-size: 1rem; }
.album-stats { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }
.album-actions { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; }

.btn-primary-mini {
  background: var(--primary);
  color: white;
  text-decoration: none;
  padding: .4rem .8rem;
  border-radius: 8px;
  font-size: .85rem;
}
.btn-primary-mini:hover { background: var(--primary-h); color: white; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}
.empty-state h2 { margin-bottom: .5rem; }
.empty-state p { color: var(--muted); }

/* Tinder header */
.tinder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: .5rem;
  font-size: .9rem;
}
.back-link {
  color: var(--muted);
  text-decoration: none;
  padding: .3rem .6rem;
  border-radius: 6px;
}
.back-link:hover { background: var(--bg-2); color: var(--fg); }
.album-context {
  font-weight: 600;
  color: var(--primary);
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 .5rem;
}
.counter { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Browse actions */
.browse-actions {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.thumb.selected {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
.thumb.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .9rem;
}

.lightbox-actions {
  position: absolute;
  top: 1rem;
  left: 1rem;
}

/* Force hidden */
.modal[hidden],
.lightbox[hidden] { display: none !important; }
