:root {
  --bg: #0f1115; --panel: #181b22; --panel2: #1f232c; --line: #2a2f3a;
  --text: #e7e9ee; --muted: #9aa3b2; --accent: #5b8cff; --good: #38b27a;
  --warn: #d8a23a; --danger: #e0524a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.muted { color: var(--muted); } .sm { font-size: .82rem; } .xs { font-size: .72rem; }
a.link { color: var(--accent); text-decoration: none; padding: 6px; }

button, .ghost, .primary { font: inherit; cursor: pointer; border-radius: 9px; border: 0; padding: 10px 14px; background: var(--accent); color: #fff; }
button:disabled { opacity: .55; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.ghost.sm, button.sm { padding: 7px 10px; font-size: .82rem; }
.ghost.xs { padding: 5px 9px; font-size: .72rem; }
.ghost.full { width: 100%; margin-top: 8px; }
.primary.big { width: 100%; padding: 15px; font-size: 1.05rem; font-weight: 600; }
.danger { color: var(--danger); border-color: var(--danger); }
input, select { font: inherit; padding: 11px 12px; margin: 6px 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); }
input { width: 100%; }
.error { color: #ff6b6b; min-height: 1.2em; margin-top: 8px; font-size: .9rem; }

/* login */
.centered { display: flex; align-items: center; justify-content: center; }
/* full-screen overlays (share password gate / messages) — cover everything behind */
#gate, #msg { position: fixed; inset: 0; z-index: 80; background: rgba(10,12,16,.93); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
#gate[hidden], #msg[hidden] { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.login { width: min(340px, 92vw); margin-top: 12vh; text-align: center; }
.login h1 { margin: 0 0 2px; font-size: 1.4rem; }
.login button { width: 100%; margin-top: 8px; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 600; font-size: 1rem; }
.spacer { flex: 1; }
.pill { font-size: .7rem; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); white-space: nowrap; }

/* folder chips */
.folderbar { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px; border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.chip { background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 8px 13px; border-radius: 999px; white-space: nowrap; font-size: .9rem; display: inline-flex; align-items: center; gap: 7px; }
.chip.active { background: var(--accent); border-color: var(--accent); }
.chip.add { color: var(--muted); }
.chipcount { font-size: .72rem; opacity: .8; }
.chipdel { margin-left: 2px; opacity: .85; font-size: .85rem; }

/* layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px; }
.uploadarea { margin-bottom: 12px; }
.uploadlist { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.upsummary { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--text); margin-bottom: 2px; }
.upsummary > span:first-child { white-space: nowrap; }
.upbar.big { flex: 1; height: 8px; }
.up { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.upn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.upbar { width: 90px; height: 6px; background: var(--panel2); border-radius: 999px; overflow: hidden; }
.upbar > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.upst { width: 64px; text-align: right; color: var(--muted); }
.upst.done { color: var(--good); } .upst.failed { color: var(--danger); } .upst.retry { color: var(--warn); }

/* people */
.peoplebox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 12px; margin-bottom: 14px; }
.peoplebox summary { cursor: pointer; padding: 8px 0; font-size: .9rem; }
.people { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.person { display: flex; align-items: center; gap: 9px; padding: 7px 12px 7px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel2); cursor: pointer; }
.person .nm { font-size: .9rem; } .person .cnt { font-size: .72rem; color: var(--muted); }
.person .avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 600; color: #fff; background: var(--accent); background-size: cover; background-position: center top; }
.person .avatar.img { background-color: var(--line); color: transparent; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: var(--panel2); }
.card .meta { padding: 5px 7px; font-size: .68rem; color: var(--muted); display: flex; justify-content: space-between; gap: 4px; }
.badge { color: var(--accent); white-space: nowrap; }
.card .names { padding: 0 7px 7px; font-size: .72rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userlist { margin: 4px 0 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 44px 16px; }

/* filter banner + gallery tools + selection */
.filterbanner { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin-bottom: 10px; font-size: .88rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.galtools { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.person.active { border-color: var(--accent); background: #1a2540; }
.person .nm { cursor: pointer; }
.card { position: relative; }
.card.sel { outline: 3px solid var(--accent); }
.card .check { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); border: 2px solid #fff; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .8rem; }

/* full-screen lightbox */
.lightbox { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lb-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(0,0,0,.55); position: relative; z-index: 3; }
.lb-top .ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
#toggleBoxesBtn.on { border-color: var(--accent); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; background: rgba(0,0,0,.4); border: 0; color: #fff; font-size: 2.4rem; line-height: 1; width: 54px; height: 84px; display: flex; align-items: center; justify-content: center; }
.lb-nav.prev { left: 0; border-radius: 0 10px 10px 0; }
.lb-nav.next { right: 0; border-radius: 10px 0 0 10px; }
.stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.boxes { position: absolute; inset: 0; pointer-events: none; }
.fbox { position: absolute; border: 2px solid var(--muted); border-radius: 4px; pointer-events: auto; cursor: pointer; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.fbox.named { border-color: var(--good); }
.fbox.auto { border-color: var(--accent); }
.fbox .tag { position: absolute; left: 0; bottom: -19px; font-size: .66rem; white-space: nowrap; background: rgba(0,0,0,.72); padding: 1px 5px; border-radius: 4px; color: #fff; }
.facepanel { padding: 12px; background: var(--panel); border-top: 1px solid var(--line); position: relative; z-index: 3; }
.facepanel[hidden] { display: none; }
.facepanel select { width: auto; min-width: 120px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }

/* animated, dimmed album background built from the album's own photos */
#bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.bglayer { position: absolute; inset: -4%; background-size: cover; background-position: center; opacity: 0; animation-name: bgcycle; animation-iteration-count: infinite; animation-timing-function: ease-in-out; will-change: opacity, transform; }
.bgdim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,17,21,.5), rgba(15,17,21,.82)); }
@keyframes bgcycle { 0%{opacity:0;transform:scale(1)} 7%{opacity:.6} 18%{opacity:.6} 26%{opacity:0;transform:scale(1.09)} 100%{opacity:0} }

/* translucent chrome so the background shows through */
.topbar { background: rgba(24,27,34,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.folderbar { background: rgba(15,17,21,.3); }

/* borderless, date-grouped gallery */
#gallery { display: block; }
.daygroup-h { font-size: .9rem; font-weight: 600; color: var(--text); opacity: .9; margin: 16px 2px 8px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.daygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 3px; margin-bottom: 6px; }
.tile { position: relative; cursor: pointer; overflow: hidden; background: var(--panel2); border-radius: 2px; }
.tile img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }
.tile .tcap { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 6px 4px; font-size: .68rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.72)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile .check { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); border: 2px solid #fff; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .8rem; }
@media (min-width: 760px) { .daygrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; } }
