/* ========================================
   全局样式与CSS变量
   ======================================== */
:root {
  /* 颜色系统 */
  --color-bg-primary: #0a0e1a;
  --color-bg-secondary: #1a1f2e;
  --color-bg-elevated: #242938;
  --color-surface: rgba(255, 255, 255, 0.05);
  --color-border: rgba(255, 255, 255, 0.1);
  
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: rgba(59, 130, 246, 0.1);
  
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  
  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  
  /* 间距系统 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
  
  /* 过渡 */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  
  /* 字体 */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* 安全区域变量（允许通过 JS 动态覆盖以适配不同环境） */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
}

/* ========================================
   基础重置
   ======================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Safari防止页面放大 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 防止iOS Safari自动缩放 */
  touch-action: manipulation;
}

body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* iOS防止滑动返回 */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  /* Safari防止页面放大 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iOS全屏模式优化 */
html.fullscreen,
html.fullscreen body,
html:fullscreen,
html:fullscreen body,
html:-webkit-full-screen,
html:-webkit-full-screen body {
  width: 100vw !important;
  height: 100vh !important;
  overflow: hidden !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}

/* 全屏时隐藏顶部导航栏 */
html.fullscreen .console-header,
html:fullscreen .console-header,
html:-webkit-full-screen .console-header {
  display: none !important;
}

/* 全屏时视频区域占据全屏 */
html.fullscreen .console-body,
html:fullscreen .console-body,
html:-webkit-full-screen .console-body {
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
}

/* 全屏时视频容器占满整个空间 */
html.fullscreen .video-container,
html:fullscreen .video-container,
html:-webkit-full-screen .video-container {
  width: 100vw !important;
  height: 100vh !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* iOS Safari: 全屏时延伸到安全区域，隐藏底部导航栏 */
.screen--console {
  /* 使用安全区域变量，便于在不同环境下动态调整 */
  padding-bottom: var(--safe-area-bottom, env(safe-area-inset-bottom));
  /* 防止滚动 */
  overflow: hidden;
  position: relative;
  /* 防止iOS Safari滑动返回上一页 */
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  -webkit-overflow-scrolling: touch;
}

html.fullscreen .screen--console,
html:fullscreen .screen--console,
html:-webkit-full-screen .screen--console {
  /* 全屏时延伸到底部，覆盖导航栏 */
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  padding: 0 !important;
  margin: 0 !important;
  /* 防止任何滚动 */
  overflow: hidden !important;
  /* 覆盖地址栏和导航栏 */
  z-index: 9999 !important;
}

/* iOS Safari 视频容器优化 - 确保视频正确填充 */
@media (max-width: 768px) {
  .screen--console {
    /* iOS Safari: 确保控制台屏幕占满整个视口 */
    height: 100vh;
    height: -webkit-fill-available; /* iOS Safari 特殊处理 */
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }
  
  /* iOS Safari: 视频容器占满可用空间 */
  .screen--console .video-container {
    flex: 1;
    min-height: 0; /* 允许flex子元素收缩 */
    display: flex;
    flex-direction: column;
  }
  
  .screen--console .video-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* iOS Safari: 视频元素填充容器 */
  .screen--console #remote-video {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
  }
}

/* 防止iOS Safari滑动返回上一页 */
/* 已合并到上面的 .screen--console 样式中 */

.screen--connect {
  touch-action: auto;
  user-select: auto;
  -webkit-user-select: auto;
}

.screen--connect .form-input,
.screen--connect button,
.screen--connect label,
.screen--connect .panel-header,
.screen--connect .form-group {
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.screen--connect .form-input {
  touch-action: manipulation;
}

.screen--connect button {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
  touch-action: manipulation;
}

input {
  font-family: inherit;
  outline: none;
}

/* ========================================
   屏幕容器
   ======================================== */
.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ========================================
   连接屏幕
   ======================================== */
.screen--connect {
  background: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 100%);
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.connect-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-xl) var(--spacing-lg);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: var(--spacing-xl);
  align-items: center;
  min-height: 100%;
}

/* 顶部 Logo 区域 */
.connect-header {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.connect-panel {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  padding: var(--spacing-xl) var(--spacing-lg);
  background: rgba(10, 14, 25, 0.55);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(148, 163, 184, 0.12);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 40px rgba(8, 12, 24, 0.45);
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-lg);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.panel-status {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.panel-status-text {
  white-space: nowrap;
  font-weight: 600;
}

.connect-hero {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  color: var(--color-text-primary);
  max-width: 540px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.2);
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  width: fit-content;
}

.hero-title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  max-width: 520px;
}

.hero-highlights {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  padding: 0;
  margin: 0;
}

.hero-highlight {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.15);
  backdrop-filter: blur(12px);
}

.highlight-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.18);
  font-size: 20px;
}

.hero-highlight h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.hero-highlight p {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.logo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
}

.logo-icon {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 8px 16px rgba(59, 130, 246, 0.3));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.app-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

/* 配置卡片 */
.config-card {
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.78));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  animation: slideDown var(--transition-base);
  backdrop-filter: blur(16px);
}

.config-card.config-card--error {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(160deg, rgba(30, 12, 18, 0.9), rgba(60, 16, 24, 0.85));
}

.config-card.config-card--error .config-badge {
  background: rgba(239, 68, 68, 0.18);
  color: var(--color-danger);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.config-card__header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.config-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.config-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.config-card__list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin: 0 0 var(--spacing-md);
}

.config-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--spacing-sm);
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.config-item dt {
  font-size: 13px;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.config-item dd {
  font-size: 14px;
  color: var(--color-text-primary);
  text-align: right;
  word-break: break-word;
  margin: 0;
}

.config-description {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

/* 连接表单 */
.connect-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.required {
  color: var(--color-danger);
  font-size: 12px;
}

.form-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-primary);
  opacity: 0.8;
}

/* 快捷入口 */
.quick-links {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.quick-link {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.quick-link--primary {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.15) 100%);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.quick-link--primary:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.25) 100%);
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-2px);
}

.quick-link--secondary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.quick-link--secondary:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(37, 99, 235, 0.25) 100%);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
}

.quick-link .link-icon {
  font-size: 18px;
  line-height: 1;
}

/* 移动端优化 */
@media (max-width: 480px) {
  .quick-links {
    flex-direction: column;
  }
  
  .quick-link {
    width: 100%;
  }
}

/* ========================================
   房间号历史记录下拉列表
   ======================================== */
.room-history-dropdown {
  position: fixed;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow: hidden;
  animation: slideDown 0.2s ease-out;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.1);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.history-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.history-close-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.history-close-btn:hover {
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--color-text-primary);
}

.history-clear-btn {
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.history-clear-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.35);
}

.history-list {
  overflow-y: auto;
  max-height: 320px;
  -webkit-overflow-scrolling: touch;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.history-item:hover {
  background: rgba(59, 130, 246, 0.08);
}

.history-item:last-child {
  border-bottom: none;
}

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

.history-device-id {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-room-code {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-delete-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--color-danger);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.35);
  transform: scale(1.1);
}

.optional {
  color: var(--color-text-muted);
  font-size: 12px;
}

.activation-status {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
}

.activation-status.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.activation-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.activation-status.info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.activation-status--guide {
  padding: 12px 14px;
  color: #d1fae5;
}

.activation-guide {
  display: grid;
  gap: 8px;
}

.activation-guide__title {
  color: var(--color-success);
  font-size: 13px;
  font-weight: 700;
}

.activation-guide__meta {
  color: rgba(209, 250, 229, 0.82);
  font-size: 12px;
}

.activation-guide__warning {
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.activation-guide__code {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: var(--color-text-primary);
  font-size: 12px;
  word-break: break-all;
}

.activation-guide__copy {
  justify-self: start;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.14);
  color: var(--color-success);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.activation-guide__copy:hover {
  background: rgba(16, 185, 129, 0.22);
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 16px;
  transition: all var(--transition-fast);
}

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

.form-input:focus {
  border-color: var(--color-primary);
  background: var(--color-bg-secondary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input--small {
  padding: 10px 12px;
  /* iOS Safari 避免聚焦自动缩放 */
  font-size: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  align-items: center;
}

.form-actions .btn {
  min-width: 180px;
}

.form-actions .status-badge {
  flex: 1 1 160px;
  justify-content: center;
}

.btn--ghost {
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: var(--color-text-primary);
  box-shadow: none;
}

.btn--ghost:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.12);
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: rgba(15, 23, 42, 0.45);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.tip-card {
  display: flex;
  gap: var(--spacing-sm);
  align-items: flex-start;
}

.tip-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.tip-body h4 {
  font-size: 14px;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.tip-body p {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.advanced-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 26, 0.65);
  backdrop-filter: blur(4px);
  z-index: 80;
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.advanced-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.advanced-backdrop[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.advanced-drawer {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(560px, 92vw);
  max-height: min(85vh, 600px);
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 60px rgba(8, 15, 30, 0.55);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--transition-base), transform var(--transition-base);
  pointer-events: none;
}

.advanced-drawer.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.advanced-drawer[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.advanced-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-md);
}

.advanced-header h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.advanced-header p {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.advanced-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  overflow-y: auto;
  padding-right: 4px;
}

.turn-section {
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.turn-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.turn-tips {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 14px 28px;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 600;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  /* 确保按钮可点击（小米浏览器兼容） */
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: rgba(59, 130, 246, 0.3);
  /* 防止Safari缩放 */
  touch-action: manipulation;
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.btn--primary:active {
  transform: translateY(0);
  /* 小米浏览器：添加点击反馈 */
  background: linear-gradient(135deg, var(--color-primary-hover) 0%, var(--color-primary) 100%);
}

.btn-icon {
  font-size: 18px;
  line-height: 1;
}

/* 纯文本图标（如 HD） */
.btn-icon--text {
  font-size: 13px !important;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.status-badge--idle {
  background: var(--color-surface);
  color: var(--color-text-secondary);
}

.status-badge--connecting {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
}

.status-badge--connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

.status-badge--info {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.status-badge--error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

/* ========================================
   控制台屏幕
   ======================================== */
.screen--console {
  background: #000;
  display: flex;
  flex-direction: column;
  /* iOS Safari: 确保占满整个视口，考虑地址栏高度 */
  height: 100vh;
  height: -webkit-fill-available; /* iOS Safari 特殊处理 */
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow: hidden;
}

/* 顶部工具栏 - 桌面端极简设计，节省垂直空间 */
.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
  min-height: 32px;
  /* PWA 模式：适配安全区域 */
  padding-top: calc(4px + var(--safe-area-top, env(safe-area-inset-top)));
  padding-left: calc(8px + var(--safe-area-left, env(safe-area-inset-left)));
  padding-right: calc(8px + var(--safe-area-right, env(safe-area-inset-right)));
}

.console-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
  min-height: 0;
  position: relative; /* 为浮动切换按钮定位 */
}

.console-stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.console-stage .video-container {
  flex: 1;
}

.console-aside {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  min-height: 0;
  transition: width 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

/* 侧边栏隐藏状态 */
.console-aside.aside-hidden {
  width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  opacity: 0;
  overflow: hidden;
  border: none !important;
  box-shadow: none !important;
}

/* 侧边栏切换按钮：浮动在侧边栏左边缘 */
.aside-toggle-btn {
  display: none;
  position: absolute;
  right: 280px; /* 侧边栏宽度 */
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 56px;
  background: rgba(10, 14, 26, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--color-text-primary);
  font-size: 14px;
  cursor: pointer;
  z-index: 50;
  transition: all 0.3s ease;
  align-items: center;
  justify-content: center;
}

.aside-toggle-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  width: 28px;
}

.aside-toggle-btn:active {
  transform: translateY(-50%) scale(0.95);
}

/* 侧边栏隐藏时，按钮移到右边缘 */
.aside-toggle-btn.aside-collapsed {
  right: 8px;
  border-radius: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

/* 中等屏幕 */
@media (min-width: 769px) and (max-width: 1023px) {
  .aside-toggle-btn {
    display: flex;
    right: 260px; /* 中等屏幕侧边栏宽度 */
  }
  
  .aside-toggle-btn.aside-collapsed {
    right: 0;
  }
}

/* 大屏幕 */
@media (min-width: 1024px) {
  .aside-toggle-btn {
    display: flex;
    right: 280px;
  }
  
  .aside-toggle-btn.aside-collapsed {
    right: 0;
  }
}

/* 移动端隐藏 */
@media (max-width: 768px) {
  .aside-toggle-btn {
    display: none !important;
  }
}

/* 移动端（<769px）：视频全屏，控制面板隐藏 */
@media (max-width: 768px) {
  .console-body {
    padding: 0;
    gap: 0;
  }

  .console-stage {
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .console-aside {
    display: none; /* 移动端隐藏右侧控制栏，使用 mobile-sidebar 替代 */
  }
}

/* 中等屏幕（769px - 1023px）：视频左侧，控制面板右侧并排（与大屏幕一致） */
@media (min-width: 769px) and (max-width: 1023px) {
  .console-body {
    flex-direction: row;
    align-items: stretch;
    padding: 8px;
    gap: 12px;
  }

  .console-stage {
    flex: 1;
    min-width: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .console-aside {
    /* 中等屏幕：与大屏幕保持一致的布局 */
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
    width: 260px;
    max-width: 260px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    background: rgba(10, 14, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: auto;
    padding: var(--spacing-sm);
  }
}

/* 大屏幕（≥1024px）：视频左侧，控制面板右侧并排 */
@media (min-width: 1024px) {
  .console-header {
    padding: 6px 12px;
  }

  .console-body {
    flex-direction: row;
    align-items: stretch;
    padding: 8px;
    gap: 12px;
  }

  .console-stage {
    flex: 1; /* 占据剩余空间 */
    min-width: 0; /* 防止撑爆 */
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .console-aside {
    display: flex;
    flex-direction: column;
    position: relative; /* 大屏幕恢复正常布局流 */
    flex-shrink: 0;
    width: 280px;
    max-width: 280px;
    max-height: calc(100vh - 60px); /* 限制高度，留出顶部导航栏空间 */
    overflow-y: auto; /* 内容超出时支持滚动 */
    background: rgba(10, 14, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: auto;
    padding: var(--spacing-sm);
  }
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 14px;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--color-bg-elevated);
}

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

.icon-btn--danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.icon-btn--danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.icon-btn--small {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.connection-info {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--color-surface);
  border-radius: var(--radius-full);
}

.info-text {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot--connected {
  background: var(--color-success);
}

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

/* 视频显示区域 */
.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 支持缩放滚动（桌面端） */
}

/* 桌面端：支持滚动查看和鼠标滚轮缩放 */
@media (min-width: 769px) {
  .video-container {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .video-container.zoom-enabled {
    cursor: grab;
  }
  
  .video-container.zoom-enabled:active {
    cursor: grabbing;
  }
}

.video-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  /* 支持缩放变换 */
  transform-origin: center center;
  transition: transform 0.1s ease-out;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  /* 优化显示：允许视频放大到更大尺寸 */
  max-width: none;
  max-height: none;
  /* 性能优化：启用硬件加速 */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
  /* 优化渲染 */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  /* 减少重绘 */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 全屏时优化视频显示 */
.video-container:fullscreen #remote-video,
.video-container:-webkit-full-screen #remote-video,
.video-container:-moz-full-screen #remote-video,
.video-container:-ms-fullscreen #remote-video {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

/* 桌面端：沉浸式大屏显示，充分利用屏幕空间 */
@media (min-width: 1024px) {
  .video-container {
    /* 减少padding，增大可视区域 */
    padding: var(--spacing-xs);
  }
  
  .video-wrapper {
    /* 桌面端：移除最大宽度限制，充分利用屏幕 */
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
  }
  
  #remote-video {
    /* 桌面端：使用 scale 放大显示，但保持比例 */
    transform-origin: center center;
    /* 高质量渲染 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* 充分利用容器空间 */
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
  }
  
  /* 视频容器支持滚动查看放大后的内容 */
  .video-container.zoomed {
    overflow: auto;
  }
}

.interaction-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
  z-index: 15; /* 提高 z-index，确保在视频和遮罩层之上，但在控制栏之下 */
  pointer-events: auto; /* 确保可以接收事件 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stream-mode-banner {
  position: absolute;
  left: max(14px, var(--safe-area-left, 0px));
  right: max(14px, var(--safe-area-right, 0px));
  top: max(14px, calc(var(--safe-area-top, 0px) + 14px));
  z-index: 28;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.55);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  transform: translate3d(0, 0, 0);
}

.stream-mode-banner--dragging {
  cursor: grabbing;
  user-select: none;
}

.stream-mode-banner[hidden],
.stream-mode-dialog[hidden] {
  display: none !important;
}

.stream-mode-banner--collapsed {
  left: auto;
  right: max(14px, var(--safe-area-right, 0px));
  width: auto;
  max-width: calc(100% - 28px);
  margin: 0;
  gap: 0;
  padding: 8px;
  border-radius: 999px;
}

.stream-mode-banner--collapsed .stream-mode-copy {
  display: none;
}

.stream-mode-banner--collapsed .stream-mode-action {
  min-width: 92px;
  height: 34px;
  padding: 0 12px;
}

.stream-mode-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stream-mode-copy strong {
  color: #fff;
  font-size: 14px;
  line-height: 1.25;
}

.stream-mode-copy span {
  color: rgba(226, 232, 240, 0.82);
  font-size: 12px;
  line-height: 1.35;
}

.stream-mode-action {
  flex: 0 0 auto;
  min-width: 88px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.stream-mode-action:active {
  transform: scale(0.98);
}

.stream-mode-dialog {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.stream-mode-dialog-card {
  width: min(520px, 100%);
  max-height: min(78vh, 560px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  -webkit-overflow-scrolling: touch;
}

.stream-mode-dialog-card h3 {
  margin: 0 0 14px;
  color: #111827;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
}

.stream-mode-dialog-card p,
.stream-mode-dialog-card li {
  color: #374151;
  font-size: 16px;
  line-height: 1.65;
}

.stream-mode-dialog-card p + p {
  margin-top: 8px;
}

.stream-mode-dialog-card ol {
  margin: 10px 0;
  padding-left: 24px;
}

.stream-mode-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.stream-mode-dialog-actions button {
  min-width: 88px;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  color: #2563eb;
  font-size: 15px;
  font-weight: 600;
}

.stream-mode-dialog-actions button:last-child {
  background: #2563eb;
  color: #fff;
}

.stream-mode-toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, calc(var(--safe-area-bottom, 0px) + 28px));
  z-index: 10000;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.stream-mode-toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 640px) {
  .stream-mode-banner {
    left: 10px;
    right: 10px;
    top: max(10px, calc(var(--safe-area-top, 0px) + 10px));
    gap: 8px;
    padding: 10px 10px;
    border-radius: 10px;
  }

  .stream-mode-banner--collapsed {
    left: auto;
    right: max(10px, var(--safe-area-right, 0px));
    max-width: calc(100% - 20px);
    padding: 7px;
    border-radius: 999px;
  }

  .stream-mode-copy strong {
    font-size: 13px;
  }

  .stream-mode-copy span {
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .stream-mode-action {
    min-width: 76px;
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .stream-mode-dialog {
    align-items: flex-end;
    padding: 12px;
  }

  .stream-mode-dialog-card {
    max-height: min(76vh, 520px);
    padding: 20px;
    border-radius: 14px;
  }

  .stream-mode-dialog-card h3 {
    font-size: 20px;
  }

  .stream-mode-dialog-card p,
  .stream-mode-dialog-card li {
    font-size: 15px;
  }
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2;
  pointer-events: none;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.overlay-content p {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* 移动端侧边浮动按钮栏：默认隐藏，可展开 - 优化位置和大小 */
.mobile-sidebar {
  position: fixed;
  right: -45px; /* 默认隐藏在屏幕外 */
  top: calc(50px + var(--safe-area-top, env(safe-area-inset-top))); /* 留出顶部导航栏空间 + 安全区域 */
  bottom: 0; /* 到底部结束 */
  width: 40px; /* 缩小宽度 */
  height: auto; /* 自动高度 */
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.6);
  z-index: 15; /* 降低 z-index，避免覆盖顶部导航栏（z-index: 20）*/
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 3px 2px;
  transition: right 0.3s ease;
}

/* 展开状态 */
.mobile-sidebar.sidebar-open {
  right: 0;
}

/* 侧边栏切换按钮（浮动在右侧边缘）- 缩小尺寸 */
.sidebar-toggle {
  position: fixed;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;  /* 从36px缩小到28px */
  height: 56px;  /* 从80px缩小到56px */
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px 0 0 14px;  /* 调整圆角 */
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.5);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-primary);
  font-size: 16px;  /* 从20px缩小到16px */
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle:active {
  transform: translateY(-50%) scale(0.95);
  background: rgba(10, 14, 26, 1);
}

/* 侧边栏展开时，切换按钮移到侧边栏左侧 */
.mobile-sidebar.sidebar-open ~ .sidebar-toggle {
  right: 40px;  /* 调整位置，匹配新的侧边栏宽度 */
}

/* 移除旧的手柄样式 */
.sidebar-handle {
  display: none;
}

.sidebar-handle:active {
  display: none;
}

.handle-icon {
  display: none;
}

.mobile-sidebar.sidebar-open .handle-icon {
  display: none;
}

.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 4px;
}

.sidebar-title {
  display: none; /* 移动端窄屏隐藏标题 */
}

.sidebar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 2px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 4px;
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
  cursor: pointer;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-btn:active {
  transform: scale(0.94);
  background: rgba(148, 163, 184, 0.22);
}

.sidebar-btn.btn--nav {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.25);
}

.sidebar-btn.btn--nav:active {
  background: rgba(59, 130, 246, 0.25);
}

.sidebar-btn.sidebar-btn--danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.25);
}

.sidebar-btn.sidebar-btn--danger:active {
  background: rgba(239, 68, 68, 0.25);
}

.sidebar-btn .btn-icon {
  font-size: 20px;
  line-height: 1;
}

.sidebar-btn .btn-label {
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
}

/* 桌面端隐藏侧边栏和切换按钮 */
@media (min-width: 769px) {
  .mobile-sidebar,
  .sidebar-toggle {
    display: none !important;
  }
}

/* 移动端隐藏底部控制栏 */
@media (max-width: 768px) {
  .console-footer {
    display: none !important;
  }
}

/* 🔧 Android 调试面板样式 */
.debug-panel {
  position: fixed;
  bottom: 60px;
  left: 10px;
  right: 10px;
  max-height: 300px;
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}

.debug-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.debug-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  font-size: 11px;
  font-family: monospace;
  color: #0f0;
  line-height: 1.4;
}

.debug-log div {
  margin-bottom: 4px;
  word-break: break-all;
}

.debug-log .log-info {
  color: #0f0;
}

.debug-log .log-warn {
  color: #ff0;
}

.debug-log .log-error {
  color: #f00;
}

.debug-toggle {
  position: fixed;
  right: 10px;
  bottom: 10px;
  width: 50px;
  height: 50px;
  background: rgba(59, 130, 246, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  -webkit-tap-highlight-color: transparent;
}

.debug-toggle:active {
  transform: scale(0.95);
  background: rgba(59, 130, 246, 1);
}

/* 底部控制栏 */
.console-footer {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  background: rgba(10, 14, 26, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: 0 16px 32px rgba(8, 12, 24, 0.35);
}

.footer-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.nav-buttons,
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.nav-buttons .control-btn,
.action-buttons .control-btn {
  width: 100%;
  justify-content: flex-start;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 12px var(--spacing-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.control-btn:hover {
  background: var(--color-bg-elevated);
}

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

.btn--nav {
  background: rgba(59, 130, 246, 0.15);
}

.action-buttons .control-btn {
  background: rgba(148, 163, 184, 0.12);
}

.btn--nav:hover {
  background: rgba(59, 130, 246, 0.25);
}

.control-btn .btn-icon {
  font-size: 18px;
  line-height: 1;
}

.control-btn .btn-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
}

/* 🎙️ 麦克风激活状态 */
.control-btn.btn--active,
.sidebar-btn.btn--active {
  background: rgba(34, 197, 94, 0.25);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
}

.control-btn.btn--active .btn-icon,
.sidebar-btn.btn--active .btn-icon {
  animation: mic-pulse 1.5s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* 隐形下拉框覆盖层（用于画质选择等） */
.control-select-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* 键盘面板 */
.keyboard-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--spacing-md);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  /* 🔧 移动端：默认隐藏键盘面板，避免遮挡视频 */
  transform: translateY(100%);
  transition: transform 0.3s ease;
  /* 🔧 关键：确保键盘面板拦截所有触摸事件，防止穿透到 interaction-layer */
  pointer-events: auto;
  touch-action: auto;
}

.keyboard-panel:not([hidden]) {
  transform: translateY(0);
}

@media (min-width: 769px) {
  .keyboard-panel {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    border-top: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 32px rgba(8, 12, 24, 0.35);
    transform: none;
    /* 桌面端默认隐藏，节省空间 */
    display: none;
  }
  
  .keyboard-panel:not([hidden]) {
    display: flex;
  }
}

.keyboard-input-row {
  display: flex;
  gap: var(--spacing-sm);
}

.keyboard-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 14px;
}

.btn--send {
  padding: 10px 20px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
}

.keyboard-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.mini-btn {
  flex: 1;
  min-width: 0;
  padding: var(--spacing-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all var(--transition-fast);
}

.mini-btn:hover {
  background: var(--color-bg-elevated);
}

.mini-btn--close {
  background: rgba(239, 68, 68, 0.15);
  color: rgb(239, 68, 68);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.mini-btn--close:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

/* 信息面板（侧边栏） */
.info-panel {
  /* 默认：悬浮模式，不占据布局空间 */
  position: fixed;
  top: 50px;
  right: 12px;
  bottom: 12px;
  width: 320px;
  max-width: min(320px, calc(100vw - 24px)); /* 防止超出屏幕 */
  background: rgba(10, 14, 26, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  z-index: 1000; /* 高于视频区域 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
}

/* 默认隐藏，通过 JS 控制显示 */
.info-panel[hidden] {
  display: none !important;
}

/* 桌面端：信息面板悬浮显示 */
@media (min-width: 1024px) {
  .info-panel {
    top: 50px;
    right: 12px;
    bottom: 12px;
    width: 360px;
    max-width: min(360px, 40vw);
  }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.info-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-panel-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.info-panel-body {
  flex: 1;
  min-height: 0; /* 🔥 关键：允许 flex 子项收缩，启用滚动 */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.info-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

.info-item dt {
  font-size: 12px;
  color: var(--color-text-muted);
  min-width: 70px;
}

.info-item dd {
  font-size: 13px;
  color: var(--color-text-primary);
  text-align: right;
  word-break: break-all;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-item:hover {
  background: var(--color-bg-elevated);
}

.toggle-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.toggle-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  user-select: none;
}

.log-list {
  display: flex;
  flex-direction: column; /* 改为正常顺序，最新日志在底部 */
  gap: 4px;
  max-height: 300px;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--spacing-sm);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
  /* 确保滚动条可见 */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* 移动端：增加日志区域高度 */
@media (max-width: 768px) {
  .log-list {
    max-height: 400px;
    min-height: 250px;
  }
}

.log-entry {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: var(--spacing-sm);
  padding: 6px 8px;
  background: var(--color-surface);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
}

.log-time {
  color: var(--color-text-muted);
  font-family: 'Courier New', monospace;
}

.log-level {
  color: var(--color-primary);
  font-weight: 600;
  text-transform: uppercase;
}

.log-message {
  color: var(--color-text-secondary);
  word-break: break-word;
}

/* ========================================
   移动端适配
   ======================================== */
@media (max-width: 1024px) {
  .connect-container {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .connect-panel {
    padding: var(--spacing-lg);
  }
}

@media (max-width: 768px) {
  .connect-container {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .panel-status {
    width: 100%;
    justify-content: flex-start;
  }

  .logo-icon {
    font-size: 48px;
  }

  .app-title {
    font-size: 24px;
  }

  .tips-grid {
    grid-template-columns: 1fr;
  }

  .info-panel {
    width: 100%;
    max-width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .connect-container {
    padding: var(--spacing-md);
  }

  .logo-icon {
    font-size: 40px;
  }

  .app-title {
    font-size: 20px;
  }

  .config-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .config-item dd {
    text-align: left;
  }

  .form-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .form-actions .status-badge {
    width: 100%;
  }
}

/* ========================================
   触摸设备优化
   ======================================== */
html.is-touch .interaction-layer {
  cursor: default;
}

/* ========================================
   横屏模式优化
   ======================================== */
@media (orientation: landscape) and (max-height: 500px) {
  .console-footer {
    padding: var(--spacing-xs);
  }

  .control-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .control-btn .btn-label {
    display: none;
  }
}

/* ========================================
   移动端优化（手机）
   ======================================== */
@media (max-width: 768px) {
  .screen--console {
    grid-template-rows: auto 1fr;
    /* 🔧 移动端：移除底部 auto，确保视频占满全部空间，不被键盘面板遮挡 */
    /* iOS Safari: 确保占满整个视口高度 */
    height: 100vh;
    height: -webkit-fill-available;
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }
  
  .console-header {
    padding: 0 var(--spacing-xs);
    padding-bottom: var(--spacing-xs);
    font-size: 11px;
    min-height: 36px;
    /* 移动端：确保头部不遮挡内容 */
    position: relative;
    z-index: 20;
    /* PWA 模式：适配安全区域 */
    padding-top: calc(var(--spacing-xs) + var(--safe-area-top, env(safe-area-inset-top)));
    padding-left: calc(var(--spacing-xs) + var(--safe-area-left, env(safe-area-inset-left)));
    padding-right: calc(var(--spacing-xs) + var(--safe-area-right, env(safe-area-inset-right)));
  }
  
  /* 🔥 移动端横屏特别优化：最大化视频显示区域 */
  @media (orientation: landscape) {
    .screen--console {
      /* 横屏时使用100dvh确保完整显示 */
      height: 100dvh;
    }
    
    .console-header {
      min-height: 28px;
      padding: 2px 6px;
      padding-bottom: 2px;
      font-size: 10px;
      padding-top: calc(2px + var(--safe-area-top, env(safe-area-inset-top)));
      padding-left: calc(6px + var(--safe-area-left, env(safe-area-inset-left)));
      padding-right: calc(6px + var(--safe-area-right, env(safe-area-inset-right)));
    }
    
    .console-header .icon-btn {
      width: 26px;
      height: 26px;
      font-size: 13px;
      min-width: 26px;
      min-height: 26px;
    }
    
    .console-header .connection-info {
      font-size: 10px;
    }
    
    .console-header .info-text {
      max-width: 80px; /* 限制文字宽度，避免占用过多空间 */
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    
    .console-body {
      padding: 0;
      gap: 0;
    }
    
    .video-container {
      height: 100%;
      min-height: 0;
    }
    
    .mobile-sidebar {
      top: calc(28px + var(--safe-area-top, env(safe-area-inset-top)));
      width: 36px; /* 横屏时进一步缩小 */
    }
    
    .mobile-sidebar.open {
      width: 200px; /* 展开时也缩小一点 */
    }
  }
  
  .connection-info {
    font-size: 10px;
  }
  
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
    /* 移动端：增大触摸目标 */
    min-width: 36px;
    min-height: 36px;
  }
  
  .video-container {
    /* 移动端全屏视频 */
    padding: 0;
    /* 确保视频区域可以接收触摸事件 */
    position: relative;
    touch-action: none;
    overflow: hidden; /* iOS Safari: 改为hidden，避免滚动问题 */
    /* 使用flex布局确保正确填充 */
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  
  .video-wrapper {
    /* 移动端：优化视频填充 */
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 支持双指缩放 */
    transform-origin: center center;
    position: relative;
  }
  
  #remote-video {
    /* 移动端：优化视频显示 */
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 使用contain保持比例，避免裁剪 */
    /* iOS视频全屏支持 */
    -webkit-playsinline: true;
    /* 移除可能导致Safari放大的transform */
    transform: none;
    /* 确保视频填充容器 */
    flex-shrink: 0;
  }
  
  /* 移动端竖屏：优化视频显示 */
  @media (orientation: portrait) {
    .video-wrapper {
      /* 竖屏时，居中显示 */
      align-items: center;
      justify-content: center;
    }
    
    #remote-video {
      /* 竖屏：使用contain保持比例 */
      object-fit: contain;
      width: 100%;
      height: 100%;
      max-width: 100%;
      max-height: 100%;
      /* 移除transform避免Safari放大问题 */
      transform: none;
    }
  }
  
  /* 移动端横屏：优化视频显示（基础样式，详细优化在移动端媒体查询中） */
  @media (orientation: landscape) {
    #remote-video {
      object-fit: contain;
      width: 100%;
      height: 100%;
      transform: none;
    }
  }
  
  .interaction-layer {
    /* 移动端：确保交互层覆盖整个视频区域 */
    position: absolute;
    inset: 0;
    z-index: 15;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    /* iOS Safari: 确保交互层可以接收所有触摸事件 */
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* iOS Safari 全屏模式下的交互优化 */
  html.fullscreen .interaction-layer,
  html:fullscreen .interaction-layer,
  html:-webkit-full-screen .interaction-layer {
    /* 全屏模式下，确保交互层覆盖整个屏幕 */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
  }
  
  /* iOS Safari 全屏模式下，视频容器优化 */
  html.fullscreen .video-container,
  html:fullscreen .video-container,
  html:-webkit-full-screen .video-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    /* 关键：高度减去底部安全区域，避免被 Home Indicator 遮挡 */
    height: calc(100vh - var(--safe-area-bottom, env(safe-area-inset-bottom)));
    padding: 0;
  }
  
  html.fullscreen .video-wrapper,
  html:fullscreen .video-wrapper,
  html:-webkit-full-screen .video-wrapper {
    width: 100vw;
    /* 高度减去底部安全区域 */
    height: calc(100vh - var(--safe-area-bottom, env(safe-area-inset-bottom)));
  }
  
  html.fullscreen #remote-video,
  html:fullscreen #remote-video,
  html:-webkit-full-screen #remote-video {
    width: 100vw !important;
    /* 关键：视频高度减去底部安全区域，画面不会被遮挡也不会上移 */
    height: calc(100vh - var(--safe-area-bottom, env(safe-area-inset-bottom))) !important;
    max-width: 100vw !important;
    max-height: calc(100vh - var(--safe-area-bottom, env(safe-area-inset-bottom))) !important;
  }
  
  .info-panel {
    /* 移动端：信息面板作为侧边抽屉 */
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 360px;
    height: 100vh;
    height: 100dvh; /* 使用动态视口高度，适配移动端 */
    z-index: 2000; /* 🔥 提权：确保高于所有视频和交互层 */
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(10, 14, 26, 0.98); /* 🔥 修复：确保有深色背景 */
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    /* 适配安全区域 */
    padding-top: var(--safe-area-top, env(safe-area-inset-top));
    padding-bottom: var(--safe-area-bottom, env(safe-area-inset-bottom));
    /* 确保内容可滚动 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto; /* 确保能点到 */
    overscroll-behavior: contain; /* 防止滚动穿透到 body */
  }
  
  .info-panel.info-panel--open {
    right: 0;
  }
  
  /* 信息面板头部适配 */
  .info-panel-header {
    flex-shrink: 0;
    padding: var(--spacing-md);
    background: rgba(10, 14, 26, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  /* 🔥 移动端优化：信息面板关闭按钮增大点击区域，往下移 */
  .info-panel-header .icon-btn--small {
    position: relative;
    padding: 12px;
    margin: -8px -8px -8px 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* 信息面板内容区域可滚动 */
  .info-panel-body {
    flex: 1;
    min-height: 0; /* 🔥 关键：允许 flex 子项收缩，启用滚动 */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y; /* 🔥 让浏览器优先把纵向手势用于滚动，减少与视频手势冲突 */
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-xl) + var(--safe-area-bottom, env(safe-area-inset-bottom)));
  }
  
  .console-footer {
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.78) 0%, rgba(10, 12, 24, 0.92) 85%);
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 -12px 32px rgba(8, 12, 24, 0.45);
    touch-action: manipulation;
  }

  .footer-toolbar {
    gap: var(--spacing-sm);
  }

  .nav-buttons,
  .action-buttons {
    gap: var(--spacing-sm);
    padding: 0;
  }

  .nav-buttons {
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    padding-bottom: var(--spacing-sm);
  }

  .control-btn {
    padding: var(--spacing-sm);
    font-size: 13px;
    min-height: 48px;
    min-width: 60px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.14);
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
  }

  .control-btn:active {
    transform: scale(0.94);
    background: rgba(148, 163, 184, 0.22);
  }

  .btn-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
  }

  .btn-icon {
    font-size: 18px;
  }
  
  /* 移动端：优化键盘面板 */
  .keyboard-panel {
    padding: var(--spacing-md);
    /* 移动端：确保键盘面板不遮挡视频 */
    max-height: 40vh;
    overflow-y: auto;
  }
  
  .keyboard-input {
    /* 移动端：增大输入框，避免虚拟键盘遮挡 */
    font-size: 16px; /* 防止iOS自动缩放 */
    padding: 12px 16px;
  }
}

/* 小屏幕手机（iPhone SE等） */
@media (max-width: 375px) {
  .console-header {
    padding: var(--spacing-xs);
  }
  
  .connection-info {
    display: none; /* 小屏幕隐藏连接信息 */
  }
  
  .control-btn .btn-label {
    font-size: 10px;
  }
  
  .nav-buttons,
  .action-buttons {
    gap: var(--spacing-xs);
  }
}

/* ========================================
   打印样式（隐藏不必要元素）
   ======================================== */
@media print {
  .console-header,
  .console-footer,
  .info-panel {
    display: none !important;
  }
}

/* ========================================
   无障碍支持
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   滚动条样式
   ======================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Honor initial/overlay hidden state even before bootstrap executes. */
.screen[hidden], .video-overlay[hidden] { display: none !important; }

/* Compact lockscreen affordance: only its own bounds intercept input. */
.remote-unlock-banner { position:absolute; top:12%; left:50%; transform:translateX(-50%); z-index:30; max-width:calc(100% - 24px); padding:12px 18px; border:1px solid #314868; border-radius:28px; background:#142135; color:#eef5ff; font-size:14px; cursor:pointer; }
/* Mirrors the Android unlock panel; the automatic entry remains a small capsule. */
.remote-unlock-panel { position:absolute; z-index:40; left:50%; top:50%; transform:translate(-50%,-50%); width:min(392px,calc(100% - 32px)); max-height:calc(100% - 24px); overflow:auto; padding:22px 24px; box-sizing:border-box; border:1px solid #2b3d57; border-radius:28px; background:#0f192b; color:#f2f6ff; box-shadow:0 12px 48px #0006; }
.remote-unlock-panel header { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.remote-unlock-panel small { color:#64a6ff; font-size:12px; letter-spacing:.08em; }
.remote-unlock-panel h3 { margin:8px 0 0; font-size:23px; font-weight:600; }
.remote-unlock-panel p { margin:16px 0 22px; font-size:14px; line-height:1.6; color:#9dafc7; }
.remote-unlock-keys { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.remote-unlock-panel button { min-height:48px; padding:4px; border:1px solid #2b3c53; border-radius:16px; background:#1c2b41; color:#f2f6ff; font-size:15px; cursor:pointer; touch-action:manipulation; }
.remote-unlock-panel button:active:not(:disabled) { filter:brightness(1.3); }
.remote-unlock-panel button:focus-visible { outline:2px solid #64a6ff; outline-offset:2px; }
.remote-unlock-panel button:disabled { color:#697a93; background:#162235; cursor:default; }
.remote-unlock-panel .primary:not(:disabled) { background:#3072f1; border-color:transparent; }
.remote-unlock-keys button { min-height:64px; }
.remote-unlock-keys button[data-key="0"], .remote-unlock-keys button[data-key="1"], .remote-unlock-keys button[data-key="2"], .remote-unlock-keys button[data-key="3"], .remote-unlock-keys button[data-key="4"], .remote-unlock-keys button[data-key="5"], .remote-unlock-keys button[data-key="6"], .remote-unlock-keys button[data-key="7"], .remote-unlock-keys button[data-key="8"], .remote-unlock-keys button[data-key="9"] { font-size:26px; }
.remote-unlock-panel .remote-unlock-close { width:48px; flex-shrink:0; border-radius:50%; font-size:28px; color:#9dafc7; }
.remote-unlock-panel > .primary { width:100%; margin-bottom:12px; }
.remote-unlock-pattern { display:block; width:100%; max-width:300px; margin:auto; border-radius:20px; background:#142135; touch-action:none; user-select:none; }
.remote-unlock-pattern[aria-disabled="true"] { opacity:.5; }
.remote-unlock-panel footer { margin-top:22px; color:#9dafc7; font-size:12px; text-align:center; }
.remote-unlock-panel [hidden], .remote-unlock-panel[hidden], .remote-unlock-banner[hidden] { display:none !important; }
@media(max-height:480px) { .remote-unlock-panel { padding:12px 24px; } .remote-unlock-panel p { margin:8px 0 12px; } .remote-unlock-keys button { min-height:48px; } .remote-unlock-pattern { max-width:220px; } .remote-unlock-panel footer { margin-top:8px; } }
