/* CrossDesk 网易 UU 风格移动端增强样式 */

:root {
  --uu-bg: rgba(15, 23, 42, 0.88);
  --uu-bg-solid: #0f172a;
  --uu-surface: rgba(30, 41, 59, 0.9);
  --uu-border: rgba(148, 163, 184, 0.24);
  --uu-text: #f8fafc;
  --uu-muted: #94a3b8;
  --uu-accent: #38bdf8;
  --uu-accent-strong: #2563eb;
  --uu-danger: #ef4444;
  --uu-shadow: 0 12px 32px rgba(2, 6, 23, 0.52);
}

html,
body {
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.app-container {
  width: 100vw;
  height: 100dvh;
}

/* ==================== 连接页移动端暗夜快捷卡片优化 ==================== */

@media (max-width: 920px) {
  .connection-overlay {
    padding: max(14px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
    background: radial-gradient(circle at top right, #1e293b, #0b1120 62%, #020617);
    color: var(--uu-text);
    border-top: 0;
  }

  .connection-layout {
    gap: 14px;
    padding-block: 4px 18px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "panel" "intro" "resources" "sponsors";
    align-items: start;
  }

  .connection-layout::before {
    display: none;
  }

  .connection-panel {
    padding: 18px 16px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid var(--uu-border);
    box-shadow: var(--uu-shadow);
    color: var(--uu-text);
  }

  .connection-panel label {
    color: #cbd5e1;
    font-size: 13px;
  }

  .connection-panel input {
    background: rgba(30, 41, 59, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    color: #f8fafc;
    font-size: 16px;
    min-height: 44px;
  }

  .connection-panel input::placeholder {
    color: #64748b;
  }

  .connection-panel button {
    border-radius: 10px;
    min-height: 46px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff;
  }

  .connection-panel button:disabled {
    background: rgba(51, 65, 85, 0.8);
    color: #94a3b8;
  }

  .connection-intro {
    padding: 4px 4px 0;
  }

  .connection-intro h1 {
    font-size: 20px;
    margin-bottom: 4px;
    color: #e2e8f0;
  }

  .connection-intro h1 span {
    display: inline;
    color: var(--uu-accent);
  }

  .connection-intro p {
    font-size: 12px;
    line-height: 1.5;
    color: var(--uu-muted);
  }

  .connection-resources,
  .connection-sponsors {
    opacity: 0.78;
    font-size: 12px;
  }

  .connection-sponsors {
    background: rgba(15, 23, 42, 0.75);
    border-color: var(--uu-border);
    border-radius: 12px;
    color: var(--uu-muted);
  }

  .sponsor-brands a {
    color: #e2e8f0;
  }

  .resource-actions {
    display: none;
  }
}

.uu-devices-section {
  margin-bottom: 16px;
}

.uu-devices-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: inherit;
}

.uu-devices-header small {
  font-weight: 400;
  opacity: 0.7;
  font-size: 11px;
}

.uu-device-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 8px;
}

.uu-device-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 26px 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: rgba(30, 41, 59, 0.65);
  color: #f8fafc;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

@media (min-width: 921px) {
  .uu-device-card {
    background: #f0f7ff;
    color: #19365b;
    border-color: #bfd7f2;
  }
}

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

.uu-device-name {
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uu-device-id {
  font-size: 11px;
  opacity: 0.78;
  font-variant-numeric: tabular-nums;
}

.uu-device-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
}

@media (min-width: 921px) {
  .uu-device-tag {
    background: #dbeafe;
    color: #1d4ed8;
  }
}

.uu-device-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  min-width: 22px !important;
  min-height: 22px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: currentColor !important;
  opacity: 0.55;
  font-size: 15px !important;
  line-height: 1;
}

.uu-device-remove:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.22) !important;
  color: #ef4444 !important;
}

.uu-pwd-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.uu-pwd-wrap input {
  padding-right: 44px;
}

.uu-pwd-eye {
  position: absolute;
  right: 6px;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: #94a3b8 !important;
  font-size: 16px !important;
}

.uu-form-extras {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.uu-remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer;
}

.uu-remember-row input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  accent-color: #2563eb;
  margin: 0;
}

/* ==================== 会话内隐藏原版占位球与大鼠标 + 为底部栏留出高度 ==================== */

body.uu-mobile-session {
  --uu-bar-h: calc(64px + env(safe-area-inset-bottom, 0px));
}

@media (max-height: 440px) {
  body.uu-mobile-session {
    --uu-bar-h: calc(50px + env(safe-area-inset-bottom, 0px));
  }
}

body.uu-mobile-session #panel-collapsed-bar,
body.uu-mobile-session #virtual-mouse {
  display: none !important;
}

body.uu-mobile-session #connected-panel {
  z-index: 320;
}

body.uu-mobile-session #session-menu-shield {
  z-index: 315;
}

body.uu-mobile-session #video-container {
  width: 100%;
  height: calc(100dvh - var(--uu-bar-h));
  min-height: 0;
  overflow: hidden;
}

body.uu-mobile-session.uu-kb-open #video-container {
  height: 100dvh;
}

/* ==================== 会话内 UU 根容器 ==================== */

#uu-mobile-root {
  position: fixed;
  inset: 0;
  z-index: 260;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

#uu-mobile-root [hidden] {
  display: none !important;
}

#uu-mobile-root [data-uu-interactive] {
  pointer-events: auto;
}

#uu-mobile-root button {
  font-family: inherit;
  border: 0;
  outline: none;
  min-width: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* 隐藏的原生系统输入法代理框：始终保留在视口顶部，保证同步 focus 唤起系统键盘 */
.uu-ime-proxy {
  position: fixed;
  top: 0;
  left: 0;
  width: 2px;
  height: 2px;
  opacity: 0.001;
  font-size: 16px;
  line-height: 1;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  resize: none;
  pointer-events: none;
  z-index: -1;
  outline: none;
}

/* ==================== 固定底部功能栏（网易 UU 同款 4 键） ==================== */

.uu-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--uu-bar-h);
  z-index: 275;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  padding: 4px 6px env(safe-area-inset-bottom, 0px);
  background: #000;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}

.uu-bar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  padding: 2px 4px;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
  transition: color 0.14s ease, transform 0.1s ease;
}

.uu-bar-btn:active {
  transform: scale(0.94);
  color: #38bdf8;
}

.uu-bar-btn.is-active {
  color: #5b9bff;
}

.uu-bar-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

@media (max-height: 440px) {
  .uu-bar-btn {
    flex-direction: row;
    gap: 6px;
    font-size: 12px;
  }

  .uu-bar-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* ==================== 右侧轻量化鼠标模式小浮球 ==================== */

.uu-mouse-pill {
  position: fixed;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: rgba(32, 36, 44, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f8fafc;
  touch-action: none;
  z-index: 278;
  transition: left 0.22s ease, top 0.22s ease, opacity 0.28s ease, transform 0.15s ease;
}

.uu-mouse-pill.is-idle {
  opacity: 0.56;
}

.uu-mouse-pill.is-trackpad {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-color: rgba(255, 255, 255, 0.72) !important;
  opacity: 1;
}

.uu-mouse-pill.is-dragging {
  transition: none;
  transform: scale(1.08);
  opacity: 1;
}

.uu-mouse-pill svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.uu-mouse-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #38bdf8;
  color: #020617;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* ==================== 网易 UU 同款 3 Tab 键盘伴随条 ==================== */

.uu-kb-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 295;
  background: #1d2028;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.48);
  color: #f8fafc;
  touch-action: manipulation;
}

.uu-kb-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 12px 0 6px;
  gap: 4px;
}

.uu-kb-tab-group {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
  min-width: 0;
}

.uu-kb-tab {
  position: relative;
  height: 44px;
  padding: 0 10px;
  background: transparent;
  color: #d8dce6;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.uu-kb-tab.is-active {
  color: #5b9bff;
  font-weight: 600;
}

.uu-kb-tab.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2.5px;
  border-radius: 999px;
  background: #5b9bff;
}

.uu-kb-close {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 50%;
  background: #e2e8f0;
  color: #1d2028;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.uu-kb-close:active {
  transform: scale(0.92);
}

.uu-kb-shortcuts-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* 电脑键盘 Tab：固定贴底并接在 .uu-kb-dock 下方 */
body.uu-mobile-session.uu-pc-kb-open #virtual-keyboard {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  transform: none !important;
  border-radius: 0 !important;
  background: #14171f !important;
  border: 0 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 8px 6px max(10px, env(safe-area-inset-bottom, 0px)) !important;
  box-shadow: none !important;
  z-index: 294 !important;
}

body.uu-mobile-session.uu-pc-kb-open #virtual-keyboard .keyboard-header {
  display: none !important;
}

body.uu-mobile-session.uu-pc-kb-open #virtual-keyboard .keyboard-key,
body.uu-mobile-session.uu-pc-kb-open #virtual-keyboard .keyboard-key:focus,
body.uu-mobile-session.uu-pc-kb-open #virtual-keyboard .keyboard-key:focus-visible {
  background-color: #2a2f3d !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: none !important;
}

/* ==================== 快捷栏与操作抽屉 ==================== */

.uu-ops-backdrop {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(2, 6, 23, 0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  touch-action: manipulation;
}

.uu-ops-sheet {
  width: 100%;
  max-width: 560px;
  padding: 14px 14px max(16px, env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: #141822;
  border-top: 1px solid var(--uu-border);
  box-shadow: var(--uu-shadow);
  color: var(--uu-text);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.uu-dock-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.uu-dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 58px;
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.84);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 500;
  transition: background-color 0.14s ease, transform 0.1s ease;
}

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

.uu-dock-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.uu-dock-btn.is-active {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.88), rgba(14, 165, 233, 0.88));
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.32);
}

.uu-dock-btn.is-warn {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.5) !important;
}

.uu-shortcut-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.uu-shortcut-row::-webkit-scrollbar {
  display: none;
}

.uu-key-chip {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  background: #2a2f3d;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.uu-key-chip:active {
  background: rgba(56, 189, 248, 0.35);
}

.uu-key-chip.is-sticky {
  border: 1px solid rgba(148, 163, 184, 0.35) !important;
}

.uu-key-chip.is-sticky.is-active {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  border-color: transparent !important;
}

/* 迷你键鼠条 */
.uu-mini-mouse {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  bottom: calc(var(--uu-bar-h, 64px) + 12px);
  z-index: 274;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--uu-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
}

.uu-mini-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(51, 65, 85, 0.85);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
}

.uu-mini-btn.is-pressed,
.uu-mini-btn:active {
  background: #0ea5e9;
  color: #fff;
}

/* 手感设置弹层 */
.uu-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(2, 6, 23, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.uu-settings-sheet {
  width: min(380px, 100%);
  max-height: 84dvh;
  overflow-y: auto;
  padding: 16px;
  border-radius: 20px;
  background: #0f172a;
  border: 1px solid var(--uu-border);
  box-shadow: var(--uu-shadow);
  color: var(--uu-text);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.uu-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.uu-sheet-header h3 {
  margin: 0;
  font-size: 16px;
}

.uu-sheet-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(51, 65, 85, 0.8);
  color: #e2e8f0;
  font-size: 18px;
  padding: 0;
}

.uu-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.uu-setting-row small {
  display: block;
  font-size: 11px;
  color: var(--uu-muted);
}

.uu-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #334155;
  flex-shrink: 0;
  padding: 0;
  transition: background-color 0.16s ease;
}

.uu-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
}

.uu-switch[aria-checked="true"] {
  background: #0ea5e9;
}

.uu-switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

.uu-range-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.uu-range-wrap input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
}

.uu-seg-group {
  display: flex;
  gap: 6px;
}

.uu-seg-btn {
  padding: 5px 12px;
  border-radius: 8px;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 12px;
}

.uu-seg-btn.is-active {
  background: #0ea5e9;
  color: #fff;
}

.uu-sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.uu-sheet-action-btn {
  flex: 1 1 auto;
  height: 38px;
  border-radius: 10px;
  background: #1e293b;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
}

.uu-sheet-action-btn.is-primary {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
}

/* 顶部状态胶囊 & 手势水波纹反馈 */
.uu-status-pill {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 295;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  white-space: nowrap;
}

.uu-status-pill.is-drag {
  background: rgba(217, 119, 6, 0.92);
  border-color: rgba(253, 224, 71, 0.65);
}

.uu-ripple {
  position: fixed;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.16);
  pointer-events: none;
  z-index: 270;
  animation: uu-ripple-pop 0.36s ease-out forwards;
}

.uu-ripple.is-right {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.22);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.18);
}

.uu-ripple.is-drag {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.24);
}

@keyframes uu-ripple-pop {
  0% {
    opacity: 0.95;
    transform: scale(0.45);
  }
  100% {
    opacity: 0;
    transform: scale(1.85);
  }
}
