/* ── Browser Stream Viewer — Minimal (body-only) ─────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.3);
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Prevent pull-to-refresh on mobile */
  overscroll-behavior: none;
  /* Prevent text selection on mobile */
  -webkit-user-select: none;
  user-select: none;
  /* Prevent tap highlight on mobile */
  -webkit-tap-highlight-color: transparent;
}

/* ── Stream Container ────────────────────────────────────────────── */

/* Fixed to the visible area. 100vh on phones includes the space behind the
   address bar, which made the canvas taller than the screen and left a black
   band above the page. */
#stream-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ── Canvas — fills the visible area ─────────────────────────────── */

#stream-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: default;
  outline: none;
  /* Touch behavior: we handle everything ourselves */
  touch-action: none;
  /* iOS: no "save image" callout or magnifier on long press */
  -webkit-touch-callout: none;
}

#stream-canvas:focus {
  outline: none;
}

/* Invisible keyboard field. 16px font stops iOS zooming in on focus; placed at
   the top so the phone never scrolls the page to show it above the keyboard. */
#ime-input {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  font-size: 16px;
  opacity: 0;
  resize: none;
  pointer-events: none;
  caret-color: transparent;
  color: transparent;
  background: transparent;
}

/* ── Bottom sheet: page dialogs and pickers ──────────────────────── */

#sheet {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  -webkit-user-select: text;
  user-select: text;
}

#sheet.hidden {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.sheet-panel {
  position: relative;
  max-height: 75%;
  display: flex;
  flex-direction: column;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
  background: #1f2328;
  color: #f0f3f6;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  font-size: 16px;
}

/* Wide screens (desktop viewers): a centered dialog instead of a bottom sheet */
@media (min-width: 700px) {
  #sheet { justify-content: center; align-items: center; }
  .sheet-panel { width: 420px; border-radius: 14px; max-height: 70%; }
}

.sheet-title {
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 6px;
}

.sheet-title:empty { display: none; }

.sheet-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
  color: #c9d1d9;
  margin-bottom: 12px;
  max-height: 40vh;
  overflow-y: auto;
}

.sheet-message:empty { display: none; }

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sheet-body:empty { display: none; }

.sheet-input {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* no iOS zoom on focus */
  color: inherit;
  background: #0d1117;
  border: 1px solid #3d444d;
  border-radius: 10px;
  margin-bottom: 12px;
  color-scheme: dark;
}

.sheet-input[type="color"] {
  height: 56px;
  padding: 4px;
}

.sheet-group {
  padding: 12px 4px 4px;
  font-size: 13px;
  font-weight: 600;
  color: #8b949e;
}

.sheet-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 10px;
}

.sheet-option:active { background: #2d333b; }
.sheet-option[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.sheet-option[aria-checked="true"]::after { content: '✓'; margin-left: auto; padding-left: 12px; }
.sheet-option:disabled { color: #6e7681; }

.sheet-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.sheet-actions button {
  min-height: 44px;
  min-width: 96px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: #2d333b;
  border: 0;
  border-radius: 10px;
}

.sheet-actions button.primary {
  color: #000;
  background: var(--accent);
}

/* ── Loading / Disconnected Overlay ──────────────────────────────── */

#overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s;
}

#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.overlay-text {
  font-size: 13px;
  color: #888;
}
