/* ──────────────────────────────────────────────
   Slumberly Web Monitor — Styles
   Matched to iOS app design language
   ────────────────────────────────────────────── */

/* --- Design Tokens (matched to iOS AppBackgroundView & ControlButton) --- */
:root {
  /* Backgrounds — from AppBackgroundView gradient */
  --bg-primary: #12122a;
  --bg-gradient-start: #12122a;
  --bg-gradient-end: #1e1940;

  /* Surfaces / Glass — from .ultraThinMaterial */
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-hover: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.15);
  --glass-blur: 20px;

  /* Accent — from iOS accentPurple / accentBlue */
  --accent-purple: #8c66f2;
  --accent-purple-dark: #7c5ce0;
  --accent-blue: #598cff;
  --gradient: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);

  /* Status */
  --green: #4ade80;
  --red: #f87171;
  --orange: #fbbf24;
  --cyan: #22d3ee;

  /* Typography — iOS uses SF Pro Rounded for headings */
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'SF Pro Display', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

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

body {
  font-family: var(--font-body);
  background: linear-gradient(145deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

/* Subtle background pattern — approximates BabyDoodles overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(140, 102, 242, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(89, 140, 255, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Screen containers ── */

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  padding: 16px;
  margin: auto 0;
  animation: fadeIn 0.4s ease;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modern Language Dropdown (iOS Frosted Glass) ── */
.lang-dropdown-wrapper {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 500;
}

.lang-dropdown-btn {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  user-select: none;
}

.lang-dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.lang-dropdown-btn:active {
  transform: scale(0.97);
}

.lang-globe-icon {
  color: var(--accent-purple);
  flex-shrink: 0;
}

.current-lang-code {
  font-size: 11px;
  font-weight: 700;
  background: rgba(140, 102, 242, 0.25);
  color: #c4b5fd;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.current-lang-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.lang-chevron-icon {
  color: var(--text-secondary);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-dropdown-wrapper.open .lang-chevron-icon {
  transform: rotate(180deg);
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  max-height: 380px;
  background: rgba(20, 20, 42, 0.92);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  padding: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.2s;
  z-index: 600;
}

.lang-dropdown-wrapper.open .lang-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.lang-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
}

.lang-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.lang-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  padding: 8px 12px 8px 32px;
  color: #fff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
}

.lang-search-input:focus {
  background: rgba(255, 255, 255, 0.10);
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(140, 102, 242, 0.25);
}

.lang-search-input::placeholder {
  color: var(--text-muted);
}

.lang-options-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 300px;
  padding-right: 2px;
}

/* Custom scrollbar */
.lang-options-list::-webkit-scrollbar {
  width: 4px;
}
.lang-options-list::-webkit-scrollbar-track {
  background: transparent;
}
.lang-options-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.lang-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
}

.lang-option-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.lang-option-item.active {
  background: linear-gradient(135deg, rgba(140, 102, 242, 0.25), rgba(89, 140, 255, 0.2));
  color: #fff;
  font-weight: 700;
}

.lang-option-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

.lang-option-item.active .lang-badge {
  color: #c4b5fd;
  background: rgba(140, 102, 242, 0.35);
}

.lang-check-icon {
  opacity: 0;
  color: var(--green);
  transition: opacity 0.15s;
}

.lang-option-item.active .lang-check-icon {
  opacity: 1;
}

/* RTL Support for Hebrew / Arabic */
html[dir="rtl"] .lang-dropdown-wrapper {
  right: auto;
  left: 16px;
}
html[dir="rtl"] .lang-dropdown-menu {
  right: auto;
  left: 0;
  transform-origin: top left;
}

@media (max-width: 480px) {
  .lang-dropdown-wrapper {
    top: 12px;
    right: 12px;
  }
  html[dir="rtl"] .lang-dropdown-wrapper {
    right: auto;
    left: 12px;
  }
  .current-lang-name {
    display: none;
  }
  .lang-dropdown-menu {
    width: calc(100vw - 24px);
    right: 0;
    max-height: 340px;
  }
  html[dir="rtl"] .lang-dropdown-menu {
    right: auto;
    left: 0;
  }
}

/* ══════════════════════════════════════════════
   ROLE SELECTION SCREEN
   ══════════════════════════════════════════════ */

.logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.logo img {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  object-fit: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
}

.brand-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: var(--gradient);
  color: white;
}

.tagline {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  text-align: center;
}

/* Role cards — side-by-side iOS-style */
.role-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  margin-top: 8px;
}

.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  padding: 24px 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  color: inherit;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  position: relative;
  overflow: hidden;
}

.role-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  opacity: 0;
  transition: opacity 0.3s;
}

.role-card:first-child::before {
  background: radial-gradient(circle at 50% 30%, rgba(140, 102, 242, 0.15) 0%, transparent 70%);
}

.role-card:last-child::before {
  background: radial-gradient(circle at 50% 30%, rgba(64, 128, 242, 0.15) 0%, transparent 70%);
}

.role-card:hover::before {
  opacity: 1;
}

.role-card:hover {
  border-color: rgba(140, 102, 242, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.role-card:active {
  transform: scale(0.97);
}

.role-card-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

/* Radial glow behind icon — matches iOS RadialGradient */
.role-card-icon::before {
  content: '';
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  z-index: -1;
}

.role-card:first-child .role-card-icon::before {
  background: radial-gradient(circle, rgba(140, 102, 242, 0.25) 0%, transparent 70%);
}

.role-card:last-child .role-card-icon::before {
  background: radial-gradient(circle, rgba(64, 128, 242, 0.25) 0%, transparent 70%);
}

.role-card-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.role-card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.role-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.role-card-arrow {
  display: none; /* Hidden in card layout, not needed */
}

/* Connect hint — bottom of role/connect screen */
.connect-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ══════════════════════════════════════════════
   CONNECT SCREEN
   ══════════════════════════════════════════════ */

/* Code Input */
.code-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.code-digit {
  width: 48px;
  height: 60px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  caret-color: var(--accent-purple);
}

.code-digit:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(140, 102, 242, 0.2);
  background: rgba(140, 102, 242, 0.06);
}

.code-digit.filled {
  border-color: var(--accent-purple);
  background: rgba(140, 102, 242, 0.08);
}

/* Connect Button — iOS-style gradient pill */
.btn-connect {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--accent-purple-dark), #5b6abf);
  color: white;
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 6px 24px rgba(124, 92, 224, 0.35);
  position: relative;
  overflow: hidden;
}

.btn-connect:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(124, 92, 224, 0.45);
}

.btn-connect:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-connect:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

.btn-connect .spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-connect.loading .btn-text {
  display: none;
}

.btn-connect.loading .spinner {
  display: inline-block;
}

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

/* Error message */
.error-message {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--red);
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.error-message.visible {
  display: flex;
}

/* QR Scan Button */
.btn-scan-qr {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
  margin-bottom: 24px;
}

.btn-scan-qr:hover {
  border-color: var(--accent-purple);
  color: var(--text-primary);
  background: rgba(140, 102, 242, 0.08);
}

.btn-scan-qr svg {
  opacity: 0.7;
}

/* Back Button */
.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  margin-top: 16px;
  transition: color 0.2s;
  font-family: inherit;
}

.btn-back:hover {
  color: var(--text-primary);
}

/* ══════════════════════════════════════════════
   MONITOR SCREEN (Parent Unit)
   ══════════════════════════════════════════════ */

#monitor-screen {
  max-width: 100%;
  padding: 0;
  height: 100dvh;
  justify-content: space-between;
  overflow: hidden;
}

/* Top bar — iOS-style with capsule badge */
.monitor-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  width: 100%;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex-shrink: 0;
}

.status-dot.connecting {
  background: var(--orange);
  box-shadow: 0 0 8px var(--orange);
  animation: pulse 1.5s ease infinite;
}

.status-dot.disconnected {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* Session timer — capsule pill below badge */
.session-timer {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

/* Disconnect — circular button matching iOS */
.btn-disconnect {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  /* Show × instead of text */
  font-size: 0;
  overflow: hidden;
}

.btn-disconnect::after {
  content: '✕';
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
}

.btn-disconnect:hover {
  background: rgba(248, 113, 113, 0.2);
}

.btn-disconnect:hover::after {
  color: var(--red);
}

/* Video container */
.video-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-placeholder {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.video-placeholder .placeholder-icon {
  font-size: 48px;
  opacity: 0.3;
}

/* Sound level bar — thin line above controls */
.sound-level-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  flex-shrink: 0;
}

.sound-level-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 0;
  transition: width 0.15s ease;
}

.sound-level-fill.alert {
  background: var(--red);
}

/* ── Bottom Controls — iOS ControlButton style ── */
.monitor-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 12px 12px max(20px, env(safe-area-inset-bottom, 20px));
  width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
  z-index: 10;
  flex-shrink: 0;
}

/* Button groups */
.controls-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
}

.controls-utility {
  margin-right: 8px;
}

.controls-main {
  flex: 0 1 auto;
}

.controls-settings {
  margin-left: 8px;
}

/* Individual control button — CIRCULAR iOS style */
.control-btn {
  width: 50px;
  height: 50px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  transition: all 0.2s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  touch-action: manipulation;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.control-btn:active {
  transform: scale(0.90);
}

/* Active state — tinted circle with glow */
.control-btn.active {
  background: rgba(140, 102, 242, 0.20);
  color: #c4b5fd;
  box-shadow: 0 0 16px rgba(140, 102, 242, 0.25);
  border: 1px solid rgba(140, 102, 242, 0.3);
}

/* Talk button active — green glow matching iOS */
.control-btn.talk-active {
  background: rgba(74, 222, 128, 0.25);
  color: var(--green);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.3);
  border: 2px solid rgba(74, 222, 128, 0.4);
  animation: talkPulse 1s ease infinite;
}

@keyframes talkPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.3); }
  50%      { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
}

/* Night vision max — cyan tint */
.control-btn.night-max {
  background: rgba(34, 211, 238, 0.25);
  color: #67e8f9;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.25);
  border: 1px solid rgba(34, 211, 238, 0.3);
}

/* Icon inside button */
.control-icon {
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
}

/* Label beneath button — positioned outside circle */
.control-label {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 0;
  letter-spacing: 0.3px;
  position: absolute;
  bottom: -16px;
  white-space: nowrap;
  pointer-events: none;
}

.control-btn.active .control-label {
  color: rgba(140, 102, 242, 0.7);
}

.control-btn.night-max .control-label {
  color: rgba(34, 211, 238, 0.7);
}

/* SVG icons in utility buttons */
.control-btn svg {
  opacity: 0.85;
}

/* Hide old tooltip, we use labels now */
.control-btn .tooltip {
  display: none;
}

/* Sound alert toast */
.sound-alert {
  display: none;
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 400px;
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 20px;
  padding: 16px 24px;
  color: var(--red);
  font-size: 16px;
  font-weight: 600;
  z-index: 30;
  animation: fadeIn 0.3s ease;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 32px rgba(248, 113, 113, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sound-alert button {
  background: none;
  border: none;
  color: inherit;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.sound-alert button:hover {
  opacity: 1;
}

.sound-alert.visible {
  display: flex;
}

.turn-alert {
  background: rgba(140, 102, 242, 0.15);
  border: 1px solid rgba(140, 102, 242, 0.4);
  color: #8c66f2; /* Slumberly primary purple */
  box-shadow: 0 8px 32px rgba(140, 102, 242, 0.2);
  top: 140px; /* Below the sound alert */
}

/* Sound picker overlay */
.sound-picker {
  display: none;
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 20, 42, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 16px;
  z-index: 20;
  min-width: 220px;
  animation: slideUp 0.25s ease;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.sound-picker.visible {
  display: block;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sound-picker-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.sound-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.sound-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sound-option.active {
  background: rgba(140, 102, 242, 0.15);
  color: var(--accent-purple);
}

.sound-option .sound-icon {
  font-size: 18px;
}

/* ══════════════════════════════════════════════
   BABY UNIT SCREEN
   ══════════════════════════════════════════════ */

#baby-screen {
  max-width: 100%;
  padding: 0;
  height: 100dvh;
  justify-content: flex-start;
}

#local-camera {
  width: 100%;
  height: auto;
  max-height: 70vh;
  border-radius: 0;
  object-fit: contain;
  background: #000;
  transform: scaleX(-1);
}

.camera-selector {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 10;
}

.baby-info {
  width: 100%;
  padding: 16px;
}

.baby-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.15);
  border-radius: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.baby-info-card span {
  font-size: 20px;
}

/* ══════════════════════════════════════════════
   SUBSCRIPTION MODAL
   ══════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-content {
  background: rgba(22, 20, 42, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.3s ease;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-content h3 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ══════════════════════════════════════════════
   QR CODE SCANNER OVERLAY
   ══════════════════════════════════════════════ */

.qr-scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-gradient-start);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.qr-scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  flex-shrink: 0;
}

.qr-scanner-header h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close-scanner {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-close-scanner:hover {
  background: rgba(255, 255, 255, 0.2);
}

.qr-scanner-viewport {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.qr-scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-scanner-guide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.qr-corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: var(--accent-purple);
  border-style: solid;
  border-width: 0;
}

.qr-corner.tl {
  top: 20%;
  left: 20%;
  border-top-width: 3px;
  border-left-width: 3px;
  border-radius: 8px 0 0 0;
}

.qr-corner.tr {
  top: 20%;
  right: 20%;
  border-top-width: 3px;
  border-right-width: 3px;
  border-radius: 0 8px 0 0;
}

.qr-corner.bl {
  bottom: 20%;
  left: 20%;
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-radius: 0 0 0 8px;
}

.qr-corner.br {
  bottom: 20%;
  right: 20%;
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-radius: 0 0 8px 0;
}

.qr-scanner-hint {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
  max-width: 300px;
}

/* ══════════════════════════════════════════════
   FOOTER & VISIBILITY
   ══════════════════════════════════════════════ */

/* Hide lang dropdown and footer on monitor/baby screens */
body:has(#monitor-screen.active) .lang-dropdown-wrapper,
body:has(#baby-screen.active) .lang-dropdown-wrapper {
  display: none;
}

body:has(#monitor-screen.active) .watch-footer,
body:has(#baby-screen.active) .watch-footer {
  display: none;
}

.watch-footer {
  margin-top: auto;
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.watch-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.watch-footer a:hover {
  color: var(--text-primary);
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */

/* Small screens — stack role cards if too narrow */
@media (max-width: 360px) {
  .role-cards {
    grid-template-columns: 1fr;
  }

  .code-digit {
    width: 42px;
    height: 54px;
    font-size: 20px;
  }
}

/* ── Portrait-specific adjustments ── */
@media (orientation: portrait) {
  #monitor-screen {
    flex-direction: column;
  }

  .monitor-controls {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .controls-utility,
  .controls-settings {
    margin-left: 0;
    margin-right: 0;
  }
}

/* Narrow portrait phones — shrink buttons slightly, remove margins */
@media (orientation: portrait) and (max-width: 400px) {
  .control-btn {
    width: 48px;
    height: 48px;
  }

  .controls-group {
    gap: 8px;
  }

  .controls-utility,
  .controls-settings {
    margin-left: 0;
    margin-right: 0;
  }

  .monitor-controls {
    gap: 6px;
    padding: 10px 8px max(16px, env(safe-area-inset-bottom, 16px));
  }

  .control-label {
    font-size: 8px;
    bottom: -14px;
  }
}

/* ── Landscape — side-by-side layout (video + controls column) ── */
@media (orientation: landscape) {
  #monitor-screen {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  .monitor-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
  }

  .video-container {
    flex: 1;
    height: 100dvh;
    min-width: 0;
  }

  .sound-level-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 15;
  }

  .monitor-controls {
    flex-direction: column;
    flex-wrap: nowrap;
    width: auto;
    max-width: 80px;
    height: 100dvh;
    padding: 60px 10px 20px;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(to left, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
  }

  .controls-group {
    flex-direction: column;
    gap: 8px;
  }

  .controls-utility,
  .controls-settings {
    margin: 0;
  }

  .controls-utility {
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .controls-settings {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .control-label {
    position: static;
    margin-top: 2px;
    font-size: 8px;
  }

  .control-btn {
    width: 48px;
    height: 48px;
  }

  /* Baby screen landscape */
  #baby-screen {
    flex-direction: row;
  }

  #baby-screen .video-container {
    flex: 1;
    height: 100dvh;
  }

  #local-camera {
    max-height: 100vh;
  }

  .baby-info {
    max-width: 240px;
  }

  /* Sound picker in landscape — anchor to right side */
  .sound-picker {
    bottom: auto;
    top: 50%;
    left: auto;
    right: 90px;
    transform: translateY(-50%);
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translateY(-50%) translateX(8px); }
    to   { opacity: 1; transform: translateY(-50%) translateX(0); }
  }
}
