:root {
  --bg: #0f1115; --panel: #181b22; --line: #262b35; --text: #e6e8ec;
  --muted: #8a92a3; --acc: #38bdf8; --bad: #f87171;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body.noscroll { overflow: hidden; }
a { color: var(--acc); text-decoration: none; }
.muted { color: var(--muted); }
code { background: var(--panel); padding: 1px 5px; border-radius: 4px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(15,17,21,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); }
.brand { color: var(--text); font-weight: 600; font-size: 17px; }
.back { font-size: 22px; line-height: 1; color: var(--text); padding: 0 4px; }
.logout { margin-left: auto; color: var(--muted); font-size: 13px; }
.title-form { flex: 1; min-width: 0; }
.title-form input { width: 100%; background: transparent; border: 1px solid transparent;
  color: var(--text); font: 600 17px/1.2 inherit; font-family: inherit; padding: 4px 6px; border-radius: 6px; }
.title-form input:hover, .title-form input:focus { border-color: var(--line); outline: none; background: var(--panel); }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }

.login { max-width: 320px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font-size: 24px; }
.login p { margin: 0; }
.login input, .login button { font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); }
.login input { background: var(--panel); color: var(--text); font-size: 18px; letter-spacing: 2px; }
.login button { background: var(--acc); color: #04121c; border: 0; font-weight: 600; cursor: pointer; }
.error { color: var(--bad); }

.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cam { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text); }
.cam:hover { border-color: var(--acc); }
.cover { aspect-ratio: 16/9; background: #0b0d10; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.cam-info b { font-size: 16px; }
.empty { text-align: center; max-width: 520px; margin: 10vh auto; }
.foot { text-align: center; font-size: 12px; margin-top: 28px; }

.days, .kinds { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; }
.days a, .kinds a { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line); color: var(--text); font-size: 14px; white-space: nowrap; }
.days a.on, .kinds a.on { background: var(--acc); border-color: var(--acc); color: #04121c; }
.kinds i { font-style: normal; opacity: .7; margin-left: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 8px; }
.tile { position: relative; aspect-ratio: 16/9; background: var(--panel); border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); color: var(--text); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .ph { display: flex; align-items: center; justify-content: center; height: 100%; padding: 8px;
  font-size: 12px; color: var(--muted); text-align: center; word-break: break-all; }
.tile.bad .ph { color: var(--bad); }
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 4px; font-size: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.tile .badge { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; font-size: 12px; }
@media (max-width: 520px) {
  main { padding: 10px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
}

.viewer { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column; }
.v-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13px; color: #cfd3da;
  background: rgba(0,0,0,.6); }
.v-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px;
  font: inherit; cursor: pointer; }
.v-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.v-stage img, .v-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0;
  background: rgba(255,255,255,.08); color: #fff; font-size: 34px; cursor: pointer; border-radius: 8px; }
.v-nav.prev { left: 8px; } .v-nav.next { right: 8px; }
@media (hover: none) { .v-nav { display: none; } }
