:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #17202a;
  --muted: #5c6878;
  --accent: #1769aa;
  --warning: #9a5b00;
  --soft: #eef3f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

/* 桌面投屏中控：以 1600×800 的操作台为基线。旧控制台仍在 DOM 中，
 * 作为高级 WebRTC/验收面板使用；主界面只展示普通操作员需要的设备与控制。 */
.desktop-console {
  --desk-bg: #20242d;
  --desk-panel: #282e3a;
  --desk-panel-deep: #16191f;
  --desk-line: #343c4a;
  --desk-text: #dfe5ee;
  --desk-muted: #98a5b8;
  --desk-blue: #2a86df;
  --desk-green: #75c255;
  display: grid;
  position: relative;
  grid-template-rows: 36px minmax(0, 1fr) 43px;
  min-width: 1024px;
  /* 固定桌面基准高度：左栏内容只能在自身滚动，不能把状态栏挤出 1600×800 视口。 */
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  color: var(--desk-text);
  background: var(--desk-bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.desktop-console button,
.desktop-console input,
.desktop-console textarea,
.desktop-console select {
  font: inherit;
}

.desktop-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px;
  border-bottom: 1px solid #3a4150;
  background: #2c323e;
  color: #d4dae5;
  font-size: 13px;
}

.desktop-brand { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.desktop-brand-mark { color: #25aee6; font-size: 16px; }
.desktop-title-actions { display: flex; align-items: center; gap: 15px; color: #9da8ba; white-space: nowrap; }
/* 标题栏是桌面窗口式单行操作区，不能继承旧面板按钮的最小高度/全宽规则而产生换行。 */
.desktop-title-actions button { width: auto; min-height: 0; height: 36px; padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; cursor: pointer; }
.desktop-title-actions button:hover { color: #fff; }
.desktop-window-controls { color: #9ea8b8; letter-spacing: 5px; white-space: nowrap; }

.desktop-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; }
.desktop-sidebar { overflow: auto; padding: 10px 0 10px 10px; border-right: 1px solid #2f3540; background: #171a20; scrollbar-color: #596473 #171a20; scrollbar-width: thin; }
.desktop-sidebar::-webkit-scrollbar { width: 8px; }
.desktop-sidebar::-webkit-scrollbar-track { background: #171a20; }
.desktop-sidebar::-webkit-scrollbar-thumb { border: 2px solid #171a20; border-radius: 8px; background: #596473; }
.desktop-notice { height: 64px; min-height: 0; margin: 0 0 12px; padding: 9px; border-radius: 7px; background: #242a35; color: #0868ff; text-align: center; font-size: 14px; line-height: 1.55; }
.desktop-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 8px 3px; }
.desktop-action-row button { height: 54px; min-height: 0; border: 1px solid #303948; border-radius: 7px; background: #272d38; color: #d4dbe6; cursor: pointer; font-size: 14px; }
.desktop-action-row button small { display: block; margin-top: 3px; color: #9ca7b8; font-size: 11px; }
.desktop-action-row .desktop-primary { border-color: #2993f4; background: #214a7a; color: #e8f4ff; }
.desktop-action-row .desktop-sync { border-color: #39794b; background: #193d27; }
.desktop-action-row-2 button { height: 36px; min-height: 0; }
.desktop-action-row-2 [data-desktop-start],
.desktop-action-row-2 [data-desktop-stop] { height: 52px; }
.desktop-cast-mode { display: grid; gap: 6px; margin: 9px 3px 12px; padding: 8px; border: 1px solid #303948; border-radius: 8px; background: #20252e; }
.desktop-cast-mode legend { padding: 0 4px; color: #cbd5e2; font-size: 12px; }
.desktop-cast-mode label { position: relative; cursor: pointer; }
.desktop-cast-mode input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.desktop-cast-mode label > span { display: block; padding: 7px 8px; border: 1px solid #343e4d; border-radius: 6px; background: #272d38; color: #d5dde8; }
.desktop-cast-mode strong, .desktop-cast-mode small { display: block; }
.desktop-cast-mode strong { font-size: 12px; font-weight: 600; }
.desktop-cast-mode small { margin-top: 2px; color: #96a4b7; font-size: 10px; line-height: 1.35; }
.desktop-cast-mode input:checked + span { border-color: #2c93ef; background: #203f61; box-shadow: inset 3px 0 #41a4ff; }
.desktop-cast-mode p { margin: 1px 2px 0; color: #8e9daf; font-size: 10px; line-height: 1.45; }
.desktop-usb-maintenance { margin: 9px 3px 12px; padding: 9px; border: 1px solid #303948; border-radius: 8px; background: #20252e; }
.desktop-usb-maintenance h2 { margin: 0 0 7px; color: #cbd5e2; font-size: 12px; font-weight: 600; }
.desktop-usb-maintenance dl { display: grid; gap: 4px; margin: 0; }
.desktop-usb-maintenance dl div { display: flex; justify-content: space-between; gap: 8px; color: #91a0b3; font-size: 10px; }
.desktop-usb-maintenance dt, .desktop-usb-maintenance dd { margin: 0; }
.desktop-usb-maintenance dd { max-width: 150px; overflow: hidden; color: #d0d9e5; text-overflow: ellipsis; white-space: nowrap; }
.desktop-usb-maintenance-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.desktop-usb-maintenance-actions button { min-height: 30px; border: 1px solid #3c4858; border-radius: 5px; background: #252c36; color: #7f8b9b; font-size: 10px; }
.desktop-usb-maintenance-actions button:disabled { cursor: not-allowed; opacity: .75; }
.desktop-usb-maintenance p { margin: 7px 0 0; color: #8290a2; font-size: 9px; line-height: 1.45; }
.desktop-search { display: grid; grid-template-columns: 1fr 34px; height: 32px; margin: 11px 3px; overflow: hidden; border-radius: 5px; background: #090b0e; font-size: 13px; }
.desktop-search input { width: auto; min-width: 0; min-height: 0; height: 32px; border: 0; border-radius: 0; outline: 0; background: transparent; color: #dce5ef; padding: 0 10px; }
.desktop-search button { min-height: 0; height: 32px; border: 0; border-radius: 0; background: #174a7c; color: #78b9ff; cursor: pointer; }
.desktop-fold { margin-top: 12px; border-top: 1px solid #303642; }
.desktop-fold h2 { display: flex; justify-content: space-between; margin: 11px 1px 0; padding: 0 5px 8px; border-bottom: 1px solid #2e3541; color: #d9e0eb; font-size: 14px; font-weight: 500; }
.desktop-fold h2 span { margin-bottom: -9px; padding: 0 6px 7px; border-bottom: 1px solid #2a8eea; color: #2098ff; font-size: 12px; }
.desktop-fold details { margin: 10px 0; padding: 0 10px 10px; border-radius: 9px; background: #292f3b; }
.desktop-fold summary { display: flex; align-items: center; min-height: 34px; list-style: none; cursor: pointer; color: #d1d9e5; font-size: 13px; }
.desktop-fold summary::-webkit-details-marker { display: none; }
.desktop-fold summary::after { content: "⌃"; margin-left: auto; color: #98a5b8; font-size: 13px; transition: transform .14s ease; }
.desktop-fold details:not([open]) summary::after { transform: rotate(180deg); }
.desktop-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.desktop-choice-grid button { min-height: 45px; border: 0; border-radius: 7px; background: #222832; color: #cbd3df; cursor: pointer; font-size: 13px; }
.desktop-choice-grid button:hover, .desktop-choice-grid button.is-active { background: #214d7e; color: #edf7ff; }
.desktop-choice-grid button:disabled { background: #20252d; color: #687383; cursor: not-allowed; }
.desktop-fold textarea { width: 100%; resize: vertical; margin-top: 10px; border: 1px solid #3b4555; border-radius: 5px; background: #15191f; color: #dbe5ee; padding: 8px; font-size: 12px; }
.desktop-script-actions { display: flex; gap: 7px; margin-top: 7px; }
.desktop-script-actions button { flex: 1; min-height: 29px; border: 0; border-radius: 4px; background: #214d7e; color: #e6f2ff; cursor: pointer; font-size: 12px; }

.desktop-workspace { position: relative; min-width: 0; overflow: hidden; background: #22272f; }
.desktop-workspace-tab { display: none; }
.desktop-workspace-tab span { margin-left: 10px; color: #83bdff; font-size: 11px; }
.desktop-live-strip { position: absolute; z-index: 3; top: 12px; left: 18px; right: 350px; display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 6px 10px; border: 1px solid #38516a; border-radius: 6px; background: #18232fe8; color: #cbd9e8; font-size: 12px; backdrop-filter: blur(8px); }
.desktop-live-strip[hidden] { display: none; }
.desktop-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #7a8798; }
.desktop-live-strip.is-connected .desktop-live-dot { background: #73c95a; box-shadow: 0 0 0 3px #73c95a26; }
.desktop-live-strip strong { color: #edf6ff; font-weight: 600; }
.desktop-live-control { color: #d9e7f5; white-space: nowrap; }
.desktop-live-strip button { min-height: 24px; margin-left: auto; border: 1px solid #42617d; border-radius: 4px; background: #213d59; color: #cce6ff; cursor: pointer; font-size: 12px; }
.desktop-live-strip button + button { margin-left: 0; }
.desktop-device-canvas { display: grid; grid-template-columns: repeat(auto-fill, 285px); align-content: start; gap: 10px; height: 100%; overflow: auto; padding: 9px 24px 56px; }
.desktop-live-strip:not([hidden]) + .desktop-device-canvas { padding-top: 56px; }
.desktop-empty-state { grid-column: 1 / -1; align-self: center; justify-self: center; margin-top: 220px; color: #bfc8d5; text-align: center; }
.desktop-empty-state small { color: #7e8b9e; }
.desktop-device-card { position: relative; overflow: hidden; border: 1px solid #3d4655; border-radius: 10px; background: #2c323e; box-shadow: 0 10px 18px #0004; }
.desktop-device-card.is-master { border: 3px solid #2d9df4; box-shadow: 0 0 0 2px #23527b, 0 10px 18px #0005; }
.desktop-device-card.is-unavailable { opacity: .7; }
.desktop-card-head { display: flex; align-items: center; gap: 8px; height: 32px; min-height: 32px; padding: 0 10px; background: #2b313d; color: #e5ebf4; font-size: 12px; }
/* 旧高级面板的通用 input 规则会放大复选框；卡头固定为紧凑选择控件，避免名称换行并撑高整卡。 */
.desktop-card-head input[type="checkbox"] { width: 14px; min-width: 14px; height: 14px; min-height: 14px; margin: 0; padding: 0; border: 0; border-radius: 2px; accent-color: #63adfb; }
.desktop-card-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desktop-card-state { width: 6px; height: 6px; border-radius: 100%; background: #83c959; }
.desktop-card-state.is-offline { background: #697585; }
.desktop-card-control-state { max-width: 90px; overflow: hidden; color: #e2b256; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-card-more { margin-left: auto; color: #8b97aa; }
.desktop-device-screen { position: relative; display: grid; height: 485px; min-height: 0; aspect-ratio: auto; overflow: hidden; place-items: center; background: #090b0d; touch-action: none; }
.desktop-device-screen p { color: #c7d0dc; font-size: 12px; }
.desktop-device-screen .desktop-live-card-placeholder { display: grid; width: 100%; height: 100%; margin: 0; place-content: center; gap: 8px; background: radial-gradient(circle at 50% 35%, #213b58 0, #111925 42%, #0a0e14 100%); text-align: center; }
.desktop-live-card-placeholder strong { color: #d7ecff; font-size: 15px; font-weight: 600; }
.desktop-live-card-placeholder small { color: #8ea6be; font-size: 12px; }
.desktop-card-footer { display: grid; grid-template-rows: 31px 38px; height: 69px; min-height: 69px; border-top: 1px solid #3d4653; }
.desktop-card-input { display: grid; grid-template-columns: 1fr 34px; min-width: 0; }
.desktop-card-input input { width: auto; min-width: 0; height: 31px; min-height: 0; border: 0; border-radius: 0; background: #2c323e; color: #c7d0dc; padding: 0 10px; }
.desktop-card-input button { min-height: 0; height: 31px; border: 0; border-left: 1px solid #46505e; border-radius: 0; background: #2c323e; color: #b5c5d8; cursor: pointer; }
.desktop-card-navigation { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #363f4d; }
.desktop-card-navigation button { min-height: 0; border: 0; border-radius: 0; background: #2b313c; color: #8591a3; cursor: pointer; }
.desktop-card-navigation button:disabled, .desktop-navigation button:disabled { border-color: transparent; background: #2b313c; color: #5d6877; cursor: not-allowed; }
.desktop-card-navigation button:not(:last-child) { border-right: 1px solid #363f4d; }
.desktop-card-navigation button:hover:not(:disabled) { background: #214d7e; color: #fff; }

.desktop-master { position: absolute; top: 38px; left: min(1000px, calc(100vw - 330px)); z-index: 2; width: 320px; overflow: hidden; margin: 0; border: 1px solid #3c424c; border-radius: 4px; background: #20242c; box-shadow: 0 8px 20px #0007; }
.desktop-master.is-hidden { visibility: hidden; }
.desktop-master-head { display: flex; justify-content: space-between; align-items: center; height: 40px; min-height: 0; padding: 0 12px; background: #101214; color: #e1e6ed; cursor: move; font-size: 16px; }
.desktop-master-head strong { white-space: nowrap; }
.desktop-master-head button { border: 0; background: transparent; color: #aeb7c4; font-size: 24px; cursor: pointer; }
.desktop-master-device { display: flex; justify-content: space-between; padding: 8px 14px; background: #29303b; color: #9ed0ff; font-size: 12px; }
.desktop-master-tools { color: #cae0fa; }
.desktop-master-screen { position: relative; display: grid; height: 478px; min-height: 0; aspect-ratio: auto; place-items: center; overflow: hidden; background: #080a0c; touch-action: none; }
/* Grid 会先用截图的固有宽高计算自动轨道，再解析百分比高度；竖屏截图因此会按
 * 容器宽度长到容器外面，页面显示被裁切，而点击换算仍按容器尺寸计算。把两处
 * WDA 截图固定到完整画框后，object-fit 的可见区域和坐标映射使用同一矩形。 */
.desktop-device-screen img,
.desktop-master-screen img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.desktop-master-screen p { color: #a9b5c6; }
.desktop-master-screen > [data-selected-preview] { position: relative; display: grid; width: 100%; height: 100%; overflow: hidden; place-items: center; background: #080a0c; }
.desktop-master-screen > [data-selected-preview] video,
.desktop-master-screen > [data-selected-preview] canvas,
.desktop-master-screen > [data-selected-preview] img { width: 100%; height: 100%; object-fit: contain; }
.desktop-master-input { display: grid; grid-template-columns: 1fr 36px; height: 35px; border-top: 1px solid #3c4656; }
.desktop-master-input input { width: auto; min-width: 0; height: 35px; min-height: 0; border: 0; border-radius: 0; background: #272d37; color: #d8e1ec; padding: 0 10px; }
.desktop-master-input button, .desktop-navigation button { min-height: 0; border: 0; border-radius: 0; background: #272d37; color: #aebcd0; cursor: pointer; }
.desktop-navigation { display: grid; grid-template-rows: 33px 49px; height: 82px; border-top: 1px solid #3c4656; }
.desktop-navigation-primary { display: grid; grid-template-columns: repeat(3, 1fr); }
.desktop-navigation-direction { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid #363f4d; }
.desktop-navigation-primary button:not(:last-child), .desktop-navigation-direction button:not(:last-child) { border-right: 1px solid #363f4d; }
.desktop-navigation button:hover:not(:disabled) { background: #214d7e; color: white; }

.desktop-statusbar { display: flex; align-items: center; gap: 12px; padding: 0 13px; border-top: 1px solid #3a4150; background: #2c323e; color: #c5cedb; font-size: 12px; }
.desktop-statusbar span:not(:last-child) { padding: 4px 8px; border-radius: 3px; background: #173e68; color: #89c9ff; }
.desktop-statusbar [data-desktop-health] { background: #25452a; color: #a8df88; }
.desktop-status-actions { display: flex; gap: 12px; margin-left: auto; }
.desktop-status-actions button { border: 0; padding: 0; background: transparent; color: #c5cedb; cursor: pointer; }
.desktop-status-actions button:hover { color: #fff; }

.desktop-settings { width: min(460px, calc(100% - 32px)); border: 1px solid #4a5667; border-radius: 8px; background: #282e3a; color: #e2e8f2; box-shadow: 0 16px 48px #0009; }
.desktop-settings::backdrop { background: #0009; }
.desktop-settings form { display: grid; gap: 15px; padding: 18px; }
.desktop-settings header { display: flex; justify-content: space-between; font-size: 16px; }
/* 旧高级面板的通用 button 规则会把关闭按钮拉成全宽；标题栏按钮必须恢复为紧凑尺寸。 */
.desktop-settings header button { width: auto; min-height: 0; padding: 0 4px; border: 0; background: transparent; color: #c8d2df; font-size: 22px; cursor: pointer; }
.desktop-settings label { display: grid; gap: 7px; color: #cfd8e4; }
.desktop-settings select { min-height: 36px; border: 1px solid #4a5667; border-radius: 5px; background: #1a1f27; color: #e3ebf5; padding: 0 8px; }
.desktop-live-toggle { position: relative; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; min-height: 62px; padding: 10px 12px; border: 1px solid #465466; border-radius: 7px; background: #202631; cursor: pointer; }
.desktop-live-toggle > span { display: grid; gap: 3px; min-width: 0; }
.desktop-live-toggle strong { color: #e5edf8; font-size: 14px; }
.desktop-live-toggle small { color: #9eafc2; font-size: 12px; line-height: 1.45; }
/* 原生 checkbox 只保留语义和键盘可达性；可见滑块独立绘制，避免旧通用 input 样式放大控件。 */
.desktop-live-toggle input { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); opacity: 0; }
.desktop-live-toggle i { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #566171; transition: background .16s ease; }
.desktop-live-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #edf3fa; box-shadow: 0 1px 4px #0006; transition: transform .16s ease; }
.desktop-live-toggle input:checked + i { background: #2188e7; }
.desktop-live-toggle input:checked + i::after { transform: translateX(18px); }
.desktop-live-toggle:focus-within { border-color: #5aafff; box-shadow: 0 0 0 2px #2084d94d; }
.desktop-settings p { margin: 0; color: #a9b5c4; font-size: 13px; line-height: 1.6; }
.desktop-settings > form > button { min-height: 38px; border: 1px solid #2c8ee7; border-radius: 5px; background: #1d4f82; color: #ecf6ff; cursor: pointer; }
.desktop-live-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border: 1px solid #455364; border-radius: 7px; background: #202631; }
.desktop-live-settings[hidden] { display: none; }
.desktop-live-config { display: grid; grid-column: 1 / -1; gap: 8px; padding: 9px; border-radius: 5px; background: #171c24; }
.desktop-live-config input { width: 100%; min-height: 34px; border: 1px solid #465466; border-radius: 5px; background: #11161d; color: #edf4fc; padding: 0 9px; }
.desktop-live-config .desktop-live-remember { display: flex; gap: 7px; align-items: center; color: #cbd7e5; font-size: 12px; }
.desktop-live-config .desktop-live-remember input { width: auto; min-height: 0; margin: 0; padding: 0; }
.desktop-live-config small { color: #91a1b4; font-size: 11px; line-height: 1.45; }
.desktop-live-settings > div:not(.desktop-live-settings-actions):not(.desktop-live-config) { display: grid; gap: 2px; padding: 7px; border-radius: 5px; background: #1a1f27; color: #9faec0; font-size: 11px; }
.desktop-live-settings strong { color: #e4edf7; font-size: 12px; }
.desktop-live-settings p { grid-column: 1 / -1; }
.desktop-live-settings-actions { display: flex; grid-column: 1 / -1; gap: 8px; }
.desktop-live-settings-actions button { flex: 1; min-height: 32px; border: 1px solid #396d9b; border-radius: 5px; background: #1d4f82; color: #edf7ff; cursor: pointer; }
/* 旧控制台只保留为运行时宿主：所有操作和状态都投射到桌面中控，不能再形成第二个页面。 */
.legacy-console { display: none !important; }

@media (max-width: 1180px) {
  .desktop-console { min-width: 0; overflow: auto; }
  .desktop-layout { grid-template-columns: 270px minmax(620px, 1fr); }
  .desktop-master { position: fixed; top: 45px; right: 8px; width: 300px; }
}

@media (max-width: 760px) {
  .desktop-console { grid-template-rows: auto auto auto; height: auto; min-height: 100vh; }
  .desktop-titlebar { min-height: 42px; }
  .desktop-user, .desktop-window-controls { display: none; }
  .desktop-layout { grid-template-columns: 1fr; }
  .desktop-sidebar { max-height: none; }
  .desktop-master { position: static; width: auto; margin: 0 10px 12px; }
  .desktop-device-canvas { grid-template-columns: minmax(250px, 1fr); padding: 10px; }
  .desktop-statusbar { flex-wrap: wrap; min-height: 38px; }
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.section-head p,
.mode-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

.summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.summary span {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
}

.summary strong {
  color: var(--text);
}

.panel,
.evidence-panel {
  margin: 20px 0 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.evidence-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.evidence-summary span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.evidence-panel-body {
  margin-top: 14px;
}

.room-form {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(240px, 1fr) repeat(3, minmax(118px, auto));
  gap: 12px;
  align-items: end;
}

.control-panel {
  margin-bottom: 18px;
}

.settings-drawer {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.settings-drawer > summary,
.advanced-connection-info > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, 1fr) minmax(220px, 1fr) minmax(160px, 0.8fr);
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.settings-grid .mode-note,
.settings-grid .advanced-connection-info {
  grid-column: 1 / -1;
}

label,
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.cast-plan-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cast-plan-field legend {
  color: var(--text);
  font-weight: 700;
}

.cast-plan-field p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.radio-field {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  min-height: 32px;
  color: var(--text);
}

.radio-field input {
  width: 18px;
  min-height: 18px;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

input,
select,
button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
}

button:disabled {
  border-color: var(--line);
  background: #d7dee8;
  color: var(--muted);
  cursor: not-allowed;
}

.local-signaling-actions {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(118px, auto);
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}

.evidence-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(154px, 0.8fr)) minmax(120px, 0.7fr) minmax(120px, 0.7fr) minmax(126px, auto);
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.checkbox-field {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  min-height: 38px;
  color: var(--text);
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

.evidence-slot-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.evidence-slot-row {
  display: grid;
  grid-template-columns: minmax(0, 66px) repeat(2, minmax(0, 0.8fr)) minmax(0, 1fr) repeat(2, minmax(0, 0.55fr)) repeat(3, minmax(0, 0.8fr));
  gap: 8px;
  align-items: end;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.evidence-slot-row legend {
  color: var(--text);
  font-weight: 700;
}

.evidence-command,
.evidence-validation,
.evidence-output {
  min-height: 116px;
  max-height: 300px;
  margin: 10px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101820;
  color: #eef6ff;
  padding: 12px;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.evidence-command {
  min-height: auto;
  color: #dcecff;
}

.runtime-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.runtime-status [data-runtime-status] {
  font-weight: 700;
  color: var(--text);
}

.runtime-status [data-runtime-error]:not(:empty) {
  color: #9b1c1c;
}

.connection-readiness,
.mode-note,
.path-legend {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--soft);
}

.connection-readiness {
  color: var(--text);
  font-size: 0.9rem;
}

.mode-note[data-level="warning"] {
  border-left-color: var(--warning);
  color: #513200;
}

.device-section {
  display: grid;
  gap: 14px;
}

.path-legend {
  display: grid;
  gap: 6px;
}

.path-legend span {
  color: var(--muted);
  font-size: 0.88rem;
}

.selected-device-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.selected-quality-controls,
.wda-action-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}

.selected-quality-controls label span {
  color: var(--text);
  font-weight: 700;
}

.selected-quality-controls input[type="range"] {
  padding: 0;
}

.wda-action-toolbar {
  grid-template-columns: repeat(5, minmax(82px, 0.7fr)) minmax(160px, 1.2fr) repeat(5, minmax(82px, 0.7fr));
  align-items: end;
}

.wda-task-runner {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.wda-task-runner label {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

.wda-task-runner textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.selected-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  min-height: 220px;
  max-height: 70vh;
  overflow: hidden;
  border: 1px solid #c3ccd8;
  border-radius: 6px;
  background: #0f1720;
}

.selected-preview video,
.selected-preview canvas,
.selected-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.selected-preview canvas {
  pointer-events: none;
}

.selected-preview img[hidden] {
  display: none;
}

.selected-preview canvas[hidden] {
  display: none;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.device-empty-state {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.device-empty-state[hidden] {
  display: none;
}

.device-card {
  --device-video-aspect-ratio: 16 / 9;
  min-height: 328px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.device-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.device-title span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.device-video-frame {
  position: relative;
  aspect-ratio: var(--device-video-aspect-ratio, 16 / 9);
  margin: 10px 0 2px;
  overflow: hidden;
  border: 1px solid #c3ccd8;
  border-radius: 6px;
  background: #0f1720;
}

.device-video-frame video,
.device-video-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.device-video-frame video[data-live-display-source],
.device-video-frame canvas {
  position: absolute;
  inset: 0;
}

.device-video-frame canvas {
  pointer-events: none;
}

.device-video-frame canvas[hidden] {
  display: none;
}

.device-video-frame[data-media-state="empty"] {
  background: #e7edf4;
}

dl {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
}

dl div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

@media (max-width: 1100px) {
  .room-form,
  .settings-grid,
  .evidence-controls,
  .evidence-slot-row,
  .device-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 640px);
    padding-top: 16px;
  }

  .topbar,
  .section-head,
  .selected-device-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-form,
  .settings-grid,
  .evidence-controls,
  .evidence-slot-row,
  .cast-plan-field,
  .selected-quality-controls,
  .wda-action-toolbar,
  .device-grid {
    grid-template-columns: 1fr;
  }
}

/* ── V9-P3 设备目录（device-directory）──────────────────────── */
.device-directory {
  margin-top: 16px;
}

.device-directory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-directory-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border, #d8dee6);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.device-directory-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.device-directory-dot.online {
  background: #1db954;
  box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.18);
}

.device-directory-dot.offline {
  background: #98a2b3;
}

.device-directory-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-directory-id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.device-directory-id {
  font-size: 16px;
  letter-spacing: 0.04em;
}

.device-directory-badge {
  font-size: 12px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.device-directory-badge.unbound {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

.device-directory-badge.watching {
  color: #065f46;
  background: #d1fae5;
  border-color: #6ee7b7;
}

.device-directory-meta {
  color: #667085;
  font-size: 12px;
}

.device-directory-watch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.device-directory-empty {
  text-align: center;
}
