:root {
  --bg: #0e1116; --panel: #161b22; --edge: #2a313c; --fg: #e6edf3;
  --dim: #8b949e; --accent: #1f6feb; --danger: #b62324; --ok: #2ea043;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
header {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--edge);
}
.brand { font-weight: 700; font-size: 16px; }
.spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 8px; color: var(--dim); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.status.online .dot { background: var(--ok); }
.status.mock .dot { background: #d29922; }
.pagenav { display: flex; align-items: center; gap: 8px; }
.pagenav span { color: var(--dim); min-width: 80px; text-align: center; }

main { flex: 1; display: flex; min-height: 0; }
#deck-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; min-width: 0; }
.hint { color: var(--dim); font-size: 12px; }
#log {
  width: min(560px, 90%); height: 88px; overflow-y: auto; margin-top: 14px;
  font: 11px/1.5 ui-monospace, monospace; color: var(--dim);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; padding: 8px 10px;
}
#log div { white-space: nowrap; }

.deck {
  display: grid; gap: 14px; padding: 22px;
  background: linear-gradient(160deg, #191f27, #10141b);
  border: 1px solid var(--edge); border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.key {
  position: relative; width: 84px; height: 84px; border-radius: 10px;
  background: #05070a; border: 2px solid var(--edge); overflow: hidden;
  cursor: pointer; transition: transform .06s, border-color .12s, box-shadow .12s;
}
.key canvas { width: 100%; height: 100%; display: block; image-rendering: auto; }
.key .idx {
  position: absolute; right: 3px; bottom: 1px; font: 9px ui-monospace, monospace;
  color: rgba(255,255,255,.45); pointer-events: none;
}
.key:hover { border-color: var(--dim); }
.key.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,235,.35); }
.key.pressed { transform: scale(.92); box-shadow: 0 0 18px rgba(255,255,255,.45); }
.key.dropok { border-color: var(--ok); border-style: dashed; }

#panel {
  width: 300px; background: var(--panel); border-left: 1px solid var(--edge);
  padding: 16px; overflow-y: auto; flex-shrink: 0;
}
#panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 18px 0 8px; }
#panel h2:first-child { margin-top: 0; }
.group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.group.row { flex-direction: row; }
.group.row > * { flex: 1; min-width: 0; }
label { font-size: 12px; color: var(--dim); }
button {
  background: #21262d; color: var(--fg); border: 1px solid var(--edge);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit;
}
button:hover { background: #2a313a; border-color: var(--dim); }
button.danger { border-color: #672a2b; color: #ff8182; }
input, select {
  background: #0d1117; color: var(--fg); border: 1px solid var(--edge);
  border-radius: 6px; padding: 6px 8px; font: inherit; width: 100%;
}
input[type="color"] { padding: 2px; height: 34px; }
input[type="file"] { display: none; }
input[type="range"] { width: 100%; }
#device-info { font: 11px/1.6 ui-monospace, monospace; color: var(--dim); margin-top: 16px; }
#device-info b { color: var(--fg); }
