:root {
  --bg: #101216;
  --panel: #1a1d23;
  --panel-2: #22262e;
  --text: #e8eaed;
  --muted: #9aa0a8;
  --accent: #4d9fff;
  --danger: #e5534b;
  --border: #2c313a;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); }

/* --- nav ------------------------------------------------------------- */
.topnav {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topnav .brand { font-weight: 650; margin-right: 8px; }
.topnav a { color: var(--muted); }
.topnav a.active, .topnav a:hover { color: var(--text); }
.logout-form { margin-left: auto; }

/* --- buttons / forms -------------------------------------------------- */
button {
  background: var(--accent); color: #fff; border: 0;
  padding: 8px 14px; border-radius: var(--radius);
  font: inherit; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.danger { color: var(--danger); }
button.linklike { background: none; border: 0; color: var(--muted); padding: 4px; }
button.linklike:hover { color: var(--text); }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font: inherit;
}
label { display: block; margin: 10px 0; }
label.check { display: flex; gap: 8px; align-items: center; }

/* --- login ------------------------------------------------------------ */
.login-box {
  max-width: 340px; margin: 12vh auto; padding: 28px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.login-box h1 { margin-top: 0; font-size: 20px; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 12px; }

/* --- page head / selection bar ---------------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 22px; margin: 10px 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.selection-bar {
  position: sticky; top: 52px; z-index: 15;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px;
}

/* --- grid -------------------------------------------------------------- */
.grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
@media (max-width: 500px) { .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }
.cell {
  position: relative; margin: 0; aspect-ratio: 1;
  background: var(--panel-2); border-radius: 6px; overflow: hidden;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .badge {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px;
  padding: 1px 7px; border-radius: 10px;
}
.cell .status-badge {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(0,0,0,.65); color: var(--muted); font-size: 11px;
  padding: 1px 7px; border-radius: 10px;
}
.cell .select-toggle {
  position: absolute; top: 6px; left: 6px; width: 22px; height: 22px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.85);
  background: rgba(0,0,0,.35); display: none; align-items: center;
  justify-content: center; color: #fff; font-size: 13px;
}
.cell:hover .select-toggle, .grid.selecting .select-toggle { display: flex; }
.cell.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.cell.selected .select-toggle { display: flex; background: var(--accent); border-color: var(--accent); }
#grid-sentinel { height: 1px; }

/* --- album grid --------------------------------------------------------- */
.album-grid .cell { aspect-ratio: 4 / 3; }
.album-grid .cell figcaption {
  position: absolute; inset: auto 0 0 0; padding: 20px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  font-size: 13px; color: #fff;
}
.album-grid .cell .count { color: rgba(255,255,255,.7); }

/* --- upload panel -------------------------------------------------------- */
.upload-panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0;
}
.upload-panel h2 { font-size: 15px; margin: 4px 0 8px; }
.upload-panel ul { list-style: none; margin: 0; padding: 0; }
.upload-panel li { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.upload-panel .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-panel progress { width: 160px; height: 8px; }
.upload-panel .ustatus { min-width: 90px; text-align: right; color: var(--muted); }
.upload-panel .ustatus.err { color: var(--danger); }
.drop-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(16,18,22,.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; border: 3px dashed var(--accent);
}

/* --- lightbox ------------------------------------------------------------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.94);
  display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-content { max-width: 100vw; max-height: 100vh; display: flex; align-items: center; justify-content: center; }
.lb-content img, .lb-content video { max-width: 96vw; max-height: 92vh; object-fit: contain; }
.lb-close, .lb-prev, .lb-next {
  position: absolute; z-index: 61; background: rgba(0,0,0,.4); color: #fff;
  border: 0; font-size: 30px; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-caption { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
  color: var(--muted); font-size: 13px; }
.lb-download {
  position: absolute; top: 18px; left: 16px; z-index: 61;
  background: rgba(0,0,0,.5); padding: 8px 14px; border-radius: var(--radius); color: #fff;
}

/* --- dialogs / tables ------------------------------------------------------ */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; max-width: 420px; width: calc(100vw - 40px);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; font-size: 17px; }
.dialog-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.dialog-row input[type=text] { flex: 1; min-width: 120px; }
#album-picker-list { max-height: 40vh; overflow-y: auto; }
#album-picker-list button { display: block; width: 100%; text-align: left; margin: 4px 0;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.share-url-row { display: flex; gap: 8px; }
.share-url-row input { flex: 1; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 500; }
.data-table .revoked { color: var(--muted); text-decoration: line-through; }
section { margin: 24px 0; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
