:root {
  --bg: #0e1110;
  --panel: #171b19;
  --line: #262c29;
  --text: #eef2ef;
  --muted: #8d9a93;
  --green: #1fa24f;
  --green-dim: #14793a;
  --red: #d8453c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h1 { margin: 0; font-size: 1.25rem; letter-spacing: .01em; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--green); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px;
}
button:hover, .btn:hover { background: var(--green-dim); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.ghost:hover { border-color: var(--muted); background: transparent; }
button.danger { background: var(--red); }
input[type=text], input[type=password], input[type=search], input:not([type]) {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus-visible, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* login */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
#loginForm { width: min(360px, 100%); display: grid; gap: 12px; text-align: center; }
#loginForm p { margin: 0; color: var(--muted); }
.logo { width: 84px; height: 84px; object-fit: contain; margin: 0 auto 4px; }
.logos { display: flex; align-items: center; justify-content: center; gap: 26px; margin: 0 auto 12px; padding: 16px 26px; background: #fff; border-radius: 16px; width: fit-content; }
.logos img:first-child { height: 74px; width: auto; }
.logos img:last-child { height: 54px; width: auto; filter: invert(1); }
.logo.sm { width: 36px; height: 36px; margin: 0; }
.error { color: var(--red) !important; min-height: 1.4em; }

/* header + toolbar */
header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
header .badge { margin-right: auto; }
.badge { font-size: .75rem; padding: 3px 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
#toolbar { display: flex; gap: 12px; align-items: center; padding: 14px 16px 0; flex-wrap: wrap; }
#tags { display: flex; gap: 8px; overflow-x: auto; flex: 1 1 100%; padding-bottom: 4px; }
#tags button { background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 6px 14px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
#tags button[aria-selected=true] { background: var(--green); border-color: var(--green); }
#search { flex: 1 1 220px; }
.summary { margin: 10px 16px 0; color: var(--muted); font-size: .875rem; }

/* uploader */
#uploader { padding: 16px 16px 0; }
#drop { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; display: grid; gap: 12px; transition: border-color .15s, background .15s; }
#drop.over { border-color: var(--green); background: rgba(31,162,79,.08); }
#drop .lead { margin: 0; }
#drop .link { color: var(--green); text-decoration: underline; cursor: pointer; }
.tagrow { max-width: 420px; margin: 0 auto; width: 100%; text-align: left; }
.tagrow .lbl { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 6px; }
#folderPick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#folderPick button { background: var(--panel); border: 2px solid var(--line); color: var(--text); }
#folderPick button[aria-checked=true] { border-color: var(--green); background: rgba(31,162,79,.18); }
.hint { margin: 0; font-size: .8rem; color: var(--muted); }
#queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
#queue li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .875rem; background: var(--panel); padding: 8px 12px; border-radius: 8px; }
#queue .bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
#queue .bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
#queue li.err .st { color: var(--red); }
#queue li.ok .st { color: var(--green); }

/* grid */
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 14px 16px 120px; }
.card { position: relative; aspect-ratio: 1; background: var(--panel); border-radius: 12px; overflow: hidden; cursor: pointer; border: 2px solid transparent; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 1.1rem; }
.card .cap { position: absolute; inset: auto 0 0 0; padding: 22px 8px 6px; font-size: .72rem; background: linear-gradient(transparent, rgba(0,0,0,.75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .chk { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.35); display: none; place-items: center; color: #fff; font-size: 14px; }
body.selecting .card .chk { display: grid; }
.card.sel { border-color: var(--green); }
.card.sel .chk { background: var(--green); border-color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* selection bar */
#bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); padding: 8px 8px 8px 16px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 8; max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; }
#bar button { padding: 8px 12px; }

/* lightbox */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 20; display: grid; place-items: center; }
#lightbox figure { margin: 0; width: 100%; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; }
#lbImg { max-width: 100%; max-height: 100%; min-height: 0; margin: auto; object-fit: contain; padding: 56px 56px 0; width: 100%; height: 100%; }
#lightbox figcaption { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
#lbMeta { display: block; color: var(--muted); font-size: .85rem; }
.lb-actions { display: flex; gap: 8px; }
.lb-btn { position: absolute; background: rgba(255,255,255,.1); color: #fff; width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 28px; line-height: 1; z-index: 2; }
.lb-btn:hover { background: rgba(255,255,255,.2); }
.lb-btn.close { top: 12px; right: 12px; }
.lb-btn.prev { left: 10px; top: 50%; }
.lb-btn.next { right: 10px; top: 50%; }

#toast { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -80px); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; transition: transform .25s; z-index: 30; }
#toast.show { transform: translate(-50%, 0); }

@media (max-width: 600px) {
  #lbImg { padding: 56px 0 0; }
  .lb-btn.prev, .lb-btn.next { top: auto; bottom: 96px; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; padding-inline: 10px; }
}

/* albums (leikmenn) */
#teams, #albums { display: flex; gap: 8px; overflow-x: auto; flex: 1 1 100%; padding-bottom: 4px; }
#teams button, #albums button { background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 6px 14px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
#teams button[aria-selected=true], #albums button[aria-selected=true] { background: var(--green); border-color: var(--green); }
#teams button { padding: 8px 18px; font-weight: 600; }
.album { padding: 8px 16px 0; }
.album-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.album-head h2 { margin: 0; font-size: 1.05rem; flex: 1 1 auto; }
.album-head small { color: var(--muted); font-weight: 400; }
.album-head button { padding: 6px 12px; font-size: .875rem; }
.album .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 10px 0 18px; }
@media (max-width: 600px) { .album .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; } .album { padding-inline: 10px; } }

/* download counter (admin) */
.card .dl { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.card .dl.zero { color: var(--muted); font-weight: 400; }
#sort { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
