:root {
  color-scheme: dark;
  --bg: #101110;
  --panel: #191b19;
  --line: #2c302b;
  --line-2: #41463e;
  --text: #f1f3ed;
  --muted: #a4aca0;
  --dim: #858e80;
  --acid: #dafa9c;
  --ember: #ffab98;
  --cyan: #a6dcd3;
  --font-ui: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
a { color: var(--acid); }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 4px; }
.shell { width: min(1120px, calc(100% - 64px)); min-height: 100svh; margin: auto; display: flex; flex-direction: column; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.brand { flex-shrink: 0; }
.wordmark { white-space: nowrap; flex-shrink: 0; display: flex; align-items: center; gap: 9px; font-size: 21px; font-weight: 800; letter-spacing: -.06em; }
.brand-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--acid); }
.top-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.user-chip { min-width: 0; max-width: 180px; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-chip b { font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; background: var(--dim); }
.pill.live { color: var(--acid); border-color: #3f4c31; }
.pill.live .dot { background: var(--acid); }
.pill.warn { color: var(--ember); }
.pill.warn .dot { background: var(--ember); }
.pill.busy { color: var(--cyan); }
.pill.busy .dot { background: var(--cyan); }
.btn { appearance: none; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: 1px solid var(--line-2); border-radius: 10px; background: #22251f; color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .15s; touch-action: manipulation; }
.btn:hover:not(:disabled) { background: #30362a; border-color: #68765b; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: .8; }
.btn[aria-busy="true"]::before { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.primary { background: var(--acid); border-color: var(--acid); color: #1a2410; font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: #e6ffb9; border-color: #e6ffb9; }
.btn.danger { color: var(--ember); background: #2b211e; border-color: #664139; }
.btn.danger:hover:not(:disabled) { background: #402a24; border-color: #b67665; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: #282c25; color: var(--text); }
.btn.sm { padding: 8px 13px; font-size: 13px; }
.btn.wide { width: 100%; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.field label { font-size: 13px; color: #c5ccc0; }
.field input, .field select { min-width: 0; width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid var(--line-2); border-radius: 9px; color: var(--text); background: #121410; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: #808879; }
.field input:focus, .field select:focus { outline: none; border-color: var(--acid); box-shadow: 0 0 0 3px #dafa9c18; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.landing { padding: clamp(64px, 10vw, 140px) 0; flex: 1; display: grid; align-items: center; }
.landing-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 80px; align-items: center; }
@media (min-width: 1280px) {
  .landing {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding: 32px 0;
  }
}
.hero { margin: 0; font-size: clamp(46px, 5.4vw, 68px); line-height: 1.28; font-weight: 650; letter-spacing: -.055em; }
.hero em { color: var(--acid); font-style: normal; }
.hero-caption { margin: 24px 0 0; font-size: 16px; color: var(--muted); }
.auth-card { padding: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.auth-card h2 { margin: 0 0 28px; font-size: 23px; font-weight: 600; letter-spacing: -.03em; }
.auth-card .btn { min-height: 48px; margin-top: 8px; }
.error-box { display: none; padding: 12px 14px; margin-bottom: 20px; border: 1px solid #774b3f; border-radius: 9px; color: var(--ember); background: #38251f; font-size: 13px; overflow-wrap: anywhere; }
.error-box.show { display: block; }
.site-footer { display: flex; justify-content: space-between; gap: 16px; padding: 22px 0; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
.site-footer span:first-child { letter-spacing: .08em; font-size: 11px; }
.dash { flex: 1; padding: 52px 0 80px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.dash-head h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -.045em; }
.dash-head p { margin: 6px 0 0; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-bottom: 32px; padding: 0 0 24px; border-bottom: 1px solid var(--line); }
.metric .k { color: var(--muted); font-size: 12px; }
.metric .v { margin-top: 6px; font: 24px/1.4 var(--font-mono); }
.metric:last-child .v { font-size: 17px; padding-top: 6px; }
.nodes { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.nodes:empty { display: none; }
.node { min-width: 0; overflow: hidden; border: 0; border-radius: 0; background: transparent; }
.node + .node { border-top: 1px solid var(--line); }
.node-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.node-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.node-title > div:last-child { min-width: 0; }
.node-title .ico { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border: 1px solid var(--line-2); border-radius: 8px; color: var(--acid); font-size: 22px; }
.node-title h3 { margin: 0; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.device { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 24px 22px; }
.device + .device { border-top: 1px solid var(--line); }
.device .name { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; font-size: 16px; overflow-wrap: anywhere; }
.device .name > span:first-child { min-width: 0; }
.meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.actions { display: flex; align-items: center; gap: 8px; }
.tag { display: inline-flex; border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 6px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.tag.ps5 { color: var(--cyan); }
.tag.ready { color: var(--acid); border-color: #485b33; }
.tag.standby { color: var(--muted); }
.empty-state { padding: 64px 24px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.empty-state h3 { margin: 0 0 10px; font-size: 18px; font-weight: 500; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; }
.list-feedback { color: var(--muted); padding: 14px 0; font-size: 13px; }
.stream-body { position: relative; height: 100vh; height: 100dvh; overflow: hidden; background: #070807; }
/* 90% of the dynamic viewport, centered. Fixed inset:0 tracked the layout viewport and got clipped when the iOS URL bar showed. */
.stage { position: absolute; top: 5%; left: 5%; width: 90%; height: 90%; display: grid; place-items: center; container-type: size; }
#stream-canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; background: #050505; }
/* Bitmap width/height attributes are the video's real ratio. Fit the largest box of that ratio inside the stage. */
@supports (aspect-ratio: attr(width number)) {
  #stream-canvas {
    aspect-ratio: attr(width number) / attr(height number);
    width: min(100cqi, calc(100cqb * attr(width number) / attr(height number)));
    height: auto;
    max-width: 100cqi;
    max-height: 100cqb;
  }
}
:fullscreen .stage,
.stage:fullscreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
:-webkit-full-screen .stage,
.stage:-webkit-full-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); background: linear-gradient(#0009, transparent); }
.hud-block { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
.hud .pill { background: #101310cc; font-size: 11px; backdrop-filter: blur(12px); }
#hud-device { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.hud .hud-loss { font-size: 10px; color: var(--dim); border-color: transparent; background: transparent; }
.hud-bottom { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; padding: 20px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); background: linear-gradient(transparent, #000a); }
.toolbar { pointer-events: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 1px solid #ffffff24; border-radius: 15px; background: #141713eb; backdrop-filter: blur(16px); }
.toolbar .secondary { color: var(--dim); font-size: 12px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 2px; }
#btn-kbm[aria-pressed="true"],
#btn-kbm.on,
#btn-hints[aria-pressed="true"] { color: #1a2410; background: var(--acid); border-color: var(--acid); font-weight: 650; }
.volume { position: relative; display: inline-flex; align-items: center; min-width: 0; max-width: 100%; }
#btn-volume svg, #btn-hints svg { display: block; }
.volume-popover {
  position: absolute;
  z-index: 6;
  bottom: calc(100% + 8px);
  left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(280px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  padding: 10px 12px;
  border: 1px solid #ffffff24;
  border-radius: 12px;
  background: #141713f2;
  box-shadow: 0 8px 28px #0008;
  pointer-events: auto;
}
.volume-popover[hidden] { display: none !important; }
.volume-popover #volume-slider { flex: 1 1 auto; width: auto; min-width: 0; height: 32px; margin: 0; accent-color: var(--acid); background: transparent; cursor: pointer; touch-action: manipulation; }
.volume-readout { flex: 0 0 auto; min-width: 2.6ch; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
@media (hover: none) {
  .volume-popover #volume-slider { height: 44px; }
}
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; overflow-y: auto; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: #0c0e0cf2; backdrop-filter: blur(8px); }
.overlay-card { width: min(440px, 100%); margin: auto; padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: center; }
.overlay-card h2 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.03em; }
.overlay-card p { color: var(--muted); font-size: 14px; margin: 10px 0 24px; overflow-wrap: anywhere; }
.overlay-card .field-row { text-align: left; }
.overlay-card .field { margin: 0; }
.overlay-card > .btn { margin-top: 24px; width: 100%; min-height: 48px; }
.overlay-card .error-box { margin-top: 20px; text-align: left; }
.spinner { width: 24px; height: 24px; margin: 20px auto; border: 2px solid var(--line-2); border-top-color: var(--acid); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100% - 32px)); pointer-events: none; }
.stream-body .toasts { bottom: calc(100px + env(safe-area-inset-bottom)); }
.toast { padding: 13px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: #252a22; font-size: 13px; overflow-wrap: anywhere; box-shadow: 0 8px 32px #0005; }
.toast.err { color: var(--ember); border-color: #815142; }
.toast.ok { color: var(--acid); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.hidden { display: none !important; }
@media (max-width: 760px) {
  .shell { width: calc(100% - 40px); }
  .topbar { min-height: 76px; }
  .top-right { gap: 6px; flex-wrap: wrap; }
  .user-chip { max-width: 100px; }
  .wordmark { font-size: 18px; letter-spacing: -.05em; }
  .landing { padding: 52px 0 64px; }
  .landing-grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .hero { font-size: clamp(40px, 9vw, 56px); }
  .hero-caption { margin-top: 16px; font-size: 14px; }
  .auth-card { padding: 26px 24px; border-radius: 8px; }
  .dash { padding: 32px 0 56px; }
  .dash-head { margin-bottom: 26px; }
  .dash-head h1 { font-size: 28px; }
  .metrics { gap: 12px; margin-bottom: 24px; }
  .metric .v { font-size: 22px; }
  .metric:last-child .v { font-size: 13px; padding-top: 10px; }
  .node-head { padding: 16px; }
  .device { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 20px 16px; }
  .actions .btn { flex: 1; }
  .hud-top { flex-direction: column; gap: 6px; }
  .toolbar { max-width: 100%; }
  .toolbar .sep { display: none; }
  .overlay-card { padding: 26px 22px; }
}
@media (max-width: 420px) {
  .top-right { column-gap: 6px; max-width: 220px; }
  .top-right .pill { padding: 4px 7px; font-size: 11px; }
  .user-chip { max-width: 70px; font-size: 12px; }
  .top-right .btn.sm { padding: 8px; }
  .toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .toolbar .btn { padding: 8px; }
  #btn-fullscreen { grid-column: 1; grid-row: 1; }
  #btn-stop { grid-column: 2; grid-row: 1; }
  #btn-back { grid-column: 3; grid-row: 1; }
  .volume { width: auto; justify-content: center; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .hud-top { flex-direction: row; padding-top: max(8px, env(safe-area-inset-top)); }
  .hud .pill { padding: 3px 8px; }
  .toolbar { flex-wrap: nowrap; gap: 4px; padding: 5px; }
  .toolbar .btn { padding: 8px 11px; }
  .volume { flex: 0 0 auto; min-width: 0; }
  .hud-bottom { padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .overlay { padding-top: 12px; padding-bottom: 12px; }
  .overlay-card { width: min(600px, 100%); padding: 18px 24px; }
  .overlay-card h2 { font-size: 22px; }
  .overlay-card p { margin: 4px 0 14px; }
  .overlay-card .field-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .overlay-card .field { gap: 4px; }
  .overlay-card .field select { padding: 8px; min-height: 44px; font-size: 14px; }
  .overlay-card > .btn { margin-top: 16px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 2s !important; }
  .btn:active:not(:disabled) { transform: none; }
}
.overlay-back { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px; padding: 8px 12px; color: var(--muted); font-size: 13px; text-decoration: none; border-radius: 8px; }
.overlay-back:hover { color: var(--text); background: #ffffff08; }

/* 键位抽屉沿用 HUD 的系统字体、酸绿和半透明面板。 */
.keymap-backdrop { position: fixed; inset: 0; z-index: 80; background: #0009; backdrop-filter: blur(3px); }
.keymap-drawer { position: fixed; inset: 0 0 0 auto; z-index: 81; width: min(420px, 92vw); max-width: 100vw; box-sizing: border-box; background: #141713fa; color: var(--text); border-left: 1px solid #ffffff24; box-shadow: -20px 0 70px #0008; overflow-y: auto; overscroll-behavior: contain; animation: keymap-in .18s ease-out; }
.keymap-drawer[hidden], .keymap-backdrop[hidden], .keymap-drawer [hidden] { display: none !important; }
@keyframes keymap-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.keymap-drawer header { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px 16px; border-bottom: 1px solid var(--line-2); }
.keymap-drawer small { color: var(--acid); font-size: 10px; letter-spacing: .16em; }
.keymap-drawer h2 { margin: 5px 0 0; font-size: 23px; }
.keymap-content { padding: 18px 20px 28px; }
.keymap-drawer h3 { font-size: 13px; color: var(--acid); margin: 25px 0 10px; }
.keymap-field { display: flex; flex-direction: column; gap: 9px; margin: 0 0 16px; font-size: 13px; }
.keymap-field select { width: 100%; min-width: 0; border-radius: 8px; padding: 10px; background: #22271f; border: 1px solid #ffffff24; color: inherit; font: inherit; }
.keymap-hint, #keymap-status { color: var(--dim); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.keymap-row { display: grid; grid-template-columns: 95px minmax(0, 1fr); align-items: center; gap: 6px 10px; padding: 7px 0; border-bottom: 1px solid #ffffff0c; font-size: 13px; }
.keymap-drawer .btn { border-radius: 8px; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.keymap-badge { justify-self: stretch; text-align: right; font-size: 12px; }
.keymap-badge[aria-pressed="true"] { color: var(--acid); border-color: var(--acid); }
.keymap-conflict { grid-column: 1 / -1; color: #f2c484; font-size: 12px; }
.keymap-conflict:empty { display: none; }
.keymap-field input { width: 100%; min-width: 0; accent-color: var(--acid); touch-action: pan-y; }
.keymap-field output { float: right; color: var(--acid); font-variant-numeric: tabular-nums; }
.keymap-toggle { display: flex; justify-content: space-between; font-size: 13px; padding: 10px 0; }
.keymap-toggle input { accent-color: var(--acid); width: 20px; height: 20px; }
.keymap-share { display: flex; gap: 10px; margin-top: 24px; }
.keymap-drawer :focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }
@media (hover: none) { .keymap-drawer .btn, .keymap-drawer select, .keymap-field input[type="range"], .keymap-toggle { min-height: 44px; touch-action: manipulation; } }
@media (prefers-reduced-motion: reduce) { .keymap-drawer { animation: none; } }

/* 非全屏键位提示。水平位置由脚本按黑边写入，垂直居中，不接指针。黑边不足、窄屏或无 hover 时不显示。 */
.kbm-hints {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  user-select: none;
}
.kbm-hints,
.kbm-hints * { pointer-events: none; }
#kbm-hints { display: none !important; }
@media (min-width: 720px) and (hover: hover) {
  #kbm-hints:not([hidden]) { display: block !important; }
}
.kbm-hints-panel {
  --hint-font: 12px;
  --hint-row: 22px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  box-sizing: border-box;
  width: 164px;
  max-width: 220px;
  max-height: calc(100dvh - 16px);
  max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  padding: 10px;
  border: 1px solid #ffffff24;
  border-radius: 8px;
  color: var(--text);
  background: rgba(16, 17, 16, .72);
  box-shadow: 0 10px 28px #0006;
  font: var(--hint-font)/1.2 var(--font-ui);
}
@supports ((backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px))) {
  .kbm-hints-panel {
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
}
.kbm-hint-group,
.kbm-hint-look,
.kbm-hint-mode,
.kbm-hint-ellipsis,
.kbm-hint-row {
  box-sizing: border-box;
  height: var(--hint-row);
  min-height: 20px;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kbm-hint-group {
  color: var(--dim);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .14em;
  line-height: var(--hint-row);
  text-transform: uppercase;
  text-overflow: ellipsis;
}
.kbm-hint-group:not(:first-child),
.kbm-hint-rule {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}
.kbm-hint-look,
.kbm-hint-mode,
.kbm-hint-ellipsis,
.kbm-hint-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-size: var(--hint-font);
  line-height: var(--hint-row);
}
.kbm-hint-ellipsis { color: var(--dim); }
.kbm-hint-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 22px;
  height: 16px;
  margin: 0;
  padding: 0 5px;
  border: 1px solid var(--acid);
  border-radius: 999px;
  background: transparent;
  color: var(--acid);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .04em;
  text-align: center;
}
.kbm-hint-chip.is-symbol {
  min-width: 20px;
  padding: 0 4px;
  font-size: 12px;
  letter-spacing: 0;
}
.kbm-hint-chip.is-tag {
  padding: 0 4px;
  font-size: 9px;
  letter-spacing: 0;
}
.kbm-hint-keys {
  display: inline-flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  min-width: 0;
  max-width: 58%;
  margin-left: auto;
  overflow: hidden;
}
/* 键盘视角的标签不参与收缩，键帽区吃掉剩余宽度，必要时省略号收尾。 */
.kbm-hint-look-keys .kbm-hint-name {
  flex: 0 0 auto;
  width: auto;
  overflow: visible;
  text-overflow: clip;
}
.kbm-hint-look-keys .kbm-hint-keys {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  overflow: hidden;
}
.kbm-hint-look-keys .kbm-key { padding: 0 3px; }
.kbm-hint-slash { flex: 0 0 auto; color: var(--dim); font-size: var(--hint-font); line-height: 1; }
.kbm-key {
  display: inline-block;
  box-sizing: border-box;
  flex: 0 0 auto;
  min-width: 16px;
  max-width: 100%;
  height: calc(var(--hint-row) - 6px);
  min-height: 0;
  margin: 0;
  padding: 0 4px;
  border: 1px solid #3a4334;
  border-radius: 4px;
  background: #1c2416;
  color: var(--text);
  font-family: inherit;
  font-size: var(--hint-font);
  font-weight: 650;
  line-height: calc(var(--hint-row) - 8px);
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 0 -1px 0 #0006;
}
/* 只有标了省略的键帽和 +N 允许变窄，普通键帽保持整字。 */
.kbm-key.is-ellipsis,
.kbm-key-more {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
/* 窄面板：标签在上。第二行 chip 与键帽等宽，键帽靠右。高度按两行计入纵向预算。 */
.kbm-hints-panel.is-compact .kbm-hint-row,
.kbm-hints-panel.is-compact .kbm-hint-look-keys {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: calc(var(--hint-row) - 2px) var(--hint-row);
  align-items: center;
  column-gap: 4px;
  row-gap: 0;
  height: calc(var(--hint-row) * 2);
  min-height: 40px;
  line-height: 1.15;
}
.kbm-hints-panel.is-compact .kbm-hint-name {
  grid-column: 1 / -1;
  grid-row: 1;
  order: 0;
  flex: none;
  width: 100%;
  min-width: 0;
  height: auto;
  line-height: calc(var(--hint-row) - 2px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kbm-hints-panel.is-compact .kbm-hint-chip {
  grid-column: 1;
  grid-row: 2;
  justify-self: stretch;
  width: auto;
  min-width: 0;
  max-width: none;
  height: calc(var(--hint-row) - 6px);
  overflow: hidden;
}
.kbm-hints-panel.is-compact .kbm-hint-keys {
  grid-column: 2;
  grid-row: 2;
  flex: none;
  width: auto;
  max-width: none;
  min-width: 0;
  height: auto;
  margin-left: 0;
  justify-self: stretch;
  justify-content: flex-end;
  overflow: hidden;
}
.kbm-hints-panel.is-compact .kbm-hint-row:not(:has(.kbm-hint-chip)) .kbm-hint-keys,
.kbm-hints-panel.is-compact .kbm-hint-look-keys .kbm-hint-keys {
  grid-column: 1 / -1;
  justify-content: flex-end;
  justify-self: end;
}
.kbm-hints-panel.is-compact .kbm-hint-row:has(.kbm-hint-chip) .kbm-key {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: 0 2px;
  text-align: center;
}
.kbm-hints-panel.is-compact .kbm-hint-mode {
  align-items: flex-start;
  height: auto;
  min-height: var(--hint-row);
  overflow: visible;
  white-space: normal;
  font-size: 10px;
  line-height: 1.35;
}
.kbm-key.is-empty {
  border-color: var(--line-2);
  background: transparent;
  color: var(--dim);
  box-shadow: none;
}
.kbm-hint-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: var(--hint-font);
  line-height: var(--hint-row);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kbm-hint-mode { color: var(--acid); font-size: 11px; letter-spacing: 0; }

/* 抽屉里的双模式页签。侧栏类来自 GTA 预设，选择器与 #kbm-hints 分开。 */
#keymap-modes { display: flex; gap: 8px; margin: 12px 0; }
#keymap-modes[hidden] { display: none; }
#keymap-modes [aria-selected="true"] { background: var(--accent, #4979db); color: white; }
.keymap-side-hint { display: none; }
@media (hover: hover) and (min-width: 1100px) {
  .keymap-side-hint { display: block; position: fixed; top: 22%; width: 175px; padding: 14px; background: #101822e8; color: #e3e9f1; border: 1px solid #445064; border-radius: 10px; pointer-events: none; font-size: 12px; z-index: 5; }
  .keymap-side-hint p { line-height: 1.9; overflow-wrap: anywhere; }
  .keymap-side-left { left: 12px; }
  .keymap-side-right { right: 12px; }
}

/* Key mapping: controller first, restrained input-tool styling. */
.keymap-drawer { width: min(460px, 92vw); background: #101110; overflow-x: hidden; }
.keymap-backdrop { backdrop-filter: none; }
.keymap-content { padding: 12px 16px 28px; }
.keymap-drawer h3 { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .16em; border-top: 1px solid #ffffff24; padding-top: 18px; margin: 20px 0 12px; }
.keymap-share { flex-wrap: wrap; margin-top: 12px; gap: 6px; }
.keymap-badge { font-family: ui-monospace, monospace; border: 1px solid #ffffff40; border-radius: 4px !important; background: #191b18; }
#keymap-views { display: flex; gap: 6px; margin-bottom: 12px; }
#keymap-modes [aria-selected="true"], #keymap-views [aria-selected="true"] { color: #101110; background: #dafa9c; border-color: #dafa9c; }
#keymap-recording { position: sticky; top: 0; z-index: 2; background: #101110; color: #dafa9c; font-size: 12px; }
#keymap-recording:empty { display: none; }
.keymap-mouse-summary, #keymap-mode-help { color: var(--dim); font-size: 11px; line-height: 1.6; }
.keymap-pad { display: block; width: 100%; height: auto; overflow: visible; }
.pad-outline { fill: none; stroke: #899580; stroke-width: 1.5; }
.pad-region { cursor: pointer; outline: none; }
.pad-button { pointer-events: none; fill: #191c18; stroke: #697260; stroke-width: 1; }
.pad-name { fill: #e2e6de; font: 11px system-ui; pointer-events: none; }
.pad-key { fill: #b9c0b0; font: 10px ui-monospace, monospace; pointer-events: none; }
.pad-region:hover .pad-button, .pad-region:focus .pad-button { stroke: #dafa9c; }
.pad-region[aria-pressed="true"] .pad-button { stroke: #dafa9c; stroke-width: 2; animation: pad-pulse .8s ease-in-out infinite alternate; }
@keyframes pad-pulse { to { fill: #36452a; } }
@media (prefers-reduced-motion: reduce) { .pad-region .pad-button { animation: none !important; } }
.keymap-drawer header { padding: 16px 16px 12px; }
.keymap-drawer h2 { font-size: 21px; }
.keymap-drawer h3 { margin-top: 16px; padding-top: 12px; }
.keymap-content > h3:first-child { border-top: 0; padding-top: 0; margin-top: 8px; }
.keymap-drawer .keymap-badge { border: 1px solid #ffffff40; background: #191b18; white-space: nowrap; }
.keymap-row > div { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; }
.keymap-side-hint { background: #101110eb; border-color: #ffffff24; border-radius: 8px; color: #dce2d5; }
.keymap-drawer { width: min(560px, 100vw); box-shadow: none; }
.keymap-pad { width: 98%; margin: 0 auto; }
.pad-outline { fill: #dafa9c08; stroke-width: 1.5; }
.pad-key { width: 48px; height: 22px; display: flex; align-items: center; justify-content: center; color: #ffffff; font: 14px system-ui; white-space: nowrap; }
.pad-name { fill: #aab3a3; font-size: 11px; }
.pad-extra { fill: #dafa9c; font: 14px system-ui; }
.pad-region.mode-related .pad-button { stroke: #c7ff77; }
.keymap-pad-help { text-align: center; color: var(--dim); font-size: 11px; margin: 6px 0 12px; }
#keymap-toast { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 100; padding: 12px 20px; background: #101110ed; border: 1px solid #dafa9c; color: #dafa9c; font: 16px system-ui; pointer-events: none; white-space: nowrap; }
#keymap-toast[hidden] { display: none; }
#keymap-toast.show { animation: sensitivity-toast 1.5s linear forwards; }
@keyframes sensitivity-toast { 0%, 65% { opacity: 1; } 100% { opacity: 0; } }

.pad-outline, .pad-button { vector-effect: non-scaling-stroke; }

/* DualSense silhouette and distinct control families. */
.pad-outline { fill: #ffffff0a; stroke: #929a8c; stroke-width: 1.5; }
.pad-panel { fill: none; stroke: #6b736555; stroke-width: 1; }
.pad-stick-disc { fill: #ffffff06; stroke: #899580; stroke-width: 1; }
.pad-dpad { fill: #242822; stroke: #899580; stroke-width: 1; stroke-linejoin: round; }
.pad-dpad-direction .pad-button { fill: transparent; stroke: none; }
.pad-dpad-direction:hover .pad-button, .pad-dpad-direction:focus .pad-button { stroke: #dafa9c; }
.pad-key { width: 100%; }
.keymap-mouse-summary { fill: #aab3a3; font: 10px system-ui; }
.pad-outline, .pad-stick-disc, .pad-dpad, .pad-panel { pointer-events: none; vector-effect: non-scaling-stroke; }
.keymap-pad-help { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }

.pad-region:has(.pad-caption) .pad-name { display: none; }
.pad-caption { font-size: 10px; line-height: 14px; height: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text, #ddd); }
.pad-caption .keymap-label-input { height: 16px; padding: 0 1px; line-height: 14px; }
.keymap-action-label { cursor: text; min-width: 0; overflow-wrap: anywhere; border-radius: 4px; }
.keymap-action-label:focus-visible { outline: 2px solid var(--accent, #63d8d1); }
.keymap-label-input { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; font: inherit; padding: 2px 4px; }

/* Keep the complete controller in the first screen; secondary settings follow. */
.keymap-content { display: flex; flex-direction: column; }
.keymap-content > .keymap-field { order: -5; margin: 0 0 6px; }
#keymap-views { order: -4; margin: 0 0 6px; }
#keymap-modes { order: -3; margin: 0 0 6px; }
#keymap-pad { order: -2; }
#keymap-status { order: -1; }
#keymap-status:empty { display: none; }
.keymap-pad { width: auto; height: auto; max-width: 100%; max-height: calc(100dvh - 260px); }
.pad-region[data-action="SHARE"] .pad-caption,
.pad-region[data-action="OPTIONS"] .pad-caption { text-overflow: clip; overflow: visible; }
.keymap-drawer { display: flex; flex-direction: column; overflow-y: hidden; }
.keymap-drawer header { flex: 0 0 auto; }
.keymap-content { overflow-y: auto; min-height: 0; }
