/* AI生成 */
/* ============================================================
   RemoteDesk 主控端 — 精致深色主题
   设计目标：美观、易用、对小白友好、无障碍支持
   ============================================================ */

:root {
  --bg-0: #0b0e14;
  --bg-1: #0f141d;
  --panel: rgba(22, 27, 36, 0.72);
  --panel-solid: #161b24;
  --panel-2: rgba(33, 40, 52, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8edf4;
  --muted: #93a1b3;
  --muted-2: #8392a8;
  --accent: #5b8cff;
  --accent-2: #2dd4bf;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;               /* 小圆角（7 处共用） */
  --radius-2xs: 6px;              /* 更小圆角（7 处共用） */
  --fs: 13px;                     /* 标准字号（23 处共用） */
  --fs-sm: 12px;                  /* 小字号（23 处共用） */
  --fs-sm-half: 12.5px;           /* 小字号半步（13 处共用） */
  --fs-base: 14px;                /* 基准字号（5 处共用） */
  --fs-xs: 11px;                  /* 极小字号（8 处共用） */
  --gap: 16px;                     /* 标准间距（14 处共用） */
  --gap-sm: 10px;                 /* 小间距（9 处共用） */
  --lh: 1.5;                      /* 标准行高（5 处共用） */
  --lh-tight: 1;                  /* 紧凑行高（5 处共用） */
  --fw-bold: 700;                 /* 粗体字重（9 处共用） */
  --fw-semibold: 600;             /* 半粗体字重（9 处共用） */
  --fw-extrabold: 800;            /* 特粗体字重（4 处共用） */
  --fw-medium: 500;              /* 中等字重（3 处共用） */
  --transition-ctrl: border-color .15s, background .15s, transform .1s;  /* 控件过渡（3 处共用） */
  --shadow-ring: 0 0 0 1px var(--accent) inset;  /* 聚焦环阴影（3 处共用） */
  --border-default: 1px solid var(--border);  /* 默认边框（7 处共用） */
  --fs-xs-half: 11.5px;          /* 极小字号半步（5 处共用） */
  --fs-md: 15px;                 /* 中字号（3 处共用） */
  --txt-on-accent: #fff;          /* 强调色背景上的文字色（6 处共用） */
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --grad-soft: linear-gradient(135deg, rgba(91,140,255,.18), rgba(45,212,191,.18));
  --ease: cubic-bezier(.22, .61, .36, 1);
  /* 主题可切换的基础色（浅色模式覆盖下列变量） */
  --topbar-bg: rgba(13, 17, 24, .92);
  --toolbar-bg: rgba(13, 17, 24, .92);
  --canvas-bg: #06080c;
  --input-bg: rgba(10, 13, 19, .6);
  --toast-bg: rgba(20, 25, 34, .92);
  --danger-fg: #ffb4b4;
  /* 动画时长基准（无障碍：prefers-reduced-motion 下置 0） */
  --anim-fast: .15s;
  --anim-normal: .25s;
  --anim-slow: .4s;
}

/* ---------- 尊重用户的「减少动画」设置 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    --anim-fast: 0s !important;
    --anim-normal: 0s !important;
    --anim-slow: 0s !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 浅色主题（覆盖变量） ---------- */
[data-theme="light"] {
  --bg-0: #e9edf3;
  --bg-1: #dde3ec;
  --panel: rgba(255, 255, 255, .82);
  --panel-solid: #fff;
  --panel-2: rgba(240, 243, 248, .92);
  --border: rgba(15, 23, 42, .1);
  --border-strong: rgba(15, 23, 42, .18);
  --text: #0f172a;
  --muted: #586172;
  --muted-2: #8a93a3;
  --topbar-bg: rgba(255, 255, 255, .72);
  --toolbar-bg: rgba(255, 255, 255, .72);
  --canvas-bg: #f1f4f8;
  --input-bg: rgba(255, 255, 255, .9);
  --toast-bg: rgba(255, 255, 255, .96);
  --danger-fg: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background:
    radial-gradient(1200px 700px at 12% -8%, rgba(91,140,255,.16), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(45,212,191,.12), transparent 55%),
    var(--bg-0);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: var(--gap-sm);
  font-weight: var(--fw-extrabold); font-size: 17px; letter-spacing: .3px;
}
.brand span { color: var(--muted); font-weight: var(--fw-medium); font-size: var(--fs); margin-left: 2px; }

.top-right { display: flex; align-items: center; gap: var(--gap-sm); }
.stats {
  font-size: var(--fs-sm); color: var(--text);
  background: var(--panel-2); border: var(--border-default);
  padding: 5px 11px; border-radius: 999px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stats .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--muted-2); }
.stats .dot.good { background: var(--good); box-shadow: 0 0 8px var(--good); }
.stats .dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.stats .dot.bad  { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

.status {
  font-size: var(--fs); padding: 5px 12px; border-radius: 999px;
  background: var(--panel-2); border: var(--border-default); color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
  transition: color .2s, border-color .2s;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.status.ok { color: var(--good); border-color: rgba(52,211,153,.35); }
.status.err { color: var(--bad); border-color: rgba(248,113,113,.35); }
.status.wait { color: var(--warn); border-color: rgba(251,191,36,.35); }

/* ---------- 通用面板 ---------- */
.panel {
  margin: auto;
  width: min(460px, 92vw);
  background: var(--panel);
  border: var(--border-default);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.panel::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--grad); opacity: .9;
}
.panel h2 { margin: 0 0 4px; font-size: 20px; font-weight: var(--fw-bold); }
.hint { color: var(--muted); font-size: var(--fs); margin: 0 0 18px; line-height: 1.6; }
.hint.small { font-size: var(--fs-sm); margin-top: 10px; line-height: var(--lh); }

/* 行内文字按钮（如「查看图文教程」）：外观像链接，不占额外块级空间。
   width:auto + box-shadow:none 必须显式覆盖基础 button 样式——表单控件是原子
   inline 级，button 基础的 width:100% 与蓝色大阴影在行内按钮上仍然生效，
   曾渲染成横贯面板、带光晕的「深色条」。 */
.link-btn {
  display: inline; width: auto; padding: 0; margin: 0 0 0 4px; border: none; background: none;
  box-shadow: none; border-radius: 4px;
  color: var(--accent); font: inherit; font-size: var(--fs); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { opacity: .82; filter: none; background: none; }

/* 步骤条 */
.steps { display: flex; gap: var(--gap); margin-bottom: 20px; }
.steps .step {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: var(--border-default);
  font-size: var(--fs-xs-half); color: var(--muted); line-height: 1.4;
}
.steps .step b { display: block; color: var(--text); font-size: var(--fs-sm-half); margin-bottom: 2px; }
.steps .step .n {
  display: inline-grid; place-items: center; width: 18px; height: 18px;
  border-radius: 50%; background: var(--grad); color: #04121f; font-weight: var(--fw-extrabold);
  font-size: var(--fs-xs); margin-right: 6px; vertical-align: middle;
}

label { display: block; font-size: var(--fs); color: var(--muted); margin-bottom: 14px; }
label .row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
label .row .act { color: var(--accent); cursor: pointer; font-size: var(--fs-sm); }

input[type="text"], input[type="password"], textarea {
  display: block; width: 100%;
  background: var(--input-bg); border: var(--border-default);
  color: var(--text); border-radius: var(--radius-sm); padding: 12px 13px;
  font-size: var(--fs-md); outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,140,255,.18);
}
.code-input {
  letter-spacing: 4px; font-size: 20px; font-weight: var(--fw-bold); text-align: center;
  font-variant-numeric: tabular-nums;
}

button {
  width: 100%; padding: 13px; border: none; border-radius: var(--radius-sm);
  background: var(--grad); color: var(--txt-on-accent); font-size: var(--fs-md); font-weight: var(--fw-bold);
  cursor: pointer; transition: transform .12s var(--ease), filter .15s, opacity .15s;
  box-shadow: 0 10px 26px rgba(91,140,255,.32);
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; filter: none; }
button.mini { width: auto; padding: 6px 14px; font-size: var(--fs-sm); box-shadow: none; }

.conn-msg { margin-top: 12px; font-size: var(--fs); min-height: 18px; color: var(--muted); line-height: var(--lh); }
.conn-msg.err { color: var(--bad); }
.conn-msg.ok { color: var(--good); }

/* 记住此设备并自动连接（用户显式开启后才会本地保存访问密码） */
.remember-row { display: flex; align-items: center; gap: 7px; margin: 2px 0 2px;
  font-size: var(--fs-sm); color: var(--muted); cursor: pointer; -webkit-user-select: none; user-select: none; }
.remember-row input { width: 15px; height: 15px; accent-color: var(--accent); flex: none; }

/* 连接方式徽标（工具栏常驻）：P2P 直连 / 经中继转发 */
.conn-badge { flex: none; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs-half);
  font-weight: var(--fw-semibold); letter-spacing: .3px; border: 1px solid transparent; }
.conn-badge.p2p { color: var(--good); background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .35); }
.conn-badge.relay { color: var(--warn); background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .35); }

/* 我的设备 */
.device-list { display: flex; flex-wrap: wrap; gap: var(--gap); margin-bottom: 4px; }
.dev-empty { font-size: var(--fs-sm-half); color: var(--muted-2); padding: 6px 2px 12px; }
.dev-chip {
  width: auto; padding: 8px 12px; font-size: var(--fs); font-weight: var(--fw-medium);
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  border-radius: 999px; cursor: pointer; transition: border-color .15s, transform .12s, background .15s;
  display: inline-flex; align-items: center; gap: var(--gap);
}
.dev-chip:hover { border-color: var(--accent); background: rgba(91,140,255,.12); transform: translateY(-1px); }
.dev-chip .copy {
  width: auto; min-width: 20px; padding: 0 5px; white-space: nowrap;
  height: 20px; display: inline-grid; place-items: center; border-radius: var(--radius-2xs);
  background: rgba(255,255,255,.06); color: var(--muted); cursor: pointer; font-size: var(--fs-xs);
}
.dev-chip .copy:hover { color: var(--text); background: rgba(255,255,255,.12); }

/* 最近连接 */
.recent-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 8px; }
.recent-head span { font-size: var(--fs-sm-half); color: var(--muted); font-weight: var(--fw-semibold); }
.recent-head .clear { font-size: var(--fs-sm); color: var(--muted-2); cursor: pointer; }
.recent-head .clear:hover { color: var(--bad); }
.recent-list { display: flex; flex-direction: column; gap: 6px; }
.recent-row {
  display: flex; align-items: center; gap: var(--gap-sm); padding: 9px 12px;
  background: var(--panel-2); border: var(--border-default); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--fs); transition: border-color .15s, background .15s;
}
.recent-row:hover { border-color: var(--accent); background: rgba(91,140,255,.1); }
.recent-row .meta { flex: 1; overflow: hidden; }
.recent-row .meta .nm { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-row .meta .tm { color: var(--muted-2); font-size: var(--fs-xs-half); }
.recent-row .go { color: var(--accent); font-size: var(--fs-sm); white-space: nowrap; }
.recent-row .del {
  /* width:auto 必须显式覆盖：基础 button 规则的 width:100% 让两个小按钮各占满
     行宽，把设备名（meta, flex-basis 0 可收缩）压成 0 宽、整行横向溢出（实测故障）。 */
  width: auto;
  background: none; border: none; color: var(--muted-2); font-size: var(--fs-sm); line-height: var(--lh-tight);
  cursor: pointer; padding: 2px 6px; border-radius: var(--radius-2xs); flex: none;
}
.recent-row .del:hover { color: #ff6b6b; background: rgba(255,107,107,.14); }
.recent-row .pin {
  width: auto;
  background: none; border: var(--border-default); color: var(--muted-2); font-size: var(--fs-sm); line-height: var(--lh-tight); opacity: .7;
  cursor: pointer; padding: 2px 6px; border-radius: var(--radius-2xs); flex: none;
  transition: opacity .15s, color .15s;
}
.recent-row .pin:hover { opacity: 1; }
.recent-row .pin.on { opacity: 1; color: var(--accent); border-color: var(--accent); }
.recent-row.pinned { border-color: rgba(91,140,255,.45); }

/* ---------- 屏幕区 ---------- */
/* position:relative：抽屉（.drawer, absolute top/right/bottom:0）的定位基准。
   此前缺失导致抽屉锚到视口、其头部内容被更高 z-index 的工具栏盖住不可见。 */
.screen-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.toolbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 9px 14px; background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 20;
  /* 中等宽度下 20+ 个按钮可能放不下一行：整体横向滚动（按钮自身不收缩），
     避免按钮被压缩成两字竖排的窄条（此前 .tool 无 flex:none 时的真实故障）。 */
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.peer-info { font-size: var(--fs); color: var(--muted); display: flex; align-items: center; gap: var(--gap); flex: none; }
.peer-info .live { color: var(--good); font-size: var(--fs-xs); display: inline-flex; align-items: center; gap: 5px; }
.peer-info .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); animation: pulse 1.6s infinite; }
.spacer { flex: 1; }

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

.tool {
  width: auto; padding: 7px 13px; font-size: var(--fs); font-weight: var(--fw-semibold);
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: var(--transition-ctrl);
  /* flex:none + nowrap：按钮绝不被压缩折行（flex 收缩曾把两字标签挤成竖排窄条）；
     放不下时由 .toolbar 整体横向滚动。 */
  flex: none; white-space: nowrap;
}
.tool:hover { border-color: var(--border-strong); background: rgba(255,255,255,.07); }
.tool:active { transform: translateY(1px); }
.tool.danger { color: var(--danger-fg); }
.tool.danger:hover { background: rgba(248,113,113,.14); border-color: rgba(248,113,113,.4); }
/* 多显示器选择器 */
.monitor-switch { display: inline-flex; align-items: center; gap: 4px; }
.monitor-select {
  padding: 5px 8px; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  border-radius: var(--radius-2xs); cursor: pointer; max-width: 180px;
}
.monitor-select:hover { border-color: var(--border-strong); }
.monitor-select:focus { outline: none; border-color: var(--accent); }
/* 音频按钮上的音量指示 (CSS 自定义属性 --audio-level/--audio-color 由JS驱动) */
#audioBtn { position: relative; }
#audioBtn::after {
  content: ""; position: absolute; right: 4px; top: 4px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--audio-color, var(--muted-2));
  opacity: calc(var(--audio-level, 0) * 0.9 + 0.1);
  transition: opacity .15s;
}

.canvas-box {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(91,140,255,.06), transparent 60%),
    var(--canvas-bg);
  overflow: hidden; padding: 10px; position: relative;
  touch-action: none; -webkit-user-select: none; user-select: none;
  transition: transform .08s ease-out; contain: layout paint style;
}
#screen {
  max-width: 100%; max-height: 100%;
  background: #0b0e12; border-radius: var(--radius-2xs); cursor: crosshair;
  touch-action: none;
  /* 提升为独立合成层并隔离渲染：远程画布每帧重绘，will-change 让浏览器为其单独建层、
     避免每帧连带上层元素回流；contain 隔离其内部渲染，不影响外部布局/绘制计算。
     注意不能用 contain: strict（含 size containment）：canvas 的固有尺寸会被按
     「无内容」计为 0×0，画布在 max-width/max-height 下直接塌缩不可见（黑屏）。
     layout/paint/style 三项保留了渲染隔离收益，且不影响固有尺寸。 */
  will-change: transform;
  contain: layout paint style;
}
.overlay {
  position: absolute; z-index: 5; pointer-events: none;
  font-size: var(--fs-base); color: var(--txt-on-accent); background: rgba(8,12,18,.88);
  padding: 9px 16px; border-radius: var(--radius-sm); border: var(--border-default);
  animation: pop .2s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }

/* ---------- 抽屉 ---------- */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 348px;
  background: var(--panel-solid); border-left: 1px solid var(--border);
  padding: 18px; overflow-y: auto; overflow-x: hidden; z-index: 25;
  box-shadow: -18px 0 50px rgba(0,0,0,.5);
  transform: translateX(0);
  animation: slideIn .24s var(--ease);
}
.drawer.wide { width: 440px; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: var(--fw-bold); font-size: var(--fs-md); margin-bottom: 16px;
}
.drawer .x {
  width: auto; padding: 3px 11px; font-size: 18px; line-height: var(--lh-tight); background: var(--panel-2);
  border: var(--border-default); color: var(--muted); border-radius: var(--radius-xs); cursor: pointer;
}
.drawer .x:hover { color: var(--text); }

.section-title { font-size: var(--fs-sm); color: var(--muted-2); text-transform: uppercase; letter-spacing: .6px; margin: 18px 0 10px; }
.section-title:first-of-type { margin-top: 0; }

/* 预设芯片 */
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); margin-bottom: 6px; }
.preset {
  width: auto; padding: 10px 6px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  text-align: center; transition: var(--transition-ctrl);
}
.preset:hover { border-color: var(--accent); transform: translateY(-1px); }
.preset.active { border-color: var(--accent); background: var(--grad-soft); box-shadow: var(--shadow-ring); }
.preset .t { font-size: var(--fs); font-weight: var(--fw-bold); }
.preset .d { font-size: 10.5px; color: var(--muted); margin-top: 3px; }

/* 滑块 */
.slider { display: block; font-size: var(--fs); color: var(--muted); margin-bottom: 16px; }
.slider .lab { display: flex; justify-content: space-between; margin-bottom: 8px; }
.slider .lab b { color: var(--text); font-variant-numeric: tabular-nums; }
.slider input[type=range] {
  width: 100%; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); outline: none; cursor: pointer;
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: pointer;
}
.slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer;
}

.check { display: flex; align-items: center; gap: var(--gap-sm); font-size: var(--fs); color: var(--muted); margin-bottom: 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
/* 禁用态（如被控端不支持 WebP 时）：变灰并禁用指针，直观告知不可用 */
.check:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.check input:disabled { cursor: not-allowed; }

/* 剪贴板 */
.clip-area {
  width: 100%; min-height: 170px; resize: vertical; line-height: var(--lh);
}
.clip-actions { display: flex; flex-wrap: wrap; gap: var(--gap); margin-top: 10px; }
.clip-actions .tool { flex: 1; justify-content: center; min-width: 90px; }

/* 文件管理器 */
.file-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap); margin-bottom: 12px; }
.file-path {
  font-size: var(--fs-sm); color: var(--muted); background: var(--panel-2);
  border: var(--border-default); border-radius: var(--radius-xs); padding: 4px 8px;
  display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: thin;
}
.file-path .crumb {
  color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: var(--radius-2xs);
  white-space: nowrap; transition: background .12s, color .12s; flex: none;
}
.file-path .crumb:hover { color: var(--text); background: rgba(91,140,255,.14); }
.file-path .crumb.cur { color: var(--text); cursor: default; font-weight: var(--fw-semibold); }
.file-path .crumb.cur:hover { background: transparent; }
.file-path .crumb-sep { color: var(--muted-2); flex: none; -webkit-user-select: none; user-select: none; }
.file-filter {
  font-size: var(--fs-sm); color: var(--text); background: var(--panel-2);
  border: var(--border-default); border-radius: var(--radius-xs); padding: 5px 10px;
  width: 130px; min-width: 0;
}
.file-filter:focus { outline: none; border-color: var(--accent); }
.file-sort {
  font-size: var(--fs-sm); color: var(--text); background: var(--panel-2);
  border: var(--border-default); border-radius: var(--radius-xs); padding: 5px 8px; flex: none;
}
.file-sort:focus { outline: none; border-color: var(--accent); }
.file-list { display: flex; flex-direction: column; gap: 3px; min-height: 120px; }
.file-empty { color: var(--muted-2); font-size: var(--fs); text-align: center; padding: 30px 0; }
.search-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap-sm);
  font-size: var(--fs-sm-half); color: var(--muted); background: var(--panel-2);
  border: var(--border-default); border-radius: var(--radius-sm);
  padding: 8px 11px; margin-bottom: 3px;
}
.search-banner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-banner .row-act { width: auto; padding: 0 10px; flex: none; }
/* 列定义不含操作列：改名/删除按钮组为绝对定位悬浮层——此前作为 auto 列参与
   grid 布局时，按钮组自然宽度（~250px）把文件名列(1fr)压到 0、整行溢出抽屉。
   文件名列用 minmax(0,1fr)：允许收缩到 0 并触发 ellipsis（1fr 默认 min-content
   下限会让长文件名把整行撑出抽屉宽度）。 */
.file-row {
  display: grid; grid-template-columns: 24px 34px minmax(0, 1fr) auto auto; align-items: center; gap: var(--gap-sm);
  padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs);
  transition: background .12s;
  position: relative;
}
.file-row:hover { background: var(--panel-2); }
/* 搜索结果行无复选框列，回退四列（类型/相对路径/时间/大小）。 */
.file-row.search { grid-template-columns: 34px minmax(0, 1fr) auto auto; }
.file-check { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.file-row.dir { color: var(--accent); }
.file-row .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-row.dir .fn { color: var(--accent); }
.file-row .fd { color: var(--muted-2); font-size: var(--fs-xs-half); font-variant-numeric: tabular-nums; white-space: nowrap; }
.file-row .fs { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
/* 类型列：纯文字标记「目录 / 文件」，不使用图标 */
.file-row .fi { text-align: center; font-size: var(--fs-xs); color: var(--muted-2); white-space: nowrap; }
/* 行内操作（改名/删除）：绝对定位悬浮在行右侧，默认隐藏，悬停或键盘聚焦时显现，
   避免干扰浏览、又触手可及；左缘渐变过渡避免盖住文件名时出现生硬切边。 */
.file-row .fa {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 4px; opacity: 0; transition: opacity .12s;
  padding: 3px 2px 3px 22px;
  background: linear-gradient(90deg, transparent, var(--panel-solid) 30%);
}
.file-row:hover .fa, .file-row:focus-within .fa { opacity: 1; }
.row-act {
  width: auto; height: 26px; padding: 0 8px; display: grid; place-items: center;
  background: var(--panel-2); border: var(--border-default); color: var(--muted);
  border-radius: 7px; cursor: pointer; font-size: var(--fs-sm); line-height: var(--lh-tight); box-shadow: none;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.row-act:hover { color: var(--text); border-color: var(--accent); background: rgba(91,140,255,.14); }
.row-act.del:hover { color: var(--bad); border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.14); }
/* 「此电脑」磁盘卡片：名称 + 容量占用条，点整卡进入该盘。 */
.drive-card {
  display: block;
  padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel-2); border: var(--border-default); transition: border-color .12s, transform .08s;
}
.drive-card:hover { border-color: var(--accent); }
.drive-card:active { transform: scale(.995); }
.drive-name { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text); margin-bottom: 6px; }
.drive-bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.drive-bar span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }
.drive-cap { font-size: var(--fs-xs-half); color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }
.tool.sm { width: auto; padding: 6px 11px; font-size: var(--fs-sm); }
.tool.sm:disabled { opacity: .4; cursor: not-allowed; }

/* 进度条 */
.progress { margin-top: 14px; height: 9px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: var(--border-default); }
.progress .bar { height: 100%; width: 0%; background: var(--grad); transition: width .15s; }

/* 键盘组合 */
.combo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
.combo {
  width: auto; padding: 11px 8px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  text-align: center; font-size: var(--fs); transition: var(--transition-ctrl);
}
.combo:hover { border-color: var(--accent); background: var(--grad-soft); transform: translateY(-1px); }
.combo .keys { font-weight: var(--fw-bold); font-size: var(--fs-sm-half); letter-spacing: .5px; }
.combo .lbl { font-size: var(--fs-xs); color: var(--muted); margin-top: 3px; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: var(--gap); align-items: center;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 15px; border-radius: 12px; font-size: 13.5px; color: var(--text);
  background: var(--toast-bg); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: toastIn .25s var(--ease);
}
.toast.out { animation: toastOut .25s var(--ease) forwards; }
/* 图标已移除，用左侧色条区分成功/失败/提示，保留状态可辨识性 */
.toast.ok  { border-left: 3px solid var(--good); }
.toast.err { border-left: 3px solid var(--bad); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- 引导弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(4, 6, 10, 0.78);
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(480px, 92vw); background: var(--panel-solid);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow);
  animation: pop .25s var(--ease);
}
.modal h3 { margin: 0 0 4px; font-size: 19px; }
.modal .sub { color: var(--muted); font-size: var(--fs); margin: 0 0 18px; }
.guide-step { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.guide-step:first-of-type { border-top: none; }
.guide-step .num {
  flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--grad);
  color: #04121f; font-weight: var(--fw-extrabold); display: grid; place-items: center; font-size: var(--fs-base);
}
.guide-step .gt > b { display: block; font-size: var(--fs-base); margin-bottom: 3px; }
.guide-step .gt p { margin: 0; font-size: var(--fs-sm-half); color: var(--muted); line-height: var(--lh); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; gap: 14px; }
/* 预览底栏状态读数（Ln/Col + 选中字符数）：靠左，margin-right:auto 把按钮组推到右侧，同 VSCode 状态栏。 */
.pv-status { margin-right: auto; color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; font-variant-numeric: tabular-nums; }
.modal-foot label { margin: 0; font-size: var(--fs-sm-half); color: var(--muted); display: flex; align-items: center; gap: 7px; cursor: pointer; }
.modal-foot button { width: auto; padding: 11px 22px; }
/* 文本预览浮层：更宽、正文可滚动的等宽代码框；左侧可选行号栏与正文共滚（scrollTop 同步）。 */
.preview-modal { width: min(860px, 94vw); }
.preview-wrap {
  display: flex; max-height: 60vh; overflow: hidden;
  background: var(--bg-1); border: var(--border-default); border-radius: var(--radius-sm);
}
.preview-gutter {
  margin: 0; flex: none; overflow: hidden; -webkit-user-select: none; user-select: none; text-align: right; cursor: pointer;
  padding: 12px 8px 12px 12px; white-space: pre; tab-size: 4;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: var(--fs-sm-half); line-height: var(--lh); color: var(--muted-2);
  background: var(--panel); border-right: 1px solid var(--border);
}
.preview-wrap.nogutter .preview-gutter { display: none; }
.preview-body {
  margin: 0; flex: 1 1 auto; min-width: 0; overflow: auto; position: relative;
  padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: var(--fs-sm-half); line-height: var(--lh); white-space: pre; tab-size: 4;
  color: var(--text); word-break: normal;
}
/* 自动换行（Word Wrap）：长行按容器宽度软折行；因软折行与独立行号栏无法 1:1 对齐，开启时行号栏被隐藏。 */
.preview-body.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
/* 当前行高亮（编辑器风格）：previewBody 内的绝对定位整行覆盖层，随内容滚动、不拦截点击；半透明蓝底 +
   左侧强调色竖条（竖条落在左内边距区，不遮正文）；宽度/高度由 JS 按该逻辑行的 Range 几何设置。 */
.preview-curline { position: absolute; left: 0; box-sizing: border-box; pointer-events: none;
  background: rgba(91, 140, 255, .10); border-left: 2px solid var(--accent); }
/* 括号匹配高亮：点击某括号 ()[]{} 时，对它与其配对括号各罩一个描边小盒（同 VSCode 的方框标示）；
   绝对定位、pointer-events:none，几何由 JS 按该字符的 Range 矩形设置（含语法/查找/换行下均正确）。 */
.pv-bracket { position: absolute; box-sizing: border-box; pointer-events: none;
  border: 1px solid var(--accent); border-radius: 2px; background: rgba(91, 140, 255, .14); }
.modal-foot .tool.on { color: var(--accent); border-color: var(--accent); }
/* 预览内查找栏：输入框 + 计数 + 上/下一个 + 关闭；匹配以 <mark> 内联高亮（不改行数，行号仍对齐）。 */
.preview-find { display: flex; align-items: center; gap: var(--gap); margin: 0 0 10px; }
.preview-find input {
  flex: 1 1 auto; min-width: 0; padding: 7px 10px; font-size: var(--fs-sm-half); color: var(--text);
  background: var(--panel-solid); border: var(--border-default); border-radius: var(--radius-xs);
}
.preview-find .tool { width: auto; padding: 6px 11px; }
.find-count { font-size: var(--fs-sm); color: var(--muted); min-width: 66px; text-align: right; white-space: nowrap; }
.find-count.none { color: var(--bad); }
/* 跳转到行输入框（复用 .preview-find 样式）：隐藏 number 微调箭头，保持与查找栏一致的简洁外观。 */
.preview-find input[type="number"] { -moz-appearance: textfield; }
.preview-find input[type="number"]::-webkit-inner-spin-button,
.preview-find input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
mark.pv-hit { background: rgba(251, 191, 36, .35); color: inherit; border-radius: 2px; }
mark.pv-hit.cur { background: var(--warn); color: #1a1a1a; }
/* 语法高亮 token 配色（暗色主题；注释/字符串/数字/关键字）。以 <span class="tok-*"> 内联包裹，不改行数、行号仍对齐。 */
.preview-body .tok-cmt { color: var(--muted); font-style: italic; }
.preview-body .tok-str { color: #7ec699; }
.preview-body .tok-num { color: #f0a35e; }
.preview-body .tok-kw  { color: #6ab7ff; }
/* 图片内联预览：棋盘底色辨识透明/白底图，图片自适应宽度、限高可滚（不撑爆弹层）。 */
.preview-imgwrap {
  max-height: 62vh; overflow: auto; text-align: center;
  border: var(--border-default); border-radius: var(--radius-sm); padding: 10px;
  background: var(--bg-1) repeating-conic-gradient(#8883 0% 25%, transparent 0% 50%) 0 / 20px 20px;
}
.preview-imgwrap img { max-width: 100%; height: auto; image-rendering: auto; border-radius: 4px; }
/* 校验和弹窗字段：标题在上、控件占满宽另起一行；期望值输入用等宽体便于比对长哈希。 */
.hash-field { margin: 4px 0 12px; }
.hash-field select, .hash-field input { display: block; width: 100%; margin-top: 6px; box-sizing: border-box; }
.hash-field input { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: var(--fs-sm-half); }

/* ---------- 响应式 ---------- */
/* 中等宽度（≤1600px）：压缩工具栏按钮内距与列间距，尽量单行放下全部按钮
   （溢出侧已由 .toolbar 横向滚动兜底）。 */
@media (max-width: 1600px) {
  .toolbar { gap: 6px; padding: 8px 10px; }
  .tool { padding: 7px 10px; }
}
@media (max-width: 560px) {
  .drawer, .drawer.wide { width: 100%; }
  .stats { display: none; }
  .sess-timer { display: none; }
  .net-chart { display: none !important; }
  .tool { padding: 7px 11px; }
  .panel { padding: 22px; }
  /* 工具栏约 20 个按钮：装饰图标已全部移除，按钮仅靠文字表意，
     因此窄屏不能再隐藏 .lbl（否则会得到一排空白方块）。
     改为保留文字 + 单行横向可滑动，并锁定按钮尺寸不被压缩，让所有按钮都能划到；
     纵向 hidden 避免出现多余竖向滚动条。 */
  .toolbar { overflow-x: auto; overflow-y: hidden; }
  .tool { flex: none; }
  /* 窄屏文件行隐藏修改时间列，回退三列（图标/名称/大小）避免文件名被挤没；
     触屏无 hover，故行操作按钮常显以便可点（悬浮层已不占 grid 列，不会挤压文件名）。 */
  .file-row { grid-template-columns: 24px 26px minmax(0, 1fr) auto; }
  .file-row.search { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .file-row .fd { display: none; }
  .file-row .fa { opacity: 1; background: none; padding-left: 2px; }
  /* iOS 安全区适配（刘海屏/灵动岛底部横条） */
  .toolbar {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .topbar {
    padding-top: max(0px, env(safe-area-inset-top));
  }
  }

/* 平板/横屏：恢复部分控件（须在 max-width:560px 块外，否则 min-width:561px 永不匹配） */
@media (min-width: 561px) and (max-width: 900px) {
  .stats { display: inline; }
}

/* 深色模式下的移动端优化 */
@media (max-width: 560px) and (prefers-color-scheme: dark) {
  .toolbar::-webkit-scrollbar { display: none; }   /* 隐藏滚动条保持简洁 */
  .toolbar { scrollbar-width: none; }
}

/* ---------- 连接质量曲线 ---------- */
.net-chart {
  width: 92px; height: 22px; opacity: .92;
  background: var(--panel-2); border: var(--border-default);
  border-radius: var(--radius-xs); padding: 1px;
}

/* ---------- 显示器切换 ---------- */
.mon-btn {
  width: auto; min-width: 26px; padding: 4px 8px; font-size: var(--fs-sm); font-weight: var(--fw-bold);
  background: var(--panel-2); border: var(--border-default); color: var(--muted);
  border-radius: var(--radius-xs); cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.mon-btn:hover { border-color: var(--accent); color: var(--text); }
.mon-btn.active { background: var(--grad-soft); border-color: var(--accent); color: var(--text); box-shadow: var(--shadow-ring); }

/* ---------- 录制中状态 ---------- */
.tool.rec-on { color: #ff6b6b; border-color: rgba(248,113,113,.45); background: rgba(248,113,113,.14); }

/* ---------- 原始大小显示（1:1，可滚动） ---------- */
.canvas-box.actual { overflow: auto; align-items: flex-start; justify-content: flex-start; }
.canvas-box.actual #screen { max-width: none; max-height: none; width: auto; height: auto; }

/* ---------- 大号连接质量曲线 + 连接信息 ---------- */
.big-chart {
  width: 100%; height: 90px; display: block;
  background: var(--panel-2); border: var(--border-default);
  border-radius: var(--radius-sm); margin-bottom: 10px;
}
.conn-info { display: flex; flex-wrap: wrap; gap: var(--gap) 18px; font-size: var(--fs-sm); color: var(--muted); }
.conn-info b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 5px; }

/* ---------- 设备与连接信息 ---------- */
.info-body { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.info-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 11px; background: var(--panel-2); border: var(--border-default);
  border-radius: var(--radius-sm); font-size: var(--fs); color: var(--muted);
}
.info-row b { color: var(--text); font-weight: var(--fw-semibold); text-align: right; word-break: break-all; }
.info-refresh { width: auto; }

/* ---------- 会话时长 ---------- */
.sess-timer {
  font-size: var(--fs-sm); color: var(--muted);
  background: var(--panel-2); border: var(--border-default);
  padding: 5px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- 工具栏激活态（锁输入） ---------- */
.tool.active { color: var(--text); border-color: var(--accent); background: var(--grad-soft); box-shadow: var(--shadow-ring); }

/* ---------- 断线重连浮层 ---------- */
.reconnect-modal { text-align: center; }
.reconnect-modal .sub { margin-bottom: 4px; }
.reconnect-count {
  font-size: 54px; font-weight: var(--fw-extrabold); line-height: var(--lh-tight); margin: 8px 0 4px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.reconnect-modal .modal-foot { justify-content: center; }
.reconnect-modal .modal-foot button { width: auto; padding: 11px 22px; }

/* ---------- 手机键盘抽屉 ---------- */
.kb-input { margin: 4px 0 4px; font-size: 16px; }
.quick-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 12px; }
.quick-keys button {
  width: auto; padding: 9px 4px; font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  border-radius: var(--radius-sm); cursor: pointer; box-shadow: none;
}
.quick-keys button:hover { border-color: var(--accent); background: rgba(91,140,255,.12); }

/* ---------- 文字聊天抽屉 ---------- */
.chat-list {
  display: flex; flex-direction: column; gap: var(--gap-sm);
  flex: 1; min-height: 160px; max-height: 46vh; overflow-y: auto;
  padding: 4px 2px;
}
.chat-msg { display: flex; flex-direction: column; max-width: 86%; }
.chat-msg .who { font-size: var(--fs-xs); color: var(--muted-2); margin: 0 4px 3px; }
.chat-msg .bubble {
  padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: var(--lh);
  background: var(--panel-2); border: var(--border-default); color: var(--text);
  word-break: break-word; white-space: pre-wrap;
}
.chat-msg.me { align-self: flex-end; align-items: flex-end; }
.chat-msg.me .bubble {
  background: var(--grad-soft); border-color: var(--accent); color: var(--text);
  border-bottom-right-radius: 4px;
}
.chat-msg.host .bubble { border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: var(--gap); margin-top: 12px; }
.chat-input-row .chat-input { margin: 0; flex: 1; }
.chat-input-row .chat-send { width: auto; padding: 10px 16px; }
.tool.has-msg { position: relative; }
.tool.has-msg::after {
  content: ""; position: absolute; top: 4px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}

/* ---------- 画中画激活态复用 .tool.active（已定义于工具栏激活态） ---------- */

/* ---------- 沉浸模式（全屏自动隐藏顶栏/工具栏） ---------- */
body.immersive .topbar,
body.immersive .toolbar {
  transform: translateY(-100%); opacity: 0; pointer-events: none;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
body.immersive.show-bar .topbar,
body.immersive.show-bar .toolbar {
  transform: none; opacity: 1; pointer-events: auto;
}
body.immersive .canvas-box { padding: 0; }

/* ---------- 电源管理 ---------- */
.power-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); margin-top: 4px; }
.power-grid .tool { width: auto; justify-content: center; font-size: var(--fs-base); padding: 14px 8px; }

/* ---------- 外观主题分段控件 ---------- */
.seg { display: inline-flex; gap: 4px; background: var(--panel-2); border: var(--border-default); border-radius: 999px; padding: 4px; margin-bottom: 6px; }
.seg button { width: auto; padding: 6px 16px; font-size: var(--fs); font-weight: var(--fw-semibold); background: transparent; color: var(--muted); border: none; box-shadow: none; border-radius: 999px; }
.seg button:hover { color: var(--text); filter: none; }
.seg button.active { background: var(--grad); color: var(--txt-on-accent); }

/* ---------- 确认弹窗主按钮 ---------- */
.primary { background: var(--grad); color: var(--txt-on-accent); }
.primary.danger { background: linear-gradient(135deg, var(--bad), #ef4444); color: var(--txt-on-accent); }
.modal-foot .primary { width: auto; padding: 11px 22px; }

/* ---------- 屏幕标注 ---------- */
.anno-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6;
  will-change: transform; contain: size layout paint; }
.canvas-box.anno .anno-canvas { pointer-events: auto; cursor: crosshair; }
.anno-bar {
  position: absolute; top: 12px; right: 12px; z-index: 9;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 7px 10px; box-shadow: var(--shadow); max-width: calc(100% - 24px);
}
.anno-bar .sw { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--border-strong); padding: 0; background-clip: padding-box; font: inherit; color: inherit; }
.anno-bar .sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.anno-bar .sw.active { border-color: var(--accent); }
.anno-bar .sw.eraser { color: var(--text); background: var(--panel-2); display: grid; place-items: center; font-size: var(--fs); }
.anno-bar .sw[data-c="#ff4d4f"] { background: #ff4d4f; }
.anno-bar .sw[data-c="#ffd43b"] { background: #ffd43b; }
.anno-bar .sw[data-c="#4dabf7"] { background: #4dabf7; }
.anno-bar .sw[data-c="#69db7c"] { background: #69db7c; }
.anno-bar .sw[data-c="#ffffff"] { background: #fff; }
.anno-bar .tool.sm { padding: 5px 10px; }

/* ---------- 网络健康徽章 ---------- */
.net-badge {
  width: auto; padding: 5px 12px; font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  border-radius: 999px; cursor: pointer; border: var(--border-default);
  background: var(--panel-2); color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums; transition: color .2s, border-color .2s, background .2s;
}
.net-badge.good { color: var(--good); border-color: rgba(52,211,153,.35); }
.net-badge.warn { color: var(--warn); border-color: rgba(251,191,36,.35); }
.net-badge.bad  { color: var(--bad); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.12); animation: pulse 1.6s infinite; }
.net-badge:hover { filter: brightness(1.08); }

/* ---------- 远程命令终端 ---------- */
.term-out {
  flex: 1; min-height: 160px; max-height: 50vh; overflow-y: auto;
  background: #0a0d12; border: var(--border-default); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: ui-monospace, "SF Mono", Consolas, Menlo, monospace;
  font-size: var(--fs-sm-half); line-height: var(--lh); color: #d6e2f0;
  white-space: pre-wrap; word-break: break-all; margin-bottom: 10px;
}
[data-theme="light"] .term-out { background: #f1f5f9; color: #1e293b; }
.term-input-row { display: flex; align-items: center; gap: var(--gap); }
.term-prompt { color: var(--good); font-family: ui-monospace, monospace; font-weight: var(--fw-bold); }
.term-input { margin: 0; flex: 1; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: var(--fs); }

/* ---------- 进程管理 ---------- */
.proc-list { display: flex; flex-direction: column; gap: 3px; min-height: 120px; max-height: 46vh; overflow-y: auto; }
.proc-row {
  display: grid; grid-template-columns: 54px 1fr auto auto auto; align-items: center; gap: var(--gap-sm);
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-sm-half);
  background: var(--panel-2); border: var(--border-default); transition: background .12s, border-color .15s;
}
.proc-row:hover { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.1); }
.proc-row .pid { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.proc-row .pname { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proc-row .pcpu { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 46px; }
.proc-row .pmem { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 58px; }
.proc-row .pk {
  width: auto; padding: 3px 9px; font-size: var(--fs-xs); cursor: pointer;
  background: rgba(248,113,113,.16); color: var(--bad); border: 1px solid rgba(248,113,113,.35); border-radius: 7px;
}
.proc-row .pk:hover { background: rgba(248,113,113,.28); }
.proc-empty { color: var(--muted-2); font-size: var(--fs); text-align: center; padding: 30px 0; }

/* ---------- 画布拖拽上传提示 ---------- */
.drop-hint {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  background: rgba(8,12,18,.78); border: 2px dashed var(--accent); border-radius: var(--radius-sm);
  color: var(--txt-on-accent); font-size: 16px; font-weight: var(--fw-bold); pointer-events: none;
}

/* ---------- 键盘可达性（焦点环） ---------- */
.tool:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible,
.seg button:focus-visible, .combo:focus-visible, .preset:focus-visible, .dev-chip:focus-visible,
/* 补齐原先遗漏的可聚焦元素：下拉框、最近连接行、文件行、磁盘卡片、显示器按钮、链接，
   否则键盘用户在这些控件上看不到任何焦点指示（WCAG 2.4.7 失败）。 */
select:focus-visible, a:focus-visible, .recent-row:focus-visible, .file-row:focus-visible,
.drive-card:focus-visible, .mon-btn:focus-visible, .link-btn:focus-visible, #screen:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- 细节打磨：主题化滚动条 + 文本选中色 ---------- */
::selection { background: rgba(91, 140, 255, .35); color: var(--text); }

/* 可滚动区域统一使用纤细、随主题变化的滚动条，替代突兀的系统默认样式。
   用 :is() 合并 6 组选择器 × 4 个伪元素的重复规则块（原先 ~24 行手写并列选择器）。 */
:is(.drawer, .chat-list, .proc-list, .term-out, .file-list, .clip-area) {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
:is(.drawer, .chat-list, .proc-list, .term-out, .file-list, .clip-area)::-webkit-scrollbar { width: 9px; height: 9px; }
:is(.drawer, .chat-list, .proc-list, .term-out, .file-list, .clip-area)::-webkit-scrollbar-track { background: transparent; }
:is(.drawer, .chat-list, .proc-list, .term-out, .file-list, .clip-area)::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
:is(.drawer, .chat-list, .proc-list, .term-out, .file-list, .clip-area)::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

/* ============================================================
   科技感增强层 —— 动态极光 + 科技网格 + 辉光点缀
   纯装饰：全部 pointer-events:none 且位于内容下方（z-index:-1），
   不影响交互/布局；上方 prefers-reduced-motion 规则会自动冻结所有动画。
   ============================================================ */

/* 科技网格：变量色细线，向四周淡出，营造聚焦的终端感 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(91,140,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,140,255,.05) 1px, transparent 1px);
  background-size: 44px 44px, 44px 44px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% -10%, #000 0%, transparent 75%);
  mask-image: radial-gradient(120% 90% at 50% -10%, #000 0%, transparent 75%);
  opacity: .75;
}
[data-theme="light"] body::before {
  background-image:
    linear-gradient(rgba(37,99,235,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.07) 1px, transparent 1px);
}

/* 全屏流动极光：两团主色模糊光晕缓慢漂移，与品牌渐变呼应 */
body::after {
  content: ""; position: fixed; inset: -25% -12% auto -12%; height: 78vh; z-index: -1;
  pointer-events: none; filter: blur(64px); opacity: .55;
  background:
    radial-gradient(closest-side, rgba(91,140,255,.55), transparent),
    radial-gradient(closest-side, rgba(45,212,191,.45), transparent);
  background-repeat: no-repeat;
  background-size: 46% 62%, 42% 56%;
  background-position: 10% 0%, 90% 12%;
  animation: aurora-drift 20s var(--ease) infinite alternate;
  /* 仅动画 background-position，隔离该巨型模糊层的渲染，避免每帧连带全页重绘 */
  will-change: background-position; contain: strict;
}
/* 尊重「减少动态效果」偏好：关闭持续的极光漂移动画，降低低端设备/省电场景的持续 GPU 占用 */
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
}
[data-theme="light"] body::after { opacity: .4; }
/* 会话期间暂停极光动画：远程操控时 GPU 资源应优先保障画面解码/渲染 */
body.in-session::after { animation-play-state: paused; }
@keyframes aurora-drift {
  0%   { background-position: 6% 0%, 94% 14%; }
  100% { background-position: 34% 10%, 62% 0%; }
}

/* 面板顶部彩条：渐变流光横扫，现代感点缀 */
.panel::before { background-size: 220% 100%; animation: accent-sheen 6.5s linear infinite; }
@keyframes accent-sheen { to { background-position: 220% 0; } }

/* 主行动按钮（渐变底）：悬停时渐变轻微滑动 + 辉光增强；.tool/.seg 因高优先级不受影响 */
button {
  background-size: 200% 100%;
  transition: transform .12s var(--ease), filter .15s, opacity .15s, background-position .6s var(--ease), box-shadow .2s var(--ease);
}
button:hover { background-position: 100% 0; }
/* 辉光增强仅限渐变底的主 CTA（连接/确认），避免工具栏小按钮悬停时出现不协调的光晕 */
#connectBtn:hover, .primary:hover { box-shadow: 0 12px 30px rgba(91,140,255,.42); }

/* 远程画面：叠加一层极淡的强调轮廓，与整体蓝-青主调呼应 */
#screen { box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(91,140,255,.28); }

/* ---------- backdrop-filter 不支持时的回退（旧浏览器/低端设备） ---------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--bg-0); }
  .toolbar { background: var(--bg-0); }
  .panel { background: var(--panel); }
  .toast { background: var(--panel); }
  .modal { background: var(--panel); }
  .overlay { background: rgba(4, 6, 10, 0.85); }
}

/* ---------- 触摸设备无障碍：WCAG 2.5.5 最小 44×44px 触摸目标 ---------- */
@media (pointer: coarse) {
  .tool { min-height: 44px; padding: 10px 14px; }
  .tool.sm { min-height: 40px; }
  .check input, .remember-row input, .file-check { width: 22px; height: 22px; }
  }

/* ---------- 打印样式：避免深色背景浪费墨水/浅色文字不可见 ---------- */
@media print {
  body::after, .topbar, .toolbar, .panel::before, .overlay, .toast, .drawer { display: none !important; }
  body { background: white !important; color: black !important; }
  #screenPanel, #connectPanel { display: block !important; }
  .hidden { display: block !important; }
  * { box-shadow: none !important; animation: none !important; }
}
