:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e2dd;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --text: #ececea;
    --muted: #9a9a94;
    --line: #2e2e2b;
    --accent: #6e9cf0;
    --accent-text: #0d0d0c;
    --danger: #ef7a6c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; }
.bar nav { display: flex; gap: 16px; align-items: center; }
.bar nav form { margin: 0; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
button[type=submit] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); padding: 10px 16px; }
button:disabled { opacity: .5; cursor: default; }
input[type=password], input[type=text], input:not([type]) {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text);
}

/* login */
.login { max-width: 340px; margin: 18vh auto 0; display: grid; gap: 10px; }
.login h1 { text-align: center; }
.error { color: var(--danger); margin: 0; }

/* albums */
.albums { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(180px, 45%), 1fr)); }
.albums a { display: block; color: var(--text); text-decoration: none; }
.albums img, .nocover { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: var(--line); }
.albums .name { display: block; margin-top: 6px; font-weight: 550; overflow-wrap: anywhere; }
.empty { color: var(--muted); }

/* album grid */
.albumhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.albumhead h1 { margin-right: auto; overflow-wrap: anywhere; }
.count { color: var(--muted); }
.grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 31%), 1fr)); }
.tile { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 4px; overflow: hidden; aspect-ratio: 1; background: var(--line); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .file { display: grid; place-items: center; height: 100%; padding: 8px; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; padding: 2px 6px; border-radius: 4px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: #000; z-index: 20; display: grid; grid-template-rows: auto 1fr; }
.lightbox[hidden] { display: none; }
.lb-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: #eee; }
.lb-top .btn { background: #222; color: #eee; border-color: #333; }
.lb-info { margin-right: auto; min-width: 0; display: grid; }
.lb-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { font-size: .75rem; color: #aaa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-top .rename { margin-right: auto; flex: 1; }
.lb-top .rename input { background: #222; color: #eee; border-color: #444; }
.lb-top .rename .ext { color: #aaa; }
.lb-top .rename button[type=submit] { padding: 6px 12px; }
.lb-top .rename .err { color: #ff9b8f; }
.lb-stage { display: grid; place-items: center; min-height: 0; padding: 0 8px 8px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-stage p { color: #ccc; text-align: center; padding: 16px; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(40,40,40,.6); color: #fff;
  border: 0; font-size: 2rem; line-height: 1; width: 44px; height: 64px; border-radius: 8px; z-index: 21; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
@media (hover: none) { .lb-nav { display: none; } }

/* upload */
.upload { display: grid; gap: 10px; max-width: 640px; }
.drop { display: grid; place-items: center; min-height: 160px; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--muted); text-align: center; padding: 16px; cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.queue { list-style: none; padding: 0; max-width: 640px; display: grid; gap: 6px; }
.queue li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .9rem; }
.queue .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .s { color: var(--muted); }
.queue .s.err { color: var(--danger); }
.queue progress { grid-column: 1 / -1; width: 100%; height: 6px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.filters input[type=search] { flex: 1 1 200px; width: auto; padding: 7px 10px; }
.filters select { font: inherit; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.filters select[hidden] { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 7px 12px; background: var(--surface); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-text); }
.seg .n { opacity: .7; font-size: .85em; }
.grid li[hidden], .albums li[hidden] { display: none; }

/* rename */
.rename { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rename input { flex: 1 1 180px; width: auto; padding: 6px 10px; }
.rename .ext { color: var(--muted); }
.rename .err { flex-basis: 100%; margin: 0; color: var(--danger); font-size: .85rem; }
.albumhead .rename { margin-right: auto; flex: 1; margin-block: 8px; }
.albumhead h1[hidden] { display: none; }

.notice { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 12px; }
.albums .moving { display: block; font-size: .8rem; color: var(--muted); }

/* favorites */
.grid li { position: relative; }
.heart {
  position: absolute; top: 4px; left: 4px; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff;
  font-size: 16px; line-height: 32px; text-align: center; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.grid li:hover .heart, .heart:focus-visible, .heart[aria-pressed=true] { opacity: 1; }
.heart[aria-pressed=true], .lb-heart[aria-pressed=true] { color: #ff4d6d; }
@media (hover: none) { .heart { opacity: .85; } }
.lb-heart { font-size: 1.1rem; line-height: 1; }
.favfilter[aria-pressed=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.favfilter .n { opacity: .7; font-size: .85em; }

/* zip status */
#zip-status.err { border-left-color: var(--danger); color: var(--danger); }
button[hidden] { display: none; }
