:root {
  --bg-base: #080c15;
  --bg-surface: #0e1524;
  --bg-card: #121c30;
  --bg-card-hover: #16233c;
  --bg-input: #0a101d;
  --border-subtle: #1e293b;
  --border-medium: #334155;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
}

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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dynamic Daily Space Wallpaper System */
.wallpaper-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.wallpaper-layer-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1000ms ease-in-out;
  transform: scale(1.02);
  z-index: 0;
}

.wallpaper-layer-image.loaded {
  opacity: 1;
}

.wallpaper-layer-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(3, 7, 18, 0.82) 0%, rgba(2, 6, 23, 0.94) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1;
}

.wallpaper-layer-texture {
  position: absolute;
  inset: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  z-index: 2;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  position: relative;
  z-index: 10;
  background-color: transparent;
}

/* Slim Application Header (44px) */
.app-header {
  height: 44px;
  min-height: 44px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  user-select: none;
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: block;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-sub {
  font-weight: 500;
  color: var(--accent-cyan);
  margin-left: 2px;
}

.brand-version {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.8;
  letter-spacing: 0.02em;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-block;
  vertical-align: middle;
}
.brand-version:empty {
  display: none;
}

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

.header-nav {
  display: flex;
  align-items: center;
}

.header-link {
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all 0.15s ease;
}

.header-link:hover {
  color: var(--text-primary);
  background-color: var(--border-subtle);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-live {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.status-live .status-indicator {
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.status-connecting, .status-waiting {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.status-connecting .status-indicator, .status-waiting .status-indicator {
  background-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
}

.status-stopped, .status-disconnected {
  background-color: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}
.status-stopped .status-indicator, .status-disconnected .status-indicator {
  background-color: #64748b;
}

.status-error {
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.status-error .status-indicator {
  background-color: #ef4444;
}

/* Path Indicator Pill */
.path-indicator {
  display: none;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.path-indicator.visible {
  display: inline-flex;
}
.path-indicator.path-lan {
  background-color: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.path-indicator.path-internet {
  background-color: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.path-indicator.path-relay {
  background-color: rgba(245, 158, 11, 0.12);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Main Workspace (Side-by-Side in Landscape) */
.app-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 10px 14px;
  overflow: hidden;
}

/* Primary Viewport Pane */
.viewport-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: #030712;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
}

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

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.video-overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  color: var(--text-secondary);
  background: radial-gradient(circle at center, rgba(14, 21, 36, 0.85) 0%, rgba(8, 12, 21, 0.95) 100%);
  z-index: 5;
}

.overlay-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 14px;
  color: var(--text-muted);
}

.overlay-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.overlay-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.5;
}

.overlay-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Floating Viewport HUD Controls */
.video-hud {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  background-color: rgba(14, 22, 36, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  padding: 4px 6px;
  z-index: 10;
}

/* Hide floating HUD control panel in fullscreen mode */
:fullscreen .video-hud {
  display: none !important;
}

:-webkit-full-screen .video-hud {
  display: none !important;
}

.is-fullscreen .video-hud {
  display: none !important;
}

.hud-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.15);
}

.hud-btn svg {
  width: 16px;
  height: 16px;
}

/* Compact Vitals / Metrics Strip Under Video */
.vitals-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 14px;
  gap: 12px;
  flex-shrink: 0;
  user-select: none;
  min-height: 38px;
}

.vital-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}

.vital-label {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.vital-value {
  font-weight: 700;
  color: var(--text-primary);
}

.vital-badge-lan { color: #34d399; }
.vital-badge-internet { color: #93c5fd; }
.vital-badge-relay { color: #fcd34d; }

/* Sidebar Controls Pane */
.sidebar-pane {
  width: 320px;
  min-width: 290px;
  max-width: 350px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  padding-bottom: 16px;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) rgba(0, 0, 0, 0.15);
}

.sidebar-pane > * {
  flex-shrink: 0;
}

/* Custom Scrollbar for Sidebar */
.sidebar-pane::-webkit-scrollbar {
  width: 6px;
}
.sidebar-pane::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-pill);
}
.sidebar-pane::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-pill);
  transition: background-color 0.15s ease;
}
.sidebar-pane::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

#fileInputGroup,
#urlInputGroup,
#screenCursorGroup {
  display: none;
}

.form-row {
  display: flex;
  gap: 8px;
}

.flex-1 {
  flex: 1;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.pin-masked {
  -webkit-text-security: disc;
  text-security: disc;
}

/* Input Action Groups (Input + button attached) */
.input-action-group {
  display: flex;
  position: relative;
}

.input-action-group input {
  padding-right: 52px;
}

.btn-action-inline {
  position: absolute;
  right: 5px;
  top: 5px;
  bottom: 5px;
  padding: 0 10px;
  background-color: var(--border-subtle);
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action-inline:hover {
  background-color: var(--border-medium);
  color: var(--text-primary);
}

/* Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-lg {
  height: 40px;
  font-size: 0.9rem;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--accent-emerald);
  color: #032014;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-emerald-hover);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--accent-red);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background-color: var(--accent-red-hover);
}

.btn-secondary {
  background-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-medium);
}

.btn-ghost-sm {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}
.btn-ghost-sm:hover {
  color: var(--text-primary);
  background-color: var(--border-subtle);
}

.btn-ghost-xs {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
}
.btn-ghost-xs:hover {
  color: var(--text-primary);
  background-color: var(--border-subtle);
}

.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* Active Session Broadcasting Banner */
.session-active-panel {
  background-color: var(--bg-card-hover);
  border-color: rgba(16, 185, 129, 0.35);
}

.session-active-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.live-pill {
  background-color: var(--accent-emerald);
  color: #032014;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.05em;
}

.viewer-count-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: #34d399;
}

.session-active-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background-color: var(--bg-base);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.detail-row {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-val {
  font-size: 0.85rem;
  font-family: monospace;
  font-weight: 700;
  color: var(--text-primary);
}

/* Share Card & Inputs */
.share-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.share-input-row input {
  flex: 1;
  min-width: 0;
}

.share-input-row button {
  flex-shrink: 0;
  white-space: nowrap;
}

.code-input {
  font-family: monospace;
  font-size: 0.78rem !important;
  background-color: var(--bg-input);
}

.qr-frame {
  display: inline-block;
  padding: 8px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-top: 6px;
}

.qr-frame img {
  width: 140px;
  height: 140px;
  display: block;
}

/* Collapsible Sections */
.collapsible-section {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  overflow: hidden;
  margin-top: 8px;
}

.collapsible-summary {
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  transition: color 0.15s ease;
}

.collapsible-summary:hover {
  color: var(--text-primary);
}

.collapsible-body {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-card);
}

.card-collapsible {
  padding: 0 !important;
}

.sub-panel {
  background-color: var(--bg-base);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 8px;
  margin-top: 8px;
}

.sub-panel-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-amber);
  margin-bottom: 6px;
}

.integration-item {
  margin-bottom: 10px;
}
.integration-item:last-child {
  margin-bottom: 0;
}

.integration-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.diagnostics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.diagnostics-actions {
  display: flex;
  gap: 4px;
}

.diagnostics-panel {
  background-color: #030712;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 8px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  color: #93c5fd;
  height: 150px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
  -webkit-user-select: text;
}

/* Alerts */
.alert {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  margin-bottom: 8px;
  display: none;
  line-height: 1.35;
}

.alert.visible {
  display: block;
}

.alert-danger {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.12);
  border: 1px solid var(--accent-blue);
  color: #93c5fd;
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--accent-amber);
  color: #fde68a;
}

.badge-hint {
  font-size: 0.7rem;
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Viewer Specific Proportions (70% video in landscape) */
.viewer-workspace .viewport-pane {
  flex: 7;
}
.viewer-workspace .sidebar-pane {
  flex: 3;
  width: auto;
  max-width: 380px;
  min-height: 0;
  max-height: 100%;
}

/* ========================================================= */
/* Responsive & Orientation Behavior                         */
/* ========================================================= */

/* Portrait Mode (Phones, Tablets & Narrow Windows - e.g. Samsung S21) */
@media (orientation: portrait), (max-width: 680px) {
  .app-shell {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow-y: auto;
  }

  /* Slim Mobile Header */
  .app-header {
    height: 42px;
    min-height: 42px;
    padding: 0 10px;
    gap: 8px;
  }

  .header-brand {
    min-width: 0;
    flex-shrink: 1;
    gap: 6px;
  }

  .brand-logo {
    width: 20px;
    height: 20px;
  }

  .brand-title {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-status {
    flex-shrink: 0;
    gap: 6px;
  }

  .status-badge {
    font-size: 0.7rem;
    padding: 2px 7px;
    white-space: nowrap;
  }

  /* Path text is already prominently displayed in the vitals bar below the video */
  .header-status .path-indicator {
    display: none !important;
  }

  .header-nav .header-link {
    font-size: 0.75rem;
    padding: 3px 6px;
    white-space: nowrap;
  }

  .app-workspace {
    flex-direction: column;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 8px 10px;
    gap: 10px;
  }

  /* Adapt Viewport for Portrait Cameras (Samsung S21 9:16 Feed) */
  .viewport-pane {
    width: 100%;
    height: 35vh;
    min-height: 220px;
    max-height: 42vh;
    aspect-ratio: auto;
    flex: none;
  }

  /* Mobile Swipeable Vitals Strip with Zero Wrapping */
  .vitals-bar {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    padding: 6px 10px;
    gap: 14px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .vitals-bar::-webkit-scrollbar {
    display: none;
  }

  .vital-item {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
  }

  .vital-label {
    font-size: 0.65rem;
  }

  .vital-value {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .sidebar-pane {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    overflow: visible;
    padding-bottom: 24px;
  }

  .card {
    padding: 12px;
  }

  /* In streaming state on mobile portrait, lift viewport to top */
  .streaming-active .viewport-pane {
    order: 1;
  }
  .streaming-active .sidebar-pane {
    order: 2;
  }
}

/* Landscape Mode (Desktops, Laptops, Rotated Phones) */
@media (orientation: landscape) and (min-width: 681px) {
  .app-shell {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .app-workspace {
    flex-direction: row;
    height: calc(100dvh - 44px);
    overflow: hidden;
  }

  .viewport-pane {
    height: 100%;
    min-height: 0;
  }

  .sidebar-pane {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow-y: auto;
  }
}

/* Short Landscape Displays (e.g. 667x320 or 844x390) */
@media (orientation: landscape) and (max-height: 480px) {
  .app-header {
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
  }

  .brand-logo {
    width: 18px;
    height: 18px;
  }

  .brand-title {
    font-size: 0.82rem;
  }

  .app-workspace {
    padding: 6px 10px;
    gap: 8px;
    height: calc(100dvh - 34px);
  }

  .sidebar-pane {
    width: 270px;
    min-width: 250px;
    gap: 6px;
    max-height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
  }

  .card {
    padding: 10px;
  }

  .card-header {
    margin-bottom: 8px;
  }

  .form-group {
    margin-bottom: 6px;
  }

  input[type="text"], input[type="password"], select {
    height: 28px;
    font-size: 0.78rem;
  }

  .btn {
    height: 28px;
    font-size: 0.75rem;
  }

  .btn-lg {
    height: 32px;
    font-size: 0.8rem;
  }

  .vitals-bar {
    padding: 4px 8px;
  }
}

/* ==========================================================================
   Hub Workspace (Role Selection Screen) Single-Screen Architecture
   ========================================================================== */
.hub-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 16px;
  padding: 16px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.hub-primary-pane {
  flex: 1.4;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hub-secondary-pane {
  flex: 1;
  min-width: 280px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
}

.hub-hero-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.hub-badge-row {
  margin-bottom: 12px;
}

.hub-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

.header-meta {
  font-size: 0.78rem;
  font-family: monospace;
  color: var(--text-muted);
}

.hub-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.25;
}

.hub-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 18px;
}

/* Role Choice Cards Grid */
.role-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.role-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.role-sender {
  border-left: 4px solid var(--accent-emerald);
}

.role-sender:hover {
  border-color: var(--accent-emerald);
  background-color: rgba(16, 185, 129, 0.05);
}

.role-viewer {
  border-left: 4px solid var(--accent-blue);
}

.role-viewer:hover {
  border-color: var(--accent-blue);
  background-color: rgba(59, 130, 246, 0.05);
}

.role-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-sender .role-icon-box {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.role-viewer .role-icon-box {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
}

.role-icon-box svg {
  width: 22px;
  height: 22px;
}

.role-content {
  flex: 1;
  min-width: 0;
}

.role-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.role-sender .role-tag {
  color: var(--accent-emerald);
}

.role-viewer .role-tag {
  color: var(--accent-blue);
}

.role-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.role-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.role-arrow {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, color 0.2s ease;
}

.role-arrow svg {
  width: 18px;
  height: 18px;
}

.role-card:hover .role-arrow {
  color: var(--text-primary);
  transform: translateX(4px);
}

/* Secondary QR Scan Card */
.hub-qr-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
}

.hub-qr-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.hub-qr-wrapper {
  margin: 14px auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hub-qr-wrapper .qr-frame {
  width: 160px;
  height: 160px;
  padding: 8px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-qr-wrapper .qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Transport Modes & Guide in Hub */
.transport-modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.mode-item {
  padding: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.mode-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.mode-primary .mode-title {
  color: #60a5fa;
}

.mode-secondary .mode-title {
  color: #facc15;
}

.mode-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--border-medium);
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-row strong {
  color: var(--text-primary);
}

.step-row code {
  background-color: var(--bg-input);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--accent-cyan);
}

/* Hub Landscape Single-Screen Fit */
@media (orientation: landscape) and (min-width: 681px) {
  .hub-workspace {
    flex-direction: row;
    height: calc(100dvh - 44px);
    max-height: calc(100dvh - 44px);
    overflow: hidden;
  }

  .hub-primary-pane, .hub-secondary-pane {
    height: 100%;
    overflow: hidden;
  }
}

/* Hub Short Landscape (e.g. 844x390, 667x320) */
@media (orientation: landscape) and (max-height: 480px) {
  .hub-workspace {
    padding: 6px 10px;
    gap: 8px;
    height: calc(100dvh - 34px);
    max-height: calc(100dvh - 34px);
  }

  .hub-title {
    font-size: 1.05rem;
    margin-bottom: 2px;
  }

  .hub-subtitle {
    font-size: 0.76rem;
    margin-bottom: 8px;
    line-height: 1.3;
  }

  .role-grid {
    gap: 6px;
  }

  .role-card {
    padding: 8px 10px;
    gap: 10px;
  }

  .role-icon-box {
    width: 32px;
    height: 32px;
  }

  .role-icon-box svg {
    width: 16px;
    height: 16px;
  }

  .role-name {
    font-size: 0.88rem;
  }

  .role-desc {
    font-size: 0.72rem;
  }

  .hub-qr-wrapper {
    margin: 6px auto;
  }

  .hub-qr-wrapper .qr-frame {
    width: 110px;
    height: 110px;
    padding: 4px;
  }

  .card-desc {
    font-size: 0.75rem;
    margin-bottom: 4px;
  }
}

/* Hub Portrait Stacking (Vertical Mobile/Tablet) */
@media (orientation: portrait), (max-width: 680px) {
  .hub-workspace {
    flex-direction: column;
    height: auto;
    max-height: none;
    overflow-y: auto;
    padding: 12px;
    gap: 12px;
  }

  .hub-primary-pane, .hub-secondary-pane {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .transport-modes-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Advanced HUD Controls & Overlays (P16 Feature Expansion)
   ========================================================================== */

/* Rule-of-Thirds Grid Overlay */
.grid-overlay {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  pointer-events: none;
  z-index: 6;
}
.grid-overlay.active {
  display: grid;
}
.grid-cell {
  border: 1px dashed rgba(255, 255, 255, 0.22);
  box-sizing: border-box;
}

/* Recording Status Indicator */
.rec-indicator {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  align-items: center;
  gap: 6px;
  background-color: rgba(220, 38, 38, 0.88);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  z-index: 12;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.rec-indicator.active {
  display: inline-flex;
}
.rec-dot {
  width: 8px;
  height: 8px;
  background-color: #ffffff;
  border-radius: 50%;
  animation: recPulse 1.2s infinite ease-in-out;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

/* OLED / Thermal Battery Saver Mode */
.oled-saver-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background-color: #000000;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.oled-saver-overlay.active {
  display: flex;
}
.oled-saver-hint {
  color: rgba(255, 255, 255, 0.28);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  text-align: center;
  padding: 20px;
}

/* Hardware Zoom Control Floating Bar */
.zoom-control-bar {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(14, 22, 36, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  align-items: center;
  gap: 8px;
  z-index: 10;
  color: var(--text-secondary);
  font-size: 0.75rem;
}
.zoom-control-bar.active {
  display: flex;
}
.zoom-slider {
  width: 110px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* Hardware Focus Control Floating Bar */
.focus-control-bar {
  display: none;
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(14, 22, 36, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  align-items: center;
  gap: 8px;
  z-index: 10;
  color: var(--text-secondary);
  font-size: 0.75rem;
}
.focus-control-bar.active {
  display: flex;
}
.focus-slider {
  width: 110px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* HUD Pill (e.g. Sender Battery Pill in Fullscreen HUD) */
.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: rgba(14, 22, 36, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}

/* Share Link Button */
.btn-action-share {
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.btn-action-share:hover {
  background-color: rgba(56, 189, 248, 0.25);
  color: #fff;
}

/* Feature 4: Studio Camera Switcher */
.studio-switcher-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 6px 14px;
  flex-shrink: 0;
  user-select: none;
  min-height: 36px;
}
.studio-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  white-space: nowrap;
}
.studio-cameras-list {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.studio-cameras-list::-webkit-scrollbar {
  display: none;
}
.studio-cam-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.studio-cam-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}
.studio-cam-btn.active {
  background: #0284c7;
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* Remote Desktop Control UI */
.control-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--accent-emerald);
  color: var(--accent-emerald);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
  animation: pulse-control 2s infinite ease-in-out;
}

@keyframes pulse-control {
  0%, 100% { box-shadow: 0 0 8px rgba(16, 185, 129, 0.2); }
  50% { box-shadow: 0 0 16px rgba(16, 185, 129, 0.45); }
}

.control-release-btn {
  background: var(--accent-red);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.control-release-btn:hover {
  background: var(--accent-red-hover);
}

.hud-btn.active-control {
  background: var(--accent-emerald) !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: modal-enter 0.2s ease-out;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: color 0.15s ease;
}

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

.modal-body {
  padding: 18px;
}

.modal-footer {
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-danger {
  background: var(--accent-red);
  color: white;
  border: 1px solid var(--accent-red-hover);
}

.btn-danger:hover {
  background: var(--accent-red-hover);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 6px 12px;
}

.cursor-remote-controlling {
  cursor: default !important;
}

/* ==========================================================================
   In-Room WhatsApp-Style Real-Time Chat System (ADR-036)
   ========================================================================== */

/* Floating Chat Action Button */
.chat-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #00a884;
  color: #ffffff;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 850;
  box-shadow: 0 4px 16px rgba(0, 168, 132, 0.4), 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s, box-shadow 0.2s;
}

.chat-floating-btn:hover {
  transform: scale(1.08);
  background-color: #02906f;
  box-shadow: 0 6px 20px rgba(0, 168, 132, 0.55);
}

.chat-floating-btn:active {
  transform: scale(0.95);
}

.chat-floating-btn .chat-btn-icon {
  width: 26px;
  height: 26px;
}

/* Unread Notification Badge Dot */
.chat-unread-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-base);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.65);
  animation: chatBadgePulse 2s infinite ease-in-out;
}

@keyframes chatBadgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.95);
  }
}

/* Chat Drawer Backdrop */
.chat-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.chat-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Slide-Out Drawer Panel */
.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background-color: #111b21;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.65);
  z-index: 999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-drawer.open {
  transform: translateX(0);
}

/* Chat Header */
.chat-header {
  height: 60px;
  min-height: 60px;
  background-color: #202c33;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.chat-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #00a884;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-avatar-circle svg {
  width: 22px;
  height: 22px;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-room-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-room-sub {
  font-size: 0.74rem;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-btn {
  background: transparent;
  border: none;
  color: #aebac1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.chat-header-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e9edef;
}

.chat-header-btn.is-muted {
  color: #ef4444;
}

.chat-header-btn svg {
  width: 18px;
  height: 18px;
}

/* User Identity Strip */
.chat-identity-strip {
  background-color: #182229;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.chat-identity-label {
  color: #8696a0;
}

.chat-identity-name {
  font-weight: 600;
  color: #00a884;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline Name Edit Bar */
.chat-name-edit-bar {
  background-color: #202c33;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.chat-name-input {
  flex: 1;
  background-color: #2a3942;
  border: 1px solid #3b4a54;
  border-radius: 6px;
  padding: 6px 10px;
  color: #e9edef;
  font-size: 0.85rem;
  outline: none;
}

.chat-name-input:focus {
  border-color: #00a884;
}

/* Chat Body & Dimmed Unsplash Background */
.chat-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: #0b141a;
}

.chat-bg-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  pointer-events: none;
  opacity: 0.20;
  filter: brightness(0.65) contrast(1.15);
  transition: background-image 0.6s ease;
}

.chat-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 20, 26, 0.85) 0%, rgba(11, 20, 26, 0.94) 100%);
  pointer-events: none;
}

.chat-messages {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

/* WhatsApp Message Bubbles */
.chat-bubble {
  max-width: 82%;
  padding: 6px 9px 5px 10px;
  font-size: 0.88rem;
  line-height: 1.35;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

.chat-bubble.outgoing {
  align-self: flex-end;
  background-color: #005c4b;
  color: #e9edef;
  border-radius: 8px 8px 0 8px;
}

.chat-bubble.incoming {
  align-self: flex-start;
  background-color: #202c33;
  color: #e9edef;
  border-radius: 8px 8px 8px 0;
}

.chat-bubble.system {
  align-self: center;
  background-color: rgba(18, 27, 34, 0.92);
  border: 1px solid rgba(134, 150, 160, 0.2);
  color: #8696a0;
  font-size: 0.72rem;
  padding: 4px 12px;
  border-radius: 8px;
  text-align: center;
  max-width: 90%;
  margin: 4px 0;
}

.chat-bubble-sender {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.2;
}

.chat-bubble-text {
  color: #e9edef;
  white-space: pre-wrap;
}

.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  float: right;
  margin-left: 10px;
  font-size: 0.68rem;
  color: #8696a0;
}

.chat-checkmarks {
  color: #53bdeb;
  font-weight: 700;
  letter-spacing: -2px;
  margin-left: 2px;
}

/* WhatsApp Input Footer */
.chat-footer {
  background-color: #202c33;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 56px;
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  background-color: #2a3942;
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
}

.chat-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #d1d7db;
  font-size: 0.88rem;
  font-family: inherit;
}

.chat-input::placeholder {
  color: #8696a0;
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #00a884;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: background-color 0.15s, transform 0.1s;
}

.chat-send-btn:hover:not(:disabled) {
  background-color: #02906f;
  transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-send-btn svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   Mobile Responsive Chat Layout & Breakpoints
   ========================================================================== */

/* Lock body background scrolling when drawer is open on mobile */
body.chat-drawer-open {
  overflow: hidden !important;
  touch-action: none !important;
}

/* Portrait and small mobile screens (<= 680px) */
@media (orientation: portrait), (max-width: 680px) {
  .chat-drawer {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    height: -webkit-fill-available;
    border-radius: 0;
  }

  /* Safe Area padding for notch, Dynamic Island, and status bar */
  .chat-header {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    min-height: calc(56px + env(safe-area-inset-top));
    height: auto;
  }

  /* Safe Area padding for bottom navigation bar / home indicator bar */
  .chat-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    min-height: calc(54px + env(safe-area-inset-bottom));
  }

  /* Prevent iOS Safari 16px auto-zoom on input focus */
  .chat-input,
  .chat-name-input {
    font-size: 16px !important;
  }

  /* Mobile touch targets (min 42x42px) */
  .chat-header-btn {
    width: 42px;
    height: 42px;
  }

  .chat-send-btn {
    width: 44px;
    height: 44px;
  }

  /* Mobile floating action button with safe margins */
  .chat-floating-btn {
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 16px));
    right: max(16px, env(safe-area-inset-right));
    width: 52px;
    height: 52px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Mobile message bubbles */
  .chat-bubble {
    max-width: 88%;
    font-size: 0.92rem;
    padding: 7px 11px 5px 12px;
  }

  .chat-messages {
    padding: 12px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* Landscape mobile screens (short height <= 500px) */
@media (orientation: landscape) and (max-height: 500px) {
  .chat-drawer {
    width: 380px;
    max-width: 68vw;
    height: 100dvh;
    height: -webkit-fill-available;
  }

  .chat-header {
    height: 44px;
    min-height: 44px;
    padding: 4px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .chat-avatar-circle {
    width: 32px;
    height: 32px;
  }

  .chat-avatar-circle svg {
    width: 16px;
    height: 16px;
  }

  .chat-room-title {
    font-size: 0.85rem;
  }

  .chat-room-sub {
    font-size: 0.68rem;
  }

  .chat-header-btn {
    width: 32px;
    height: 32px;
  }

  .chat-header-btn svg {
    width: 16px;
    height: 16px;
  }

  .chat-identity-strip {
    padding: 3px 10px;
    font-size: 0.74rem;
  }

  .chat-messages {
    padding: 8px 8px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .chat-bubble {
    font-size: 0.82rem;
    padding: 5px 8px 4px 9px;
    max-width: 85%;
  }

  .chat-footer {
    min-height: 44px;
    padding: 4px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .chat-input,
  .chat-name-input {
    font-size: 14px;
  }

  .chat-send-btn {
    width: 34px;
    height: 34px;
  }

  .chat-send-btn svg {
    width: 16px;
    height: 16px;
  }

  .chat-floating-btn {
    bottom: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    touch-action: manipulation;
  }

  .chat-floating-btn .chat-btn-icon {
    width: 22px;
    height: 22px;
  }
}



