/* Webcam Gallery – shared styles */
:root {
  --bg: #16181b;
  --panel: #202328;
  --panel-2: #2a2e34;
  --line: #353a41;
  --text: #e8e9eb;
  --muted: #9aa1aa;
  --accent: #f2b33d;          /* warm alpine-sunrise yellow */
  --accent-ink: #1a1405;
  --ok: #5cc28a;
  --warn: #e07b5a;
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; background: rgba(22,24,27,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; font-size: 16px; }
.brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.btn, .topbar nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius); border: 1px solid transparent;
  background: transparent; cursor: pointer; white-space: nowrap; color: var(--text);
}
.btn:hover, .topbar nav a:hover { background: var(--panel-2); }
.btn.on, .topbar nav a.on { background: var(--accent); color: var(--accent-ink); }
.btn.outline { border-color: var(--line); }
.btn:disabled { opacity: .35; cursor: default; background: transparent; }
select.btn { background: var(--panel); border-color: var(--line); }

/* ---------- overview grid ---------- */
.grid {
  display: grid; gap: 10px; padding: 14px 16px 40px;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile, 300px), 1fr));
}
.grid.small { --tile: 200px; }
.tile { position: relative; display: block; border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.tile img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #0e0f11; transition: transform .25s; }
.tile:hover img { transform: scale(1.03); }
.tile .cap {
  position: absolute; inset: auto 0 0 0; padding: 22px 10px 7px;
  background: linear-gradient(transparent, rgba(0,0,0,.78));
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.tile .name { font-weight: 600; text-shadow: 0 1px 2px #000; }
.tile .age { font-size: 12px; color: #d6d9dd; font-variant-numeric: tabular-nums; }
.tile.stale .age { color: var(--warn); }
.tile .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
.tile.stale .dot { background: var(--warn); }
.tile .best-ts { position: absolute; top: 6px; left: 6px; font-size: 12px; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 4px; }
.empty { padding: 60px 16px; text-align: center; color: var(--muted); }

/* ---------- camera viewer ---------- */
.cam-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.cam-head h1 { font-size: 17px; margin: 0; }
.cam-head .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.stats { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; font-size: 12px; color: var(--text);
  padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.stats .stat { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats b { color: var(--muted); font-weight: 500; margin-right: 3px; }
.stats .warn { color: var(--warn); }
.stats .meter { display: inline-block; width: 46px; height: 5px; margin-left: 6px; vertical-align: middle;
  background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.stats .meter i { display: block; height: 100%; background: var(--accent); }
.stats .meter i.hot { background: var(--warn); }

.stage { position: relative; background: #0b0c0d; display: flex; justify-content: center; user-select: none; }
.stage img#main {
  display: block; max-width: 100%; max-height: calc(100vh - 190px); width: auto; height: auto;
  cursor: zoom-in;
}
.stage .stamp {
  position: absolute; top: 10px; left: 12px; padding: 4px 9px; border-radius: 4px;
  background: rgba(0,0,0,.55); font-variant-numeric: tabular-nums; font-weight: 600; pointer-events: none;
}
.stage .stamp .star { color: var(--accent); margin-left: 6px; }
.stage .loading { position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage .nav-zone { position: absolute; top: 0; bottom: 0; width: 12%; cursor: pointer; opacity: 0; transition: opacity .2s;
  display: flex; align-items: center; font-size: 42px; color: #fff; text-shadow: 0 0 8px #000; }
.stage .nav-zone:hover { opacity: .85; }
.stage .nav-zone.prev { left: 0; justify-content: flex-start; padding-left: 14px; }
.stage .nav-zone.next { right: 0; justify-content: flex-end; padding-right: 14px; }

.controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.controls .group { display: flex; align-items: center; gap: 2px; }
.controls .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.controls input[type=date] { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 8px; color-scheme: dark; }
.slider-wrap { flex: 1 1 260px; display: flex; align-items: center; gap: 10px; min-width: 200px; position: relative; }
.slider-wrap input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-wrap .time { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; font-weight: 600; }
.sun { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* thumbnail strip */
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 10px 16px 14px; }
.strip a { position: relative; border-radius: 4px; overflow: hidden; border: 2px solid transparent; }
.strip a:hover { border-color: var(--line); }
.strip a.cur { border-color: var(--accent); }
.strip img { display: block; width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover; background: #0e0f11; }
.strip span { position: absolute; bottom: 2px; left: 4px; font-size: 11px; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }
.strip a.best::after { content: "★"; position: absolute; top: 1px; right: 4px; color: var(--accent); font-size: 12px; text-shadow: 0 0 3px #000; }

/* dropdown menus */
.menu { position: relative; }
.menu > .list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 230px; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.menu > .list button, .menu > .list a { display: flex; justify-content: space-between; gap: 14px; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; }
.menu > .list button:hover, .menu > .list a:hover { background: var(--panel-2); }
.menu kbd { color: var(--muted); font: 12px var(--font); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* full-resolution zoom overlay */
.zoom { position: fixed; inset: 0; z-index: 100; background: #000; overflow: hidden; cursor: grab; }
.zoom.drag { cursor: grabbing; }
.zoom img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.zoom .hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6);
  padding: 5px 12px; border-radius: 4px; color: #ddd; font-size: 12px; pointer-events: none; }
.zoom .close { position: absolute; top: 10px; right: 12px; z-index: 2; background: rgba(0,0,0,.6); }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; max-width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 10px; font-size: 16px; }
dialog table { border-collapse: collapse; width: 100%; }
dialog td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
dialog td:first-child { color: var(--muted); white-space: nowrap; }
dialog input[type=password], dialog input[type=text], dialog textarea { width: 100%; padding: 7px 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
dialog textarea { height: 70px; font-family: ui-monospace, monospace; font-size: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--radius); z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 18px; }

@media (max-width: 700px) {
  .topbar { padding: 6px 10px; }
  .controls { padding: 6px 10px; }
  .controls .sep { display: none; }
  .strip { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 4px; padding: 8px 10px; }
  .stats { order: 10; width: 100%; justify-content: space-between; }
  .stage img#main { max-height: none; }
  .stage .nav-zone { display: none; }
  .grid { padding: 10px; --tile: 100%; }
  .grid.small { --tile: 150px; }
}
