:root {
  --bg: #0b1016;
  --bg-2: #111a24;
  --surface: #15212e;
  --surface-2: #1b2a3a;
  --surface-3: #203548;
  --border: #243748;
  --border-strong: #355166;
  --text: #e6f0f7;
  --text-dim: #8aa0b3;
  --accent: #2fd2e0;
  --accent-2: #3aa0ff;
  --ok: #39d98a;
  --err: #ff6b6b;
  --warn: #ffb454;
  --radius: 12px;
  --bar-h: 52px;
  --tool-h: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}
body { display: flex; flex-direction: column; overflow: hidden; }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hidden { display: none !important; }

/* 顶栏 */
.topbar, .sessbar {
  height: var(--bar-h); flex: 0 0 var(--bar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .3px; }
.logo { width: 22px; height: 22px; color: var(--accent); }
.sess-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.sess-peer { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-status { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-badge {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; max-width: 124px;
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-dim); font-size: 10px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.path-badge::before { content: ''; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
.path-badge[data-path='direct'] { color: var(--ok); border-color: rgba(57,217,138,.35); }
.path-badge[data-path='stun'] { color: var(--accent); border-color: rgba(47,210,224,.35); }
.path-badge[data-path='turn'] { color: var(--warn); border-color: rgba(255,180,84,.4); }
.quality-badge {
  display: inline-flex; align-items: center; flex: 0 1 auto; max-width: 170px;
  color: var(--text-dim); font-size: 10px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quality-badge[data-quality='warn'] { color: var(--warn); }

/* Tabs */
.tabs { display: flex; gap: 8px; padding: 12px 14px 4px; }
.tab {
  flex: 1; padding: 10px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 14px; font-weight: 600;
}
.tab.active { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.tabpane { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 12px; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--text-dim); }
.field input {
  width: 100%; padding: 12px 12px; font-size: 15px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); outline: none;
}
.field input:focus { border-color: var(--accent); }

.btn {
  padding: 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #04121a; border: none; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: wait; }

.status { margin: 0; font-size: 13px; color: var(--text-dim); min-height: 16px; }
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.hint { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin: 0; }

/* 账号工作区 */
.auth-intro { display: flex; flex-direction: column; gap: 7px; margin-bottom: 4px; }
.section-kicker {
  color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em;
  line-height: 1.3;
}
.auth-intro h3, .device-heading h3 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -.2px; }
.auth-intro p { margin: 0 0 5px; color: var(--text-dim); font-size: 12px; line-height: 1.6; }
.privacy-note { margin: 12px 0 0; color: var(--text-dim); font-size: 11px; line-height: 1.5; }
.account-summary {
  display: flex; align-items: center; gap: 11px; min-width: 0; padding: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
}
.account-avatar {
  width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center;
  border-radius: 12px; color: #04121a; background: var(--accent); font-size: 16px; font-weight: 800;
  text-transform: uppercase;
}
.account-summary-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.account-summary-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.account-state-badge {
  margin-left: auto; flex: 0 0 auto; padding: 4px 7px; border: 1px solid rgba(57,217,138,.3);
  border-radius: 999px; color: var(--ok); background: rgba(57,217,138,.1); font-size: 10px; white-space: nowrap;
}
.account-state-badge.warn {
  color: var(--warn); background: rgba(255,180,84,.1); border-color: rgba(255,180,84,.35);
}
.account-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.account-actions .btn { min-height: 42px; padding: 10px 12px; font-size: 13px; }
.devices-pane { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.device-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.device-heading h3 { margin-top: 5px; font-size: 17px; }
.devices-count { color: var(--text-dim); font-size: 12px; font-weight: 500; }
.device-heading-note { color: var(--text-dim); font-size: 11px; text-align: right; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 22px 14px;
  border: 1px dashed var(--border-strong); border-radius: 11px; background: var(--bg-2); text-align: center;
}
.empty-mark { color: var(--accent); font-size: 24px; line-height: 1; }
.empty-state strong { font-size: 13px; }
.empty-state p { max-width: 280px; margin: 0; color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.empty-state .btn { margin-top: 4px; }

/* 设备列表 */
.dev-list { display: flex; flex-direction: column; gap: 10px; }
.dev-item {
  text-align: left; padding: 12px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.dev-item .name { font-weight: 600; }
.dev-item .meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.dev-item .tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.dev-item .tag.on { background: rgba(57,217,138,.15); color: var(--ok); }
.dev-item .tag.off { background: rgba(138,160,179,.15); color: var(--text-dim); }
.dev-item.off { opacity: .6; }
.dev-item.local { opacity: .78; cursor: not-allowed; border-color: rgba(34,211,238,.38); }
.dev-item .tag.local { background: rgba(34,211,238,.14); color: var(--accent); }

/* 会话舞台 */
.stage { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
.session-video {
  width: 100%; height: 100%; object-fit: contain; background: #000; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none; outline: none; cursor: none;
}
.optimistic-cursor {
  position: absolute; left: 0; top: 0; z-index: 4; width: 24px; height: 32px;
  pointer-events: none; opacity: 0; transform: translate3d(-100px, -100px, 0);
  transform-origin: 0 0; contain: layout style paint; will-change: transform, opacity;
}
.optimistic-cursor.is-visible { opacity: 1; }
.optimistic-cursor[data-platform="macos"] { width: 23px; height: 31px; }
.optimistic-cursor[data-platform="linux"] { width: 23px; height: 31px; }
.optimistic-cursor svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .55)); }
.optimistic-cursor .cursor-outline { fill: #10161d; }
.optimistic-cursor .cursor-fill { fill: #fff; }
@media (prefers-reduced-motion: reduce) {
  .optimistic-cursor { transition: none; }
}
.iconbtn {
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:active { border-color: var(--accent); }

/* 工具栏 */
.toolbar {
  height: var(--tool-h); flex: 0 0 var(--tool-h);
  display: flex; align-items: stretch; gap: 2px;
  background: var(--bg-2);
  border-top: 1px solid var(--border); padding: 6px 4px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  overflow-x: auto; scrollbar-width: thin;
}
.toolbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 11px;
}
.toolbtn svg { width: 22px; height: 22px; }
.toolbtn.active { color: var(--accent); }
.toolbtn.active svg { filter: drop-shadow(0 0 4px rgba(47,210,224,.6)); }

/* 虚拟键盘层 */
.kbd-layer {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(11,16,22,.96); border-top: 1px solid var(--border);
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px;
}
.kbd-row { display: flex; gap: 8px; justify-content: center; }
.kbd-key, .kbd-mod {
  min-width: 56px; padding: 12px 8px; border-radius: 9px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 14px;
}
.kbd-mod.active { color: #04121a; background: var(--accent); border: none; }
.kbd-text {
  width: 100%; padding: 12px; font-size: 15px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); outline: none;
}

/* 文本发送弹层 */
.text-layer {
  position: absolute; inset: 0; background: rgba(4,8,12,.7);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.text-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.text-title { font-weight: 600; margin: 0; }
.text-card textarea {
  width: 100%; border-radius: 9px; padding: 10px; resize: none;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text); outline: none; font-size: 14px;
}
.text-actions { display: flex; gap: 10px; }
.text-actions .btn { flex: 1; }

/* 连接/重连遮罩提示 */
.reconnect {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(255,180,84,.15); color: var(--warn);
  border: 1px solid var(--warn); border-radius: 999px; padding: 6px 14px; font-size: 12px;
}

/* 局域网历史记录 */
.history { display: flex; flex-direction: column; gap: 8px; }
.history .hint { padding: 4px 2px; }
.hist-item {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.hist-fill {
  flex: 1; text-align: left; cursor: pointer; padding: 10px 12px;
  background: transparent; border: none; color: var(--text);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.hist-fill:active { background: var(--surface-2); }
.hist-addr { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-pass { font-size: 12px; color: var(--text-dim); }
.hist-del {
  width: 44px; flex: 0 0 44px; cursor: pointer; font-size: 16px;
  background: transparent; border: none; border-left: 1px solid var(--border); color: var(--text-dim);
}
.hist-del:active { color: var(--err); }
.btn.small { padding: 9px 12px; font-size: 13px; align-self: flex-start; }

.control-hint { display: none; }

@media (min-width: 768px) {
  .toolbar { justify-content: flex-start; gap: 10px; padding-left: 12px; padding-right: 12px; }
  .toolbtn { flex: 0 0 auto; min-width: 78px; padding: 0 8px; }
  .control-hint { display: inline-flex; align-items: center; margin-right: 10px; color: var(--text-dim); font-size: 12px; white-space: nowrap; }
}

@media (max-width: 560px) {
  .quality-badge { max-width: 82px; }
}

/* 响应式基础：移动端优先，桌面端在宽屏上重组信息层级 */
button, input, textarea { font: inherit; }
button { -webkit-appearance: none; }
.view { min-width: 0; }
#view-connect { overflow: auto; overscroll-behavior: contain; }
#view-session { position: relative; overflow: hidden; }
.connect-layout {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
}
.connect-panel { min-width: 0; display: flex; flex-direction: column; }
.session-workspace {
  flex: 1; min-width: 0; min-height: 0;
  display: flex;
}
.stage { min-width: 0; min-height: 0; }
.connect-hero, .panel-heading, .topbar-caption, .session-desktop-hint, .session-sidepanel { display: none; }
.topbar-state {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 11px; white-space: nowrap;
}
.state-dot {
  width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 3px rgba(57,217,138,.12);
}
.state-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(255,180,84,.12); }
.state-dot.error { background: var(--err); box-shadow: 0 0 0 3px rgba(255,107,107,.12); }
.state-dot.neutral { background: var(--text-dim); box-shadow: 0 0 0 3px rgba(138,160,179,.12); }
.session-kicker { display: none; }
.btn, .tab, .iconbtn, .kbd-key, .kbd-mod { min-height: 44px; }
.field input { min-height: 46px; font-size: 16px; }
.text-card textarea, .kbd-text { font-size: 16px; }
.auth-actions { display: grid; gap: 8px; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:active, .tab:active, .dev-item:active, .toolbtn:active { transform: translateY(1px); }

@media (min-width: 1024px) {
  :root {
    --bar-h: 68px;
    --tool-h: 76px;
  }

  #view-connect { background: var(--bg); }
  #view-connect .topbar {
    height: var(--bar-h); flex-basis: var(--bar-h);
    padding: 0 clamp(24px, 4vw, 64px);
    border-bottom-color: var(--border-strong);
  }
  .topbar-caption {
    display: inline-flex; align-items: center; margin-left: 4px; padding-left: 14px;
    border-left: 1px solid var(--border); color: var(--text-dim); font-size: 13px;
  }
  .topbar-state {
    padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text-dim); font-size: 12px;
  }

  .connect-layout {
    width: min(1240px, 100%); margin: 0 auto;
    display: grid; grid-template-columns: minmax(300px, .88fr) minmax(440px, 1fr);
    align-items: start; gap: clamp(42px, 7vw, 104px);
    padding: clamp(42px, 7vh, 76px) clamp(32px, 5vw, 72px) 64px;
  }
  .connect-hero {
    display: flex; flex-direction: column; align-self: center;
    max-width: 490px; padding-bottom: 10px;
  }
  .hero-kicker, .panel-kicker, .sidepanel-kicker {
    margin: 0; color: var(--accent); font-size: 11px; font-weight: 700;
    letter-spacing: .16em; line-height: 1.3;
  }
  .connect-hero h1 {
    margin: 18px 0 18px; color: var(--text); font-size: clamp(42px, 4.5vw, 64px);
    line-height: 1.08; letter-spacing: -1.8px; text-wrap: balance;
  }
  .connect-hero h1 span { color: var(--accent); }
  .hero-copy {
    max-width: 430px; margin: 0; color: var(--text-dim); font-size: 16px;
    line-height: 1.75; text-wrap: pretty;
  }
  .hero-features {
    display: grid; gap: 0; margin-top: 38px; border-top: 1px solid var(--border);
  }
  .hero-feature {
    display: flex; align-items: flex-start; gap: 14px; padding: 16px 0;
    border-bottom: 1px solid var(--border);
  }
  .feature-mark {
    width: 28px; flex: 0 0 28px; padding-top: 2px; color: var(--accent);
    font-size: 11px; font-variant-numeric: tabular-nums;
  }
  .hero-feature strong, .hero-feature small { display: block; }
  .hero-feature strong { font-size: 14px; line-height: 1.4; }
  .hero-feature small { margin-top: 3px; color: var(--text-dim); font-size: 12px; line-height: 1.4; }
  .hero-note {
    display: flex; align-items: flex-start; gap: 9px; margin-top: 22px;
    color: var(--text-dim); font-size: 12px; line-height: 1.55;
  }
  .note-icon { color: var(--accent); font-size: 16px; line-height: 1.1; }

  .connect-panel {
    align-self: start; width: min(520px, 100%); margin-left: auto;
    padding: 28px; background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: 20px; box-shadow: 0 20px 56px rgba(0,0,0,.22);
  }
  .panel-heading {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  }
  .panel-heading h2 {
    margin: 8px 0 0; color: var(--text); font-size: 26px; line-height: 1.2;
    letter-spacing: -.5px;
  }
  .panel-badge {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 9px;
    border: 1px solid var(--border); border-radius: 999px; color: var(--text-dim);
    font-size: 11px; white-space: nowrap;
  }
  .panel-badge .state-dot { width: 6px; height: 6px; flex-basis: 6px; box-shadow: none; }
  .connect-panel .tabs { gap: 8px; padding: 0; margin-top: 26px; }
  .connect-panel .tab {
    min-height: 46px; padding: 11px 16px; border-radius: 10px;
    background: var(--bg-2); border-color: var(--border); font-size: 13px;
  }
  .connect-panel .tab.active {
    color: var(--text); background: rgba(47,210,224,.1); border-color: var(--accent);
    box-shadow: none;
  }
  .connect-panel .tabpane { padding: 22px 0 0; gap: 14px; }
  .connect-panel .field { gap: 8px; }
  .connect-panel .field > span { font-size: 13px; }
  .connect-panel .field input {
    height: 48px; padding: 0 14px; background: var(--bg-2); border-color: var(--border-strong);
  }
  .connect-panel .field input:focus { border-color: var(--accent); }
  .connect-panel .btn { min-height: 48px; padding: 12px 16px; }
  .connect-panel .auth-actions { grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr); }
  .connect-panel .btn.primary { background: var(--accent); }
  .connect-panel .btn.ghost { background: transparent; }
  .connect-panel .btn.small { min-height: 40px; padding: 9px 12px; }
  .connect-panel .hint { max-width: 440px; line-height: 1.6; }
  .connect-panel #devices-pane:not(.hidden) {
    margin-top: 4px; padding-top: 18px; border-top: 1px solid var(--border);
  }
  .connect-panel .account-summary { padding: 15px; background: var(--bg-2); border-color: var(--border-strong); }
  .connect-panel .devices-pane { margin-top: 22px; }
  .connect-panel .dev-list { gap: 8px; }
  .connect-panel .dev-item {
    min-height: 76px; padding: 15px 16px; background: var(--bg-2);
    border-color: var(--border-strong); border-radius: 12px;
  }
  .connect-panel .dev-item .name { font-size: 14px; }

  #view-session .sessbar {
    height: var(--bar-h); flex-basis: var(--bar-h); padding: 0 24px;
    background: var(--bg-2); border-bottom-color: var(--border-strong);
  }
  #view-session .iconbtn {
    width: 44px; height: 44px; background: transparent; border-color: var(--border-strong);
  }
  #view-session .sess-info { flex: 0 1 360px; gap: 2px; }
  .session-kicker {
    display: block; color: var(--accent); font-size: 10px; font-weight: 700;
    letter-spacing: .12em; line-height: 1.2;
  }
  #view-session .sess-peer { font-size: 14px; }
  #view-session .sess-status { font-size: 12px; }
  .session-desktop-hint {
    display: inline-flex; align-items: center; margin-left: auto; padding: 8px 12px;
    color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; font-size: 12px; white-space: nowrap;
  }
  .session-workspace { gap: 16px; padding: 16px 24px 20px; background: var(--bg); }
  #view-session .stage {
    border: 1px solid var(--border-strong); border-radius: 16px; background: #05080c;
    box-shadow: 0 16px 40px rgba(0,0,0,.2);
  }
  #view-session .session-video { border-radius: 15px; }
  .session-sidepanel {
    display: flex; flex: 0 0 250px; width: 250px; flex-direction: column;
    padding: 22px 20px; background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: 16px;
  }
  .session-sidepanel h2 { margin: 10px 0 8px; font-size: 18px; line-height: 1.35; }
  .sidepanel-copy { margin: 0; color: var(--text-dim); font-size: 12px; line-height: 1.6; }
  .shortcut-list { display: grid; gap: 10px; margin-top: 24px; }
  .shortcut-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    color: var(--text-dim); font-size: 11px;
  }
  .shortcut-row kbd {
    min-width: 76px; padding: 6px 7px; color: var(--text); background: var(--bg-2);
    border: 1px solid var(--border); border-radius: 6px; font-size: 11px; text-align: center;
  }
  .sidepanel-note {
    display: flex; align-items: center; gap: 9px; margin-top: auto; padding-top: 18px;
    border-top: 1px solid var(--border); color: var(--text-dim); font-size: 11px; line-height: 1.45;
  }
  .sidepanel-note .state-dot { width: 6px; height: 6px; flex-basis: 6px; box-shadow: none; }

  #view-session .toolbar {
    height: var(--tool-h); flex-basis: var(--tool-h); align-items: center; gap: 8px;
    padding: 12px 24px max(12px, env(safe-area-inset-bottom, 0px));
    background: var(--bg-2); border-top-color: var(--border-strong); overflow: visible;
  }
  #view-session .control-hint {
    order: 0; display: inline-flex; align-items: center; margin: 0 auto 0 0; padding: 9px 12px;
    color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; font-size: 12px;
  }
  #view-session .toolbtn {
    flex: 0 0 auto; min-width: 96px; min-height: 48px; height: 48px; flex-direction: row;
    gap: 8px; padding: 0 14px; color: var(--text-dim); background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
  }
  #view-session .toolbtn svg { width: 20px; height: 20px; }
  #view-session .toolbtn.active { color: var(--accent); border-color: var(--accent); background: rgba(47,210,224,.1); }
  #view-session #tb-right, #view-session #tb-drag { display: none; }

  #view-session .kbd-layer {
    left: auto; right: 20px; bottom: 18px; width: min(520px, calc(100% - 40px));
    padding: 16px; background: rgba(21,33,46,.98); border: 1px solid var(--border-strong);
    border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
  }
  #view-session .kbd-row { justify-content: flex-start; gap: 8px; }
  #view-session .kbd-key, #view-session .kbd-mod { min-width: 64px; min-height: 44px; padding: 10px 12px; }
  #view-session .kbd-text { min-height: 46px; background: var(--bg-2); }
  #view-session .text-card { max-width: 520px; padding: 24px; }
}

@media (hover: hover) {
  .btn:hover, .tab:hover, .dev-item:hover, .iconbtn:hover, .toolbtn:hover {
    border-color: var(--border-strong);
  }
  .btn.primary:hover { background: #56dce6; }
  .connect-panel .tab.active:hover, #view-session .toolbtn.active:hover { border-color: var(--accent); }
}

@media (max-width: 420px) {
  .topbar, .sessbar { padding-left: 12px; padding-right: 12px; }
  .path-badge { max-width: 92px; padding-left: 6px; padding-right: 6px; }
  .account-actions { grid-template-columns: 1fr; }
  .device-heading { align-items: flex-start; flex-direction: column; }
  .device-heading-note { text-align: left; }
  .tabpane { padding-left: 12px; padding-right: 12px; }
  .toolbtn svg { width: 21px; height: 21px; }
  .kbd-row { gap: 6px; }
  .kbd-key, .kbd-mod { min-width: 52px; padding-left: 6px; padding-right: 6px; }
}
