/* viewmon styles */

* { box-sizing: border-box; }

/* the `hidden` attribute must always win over display rules below */
[hidden] { display: none !important; }

/* no rubber-band bounce / scroll chaining anywhere */
html, body { overscroll-behavior: none; }

/* feed is frozen while an overlay (lightbox / video modal) is open */
body.overlay-open { overflow: hidden; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #14171a;
  color: #e6e6e6;
}

/* header */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #1d2126;
  border-bottom: 1px solid #2c3138;
}

.logo { font-weight: 700; letter-spacing: 0.04em; }

#camera-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; flex: 1; }

#type-chips { display: flex; gap: 0.5rem; }

.chip-sep { width: 1px; height: 1.4rem; background: #3a4149; }

.chip {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #3a4149;
  background: transparent;
  color: #9aa3ad;
  cursor: pointer;
}
.chip.on { background: #2f6fed; border-color: #2f6fed; color: #fff; }

.logout-form button {
  background: transparent;
  border: 1px solid #3a4149;
  color: #9aa3ad;
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
}
.logout-form button:hover { color: #fff; border-color: #5a636e; }

/* timeline */

main#timeline { padding: 1rem; max-width: 1400px; margin: 0 auto; }

.date-header {
  font-size: 0.95rem;
  color: #9aa3ad;
  border-bottom: 1px solid #2c3138;
  padding-bottom: 0.3rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.cell {
  position: relative;
  margin: 0;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  background: #1d2126;
}

.cell img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }

.cell .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
  font-size: 0.9rem;
}

.cell .badge.pin { top: auto; bottom: 8px; }

.cell figcaption {
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  color: #9aa3ad;
}

#end-of-feed { text-align: center; color: #5a636e; padding: 2rem; }
#sentinel { height: 1px; }

/* header links (system page / back to timeline) */

.header-link, #system-link {
  color: #9aa3ad;
  text-decoration: none;
  font-size: 0.9rem;
}
.header-link:hover, #system-link:hover { color: #fff; }

.page-title { color: #9aa3ad; font-size: 0.95rem; }

/* system page */

main#system { padding: 1rem; max-width: 720px; margin: 0 auto; }

#system-loading { color: #9aa3ad; text-align: center; padding: 2rem; }

.card {
  background: #1d2126;
  border: 1px solid #2c3138;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
  color: #9aa3ad;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
  font-size: 0.92rem;
}
.stat-row > span:first-child { color: #9aa3ad; }

.bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: #14171a;
  margin: 0.6rem 0 0.4rem;
}

.bar .seg { display: block; height: 100%; }
.seg-images { background: #2f6fed; }
.seg-videos { background: #e08a2f; }
.seg-used { background: #2f6fed; }

.bar-legend {
  display: flex;
  gap: 1.2rem;
  font-size: 0.8rem;
  color: #9aa3ad;
}

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: -0.05rem;
}

.fs + .fs { margin-top: 1rem; border-top: 1px solid #2c3138; padding-top: 0.6rem; }

/* lightbox & video modal */

#lightbox, #video-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: none;
  /* we handle pan gestures ourselves (swipe nav/dismiss); the browser
     must not turn them into scrolling */
  touch-action: none;
}

#lightbox img { max-width: 96vw; max-height: 96vh; }
#video-modal video {
  max-width: 96vw;
  max-height: 96vh;
  /* native controls/seek bar keep their default touch behavior */
  touch-action: auto;
}

/* overlay pin/trash actions (top-right, only while an overlay is open) */

#overlay-actions {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  display: flex;
  gap: 0.5rem;
}

#overlay-actions button {
  font-size: 1.2rem;
  line-height: 1;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #3a4149;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: #e6e6e6;
}
#overlay-actions button:hover { border-color: #5a636e; }
#overlay-actions button:disabled { opacity: 0.4; cursor: default; }
#pin-btn.on { background: #2f6fed; border-color: #2f6fed; }

/* system page trash list */

#trash-list { margin-top: 0.4rem; }
.trash-row { align-items: center; }
.restore-btn {
  background: transparent;
  border: 1px solid #3a4149;
  color: #9aa3ad;
  border-radius: 6px;
  padding: 0.15rem 0.6rem;
  margin-left: 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.restore-btn:hover { color: #fff; border-color: #5a636e; }
.restore-btn:disabled { opacity: 0.4; cursor: default; }

/* login */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #1d2126;
  border: 1px solid #2c3138;
  border-radius: 12px;
  padding: 2rem 2.4rem;
  width: min(360px, 92vw);
}

.login-card h1 { margin-top: 0; text-align: center; }

.login-card form { display: flex; flex-direction: column; gap: 1rem; }

.login-card label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }

.login-card input {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid #3a4149;
  background: #14171a;
  color: #e6e6e6;
}

.login-card button {
  padding: 0.6rem;
  border: none;
  border-radius: 6px;
  background: #2f6fed;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.login-card .error {
  background: #4a1f24;
  border: 1px solid #7a3038;
  color: #f0a3ab;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
}
