/* ============================================================
   DUALSENSE HUB · 样式表
   主题：深空蓝黑 + 玻璃拟态 + 每插槽专属霓虹强调色
   ============================================================ */

:root {
  --bg: #06080e;
  --bg-soft: #0a0e18;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #0d1220;
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-soft: rgba(255, 255, 255, 0.055);
  --text: #e9eefb;
  --muted: #8b96b0;
  --muted-2: #5d6780;
  --ps: #2f8bff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 18px;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --sans: "Inter", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- 背景 ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: -3; pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 20%, transparent 78%);
}
.bg-glow {
  position: fixed; z-index: -2; width: 720px; height: 720px; border-radius: 50%;
  filter: blur(120px); opacity: 0.3; pointer-events: none;
}
.bg-glow.g1 { top: -320px; left: -180px; background: radial-gradient(circle, #1d6bff, transparent 65%); }
.bg-glow.g2 { top: -260px; right: -220px; background: radial-gradient(circle, #b04bff, transparent 65%); opacity: 0.22; }

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 16px clamp(16px, 3vw, 40px);
  background: linear-gradient(180deg, rgba(6, 8, 14, 0.92), rgba(6, 8, 14, 0.55));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--stroke-soft);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 46px; height: 46px; flex: none; border-radius: 14px;
  display: grid; place-items: center; color: #dce8ff;
  background: linear-gradient(145deg, rgba(47, 139, 255, 0.28), rgba(176, 75, 255, 0.16));
  border: 1px solid rgba(140, 180, 255, 0.25);
  box-shadow: 0 8px 26px rgba(47, 139, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.brand-mark svg { width: 28px; height: 20px; }
.brand-text h1 {
  margin: 0; font-size: 19px; letter-spacing: 2.4px; font-weight: 700;
  background: linear-gradient(92deg, #ffffff, #9fc2ff 55%, #c9a6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text h1 span { color: transparent; font-weight: 300; opacity: 0.85; }
.brand-text p { margin: 3px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.4px; }

.top-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stat {
  display: flex; align-items: baseline; gap: 3px; padding: 7px 13px;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--stroke-soft);
}
.stat-num { font-family: var(--mono); font-size: 19px; font-weight: 600; color: #fff; }
.stat-sep { color: var(--muted-2); font-family: var(--mono); }
.stat-max { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.stat-label { font-size: 11px; color: var(--muted); margin-left: 7px; letter-spacing: 0.6px; }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.sw-box {
  width: 38px; height: 21px; border-radius: 99px; position: relative;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--stroke); transition: 0.2s;
}
.sw-box i {
  position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #9aa6c0; transition: 0.22s cubic-bezier(0.4, 1.4, 0.5, 1);
}
.switch input:checked + .sw-box { background: rgba(47, 139, 255, 0.42); border-color: rgba(47, 139, 255, 0.6); }
.switch input:checked + .sw-box i { left: 19px; background: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.6); }
.switch input:focus-visible + .sw-box { outline: 2px solid var(--ps); outline-offset: 3px; }
.sw-text { font-size: 12px; color: var(--muted); }
.switch input:checked ~ .sw-text { color: var(--text); }

.btn-ghost, .mini {
  font-family: inherit; color: var(--text); cursor: pointer;
  background: var(--panel); border: 1px solid var(--stroke);
  border-radius: 10px; transition: 0.18s;
}
.btn-ghost { padding: 9px 16px; font-size: 12.5px; letter-spacing: 0.6px; }
.mini { padding: 4px 10px; font-size: 11px; color: var(--muted); }
.btn-ghost:hover, .mini:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.22); color: #fff; }
.btn-ghost:active { transform: translateY(1px); }

/* ---------- 通知条 ---------- */
.notice {
  margin: 14px auto 0; max-width: 1440px; padding: 12px 18px;
  border-radius: 14px; font-size: 13px; line-height: 1.6;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08); color: #fcd77f;
}
.notice b { color: #ffe9a8; }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1440px; margin: 0 auto; padding: 26px clamp(16px, 3vw, 40px) 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start;
}
@media (max-width: 1080px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 15px; letter-spacing: 1.6px; font-weight: 600; }
.section-head h2 em {
  font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--muted-2);
  margin-left: 8px; letter-spacing: 2px;
}
.section-head p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- 插槽网格 ---------- */
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 720px) { .slots { grid-template-columns: minmax(0, 1fr); } }

.slot {
  --accent: #4cc2ff;
  --accent-soft: rgba(76, 194, 255, 0.18);
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--stroke);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5);
  transition: border-color 0.3s, box-shadow 0.3s, opacity 0.35s;
}
.slot::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(420px circle at 50% -10%, var(--accent-soft), transparent 62%);
  transition: opacity 0.4s;
}
.slot.is-live { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.slot.is-live::before { opacity: 1; }
.slot.is-live { box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5), 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent) inset; }
.slot.is-ghost { opacity: 0.62; border-style: dashed; border-color: rgba(251, 191, 36, 0.38); }
.slot.is-ghost::before { opacity: 0; }

.slot-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--stroke-soft);
  background: rgba(255, 255, 255, 0.015);
}
.slot-id { display: flex; align-items: center; gap: 8px; flex: none; }
.idx {
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 1px;
  padding: 4px 9px; border-radius: 8px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; letter-spacing: 0.6px; padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--stroke); color: var(--muted); background: rgba(255, 255, 255, 0.04);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.1); }
.badge.on::before { animation: pulse 1.6s infinite; }
.badge.ghost { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.1); }
.badge.virtual { color: #c4a2ff; border-color: rgba(176, 75, 255, 0.4); background: rgba(176, 75, 255, 0.12); }

.dev { min-width: 0; flex: 1; }
.dev-name {
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.3px;
}
.dev-meta {
  font-family: var(--mono); font-size: 10px; color: var(--muted-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot-acts { display: flex; gap: 6px; flex: none; }

/* ---------- 舞台 ---------- */
.stage {
  position: relative; padding: 6px 10px 0;
  background:
    radial-gradient(ellipse 60% 46% at 50% 8%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 60%);
}
.stage::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 6px; height: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.62), transparent 70%);
  filter: blur(6px); pointer-events: none;
}
.pad { display: block; width: 100%; height: auto; position: relative; z-index: 1; }

.slot.is-ghost .pad { filter: grayscale(0.85) brightness(0.62) contrast(0.9); }

.ghost-tag {
  position: absolute; inset: 0; display: none; place-items: center; z-index: 4; pointer-events: none;
}
.slot.is-ghost .ghost-tag { display: grid; }
.ghost-tag span {
  font-size: 12px; letter-spacing: 3px; color: #fcd77f; text-transform: uppercase;
  padding: 9px 18px; border-radius: 99px; border: 1px dashed rgba(251, 191, 36, 0.5);
  background: rgba(20, 16, 6, 0.72); backdrop-filter: blur(4px);
}
.ghost-count {
  position: absolute; top: 10px; right: 14px; z-index: 5;
  font-family: var(--mono); font-size: 10px; color: #fcd77f; opacity: 0.8;
}

.ripples { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.ripple {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0.85;
  animation: ripple 0.62s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes ripple {
  from { transform: scale(0.3); opacity: 0.9; }
  to { transform: scale(14); opacity: 0; }
}

/* ---------- 手柄 SVG 部件 ---------- */
.shell { fill: url(#shellGrad); stroke: url(#rimGrad); stroke-width: 2.2; filter: url(#dropSoft); }
.sheen { fill: url(#sheenGrad); pointer-events: none; }
.grip-shade { fill: url(#gripGrad); pointer-events: none; }
.shoulder {
  fill: url(#btnGrad); stroke: rgba(255, 255, 255, 0.14); stroke-width: 1.4;
  filter: url(#dropTiny); transition: 0.1s;
}
.touchpad {
  fill: url(#padGrad); stroke: rgba(255, 255, 255, 0.085); stroke-width: 1.4;
  filter: url(#dropTiny);
}
.touchpad-split { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1.2; fill: none; }
.lightbar {
  fill: var(--accent); opacity: 0.55; filter: drop-shadow(0 0 10px var(--accent));
  transition: opacity 0.2s;
}
.slot.is-live .lightbar { opacity: 0.95; }
.lightbar.on { opacity: 1 !important; }

.btn { transition: transform 0.09s cubic-bezier(0.3, 0.9, 0.4, 1), filter 0.09s, opacity 0.12s; transform-box: fill-box; transform-origin: 50% 50%; }
.btn.pressed { filter: brightness(1.75) drop-shadow(0 0 9px var(--accent)); transform: scale(0.9); }

.dpad-arm { fill: url(#btnGrad); stroke: rgba(255, 255, 255, 0.1); stroke-width: 1.2; }
.dpad-hub { fill: #1d2433; stroke: rgba(255, 255, 255, 0.1); }

.fbtn-bg { fill: url(#btnGrad); stroke: rgba(255, 255, 255, 0.12); stroke-width: 1.3; filter: url(#dropTiny); }
.fbtn-glyph { fill: none; stroke: #cfd8ea; stroke-width: 3.4; stroke-linejoin: round; stroke-linecap: round; }
.btn.pressed .fbtn-glyph { stroke: #fff; }
.face-base { fill: rgba(255, 255, 255, 0.022); stroke: rgba(255, 255, 255, 0.05); }

.stick-base { fill: url(#baseGrad); stroke: rgba(255, 255, 255, 0.09); stroke-width: 1.4; }
.stick-ring { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; stroke-dasharray: 2 4; }
.stick-cap { transition: transform 55ms linear; }
.cap { fill: url(#capGrad); stroke: rgba(255, 255, 255, 0.14); stroke-width: 1.4; }
.cap-ring { fill: none; stroke: rgba(0, 0, 0, 0.45); stroke-width: 1.1; }
.cap-dimple { fill: rgba(255, 255, 255, 0.06); }

.mini-btn { fill: #283046; stroke: rgba(255, 255, 255, 0.13); stroke-width: 1.1; }
.ps-logo { fill: #9fb4dc; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-anchor: middle; }
.grille-dot { fill: #0b0e15; stroke: rgba(255, 255, 255, 0.06); stroke-width: 0.8; }
.mute-glyph { fill: none; stroke: #9fb4dc; stroke-width: 1.6; stroke-linecap: round; }

/* ---------- 遥测 ---------- */
.telemetry {
  padding: 12px 16px 15px; border-top: 1px solid var(--stroke-soft);
  display: grid; gap: 9px;
}
.tm-row { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.tm-tag {
  font-size: 9.5px; letter-spacing: 1px; color: var(--muted-2);
  border: 1px solid var(--stroke-soft); border-radius: 6px; padding: 1px 6px;
}
.tm-val { color: #cdd8ee; }
.tm-val b { color: var(--accent); font-weight: 600; }

.tg { display: flex; align-items: center; gap: 7px; flex: 1; }
.tg span { font-family: var(--mono); font-size: 10px; color: var(--muted-2); width: 20px; }
.tg-bar {
  flex: 1; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.07);
  overflow: hidden; position: relative;
}
.tg-bar i {
  position: absolute; inset: 0 100% 0 0; display: block; border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent));
  box-shadow: 0 0 10px var(--accent);
  transition: right 0.06s linear;
}

.leds { display: flex; gap: 4px; flex-wrap: wrap; }
.led {
  width: 15px; height: 15px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--stroke-soft);
  font-family: var(--mono); font-size: 8px; color: var(--muted-2);
  display: grid; place-items: center; transition: 0.08s;
}
.led.on {
  background: var(--accent); border-color: var(--accent); color: #06101c;
  box-shadow: 0 0 10px var(--accent); font-weight: 700;
}

/* ---------- 空插槽 ---------- */
.slot.is-empty .pad { opacity: 0.3; filter: grayscale(1) brightness(1.5); }
.empty-note {
  position: absolute; inset: 0; display: none; place-items: center; z-index: 4; pointer-events: none;
}
.slot.is-empty .empty-note { display: grid; }
.empty-note div {
  text-align: center; color: var(--muted-2); font-size: 12px; letter-spacing: 2px;
}
.empty-note b { display: block; font-size: 26px; font-weight: 200; color: rgba(255, 255, 255, 0.18); margin-bottom: 6px; }

/* ---------- 侧栏面板 ---------- */
.side { display: grid; gap: 16px; position: sticky; top: 92px; }
@media (max-width: 1080px) { .side { position: static; } }
.panel {
  border-radius: var(--radius); border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  overflow: hidden; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 15px; border-bottom: 1px solid var(--stroke-soft);
}
.panel-head h3 { margin: 0; font-size: 12px; letter-spacing: 1.6px; color: #cdd6e8; font-weight: 600; }
.panel-tag { font-family: var(--mono); font-size: 10px; color: var(--muted-2); }

.dev-list, .log { list-style: none; margin: 0; padding: 8px; max-height: 260px; overflow-y: auto; }
.log { max-height: 300px; }
.dev-list::-webkit-scrollbar, .log::-webkit-scrollbar { width: 6px; }
.dev-list::-webkit-scrollbar-thumb, .log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }

.dev-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 10px;
  transition: background 0.2s;
}
.dev-item:hover { background: rgba(255, 255, 255, 0.05); }
.dev-item.is-ghost { opacity: 0.55; }
.dev-item.is-ghost .dev-body strong { text-decoration: line-through; text-decoration-color: rgba(255,255,255,.35); }
.dev-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 9px currentColor; background: currentColor; }
.dev-body { min-width: 0; flex: 1; }
.dev-body strong { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-body code { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-item .pill { font-family: var(--mono); font-size: 9px; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--stroke); color: var(--muted); }

.log-item {
  display: grid; grid-template-columns: 54px 1fr; gap: 8px; align-items: baseline;
  padding: 5px 7px; border-radius: 8px; font-size: 11.5px; line-height: 1.45;
}
.log-item + .log-item { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.log-time { font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); }
.log-msg { color: #b9c4da; word-break: break-word; }
.log-msg .k {
  display: inline-block; line-height: 1.35;
  font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.08); color: #dce6f8; margin: 0 2px;
  vertical-align: baseline;
}
.log-item.ok .log-msg { color: #9ce8b6; }
.log-item.warn .log-msg { color: #fcd77f; }
.log-item.err .log-msg { color: #fda4b0; }

.keymap { padding: 10px 14px 14px; display: grid; gap: 6px; }
.km-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--muted); }
.km-row span { font-family: var(--mono); font-size: 10.5px; color: #cdd8ee; letter-spacing: 0.6px; }
.km-row i { font-style: normal; font-size: 11px; color: var(--muted-2); }

/* ---------- 底部 ---------- */
.footer {
  max-width: 1440px; margin: 0 auto; padding: 26px clamp(16px, 3vw, 40px) 56px;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px;
  border-top: 1px solid var(--stroke-soft);
}
@media (max-width: 860px) { .footer { grid-template-columns: minmax(0, 1fr); } }
.foot-col h4 { margin: 0 0 7px; font-size: 12px; letter-spacing: 1.4px; color: #cdd6e8; }
.foot-col p { margin: 0; font-size: 12px; line-height: 1.75; color: var(--muted); }
.foot-col b { color: #dbe5f7; font-weight: 600; }
.foot-col code { font-family: var(--mono); font-size: 11px; color: #9fc2ff; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; justify-items: end; }
.toast {
  padding: 11px 16px; border-radius: 12px; font-size: 12.5px; max-width: 330px;
  background: rgba(16, 21, 34, 0.95); border: 1px solid var(--stroke); color: #dbe4f5;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px);
  animation: toastIn 0.28s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.toast.warn { border-color: rgba(251, 191, 36, 0.45); color: #fcd77f; }
.toast.ok { border-color: rgba(74, 222, 128, 0.4); color: #a7f0c3; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
