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

:root {
  --bg-primary: #000000;
  --bg-card: rgba(28, 28, 30, 0.85);
  --bg-bar: #1C1C1E;
  --bg-input: #2C2C2E;
  --btn-blue: #0A84FF;
  --btn-blue-press: #007AFF;
  --btn-red: #FF453A;
  --btn-gray: #3A3A3C;
  --text-primary: #FFFFFF;
  --text-secondary: #8E8E93;
  --text-tertiary: #555555;
  --border-subtle: rgba(255, 255, 255, 0.08);
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; }

/* ===== 通用按钮 ===== */
.btn-blue {
  background: var(--btn-blue);
  color: var(--text-primary);
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-blue:active { background: var(--btn-blue-press); }
.btn-blue:disabled { opacity: 0.4; }

.btn-red {
  background: var(--btn-red);
  color: var(--text-primary);
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-red:active { background: #D63030; }

.btn-gray {
  background: var(--btn-gray);
  color: var(--text-primary);
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-gray:active { background: #2A2A2C; }

.btn-sm { padding: 8px 14px; font-size: 14px; }

/* ===== 入口界面 ===== */
.entry-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #1C1C2E 0%, #000000 50%);
}

.entry-header {
  text-align: center;
  margin-bottom: 40px;
}

.entry-logo {
  font-size: 56px;
  margin-bottom: 12px;
}

.entry-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
}

.entry-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 8px;
}

.entry-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--btn-blue); }
.form-group input::placeholder { color: var(--text-tertiary); }

.entry-buttons { display: flex; gap: 12px; }
.entry-buttons button { flex: 1; }

.entry-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.entry-features {
  margin-top: 40px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.entry-features span {
  background: var(--bg-input);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== 会议界面 ===== */
.meeting-screen {
  background: var(--bg-primary);
}

/* 左上角信息卡片 — 小条样式，不挡视野 */
.info-card {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-title {
  display: none;
}

.info-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.3;
}

.info-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--btn-gray);
  color: var(--text-primary);
}
.info-badge.active {
  background: #30D158;
  color: #000;
}

/* 右上角按钮组 */
.top-right-group {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 50;
}

.member-pill {
  background: var(--bg-input);
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-primary);
}

/* 中央视频区 */
.video-area {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  overflow: hidden;
  /* 关键：视频区不拦截触摸事件，让底层 bottom-bar 的按钮可点击 */
  pointer-events: none;
}

.video-area video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  pointer-events: none;
}
.video-area video.active { display: block; }
.video-area video.fit-contain { object-fit: contain; }

/* 视频区控制按钮 */
.video-controls {
  position: absolute;
  bottom: 140px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 11;
  /* 视频控制按钮需要可点击 */
  pointer-events: auto;
}

.video-ctrl-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(28, 28, 30, 0.92); /* 不用 backdrop-filter 省 GPU */
  border: 0.5px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.video-ctrl-btn:active { background: var(--btn-blue); }
.video-ctrl-btn.active { background: var(--btn-blue); }

.video-placeholder {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 15px;
  padding: 20px;
}

/* 底部控制栏 */
.bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: #1C1C1E;
  z-index: 50;
  pointer-events: auto;
}

.bottom-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.btn-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 8px;
  min-height: 52px;
  border-radius: 12px;
  font-size: 14px;
}
.btn-action .btn-icon { font-size: 20px; }

.bottom-status {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-line {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.status-line.sharing { color: #30D158; }

.status-detail {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== 浮窗面板 ===== */
.member-panel, .chat-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88%;
  max-width: 360px;
  max-height: 70vh;
  background: var(--bg-bar);
  border-radius: 20px;
  border: 0.5px solid var(--border-subtle);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--border-subtle);
  font-size: 16px;
  font-weight: 600;
}

.close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #FFFFFF;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.close-btn:active { background: rgba(255, 255, 255, 0.25); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* 成员列表 */
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
}
.member-item:active { background: var(--bg-input); }

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.member-name { flex: 1; color: var(--text-primary); }

.member-status-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
}
.member-status-tag.sharing { background: #30D158; color: #000; }
.member-status-tag.me { background: var(--btn-blue); color: white; }

.empty-text {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 30px 0;
}

/* 聊天区 */
.chat-messages { min-height: 200px; }

.chat-msg {
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 12px;
}
.chat-msg.self { background: rgba(10, 132, 255, 0.15); }
.chat-msg .msg-name { font-size: 12px; font-weight: 600; color: var(--btn-blue); margin-bottom: 2px; }
.chat-msg.self .msg-name { color: #30D158; }
.chat-msg .msg-text { font-size: 14px; color: var(--text-primary); word-break: break-word; }

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 0.5px solid var(--border-subtle);
}
.chat-input-bar textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  font-family: inherit;
  outline: none;
  max-height: 80px;
}
.chat-input-bar textarea:focus { border-color: var(--btn-blue); }
.chat-input-bar textarea:disabled { opacity: 0.4; }
.btn-send { padding: 10px 16px; font-size: 14px; }

/* ===== 全屏 ===== */
.fullscreen-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fullscreen-container video.fit-contain { object-fit: contain; }
.exit-fullscreen {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

/* ===== 登录区域 ===== */
.login-section, .logged-in-info {
  width: 100%;
  max-width: 340px;
  margin-bottom: 16px;
}

.login-card {
  background: rgba(28, 28, 30, 0.92);
  border: 0.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px 16px;
}

.login-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-hint {
  font-size: 13px;
  color: var(--btn-blue);
  margin-bottom: 16px;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form .form-group {
  margin: 0;
}

.login-form .form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.login-form .form-group input:focus {
  border-color: var(--btn-blue);
}

.login-form .form-group input::placeholder {
  color: var(--text-tertiary);
}

/* ===== 按钮扩展 ===== */
.btn-full { width: 100%; }

.btn-light-blue {
  background: rgba(10, 132, 255, 0.15);
  color: var(--btn-blue);
  border: 1px solid rgba(10, 132, 255, 0.3);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-light-blue:active {
  background: rgba(10, 132, 255, 0.25);
}

.entry-buttons-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== 图片预览弹窗 ===== */
.image-preview-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-overlay img {
  max-width: 95vw;
  max-height: 85vh;
  border-radius: 8px;
}

.image-preview-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ===== 聊天图片消息 ===== */
.chat-msg .msg-image {
  margin-top: 4px;
  cursor: pointer;
}

.chat-msg .msg-image img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
}

/* ===== 聊天上传按钮 ===== */
.chat-upload-btn {
  background: var(--bg-input);
  border: 0.5px solid var(--border-subtle);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-upload-btn:active { opacity: 0.7; }
.chat-upload-btn:disabled { opacity: 0.4; }

/* ===== 入口提示文字 ===== */
.entry-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.6;
}

/* ===== 入口操作区 ===== */
.entry-actions {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== 加入会议弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-dialog {
  background: var(--bg-bar);
  border-radius: 20px;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  border: 0.5px solid var(--border-subtle);
}

.modal-header-bar {
  padding: 20px 20px 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body-content {
  padding: 8px 20px 20px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-input-group {
  margin-bottom: 12px;
}

.modal-input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.modal-input-group input:focus {
  border-color: var(--btn-blue);
}

.modal-input-group input::placeholder {
  color: var(--text-tertiary);
}

.modal-footer-bar {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding: 12px 20px 20px;
}

.modal-btn-cancel {
  background: none;
  border: none;
  color: var(--btn-blue);
  font-size: 16px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
}

.modal-btn-confirm {
  background: none;
  border: none;
  color: var(--btn-blue);
  font-size: 16px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
}

.modal-btn-confirm:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}

/* ===== 加入会议内联错误提示 ===== */
.join-error-tip {
  color: var(--btn-red);
  font-size: 14px;
  margin: 4px 20px 0;
  line-height: 1.4;
}
.join-error-tip.hidden { display: none; }

/* ===== 管理后台 ===== */
.admin-screen {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.admin-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.admin-who {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--bg-bar);
  border-radius: 10px;
  padding: 4px;
}
.admin-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 9px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.admin-tab.active {
  background: var(--btn-blue);
  color: #fff;
  font-weight: 600;
}
.admin-pane.hidden { display: none; }
.admin-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}
.admin-list { display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}
.admin-row-main { flex: 1; min-width: 0; }
.admin-room-id {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-primary);
  word-break: break-all;
}
.admin-row-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.admin-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 32px 0;
}
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.admin-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.admin-card .modal-input-group { margin-bottom: 10px; }
.role-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 6px;
  vertical-align: middle;
}
.role-tag.root_admin { background: rgba(10,132,255,0.2); color: #6DB5FF; }
.role-tag.sub_admin { background: rgba(142,142,147,0.2); color: var(--text-secondary); }
.muted { color: var(--text-tertiary); font-size: 13px; }
