:root {
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --surface-2: #232329;
  --text: #eaeaea;
  --text-dim: #9a9aa2;
  --accent: #5b8cff;
  --danger: #ff5b6f;
  --border: #2c2c33;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ---------- auth ---------- */

.view.center, #auth-view, #pending-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 { margin-top: 0; }

#auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 10px;
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
}
.tab.active { background: var(--accent); color: white; }

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}
.auth-form button {
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.error { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ---------- app shell ---------- */

#app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#app-header h1 { font-size: 18px; margin: 0; margin-right: auto; }
#app-header nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn, #upload-btn, #logout-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.nav-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
#upload-btn { background: var(--accent); border-color: var(--accent); color: white; }

#main-content { padding: 20px; max-width: 1200px; margin: 0 auto; }

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.grid-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}
.grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-item .dup-badge {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.7); color: white;
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
}

#load-more {
  display: block;
  margin: 20px auto;
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

/* ---------- lists (albums, connections, admin) ---------- */

.list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.list-row button {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 13px;
}
.list-row button.danger { background: var(--danger); }

#create-album-form, #search-user-form {
  display: flex;
  gap: 8px;
}
#create-album-form input, #search-user-form input {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
#create-album-form button, #search-user-form button {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

/* ---------- upload drawer ---------- */

.drawer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.drawer-content {
  background: var(--surface);
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 24px;
}
#file-input {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 12px;
}
#advanced-settings {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
#advanced-settings label { display: block; padding: 6px 0; font-size: 14px; }
#advanced-settings summary { cursor: pointer; color: var(--text-dim); }

.upload-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.upload-item .bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.upload-item .bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}
.upload-item.error .bar-fill { background: var(--danger); }
.upload-item.dup { color: var(--text-dim); }

#close-drawer, #close-share-modal {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  margin-top: 8px;
}

/* ---------- share modal ---------- */

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 360px;
}
#public-link-display {
  word-break: break-all;
  font-size: 13px;
  background: var(--surface-2);
  padding: 10px;
  border-radius: 6px;
}

@media (max-width: 600px) {
  #app-header { padding: 10px 14px; }
  #main-content { padding: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
