/* ============================================================
   TapoAppForPC, Windows desktop app stylesheet
   Brand: slate + teal, matches tapoappforpc.com landing page
   ============================================================ */

:root {
  --c-bg:        #0f172a;   /* slate 900, main window chrome */
  --c-bg-2:      #1e293b;   /* slate 800, panels */
  --c-bg-3:      #334155;   /* slate 700, borders/hover */
  --c-surface:   #f8fafc;   /* slate 50, main content bg */
  --c-surface-2: #ffffff;
  --c-ink:       #0f172a;
  --c-ink-soft:  #475569;
  --c-ink-mute:  #94a3b8;
  --c-line:      #e2e8f0;
  --c-accent:    #0d9488;   /* teal 600 */
  --c-accent-2:  #2dd4bf;   /* teal 400 */
  --c-ok:        #15803d;
  --c-err:       #b91c1c;

  --r:  10px;
  --r-sm: 6px;
  --r-lg: 14px;

  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* The HTML `hidden` attribute gets overridden by flex/grid display rules.
   This rule restores its expected behaviour everywhere in the app. */
[hidden] { display: none !important; }
body.app {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--c-ink);
  background: var(--c-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Title bar / top toolbar
   ============================================================ */
.app-bar {
  flex: 0 0 auto;
  height: 48px;
  background: var(--c-bg);
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #1e293b;
  -webkit-app-region: drag;
  user-select: none;
}
.app-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-bar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-accent-2);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}
.app-bar__name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.app-bar__nav {
  display: flex;
  gap: 4px;
  -webkit-app-region: no-drag;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tb-btn:hover {
  background: rgba(45, 212, 191, 0.14);
  border-color: rgba(45, 212, 191, 0.45);
  color: #ffffff;
}
.tb-btn:active { transform: translateY(1px); }
.tb-btn svg { color: var(--c-accent-2); }
.tb-btn--ghost { background: transparent; }
.tb-btn--ghost:hover svg { color: #ffffff; }
.tb-btn--mini {
  padding: 3px 8px;
  font-size: 11px;
}

/* ============================================================
   Main content area
   ============================================================ */
.app-main {
  flex: 1 1 auto;
  overflow: auto;
  background:
    radial-gradient(ellipse 800px 400px at 50% -100px, rgba(45, 212, 191, 0.08), transparent),
    var(--c-surface);
}

/* ============================================================
   Empty state (first launch)
   ============================================================ */
.empty {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 88px 24px 48px;
}
/* In demo mode give it even more breathing room so the welcome card isn't
   squeezed against the demo modal header banner. */
.is-demo-env .empty { padding-top: 120px; }
.empty__card {
  max-width: 520px;
  text-align: center;
}
.empty__logo {
  margin: 0 auto 24px;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  box-shadow: 0 18px 40px -14px rgba(13, 148, 136, 0.4);
}
.empty__logo svg { display: block; border-radius: 18px; }
.empty__title {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 800;
  color: var(--c-ink);
  letter-spacing: -0.3px;
}
.empty__lede {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-ink-soft);
}
.empty__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.empty__hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--c-ink-mute);
}
.empty__hint a { color: var(--c-accent); font-weight: 600; text-decoration: none; }
.empty__hint a:hover { text-decoration: underline; }

/* Status bar demo toggle */
.status-bar__demo {
  color: var(--c-accent-2);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed rgba(45, 212, 191, 0.4);
  padding-bottom: 1px;
  transition: color 0.12s, border-color 0.12s;
}
.status-bar__demo:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
}

/* Camera tile demo mode — digital zoom + pan viewport */
.camera-tile--demo .camera-tile__head {
  padding: 10px 14px;
}
.camera-tile__head > div { display: flex; flex-direction: column; gap: 2px; }
.camera-tile__sub {
  margin: 0;
  font-size: 10.5px;
  color: #94a3b8;
  font-weight: 500;
}
.camera-tile__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ef4444;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.camera-tile__status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: none;
}
.camera-tile__viewport {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000000;
  cursor: grab;
  flex: 1 1 auto;
  min-height: 0;
}
/* When the tile height is explicitly set (user resized), the viewport fills
   whatever vertical space is left after the header + controls instead of
   enforcing its 16:9 ratio. */
.camera-tile[style*="height"] .camera-tile__viewport {
  aspect-ratio: auto;
}
.camera-tile__viewport.is-dragging { cursor: grabbing; }
.camera-tile__feed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transform-origin: 0 0;
}
.camera-tile__head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.camera-tile__zoom-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(45, 212, 191, 0.4);
  border-radius: 999px;
  color: #2dd4bf;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
/* Live <video> tiles: progressive MP4 stream from the streaming engine /api/stream.mp4.
   No native controls, TapoAppForPC draws its own pause/mute/fullscreen. */
video.camera-tile__feed {
  background: #000;
}
video.camera-tile__feed::-webkit-media-controls,
video.camera-tile__feed::-webkit-media-controls-enclosure,
video.camera-tile__feed::-webkit-media-controls-panel {
  display: none !important;
  -webkit-appearance: none !important;
}

/* ============================================================
   Shared buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #ffffff;
}
.btn--primary:hover { background: #0f766e; border-color: #0f766e; }
.btn--primary svg { color: #ffffff; }
.btn--ghost {
  background: transparent;
  border-color: var(--c-line);
  color: var(--c-ink);
}
.btn--ghost:hover { border-color: var(--c-accent); color: var(--c-accent); }

/* ============================================================
   Camera grid
   ============================================================ */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px;
  align-content: flex-start;
}
.camera-tile {
  background: #000000;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--c-line);
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 20px -12px rgba(15, 23, 42, 0.25);
  /* Resizable: user can drag the bottom-right corner to make any tile
     bigger or smaller. Default flex-basis uses calc so 2 tiles fit per row
     in an ~1100px container (modal iframe) and 1 per row on narrow mobile. */
  resize: both;
  flex: 1 1 calc(50% - 14px);
  min-width: 260px;
  max-width: 100%;
  min-height: 220px;
}
.camera-tile:fullscreen,
.camera-tile.is-fullscreen,
.camera-tile--auto-pip,
.camera-tile--pip-fallback {
  resize: none;
  width: auto;
  min-width: 0;
}
.camera-tile__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--c-bg);
  color: #e2e8f0;
}
.camera-tile__name {
  font-weight: 700;
  font-size: 13px;
  margin: 0;
}
.camera-tile__status {
  font-size: 11px;
  color: var(--c-accent-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.camera-tile__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent-2);
  box-shadow: 0 0 0 2.5px rgba(45, 212, 191, 0.3);
}
.camera-tile__video {
  aspect-ratio: 16 / 9;
  background: #0f172a;
  display: block;
  width: 100%;
  object-fit: cover;
}
.camera-tile__controls {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  background: #020617;
  border-top: 1px solid #1e293b;
}
.camera-tile__ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  color: #94a3b8;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.camera-tile__ctrl:hover { background: rgba(45, 212, 191, 0.15); color: #ffffff; }

/* ============================================================
   Status bar (bottom)
   ============================================================ */
.status-bar {
  flex: 0 0 auto;
  height: 28px;
  background: var(--c-bg);
  color: #94a3b8;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-top: 1px solid #1e293b;
  user-select: none;
}
.status-bar__left,
.status-bar__center,
.status-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-bar__center code {
  background: rgba(45, 212, 191, 0.12);
  color: var(--c-accent-2);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  user-select: all;
}
.status-bar__label { color: #64748b; }
.status-bar__sep { opacity: 0.4; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-ink-mute);
}
.status-dot--ready  { background: var(--c-accent-2); box-shadow: 0 0 0 2.5px rgba(45, 212, 191, 0.25); }
.status-dot--busy   { background: #f59e0b; box-shadow: 0 0 0 2.5px rgba(245, 158, 11, 0.25); }
.status-dot--error  { background: var(--c-err); box-shadow: 0 0 0 2.5px rgba(185, 28, 28, 0.25); }

/* ============================================================
   Scrollbar styling (Windows Edge/Chromium)
   ============================================================ */
.app-main::-webkit-scrollbar { width: 12px; }
.app-main::-webkit-scrollbar-track { background: transparent; }
.app-main::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
  border: 3px solid var(--c-surface);
}
.app-main::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   Modal + Toast system (vanilla, no deps)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-overlay.is-visible { opacity: 1; }
.modal {
  background: #ffffff;
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px -20px rgba(15, 23, 42, 0.45);
  transform: translateY(6px) scale(0.98);
  transition: transform 0.18s ease;
  overflow: hidden;
}
.modal-overlay.is-visible .modal { transform: translateY(0) scale(1); }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--c-line);
}
.modal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--c-ink);
}
.modal__close {
  background: transparent;
  border: 0;
  padding: 6px;
  border-radius: var(--r-sm);
  color: var(--c-ink-soft);
  cursor: pointer;
  display: inline-flex;
}
.modal__close:hover { background: #f1f5f9; color: var(--c-ink); }
.modal__body {
  padding: 20px 22px;
  overflow-y: auto;
  color: var(--c-ink);
  font-size: 14px;
  line-height: 1.6;
}
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  background: #f8fafc;
  border-top: 1px solid var(--c-line);
}

/* Toasts */
#toast-root {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}
.toast {
  background: var(--c-bg);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.4);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--ok { background: var(--c-accent); }

/* Scan animation */
.scan-anim {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px 0;
}
.scan-anim__radar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(45, 212, 191, 0.25) 0%, transparent 70%),
    conic-gradient(from 0deg, transparent 0%, rgba(13, 148, 136, 0.6) 20%, transparent 40%);
  animation: scan-spin 1.4s linear infinite;
  position: relative;
}
.scan-anim__radar::before,
.scan-anim__radar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(13, 148, 136, 0.25);
}
.scan-anim__radar::after { inset: 22px; }
@keyframes scan-spin { to { transform: rotate(360deg); } }
.scan-anim__text {
  margin: 0;
  font-size: 13px;
  color: var(--c-ink-soft);
  font-variant-numeric: tabular-nums;
}

/* Scan results */
.scan-results__lede { margin: 0 0 14px; }
.scan-results {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scan-result {
  background: #f8fafc;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  transition: border-color 0.12s;
}
.scan-result:hover { border-color: var(--c-accent); }
.scan-result label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}
.scan-result input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--c-accent);
  margin-top: 2px;
  flex-shrink: 0;
}
.scan-result strong {
  display: block;
  color: var(--c-ink);
  font-size: 14px;
  margin-bottom: 2px;
}
.scan-result span {
  display: block;
  color: var(--c-ink-soft);
  font-size: 12px;
}
.scan-result a {
  color: var(--c-accent);
  margin-left: 6px;
  text-decoration: none;
  font-weight: 600;
}
.scan-result a:hover { text-decoration: underline; }
.scan-results__note {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #fef3c7;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: #78350f;
}

/* Manual add form */
.manual-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.manual-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.manual-form label span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-ink-soft);
}
.manual-form input {
  padding: 10px 12px;
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  background: #ffffff;
  color: var(--c-ink);
  transition: border-color 0.12s;
}
.manual-form input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}
.manual-form__hint {
  margin: 0;
  padding: 10px 12px;
  background: #f0fdfa;
  border-left: 3px solid var(--c-accent);
  border-radius: 4px;
  font-size: 12px;
  color: var(--c-ink-soft);
}

/* Settings */
.settings section { margin-bottom: 18px; }
.settings section:last-child { margin-bottom: 0; }
.settings h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-accent);
}
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--c-ink);
}
.toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--c-accent);
}
.settings__hint {
  margin: 6px 0 0 26px;
  font-size: 12px;
  color: var(--c-ink-soft);
}
.settings__about {
  margin: 0;
  padding: 12px 14px;
  background: #f8fafc;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--c-ink-soft);
  line-height: 1.55;
}
.settings__about strong { color: var(--c-ink); }

/* Guide modal */
.guide {
  margin: 0 0 14px;
  padding-left: 22px;
  line-height: 1.7;
}
.guide li { margin-bottom: 6px; }
.guide__hint {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 12.5px;
  color: #78350f;
  line-height: 1.55;
}

/* ============================================================
   Add Camera wizard (5 steps)
   ============================================================ */
.wizard { min-height: 280px; }
.wizard__body { min-height: 260px; }

.wizard__steps {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-right: auto;
}
.wiz-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-line);
  transition: background 0.15s, transform 0.15s;
}
.wiz-dot.is-done   { background: var(--c-accent); }
.wiz-dot.is-active { background: var(--c-accent); transform: scale(1.5); }

.wizard__actions {
  display: flex;
  gap: 10px;
}

/* Step 1 welcome */
.wiz-welcome h3 { margin: 0 0 10px; font-size: 16px; color: var(--c-ink); }
.wiz-welcome p  { margin: 0 0 12px; color: var(--c-ink-soft); line-height: 1.6; }
.wiz-checklist {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}
.wiz-checklist li {
  position: relative;
  padding: 6px 0 6px 24px;
  color: var(--c-ink);
  font-size: 13.5px;
  line-height: 1.5;
}
.wiz-checklist li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 6px;
  color: var(--c-accent);
  font-weight: 800;
  font-size: 14px;
}
.wiz-welcome__note {
  padding: 10px 12px;
  background: #f0fdfa;
  border-left: 3px solid var(--c-accent);
  border-radius: 4px;
  font-size: 12px;
  color: var(--c-ink-soft);
}

/* Step 2 scanning */
.wiz-scanning {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
}
.wiz-scan-log {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  background: #0f172a;
  color: #2dd4bf;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.6;
}
.wiz-scan-log__line {
  white-space: nowrap;
  opacity: 0;
  animation: wiz-log-in 0.2s forwards;
}
@keyframes wiz-log-in { to { opacity: 1; } }

.scan-result.is-ready strong  { color: var(--c-accent); }
.scan-result.is-needs-setup   { border-color: #fcd34d; background: #fffbeb; }
.scan-result.is-needs-setup strong { color: #b45309; }

/* Step 3 credentials */
.wiz-credentials h3 { margin: 0 0 10px; font-size: 16px; color: var(--c-ink); }
.wiz-credentials p  { margin: 0 0 14px; color: var(--c-ink-soft); line-height: 1.6; font-size: 13px; }
.wiz-credentials form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wiz-credentials label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wiz-credentials label span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-ink-soft);
}
.wiz-credentials input {
  padding: 10px 12px;
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  background: #ffffff;
  color: var(--c-ink);
}
.wiz-credentials input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}
.wiz-creds__same {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 12px;
  color: var(--c-ink-soft);
}

/* Step 4 validate */
.wiz-validate h3 { margin: 0 0 10px; font-size: 16px; color: var(--c-ink); }
.wiz-validate p  { margin: 0 0 14px; color: var(--c-ink-soft); font-size: 13px; }
.wiz-validate__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wiz-validate__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--c-line);
  border-radius: 8px;
  font-size: 13px;
  transition: background 0.2s, border-color 0.2s;
}
.wiz-validate__row div strong {
  display: block;
  color: var(--c-ink);
  font-size: 14px;
}
.wiz-validate__row div span {
  display: block;
  color: var(--c-ink-soft);
  font-size: 11.5px;
  margin-top: 2px;
}
.wiz-validate__status {
  font-weight: 600;
  font-size: 12px;
  color: var(--c-ink-soft);
}
.wiz-validate__row.is-pending {
  background: #fffbeb;
  border-color: #fcd34d;
}
.wiz-validate__row.is-pending .wiz-validate__status {
  color: #b45309;
}
.wiz-validate__row.is-pending .wiz-validate__status::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid #fcd34d;
  border-top-color: #b45309;
  border-radius: 50%;
  animation: wiz-spin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes wiz-spin { to { transform: rotate(360deg); } }
.wiz-validate__row.is-ok {
  background: #f0fdfa;
  border-color: var(--c-accent);
}
.wiz-validate__row.is-ok .wiz-validate__status {
  color: var(--c-accent);
}
.wiz-validate__row.is-ok .wiz-validate__status::before {
  content: '✓';
  display: inline-block;
  margin-right: 6px;
  color: var(--c-accent);
  font-weight: 800;
}

/* Step 5 naming */
.wiz-name h3 { margin: 0 0 10px; font-size: 16px; color: var(--c-ink); }
.wiz-name p  { margin: 0 0 14px; color: var(--c-ink-soft); font-size: 13px; }
.wiz-name__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wiz-name__list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--c-line);
  border-radius: 8px;
}
.wiz-name__model {
  flex-shrink: 0;
  min-width: 160px;
  font-weight: 700;
  font-size: 13px;
  color: var(--c-ink);
}
.wiz-name__model small {
  display: block;
  font-weight: 500;
  color: var(--c-ink-soft);
  font-size: 11px;
  margin-top: 2px;
}
.wiz-name__list input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  background: #ffffff;
  color: var(--c-ink);
}
.wiz-name__list input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

/* ============================================================
   Camera tile paused + fullscreen states
   ============================================================ */
.camera-tile.is-paused .camera-tile__viewport::after {
  content: 'PAUSED';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  z-index: 3;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* Fullscreen: fill the screen and keep the grid layout tidy */
.camera-tile:fullscreen,
.camera-tile.is-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  background: #000000;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
}
.camera-tile:fullscreen .camera-tile__viewport,
.camera-tile.is-fullscreen .camera-tile__viewport {
  flex: 1;
  aspect-ratio: auto;
}
.camera-tile:fullscreen .camera-tile__feed,
.camera-tile.is-fullscreen .camera-tile__feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============================================================
   PTZ (Pan / Tilt / Zoom) D-pad overlay for PTZ-capable cameras
   ============================================================ */
.ptz-pad {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 120px;
  height: 120px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 4px;
  z-index: 4;
  pointer-events: auto;
  opacity: 0.35;
  transition: opacity 0.15s;
  cursor: move;
}
.camera-tile:hover .ptz-pad { opacity: 0.9; }
.ptz-pad.is-dragging { opacity: 1; transition: none; }
.ptz-btn {
  background: rgba(15, 23, 42, 0.75);
  color: #2dd4bf;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.08s, border-color 0.12s;
  padding: 0;
  line-height: 1;
}
.ptz-btn:hover {
  background: rgba(13, 148, 136, 0.85);
  color: #ffffff;
  border-color: #2dd4bf;
}
.ptz-btn:active,
.ptz-btn.is-pressed {
  transform: scale(0.92);
  background: rgba(45, 212, 191, 0.35);
  border-color: #2dd4bf;
  color: #f0fdfa;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.5), 0 0 18px rgba(45, 212, 191, 0.4);
}
.ptz-btn--up    { grid-column: 2; grid-row: 1; }
.ptz-btn--left  { grid-column: 1; grid-row: 2; }
.ptz-btn--home  { grid-column: 2; grid-row: 2; }
.ptz-btn--right { grid-column: 3; grid-row: 2; }
.ptz-btn--down  { grid-column: 2; grid-row: 3; }
.ptz-btn--home {
  background: rgba(13, 148, 136, 0.4);
  border-color: rgba(45, 212, 191, 0.5);
}

/* ============================================================
   Single-instance lock, "another window took over" overlay
   ============================================================ */
.yield-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.96);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  font-family: var(--font, -apple-system, sans-serif);
  padding: 24px;
}
.yield-overlay__card {
  max-width: 460px;
  text-align: center;
  color: #e2e8f0;
}
.yield-overlay__icon {
  font-size: 56px;
  margin-bottom: 18px;
}
.yield-overlay__card h1 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}
.yield-overlay__card p {
  margin: 0 0 24px;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.6;
}
.yield-overlay__card .btn {
  font-size: 14px;
  padding: 12px 24px;
}

/* Picture-in-picture floating fallback for demo / non-video tiles */
.camera-tile--pip-fallback {
  position: fixed;
  right: 24px;
  bottom: 84px;
  width: 340px;
  z-index: 99999;
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  overflow: hidden;
  resize: both;
  min-width: 220px;
  min-height: 150px;
  max-width: 80vw;
  max-height: 80vh;
}
.camera-tile__pip-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 14px;
  cursor: pointer;
  z-index: 2;
}
.camera-tile__pip-close:hover { background: #e11d48; }

/* Iframe video feed: the streaming engine built-in player, same-origin with the engine. */
iframe.camera-tile__feed {
  border: 0;
  background: #000;
  width: 100%;
  height: 100%;
  display: block;
}

/* Auto picture-in-picture: clones of other tiles that appear inside a
   fullscreened tile so the user can keep watching every camera at once. */
.camera-tile--auto-pip {
  position: absolute;
  right: 24px;
  width: 320px;
  aspect-ratio: 16 / 10;
  z-index: 9999;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7),
              0 0 0 2px rgba(45, 212, 191, 0.4);
  background: #000;
  opacity: 0.95;
  transition: opacity 0.15s, transform 0.15s;
}
.camera-tile--auto-pip:hover {
  opacity: 1;
  transform: scale(1.02);
}
.camera-tile--auto-pip .camera-tile__viewport {
  aspect-ratio: 16 / 10;
  height: calc(100% - 48px);
}
.camera-tile--auto-pip .camera-tile__head {
  padding: 8px 12px;
}
.camera-tile--auto-pip .camera-tile__name {
  font-size: 13px;
}
.camera-tile--auto-pip .camera-tile__sub {
  font-size: 10px;
}

/* PiP drag handle + resize grip */
.camera-tile--auto-pip .camera-tile__head {
  cursor: move;
  user-select: none;
}
.camera-tile__pip-grip {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(45, 212, 191, 0.9) 50%);
  z-index: 3;
}
.camera-tile--auto-pip iframe {
  /* prevent iframe from swallowing drag events on the header */
  pointer-events: none;
}
.camera-tile--auto-pip:hover iframe {
  pointer-events: auto;
}

/* Mask the streaming engine's native <video> controls inside the iframe by overlaying a
   dark strip along the bottom edge. We can't hide the cross-origin iframe's
   UI directly, so we cover it. */
/* pip-mask rule removed: keeping the streaming engine's native player controls visible */
/* Also mask the top-right MSE / mode badge on the iframe */
.camera-tile--auto-pip::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 90px;
  height: 34px;
  background: linear-gradient(225deg, #0b1220 30%, transparent 100%);
  z-index: 3;
  pointer-events: none;
}

/* Swap-to-fullscreen button on each PiP clone */
.camera-tile__pip-full {
  position: absolute;
  top: 8px;
  right: 44px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  color: #2dd4bf;
  border: 1px solid rgba(45, 212, 191, 0.4);
  font-size: 15px;
  cursor: pointer;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-tile__pip-full:hover {
  background: #0d9488;
  color: #fff;
  border-color: #2dd4bf;
}
.camera-tile__pip-close {
  z-index: 4;
}

/* Minimise PiP clone chrome: hide the full header, shrink the bottom mask,
   only leave the fullscreen/close buttons floating over the video. */
.camera-tile--auto-pip .camera-tile__head {
  display: none;
}
.camera-tile--auto-pip .camera-tile__pip-mask {
  height: 34px;
  background: linear-gradient(180deg, transparent 0%, rgba(15, 23, 42, 0.9) 100%);
}
.camera-tile--auto-pip .camera-tile__viewport {
  height: 100%;
}
.camera-tile--auto-pip .camera-tile__pip-full,
.camera-tile--auto-pip .camera-tile__pip-close {
  top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.camera-tile--auto-pip:hover .camera-tile__pip-full,
.camera-tile--auto-pip:hover .camera-tile__pip-close {
  opacity: 1;
}
/* Drag handle: since the header is gone, make the whole PiP draggable via
   a transparent top strip that only reacts to mousedown, not the iframe. */
.camera-tile--auto-pip::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 76px; /* leave room for the buttons */
  height: 34px;
  cursor: move;
  z-index: 3;
}

/* Let zoom / pan / double-click events reach the viewport listener instead
   of being swallowed by the the streaming engine iframe. */
.camera-tile iframe.camera-tile__feed {
  pointer-events: none;
}

/* Demo mode loader: three bouncing dots shown in the welcome card while the
   fake cameras "load" inside the landing page's Try the demo modal. */
.demo-loader {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.demo-loader__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0d9488;
  animation: demo-dot-bounce 1.2s infinite ease-in-out both;
}
.demo-loader__dot:nth-child(1) { animation-delay: -0.3s; }
.demo-loader__dot:nth-child(2) { animation-delay: -0.15s; }
@keyframes demo-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* Permanent DEMO badge on the masthead whenever the app runs in demo mode */
.app-bar__demo-badge {
  margin-left: 10px;
  padding: 3px 8px;
  background: #f59e0b;
  color: #0f172a;
  border-radius: 999px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.4);
}
/* In demo env, fake the LAN URL colour so it's clearly not a real IP */
.is-demo-env #lan-url { color: #f59e0b; }
/* Hide the Live staging toolbar button in demo env entirely */
.is-demo-env #empty-live { display: none !important; }

/* Demo tutorial tooltips: speech bubbles that pulse next to each CTA the
   first time a visitor lands in the /app/?demo=1 playground. */
.is-demo-env #demo-toggle { display: none !important; }
.demo-tip-wrap {
  position: relative;
  display: inline-block;
}
.demo-tip {
  position: absolute;
  z-index: 50;
  max-width: 260px;
  padding: 10px 12px 10px 14px;
  background: #0d9488;
  color: #f0fdfa;
  border-radius: 10px;
  box-shadow: 0 12px 30px -10px rgba(13, 148, 136, 0.45);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  pointer-events: auto;
  animation: demo-tip-pulse 2.4s ease-in-out infinite;
}
.demo-tip strong {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  color: #ccfbf1;
}
.demo-tip span { display: block; color: #f0fdfa; }
.demo-tip--bottom {
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
}
.demo-tip--bottom::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #0d9488;
  border-radius: 2px;
}
@keyframes demo-tip-pulse {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-3px); }
}

/* Demo tour: single fixed bubble at bottom-center that walks the visitor
   through Scan -> wizard -> interact -> Add -> Share -> Settings one step
   at a time. Each step highlights its target with a pulsing ring, and the
   bubble body updates in place (no stacked tooltips). */
.demo-tour {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  width: min(520px, 92vw);
  z-index: 9998;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 14px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.6),
              0 0 0 1px rgba(45, 212, 191, 0.3);
  overflow: hidden;
  font-family: var(--font-sans, 'Inter', sans-serif);
  transition: opacity 0.25s, transform 0.25s;
}
.demo-tour.is-hiding {
  opacity: 0;
  transform: translate(-50%, 12px);
}
.demo-tour__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0d9488;
  color: #ccfbf1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.demo-tour__close {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.4);
  color: #f0fdfa;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.demo-tour__close:hover { background: rgba(15, 23, 42, 0.7); }
.demo-tour__body {
  padding: 14px 16px 4px;
  font-size: 13px;
  line-height: 1.55;
  color: #e2e8f0;
}
.demo-tour__body strong { color: #2dd4bf; font-weight: 700; }
.demo-tour__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
}
.demo-tour__skip,
.demo-tour__next {
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.demo-tour__skip {
  background: transparent;
  color: #94a3b8;
  border-color: #334155;
}
.demo-tour__skip:hover {
  color: #f8fafc;
  border-color: #64748b;
}
.demo-tour__next {
  background: #2dd4bf;
  color: #0f172a;
}
.demo-tour__next:hover { background: #5eead4; }

/* Pulsing ring on whatever element the current tour step points at */
.demo-tour-pulse {
  position: relative;
  z-index: 60;
  animation: demo-tour-ring 1.8s ease-out infinite;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.85),
              0 0 0 8px rgba(45, 212, 191, 0.35) !important;
  border-radius: 12px;
}
@keyframes demo-tour-ring {
  0%   { box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.85), 0 0 0 0 rgba(45, 212, 191, 0.6); }
  70%  { box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.85), 0 0 0 14px rgba(45, 212, 191, 0); }
  100% { box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.85), 0 0 0 0 rgba(45, 212, 191, 0); }
}

/* Per-camera credentials step in the Add Camera wizard */
.wiz-credentials h3 { margin: 0 0 0.4rem; font-size: 1.1rem; color: #0f172a; }
.wiz-credentials > p {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.55;
}
.wiz-creds-bulk {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.2rem;
}
.wiz-creds-bulk__title {
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #0d9488;
}
.wiz-creds-bulk__row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
}
.wiz-creds-bulk__row input {
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.88rem;
  background: #ffffff;
  color: #0f172a;
  font-family: var(--font-sans, 'Inter', sans-serif);
}
.wiz-creds-bulk__row input:focus {
  outline: none;
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
.wiz-creds-bulk__row .btn--sm {
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  border-radius: 6px;
  white-space: nowrap;
}
.wiz-creds-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}
.wiz-creds-row {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: #ffffff;
}
.wiz-creds-row__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}
.wiz-creds-row__head strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}
.wiz-creds-row__head span {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
}
.wiz-creds-row__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.wiz-creds-row__fields label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.wiz-creds-row__fields label span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}
.wiz-creds-row__fields input {
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #ffffff;
  color: #0f172a;
  font-family: var(--font-sans, 'Inter', sans-serif);
}
.wiz-creds-row__fields input:focus {
  outline: none;
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
@media (max-width: 560px) {
  .wiz-creds-bulk__row { grid-template-columns: 1fr; }
  .wiz-creds-row__fields { grid-template-columns: 1fr; }
}

/* Finish demo CTA: floating bottom-right pill inside the demo app that
   closes the landing-page modal and scrolls to the Buy buttons. */
.finish-demo-cta {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 18px;
  background: #0d9488;
  color: #f0fdfa;
  border: 0;
  border-radius: 12px;
  font-family: var(--font-sans, 'Inter', sans-serif);
  cursor: pointer;
  box-shadow: 0 20px 45px -10px rgba(13, 148, 136, 0.55);
  transition: transform 0.15s, box-shadow 0.15s;
}
.finish-demo-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 55px -10px rgba(13, 148, 136, 0.7);
  background: #2dd4bf;
  color: #0f172a;
}
.finish-demo-cta__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #ccfbf1;
}
.finish-demo-cta:hover .finish-demo-cta__label { color: #0f172a; }
.finish-demo-cta__main {
  font-size: 14px;
  font-weight: 700;
}
