:root {
  --brand-blue: #1E6BFF;
  --brand-blue-dark: #0F46C7;
  --brand-blue-soft: rgba(30, 107, 255, 0.14);
  --bg-dark: #0B0F17;
  --bg-shell: #111827;
  --bg-card: #1A2333;
  --bg-card-hover: #222E42;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --text-main: #F3F6FC;
  --text-muted: #94A3B8;
  --accent-green: #10B981;
  --accent-orange: #F59E0B;
  --accent-red: #EF4444;
  --radius-lg: 16px;
  --radius-md: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Noto Sans Thai', sans-serif;
  background: radial-gradient(circle at top, #172544 0%, #090D16 70%);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* Top Multi-Platform Workspace Bar */
.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.domecam-logo-icon svg {
  width: 38px;
  height: 38px;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(30, 107, 255, 0.4));
}

.workspace-title {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-pro {
  font-size: 0.68rem;
  background: linear-gradient(135deg, #1E6BFF, #06B6D4);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}

.detected-os-badge {
  font-size: 0.7rem;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6EE7B7;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}

.workspace-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.view-mode-switch {
  display: flex;
  background: #0B111E;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--brand-blue);
  color: #fff;
  font-weight: 600;
}

.btn-install-app {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  border: none;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* =====================================================
   DEVICE SHELL MODES: iOS / Android / iPad / Desktop PC
   ===================================================== */
.app-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 18px 12px;
  transition: all 0.25s ease;
}

.phone-shell {
  background: var(--bg-shell);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: all 0.25s ease;
}

/* 1. iOS (iPhone 16 Pro Style Frame) */
.app-wrapper.mode-ios .phone-shell {
  width: 410px;
  max-width: 100%;
  height: 844px;
  max-height: 89vh;
  border-radius: 48px;
  border: 8px solid #2A3446;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.7), 0 0 0 2px #526079;
}

.app-wrapper.mode-ios .hw-notch {
  display: block;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 112px;
  height: 24px;
  background: #000;
  border-radius: 99px;
  z-index: 30;
}

/* 2. Android (Samsung Galaxy / Pixel Style Frame) */
.app-wrapper.mode-android .phone-shell {
  width: 412px;
  max-width: 100%;
  height: 850px;
  max-height: 89vh;
  border-radius: 26px;
  border: 6px solid #1E2633;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.7);
}

.app-wrapper.mode-android .hw-notch {
  display: block;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: #000;
  border-radius: 50%;
  z-index: 30;
}

/* 3. iPad / Tablet Split-View Frame */
.app-wrapper.mode-ipad .phone-shell {
  width: 1060px;
  max-width: 98vw;
  height: 760px;
  max-height: 88vh;
  border-radius: 32px;
  border: 10px solid #253042;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.75);
}

.app-wrapper.mode-ipad .hw-notch {
  display: none;
}

/* 4. Desktop PC Full Monitor Mode */
.app-wrapper.mode-desktop {
  padding: 0;
}

.app-wrapper.mode-desktop .phone-shell {
  width: 100%;
  max-width: 1600px;
  min-height: calc(100vh - 59px);
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.app-wrapper.mode-desktop .hw-notch,
.app-wrapper.mode-desktop .status-bar,
.app-wrapper.mode-desktop .home-indicator-bar {
  display: none;
}

/* Side Navigation Rail vs Bottom Bar Visibility */
.shell-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.side-rail {
  display: none;
  width: 200px;
  background: #0D1424;
  border-right: 1px solid var(--border-subtle);
  flex-direction: column;
  padding: 14px 10px;
  gap: 6px;
  flex-shrink: 0;
}

.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 11px 12px;
  border-radius: 11px;
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  text-align: left;
  transition: 0.18s;
}

.rail-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.rail-item.active {
  background: var(--brand-blue-soft);
  border-color: rgba(30, 107, 255, 0.45);
  color: #60A5FA;
  font-weight: 600;
}

.rail-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: #fff;
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 99px;
}

.rail-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.rail-install-btn {
  width: 100%;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6EE7B7;
  padding: 9px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.pages-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Activate Side Rail & Split Layout in iPad and Desktop Modes */
.app-wrapper.mode-ipad .side-rail,
.app-wrapper.mode-desktop .side-rail {
  display: flex;
}

.app-wrapper.mode-ipad .bottom-nav,
.app-wrapper.mode-desktop .bottom-nav {
  display: none;
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(10px + var(--safe-top)) 24px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  background: #0D131F;
}

.status-bar-icons {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 18px;
  background: #0F172A;
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-name {
  font-size: 1.12rem;
  font-weight: 700;
}

.app-tagline {
  font-size: 0.74rem;
  color: var(--accent-green);
}

.header-right {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-add-primary {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
}

/* Tab Pages */
.tab-page {
  display: none;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(84px + var(--safe-bottom));
}

.app-wrapper.mode-ipad .tab-page,
.app-wrapper.mode-desktop .tab-page {
  padding-bottom: 24px;
}

.tab-page.active {
  display: block;
}

/* Security Banner */
.security-banner {
  background: linear-gradient(135deg, #172B4D 0%, #101C33 100%);
  border: 1px solid rgba(30, 107, 255, 0.3);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-wrapper.mode-desktop .security-banner,
.app-wrapper.mode-ipad .security-banner {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.sec-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sec-shield {
  font-size: 1.5rem;
}

.sec-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.sec-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sec-modes {
  display: flex;
  gap: 6px;
}

.sec-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
}

.sec-chip.active {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
  font-weight: 600;
}

/* Room Filter Pills */
.room-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.room-pill {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.room-pill.active {
  background: var(--brand-blue-soft);
  color: #60A5FA;
  border-color: var(--brand-blue);
  font-weight: 600;
}

/* Camera List Grid */
.camera-list-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.camera-list-container.quad-grid,
.app-wrapper.mode-ipad .camera-list-container,
.app-wrapper.mode-desktop .camera-list-container {
  grid-template-columns: repeat(2, 1fr);
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.camera-card:hover {
  transform: translateY(-2px);
  border-color: rgba(30, 107, 255, 0.55);
}

.cam-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
}

.cam-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cam-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-green);
}

.cam-card-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.cam-room-tag {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-muted);
}

.cam-preview-box {
  position: relative;
  height: 185px;
  background: #05080F;
  overflow: hidden;
}

.cam-preview-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-preview-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 45%, rgba(0,0,0,0.45) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 12px;
}

.preview-top-badges {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
}

.live-pill {
  background: rgba(239, 68, 68, 0.88);
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.wifi-pill {
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 7px;
  border-radius: 4px;
}

.preview-play-btn {
  align-self: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(30, 107, 255, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.preview-bottom-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #CBD5E1;
}

/* =================================================
   LIVE VIEW SPLIT-GRID FOR iPad & PC vs Mobile
   ================================================= */
.live-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.back-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}

.cam-select {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.84rem;
}

.quality-badge {
  background: var(--brand-blue-soft);
  border: 1px solid var(--brand-blue);
  color: #60A5FA;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.live-responsive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.app-wrapper.mode-ipad .live-responsive-grid,
.app-wrapper.mode-desktop .live-responsive-grid {
  grid-template-columns: 1.45fr 1fr;
  align-items: start;
}

.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* CSS Fullscreen fallback for iOS Safari */
.video-stage.stage-css-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
}

.video-stage canvas,
.video-stage video,
.video-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.18s ease;
}

.osd-top-left {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.74rem;
  pointer-events: none;
}

.rec-dot {
  color: #EF4444;
  font-weight: 700;
  animation: blink 1.2s infinite;
}

@keyframes blink {
  50% { opacity: 0.35; }
}

.osd-bitrate {
  color: #38BDF8;
  font-family: monospace;
}

.osd-top-right {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.74rem;
  pointer-events: none;
}

.osd-bottom-left {
  position: absolute;
  bottom: 10px;
  left: 12px;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

.osd-pill {
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.7rem;
}

.ai-pill {
  color: #34D399;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.talk-overlay {
  position: absolute;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 107, 255, 0.92);
  padding: 8px 16px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.wave-bars {
  display: flex;
  gap: 3px;
  align-items: center;
}

.wave-bars span {
  width: 3px;
  height: 12px;
  background: #fff;
  animation: soundwave 0.6s infinite ease-in-out alternate;
}

@keyframes soundwave {
  from { transform: scaleY(0.4); }
  to { transform: scaleY(1.2); }
}

.privacy-overlay {
  position: absolute;
  inset: 0;
  background: #090D16;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
}

/* Player Action Bar */
.player-action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.action-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 10px;
  padding: 9px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}

.action-item:active,
.action-item.active {
  background: var(--brand-blue-soft);
  border-color: var(--brand-blue);
  color: #60A5FA;
}

.act-icon {
  font-size: 1.15rem;
}

.act-label {
  font-size: 0.7rem;
}

/* Live Subtabs & PTZ */
.live-subtabs {
  display: flex;
  background: #0D131F;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.subtab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 6px;
  border-radius: 7px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
}

.subtab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
}

.live-subpanel {
  display: none;
}

.live-subpanel.active {
  display: block;
}

.ptz-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ptz-pad-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.ptz-dpad {
  position: relative;
  width: 152px;
  height: 152px;
  border-radius: 50%;
  background: radial-gradient(circle, #1E293B 0%, #0F172A 100%);
  border: 2px solid rgba(30, 107, 255, 0.45);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
  touch-action: none;
}

.ptz-dir {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  touch-action: none;
}

.ptz-dir:active {
  background: var(--brand-blue);
}

.ptz-dir.up { top: 6px; left: 50%; transform: translateX(-50%); }
.ptz-dir.down { bottom: 6px; left: 50%; transform: translateX(-50%); }
.ptz-dir.left { left: 6px; top: 50%; transform: translateY(-50%); }
.ptz-dir.right { right: 6px; top: 50%; transform: translateY(-50%); }

.ptz-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: #1E293B;
  color: #93C5FD;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.zoom-btn {
  background: #0F172A;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

.keyboard-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.preset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.preset-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 9px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
}

.preset-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--brand-blue-soft);
  color: #60A5FA;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Playback Timeline */
.playback-source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.source-tabs {
  display: flex;
  gap: 6px;
}

.source-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-family: inherit;
  cursor: pointer;
}

.source-btn.active {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
}

.date-picker {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
}

.timeline-Status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  margin-bottom: 8px;
}

.btn-live-return {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
}

.timeline-ruler-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.timeline-legend {
  display: flex;
  gap: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dot-legend {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
}
.dot-legend.human { background: #EF4444; }
.dot-legend.motion { background: #F59E0B; }
.dot-legend.cont { background: #10B981; }

.timeline-track {
  position: relative;
  height: 28px;
  background: #0B111E;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}

.timeline-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.85;
}

.timeline-playhead {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  z-index: 4;
}

.timeline-hours {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.playback-clips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clip-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

/* Add Camera & Forms */
.section-header-box h2 { font-size: 1.05rem; margin-bottom: 4px; }
.section-header-box p { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 12px; }

.conn-method-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.conn-tab {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

.conn-tab.active {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
  font-weight: 600;
}

.conn-panel { display: none; }
.conn-panel.active { display: block; }

.scan-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.radar-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--brand-blue-soft);
  border: 2px solid var(--brand-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.radar-circle.scanning {
  animation: pulseRadar 1s infinite ease-in-out;
}

@keyframes pulseRadar {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(30, 107, 255, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 14px rgba(30, 107, 255, 0); }
  100% { transform: scale(0.95); }
}

.scan-info h3 { font-size: 0.9rem; margin-bottom: 4px; }
.scan-info p { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 10px; }

.btn-primary-full {
  width: 100%;
  background: var(--brand-blue);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

.scan-device-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.scan-device-card.likely-cam {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.06);
}

.add-cam-form {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 0.75rem; color: var(--text-muted); }
.form-group input, .form-group select {
  background: #0D131F;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px; /* Prevents iOS auto-zoom on input focus */
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-row-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.url-test-row { display: flex; gap: 6px; }
.url-test-row input { flex: 1; }

.btn-secondary {
  background: #263248;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary-sm {
  background: var(--brand-blue);
  color: #fff;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
}

.btn-link-sm {
  background: none;
  border: none;
  color: #60A5FA;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

/* QR Code Pairing */
.qr-pairing-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.qr-instruction { font-size: 0.75rem; color: var(--text-muted); margin: 6px 0 12px; line-height: 1.45; }
.qr-box-wrapper { display: flex; justify-content: center; margin: 14px 0; }
#qrcodeContainer, #mobileAccessQr { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.qr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Alerts & Profile */
.alerts-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.sub-box-title { font-size: 0.8rem; font-weight: 600; margin-bottom: 8px; color: #93C5FD; }
.snapshot-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.snap-thumb { width: 130px; flex-shrink: 0; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden; }
.snap-thumb img { width: 100%; height: 74px; object-fit: cover; display: block; }
.snap-meta { padding: 4px 6px; font-size: 0.68rem; color: var(--text-muted); }

.alert-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.settings-list { display: flex; flex-direction: column; gap: 10px; }
.setting-row {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.setting-title { font-size: 0.82rem; font-weight: 600; }
.setting-sub { font-size: 0.72rem; color: var(--text-muted); }

.profile-card, .guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}
.profile-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.profile-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--brand-blue); display: flex; align-items: center; justify-content: center; font-weight: 700; }

.platform-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.plat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
}
.plat-icon { font-size: 1.5rem; margin-bottom: 4px; }
.plat-card h4 { font-size: 0.86rem; margin-bottom: 4px; color: #93C5FD; }
.plat-card p { font-size: 0.74rem; color: var(--text-muted); line-height: 1.45; }

.guide-steps { padding-left: 18px; margin-top: 8px; font-size: 0.78rem; color: #CBD5E1; line-height: 1.55; }

/* Bottom Navigation (iOS / Android) */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 20;
}

.nav-item {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 12px;
}

.nav-item.active { color: #60A5FA; font-weight: 600; }
.nav-icon { font-size: 1.2rem; }
.nav-text { font-size: 0.7rem; }
.nav-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  background: var(--accent-red);
  color: #fff;
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 99px;
}

/* iOS / Android Home Gesture Indicator */
.home-indicator-bar {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 25;
}
.home-indicator-bar span {
  width: 120px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.35);
}

/* Modal Install & QR */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  width: 100%;
  max-width: 640px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #0F172A;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 { font-size: 0.98rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-body { padding: 18px; max-height: 82vh; overflow-y: auto; }

.install-qr-section {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--bg-card);
  padding: 14px;
  border-radius: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.install-qr-info { flex: 1; min-width: 240px; }
.qr-badge-live { font-size: 0.72rem; color: #34D399; font-weight: 600; margin-bottom: 4px; }
.install-qr-info h4 { font-size: 0.92rem; margin-bottom: 4px; }
.install-qr-info p { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; }

.copy-url-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0B0F17;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.copy-url-box code { color: #60A5FA; font-size: 0.85rem; }

.install-os-guides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.os-guide-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 12px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.os-guide-box strong { display: block; margin-bottom: 6px; color: #F3F6FC; font-size: 0.82rem; }
.os-guide-box ol { padding-left: 16px; color: #CBD5E1; line-height: 1.5; }

/* Native Mobile / iPad Real Device Media Queries */
@media (max-width: 767px) {
  .workspace-bar { display: none; }
  .app-wrapper { padding: 0 !important; }
  .phone-shell {
    width: 100vw !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
  }
  .hw-notch, .status-bar { display: none !important; }
  .side-rail { display: none !important; }
  .bottom-nav { display: flex !important; }
  .camera-list-container { grid-template-columns: 1fr !important; }
  .live-responsive-grid { grid-template-columns: 1fr !important; }
}

@media (min-width: 768px) and (max-width: 1180px) {
  /* Real iPad / Android Tablet Auto Optimization */
  .app-wrapper.real-tablet { padding: 0 !important; }
  .app-wrapper.real-tablet .phone-shell {
    width: 100vw !important;
    height: 100dvh !important;
    max-height: none !important;
    border: none !important;
    border-radius: 0 !important;
  }
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1E293B;
  border-left: 4px solid var(--brand-blue);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-size: 0.82rem;
}

.empty-hint, .empty-hint-sm {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 16px;
}
