:root {
  --bg: #0f1115; --panel: #1a1d24; --line: #2a2e38; --text: #e8eaef; --muted: #8b91a0;
  --accent: #2f80ed; --danger: #e5484d; --ok: #30a46c;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: default; }
a { color: inherit; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.login form { width: min(340px, 90vw); display: grid; gap: 12px; background: var(--panel); padding: 24px; border-radius: 14px; border: 1px solid var(--line); }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login input { padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.login .err { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- camera ---------- */
body.cam { position: fixed; inset: 0; overflow: hidden; touch-action: manipulation; user-select: none; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.cam .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.cam .flash.on { opacity: .7; transition: none; }
.cam .top { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  display: flex; gap: 8px; align-items: center; background: linear-gradient(#000a, #0000); }
.chip { border-radius: 999px; padding: 7px 13px; background: #000a; border: 1px solid #fff3; font-size: 14px; white-space: nowrap; }
.chip.tag { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; }
.chip.pending { margin-left: auto; }
.chip.pending.up { border-color: var(--ok); }
.chip.pending.wait { border-color: #f5a524; }
.cam .bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 18px 26px calc(env(safe-area-inset-bottom) + 26px);
  display: flex; align-items: center; justify-content: space-between; background: linear-gradient(#0000, #000a); }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: #fff3; padding: 0; }
.shutter:active { background: #fffa; transform: scale(.95); }
.side { width: 56px; height: 56px; border-radius: 12px; border: 2px solid #fff6; background: #000a center/cover; padding: 0; font-size: 22px; }
.cam .msg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; width: 85vw; display: grid; gap: 14px; }
.toast { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%); background: #000c; padding: 8px 14px; border-radius: 8px; font-size: 14px; z-index: 40; }

/* ---------- gallery ---------- */
.bar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 20px; background: #0f1115ee; backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: 18px; margin: 0 12px 0 0; }
.bar select { padding: 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.bar .spacer { flex: 1; }
.bar .count { color: var(--muted); font-size: 14px; }
main.gallery { padding: 8px 20px 60px; }
.day h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 22px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; background: var(--panel); border-radius: 6px; overflow: hidden; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .t { position: absolute; left: 6px; bottom: 6px; font-size: 11px; background: #000a; padding: 2px 6px; border-radius: 4px; }
.tile .chk { position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: #0005; display: none; }
.selecting .tile .chk { display: block; }
.tile.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.sel .chk { background: var(--accent); }
.empty { color: var(--muted); text-align: center; margin-top: 15vh; }
.more { display: block; margin: 24px auto; }

.lightbox { position: fixed; inset: 0; background: #000e; z-index: 30; display: grid; grid-template-rows: auto 1fr; }
.lightbox .lbar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; }
.lightbox .lbar .info { flex: 1; color: var(--muted); font-size: 14px; }
.lightbox .stage { position: relative; display: grid; place-items: center; min-height: 0; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 28px; background: #0006; border: 0; width: 52px; height: 72px; }
.lightbox .prev { left: 10px; } .lightbox .next { right: 10px; }
