/* ============================================================
   内置字体：Noto Sans SC（思源黑体，Google/Adobe 联合发布，SIL OFL 1.0）
   免费商用、可嵌入、可再分发；自托管 woff2，不依赖系统字体，
   规避微软雅黑/Segoe UI 等商业字体版权风险。
   拉丁子集约 13KB/字重，简体中文子集约 1.1MB/字重。
   ============================================================ */
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/noto-sans-sc-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F;
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/noto-sans-sc-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F;
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/noto-sans-sc-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F;
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/noto-sans-sc-chinese-simplified-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/noto-sans-sc-chinese-simplified-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/noto-sans-sc-chinese-simplified-700-normal.woff2') format('woff2');
}

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

:root {
  --bg: #0f1420;
  --card: #1a2233;
  --card-2: #232d42;
  --text: #e8edf6;
  --muted: #8b97ad;
  --primary: #3b82f6;
  --primary-hover: #2f6fe0;
  --danger: #ef4444;
  --ok: #22c55e;
  --border: #2d3850;
}

body {
  font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 17px; font-weight: 600; }
.tag {
  font-size: 12px;
  background: var(--card-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-off { background: var(--danger); }
.dot-on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* 顶栏右侧操作区 + 语言切换按钮（下载页/主控页共用） */
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(59, 130, 246, .12);
  border: 1px solid rgba(59, 130, 246, .4);
  color: var(--primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.lang-btn:hover { background: rgba(59, 130, 246, .24); border-color: rgba(59, 130, 246, .7); }
.lang-btn svg { opacity: .85; }

.card {
  margin: 60px auto;
  width: min(460px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 30px;
}
.card h1 { font-size: 20px; margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 22px; }

.code-row { display: flex; gap: 10px; }
#code-input {
  flex: 1;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 28px;
  letter-spacing: 10px;
  text-align: center;
  padding: 12px 8px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
#code-input:focus { border-color: var(--primary); }

.btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #2c3852; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: #fca5a5; }
.btn-danger:hover { background: rgba(239, 68, 68, .12); }

.status { margin-top: 16px; font-size: 14px; color: var(--muted); min-height: 22px; }
.status.err { color: #fca5a5; }
.status.ok { color: var(--ok); }

/* 会话视图 */
.session { flex: 1; display: flex; flex-direction: column; padding: 14px 18px; gap: 12px; }
.hidden { display: none !important; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.session-status { font-size: 14px; color: var(--muted); }
.toolbar-actions { display: flex; gap: 8px; }

.stage {
  position: relative;
  flex: 1;
  background: #05080f;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}
#remote-video {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  width: auto;
  height: auto;
  cursor: crosshair;
  user-select: none;
  -webkit-user-drag: none;
}
/* 极速模式：接收端也叠一层去色，点击瞬间即黑白，无需等待编码切换 */
#remote-video.turbo { filter: grayscale(1) contrast(1.06); }
.btn.btn-active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1a1300;
  font-weight: 600;
}
.btn.btn-active:hover { background: #d98a06; border-color: #d98a06; }
.stage.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; }

/* 全屏：画面铺满整个屏幕，工具栏悬浮在顶部 */
.session:fullscreen { background: #05080f; width: 100%; height: 100%; padding: 10px 12px; }
.session:fullscreen .toolbar {
  position: absolute; top: 10px; left: 12px; right: 12px; z-index: 10;
  background: rgba(15, 20, 32, .82); backdrop-filter: blur(6px);
}
.session:fullscreen .stage { min-height: 0; flex: 1; border: none; border-radius: 0; }
.session:fullscreen #remote-video { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.session:fullscreen .transfers { display: none; }

.lock-badge {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(15, 20, 32, .85);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
  transition: opacity .2s;
  white-space: nowrap;
}
.lock-badge.locked {
  background: rgba(59, 130, 246, .92);
  color: #fff;
  border-color: var(--primary);
}

.transfers { display: flex; flex-direction: column; gap: 8px; }
.transfer-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.transfer-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.transfer-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--card-2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .15s; }
.progress-bar.done { background: var(--ok); }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.web-ver { margin-left: 6px; color: var(--primary); font-variant-numeric: tabular-nums; }
