:root {
  --bg: #131722;
  --panel: #1c2230;
  --panel-2: #252d3f;
  --border: #3a4358;
  --text: #f4f6fa;
  --muted: #aab4c8;
  --accent: #7c8cff;
  --accent-hover: #97a4ff;
  --danger: #ff6b78;
  --ok: #3ecf8e;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Centered auth card (setup / login / 404) ---------- */
.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.card h1 { font-size: 20px; margin-bottom: 6px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

input[type="text"], input[type="password"], input[type="search"], select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

input:focus, select:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); }
.btn.block { width: 100%; margin-top: 20px; }
.btn.ghost {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
.btn.ghost:hover { border-color: var(--accent); background: var(--panel-2); }
.btn.danger { background: transparent; border: 1px solid var(--border); color: var(--danger); font-weight: 500; }
.btn.danger:hover { border-color: var(--danger); background: rgba(239, 85, 99, 0.08); }
.btn.small { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }

.error {
  background: rgba(239, 85, 99, 0.12);
  border: 1px solid rgba(239, 85, 99, 0.4);
  color: #ff8f9a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 4px;
}

/* ---------- Viewer page ---------- */
.viewer {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 18px;
}

.viewer .media-frame {
  max-width: min(1100px, 100%);
  display: flex;
  justify-content: center;
}

.viewer img, .viewer video {
  max-width: 100%;
  max-height: 78vh;
  border-radius: var(--radius);
  background: #000;
}

.viewer .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.viewer .meta .name { color: var(--text); font-weight: 600; font-size: 14px; }
.viewer .meta .dot::before { content: "·"; }

.viewer .actions { display: flex; gap: 8px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  transition: transform 0.25s ease;
  z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Dashboard ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.topbar .brand { font-weight: 700; font-size: 16px; margin-right: auto; }
.topbar .brand span { color: var(--accent); }

.main { padding: 22px; max-width: 1500px; margin: 0 auto; }

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}
.controls input[type="search"] { max-width: 280px; }
.controls select { width: auto; }
.controls .count { color: var(--muted); font-size: 13px; margin-left: auto; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(100, 115, 255, 0.05);
  color: var(--text);
}

.upload-progress {
  margin: -8px 0 20px;
  display: none;
}
.upload-progress.active { display: block; }
.upload-progress .bar-track {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}
.upload-progress .bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s;
}
.upload-progress .label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.item.hidden-item { opacity: 0.55; }

.item .thumb {
  aspect-ratio: 16 / 10;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.item .thumb img, .item .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 5px;
  padding: 2px 7px;
}
.item .badge.hidden-badge { left: auto; right: 8px; background: rgba(239, 85, 99, 0.85); }

.item .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }

.item .name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item .sub {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.item .vanity-tag { color: var(--accent); }

.item .row { display: flex; gap: 6px; flex-wrap: wrap; }

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 26px 0 10px;
  color: var(--muted);
  font-size: 13.5px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 14px;
}

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { font-size: 16px; margin-bottom: 4px; }
dialog .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
