:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --border: #2a2f3a;
  --text: #e6e8ee; --muted: #9aa3b2; --accent: #4f8cff; --accent-2:#2f6fe0;
  --ok: #3fb950; --warn: #d29922; --danger: #f85149;
  --radius: 10px; --gap: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.who { color: var(--muted); }
.btn-link { color: var(--muted); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.flash {
  background: #14310f; border: 1px solid #2ea043; color: #d6ffd6;
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px;
}

/* Two devices per row (stacks to one on narrow screens) → bigger cards + thumbnails. */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: block; color: var(--text);
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 10px; font-size: 17px; }
.card .thumb { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border); }
.card .meta { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* "Live" badge in the top-right of an online device card. */
.live-badge {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .02em;
}
.live-badge .live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: ws-pulse 1.1s ease-in-out infinite; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.off { background: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 9px 11px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > div { flex: 1 1 160px; }

.btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font: inherit; cursor: pointer; margin-top: 14px;
}
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }

.keybox { background: #101418; border: 1px dashed var(--accent); border-radius: 8px;
  padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; word-break: break-all; margin: 8px 0; }

.shots { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.shot img { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); display:block; }
.shot .t { color: var(--muted); font-size: 12px; margin-top: 4px; }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; }

.login-wrap { max-width: 360px; margin: 8vh auto; }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.spacer { flex: 1; }
small.hint { color: var(--muted); }

/* ---- Collapsible sections (native <details>) ---- */
.collapsible { padding: 0; margin-bottom: 16px; }
.collapsible > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; font-size: 16px;
}
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary:hover { background: var(--panel-2); border-radius: var(--radius); }
.collapsible .chev { color: var(--muted); transition: transform .15s ease; display: inline-block; }
.collapsible[open] > summary .chev { transform: rotate(90deg); }
.collapsible .summary-meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.collapsible .collapsible-body { padding: 4px 18px 18px; border-top: 1px solid var(--border); }
.collapsible.danger[open] > summary strong { color: var(--danger); }
.collapsible.danger .collapsible-body .row { gap: 10px; }

/* ---- Latest-screenshot viewer + scrubber ---- */
.viewer { margin: 8px 0 28px; }
.viewer-stage {
  background: #0a0d11; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 16 / 10; max-height: 72vh; overflow: hidden;
  /* fixed-shape box: never resizes per frame; matches typical screen aspect */
}
.viewer-stage img {
  width: 100%; height: 100%;
  object-fit: contain; display: block;   /* scale any resolution up/down to fill the box, no distortion */
}
.viewer-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.viewer-controls input[type=range] { flex: 1; accent-color: var(--accent); height: 6px; cursor: pointer; }
.scrub-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; width: 38px; height: 34px; font-size: 20px; line-height: 1; cursor: pointer;
}
.scrub-btn:hover { border-color: var(--accent); }
.viewer-meta { display: flex; align-items: center; margin-top: 8px; color: var(--muted); font-size: 13px; }
.viewer-meta #viewer-when { color: var(--text); font-variant-numeric: tabular-nums; }
.shot { cursor: pointer; }
.shot:hover img { border-color: var(--accent); }
.scrub-speed {
  width: auto; padding: 6px 8px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit; cursor: pointer;
}
/* Live toggle + fullscreen button share the scrub-btn look but size to their label. */
.scrub-btn.wide { width: auto; padding: 0 12px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.scrub-btn.live-on { border-color: var(--danger); color: #fff; background: var(--danger); }
.scrub-btn.live-on .live-dot { animation: ws-pulse 1.1s ease-in-out infinite; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
@keyframes ws-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
/* Zoom + pan: the image is transformed via JS; the stage clips it. */
.viewer-stage { position: relative; }
.viewer-stage img { transform-origin: 0 0; will-change: transform; }
.viewer-stage.zoomable { cursor: grab; }
.viewer-stage.panning { cursor: grabbing; }

/* Fullscreen the whole viewer (stage + controls) so the player controls,
   live toggle and scrubber stay visible at the bottom. */
.viewer:fullscreen { display: flex; flex-direction: column; width: 100vw; height: 100vh; background: #000; margin: 0; }
.viewer:fullscreen .viewer-stage {
  flex: 1 1 auto; min-height: 0; max-height: none; aspect-ratio: auto;
  border: 0; border-radius: 0;
}
.viewer:fullscreen .viewer-controls { padding: 10px 16px; margin: 0; }
.viewer:fullscreen .viewer-meta { padding: 0 16px 12px; margin: 0; }
