:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --accent: #6aa8ff;
  --accent2: #3f7de0;
  --danger: #e06565;
  --ok: #5ecf8f;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  display: flex; flex-direction: column; overflow: hidden;
}
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
p { margin: 0.4rem 0; }
button {
  font-family: var(--font); font-size: 0.92rem;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.45rem 0.9rem; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
button.primary:hover { background: var(--accent); }
button.big { font-size: 1.05rem; padding: 0.7rem 1.4rem; }
button.danger { border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.45; cursor: default; }
input, select {
  font-family: var(--font); font-size: 0.92rem;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.6rem;
}
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }

#topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem 1rem; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.brand { margin-right: auto; }
.tagline { margin: 0; font-size: 0.82rem; color: var(--muted); }
#mainnav { display: flex; gap: 0.4rem; }
.navbtn.active { border-color: var(--accent); color: var(--accent); }

#statusbar, #grantbar {
  padding: 0.55rem 1rem; font-size: 0.9rem; flex: 0 0 auto;
  border-bottom: 1px solid var(--line); background: var(--panel2);
}
#statusbar.ok { color: var(--ok); }
#statusbar.err { color: var(--danger); }
#grantbar { display: flex; align-items: center; gap: 0.8rem; }
.hidden { display: none !important; }

main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 1rem; gap: 1rem; overflow: hidden; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem; max-width: 860px;
}
.meta { color: var(--muted); font-size: 0.85rem; }
.fineprint { color: var(--muted); font-size: 0.8rem; }

.gridwrap { flex: 1 1 auto; min-height: 0; overflow-y: auto; position: relative; outline: none; }
.grid-spacer { position: relative; width: 100%; }
.grid-row { position: absolute; left: 0; right: 0; display: flex; gap: 12px; align-items: flex-start; }
.date-header {
  position: absolute; left: 0; right: 0;
  display: flex; align-items: baseline; gap: 0.7rem;
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.date-header h3 { margin: 0; font-size: 1rem; }
.date-header .count { color: var(--muted); font-size: 0.82rem; }
.photo-cell {
  width: 180px; flex: 0 0 180px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.photo-cell:hover { border-color: var(--accent); }
.photo-cell img {
  width: 180px; height: 150px; object-fit: cover; display: block; background: #000;
}
.photo-cell .cap {
  font-size: 0.75rem; color: var(--muted); padding: 4px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid-empty { padding: 2rem; color: var(--muted); text-align: center; }

.searchform .srow { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; }
.searchform .grow { flex: 1 1 200px; }
#searchmeta { margin-top: 0.6rem; }

#dupresults { overflow-y: auto; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 1rem; }
.dup-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.dup-group h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.dup-members { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 0.7rem; }

#progress {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  width: min(520px, 92vw); z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#progress .prow { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.bar { height: 10px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
#progressfill { height: 100%; width: 0%; background: var(--accent); border-radius: 6px; transition: width 0.15s; }
.bar.indet #progressfill { width: 100% !important; animation: indetpulse 1.2s ease-in-out infinite; }
@keyframes indetpulse { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }

#lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem;
  padding: 1.5rem;
}
#lb-img { max-width: 92vw; max-height: 70vh; object-fit: contain; border-radius: 8px; }
#lb-meta { max-width: 860px; width: min(860px, 92vw); font-size: 0.85rem; }
#lb-meta dt { color: var(--muted); float: left; clear: left; width: 110px; }
#lb-meta dd { margin: 0 0 0.2rem 120px; word-break: break-all; }
#lb-close { position: absolute; top: 1rem; right: 1rem; }

@media (max-width: 640px) {
  #topbar { flex-wrap: wrap; }
  .brand { flex: 1 1 100%; }
}
