:root {
  --bg: #171717;
  --bg-elevated: #202020;
  --bg-card: #262626;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-dim: #9a9a9a;
  --accent: #4f8cff;
  --accent-hover: #6ea0ff;
  --danger: #ff5f5f;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}
.topbar .brand span { color: var(--accent); }
.brand-icon { height: 34px; width: auto; display: block; }

.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 0.9rem; color: var(--text-dim); }

.filter-row { display: flex; align-items: center; gap: 8px; }
.filter-row input[type="text"],
.filter-row select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
}
.filter-row input[type="text"] { min-width: 200px; }

.layout { display: flex; min-height: calc(100vh - 58px); }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 20px;
  border-right: 1px solid var(--border);
}

.sidebar h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 20px 0 8px; }
.sidebar h3:first-child { margin-top: 0; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin-bottom: 4px; }
.sidebar a.active { color: var(--text); font-weight: 600; }

.tag-pill {
  display: inline-block;
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  margin: 2px 4px 2px 0;
  color: var(--text-dim);
}
.tag-pill.active { border-color: var(--accent); color: var(--text); background: rgba(79, 140, 255, 0.15); }

.main { flex: 1; padding: 24px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn.secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s ease;
}
.card:hover { transform: translateY(-2px); }
/* the item closest to the date picked on the gallery's date slider */
.card.anchor { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 4px 18px rgba(79, 140, 255, 0.35); }

.kind-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.15) inset;
}
.kind-badge.kind-video { background: #22c55e; color: #fff; }
.kind-badge.kind-photo { background: #ffb454; color: #1a1a1a; }
.grid.list-view .kind-badge { top: 6px; left: 6px; width: 24px; height: 24px; font-size: 0.85rem; }

.card .thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #000;
  display: block;
}
.card .thumb-placeholder {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  overflow: hidden;
}
.card .thumb-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('../img/icon.webp');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 56px;
  opacity: 0.15;
  z-index: -1;
}
.card .body { padding: 12px; }
.card .title { font-weight: 600; margin-bottom: 4px; }
.card .meta { font-size: 0.8rem; color: var(--text-dim); }

.player-wrap { max-width: 960px; margin: 0 auto; }
.plyr { border-radius: var(--radius); overflow: hidden; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 6px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}
.form-row textarea { resize: vertical; min-height: 70px; }

.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment .author { font-weight: 600; font-size: 0.9rem; }
.comment .when { color: var(--text-dim); font-size: 0.75rem; margin-left: 8px; }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 420px;
  max-width: 90vw;
}
.modal h2 { margin-top: 0; }

.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 360px;
}
.login-box h1 { font-size: 1.4rem; margin-top: 0; }
.login-logo { display: block; width: 100%; max-width: 260px; margin: 0 auto 20px; }
.error-banner {
  background: rgba(255,95,95,0.15);
  border: 1px solid var(--danger);
  color: #ffb3b3;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.progress-bar {
  height: 6px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar .fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s; }

.upload-row { margin-bottom: 14px; }
.upload-row .upload-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.upload-row .upload-row-name { font-size: 0.9rem; word-break: break-all; }
.upload-cancel {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 2px 10px;
}
.upload-cancel:hover { color: var(--danger); border-color: var(--danger); }
.upload-row .fill.error { background: var(--danger); }

.empty-state { color: var(--text-dim); padding: 40px 0; text-align: center; }

.view-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.view-toggle button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.view-toggle button.active { color: var(--text); border-color: var(--accent); }

.grid.list-view {
  grid-template-columns: 1fr;
  gap: 8px;
}
.grid.list-view .card {
  display: flex;
  align-items: center;
}
.grid.list-view .card:hover { transform: none; }
.grid.list-view .card .thumb,
.grid.list-view .card .thumb-placeholder {
  width: 160px;
  aspect-ratio: 16/9;
  flex-shrink: 0;
}
.grid.list-view .card .body { flex: 1; padding: 8px 16px; }
.grid.list-view .card .title { margin-bottom: 2px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 28px;
}
.pagination.pagination-inline { margin-top: 0; gap: 10px; }
.pagination .btn { padding: 6px 14px; font-size: 0.85rem; }

.gallery-date-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 14px;
  margin-bottom: 20px;
}
.gallery-date-current {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  min-height: 1.4em;
}
.gallery-date-axis {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.gallery-date-axis a { font-size: 0.78rem; }

.date-slider { position: relative; height: 28px; margin: 0 4px; }
.date-slider input[type="range"] {
  position: absolute;
  top: 6px;
  left: 0;
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.date-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.date-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.date-slider input[type="range"]::-moz-range-track { background: transparent; }
.date-slider-track {
  position: absolute;
  top: 13px;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}
.date-slider-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
}

.share-splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1000;
  cursor: pointer;
  transition: opacity 0.4s ease;
}
.share-splash.share-splash-out { opacity: 0; }
.share-splash-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 32px;
}
