/* ============================================================
   G3M PRO console — Teenage Engineering 风格
   铝灰机身 · 平面板 · 2px 墨线 · 键帽按钮 · 橙/蓝/绿/白
   ============================================================ */

:root {
  --body: #cfcfca;         /* 铝灰 */
  --panel: #e9e9e5;        /* 面板 */
  --panel-hi: #f7f7f4;     /* 键帽面 */
  --ink: #1e1e1c;          /* 墨色 */
  --ink-soft: #75756e;     /* 弱文字 */
  --orange: #ff4b00;       /* TE 橙 */
  --blue: #2559f5;
  --green: #00a35c;
  --lcd-bg: #201f1b;       /* 显示屏 */
  --lcd-fg: #e9e7da;       /* 屏显字 */
  --lcd-dim: #6f6d60;
  --line: 2px solid var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--body);
  background-image: linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px);
  background-size: 100% 28px;
  color: var(--ink);
  font: 13px/1.5 "Helvetica Neue", Helvetica, Arial, "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: var(--ink);
  color: #f2f2ee;
  border-bottom: 4px solid var(--orange);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px;
  background: var(--orange); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 11px; letter-spacing: .5px;
}
.brand-name { font-size: 16px; font-weight: 750; letter-spacing: .3px; }
.brand-sub { font-size: 10px; font-weight: 500; color: #9a9a94; letter-spacing: 1.5px; margin-left: 6px; }
.brand-model { font-size: 10px; color: #9a9a94; letter-spacing: 1.2px; margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* LED 状态 */
.led {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  color: #9a9a94;
}
.led::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4a4a45; }
.led.on { color: #f2f2ee; }
.led.on::before { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ---------- 键帽按钮 ---------- */

.key {
  appearance: none;
  background: var(--panel-hi);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 8px 16px;
  font: 700 11px/1 "Helvetica Neue", Arial, "Microsoft YaHei UI", sans-serif;
  letter-spacing: 1.2px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: background .1s;
}
.key:hover { background: #fff; }
.key:active { transform: translateY(3px); box-shadow: none; }
.key:disabled { opacity: .35; box-shadow: 0 3px 0 var(--ink); cursor: not-allowed; }
.key-orange { background: var(--orange); color: #fff; }
.key-orange:hover { background: #ff5c14; }
.key-s { padding: 6px 11px; font-size: 10px; }

/* ---------- 布局 ---------- */

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 22px 60px;
  display: flex; flex-direction: column; gap: 14px;
}

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 780px) { .cols { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: var(--line);
  border-radius: 0;
  padding: 14px 16px 16px;
  box-shadow: 0 4px 0 rgba(30,30,28,.28);
}

.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: var(--line);
}
.panel-no {
  font: 800 11px/1 "Helvetica Neue", Arial, sans-serif;
  background: var(--ink); color: var(--panel);
  padding: 4px 7px; border-radius: 2px;
}
.panel-title { font-size: 12px; font-weight: 800; letter-spacing: 1.6px; }
.panel-title em { font-style: normal; font-weight: 500; color: var(--ink-soft); letter-spacing: .5px; font-size: 11px; }
.panel-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.group-label {
  font-size: 10px; font-weight: 800; letter-spacing: 1.8px;
  color: var(--ink-soft);
  margin: 16px 0 8px;
}
.group-label-info { font-weight: 500; letter-spacing: .3px; color: var(--orange); }

.status-line { font-size: 11.5px; color: var(--ink-soft); min-height: 18px; }
.status-line.err { color: #c81e00; font-weight: 600; }
.status-line.ok { color: var(--green); font-weight: 600; }

.tiny { font-size: 10.5px; color: var(--ink-soft); }

.hint {
  max-width: 956px; margin: 12px auto 0;
  padding: 10px 14px;
  background: var(--panel); border: var(--line); border-radius: 8px;
  font-size: 12px;
}
.hidden { display: none; }

/* ---------- 档位键帽 ---------- */

.stage-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
@media (max-width: 780px) { .stage-row { grid-template-columns: repeat(4, 1fr); } }

.stage-tile {
  position: relative;
  background: var(--panel-hi);
  border: 2px solid var(--ink);
  border-radius: 2px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 10px 4px 8px;
  text-align: center;
  cursor: pointer;
  transition: background .1s;
}
.stage-tile:hover { background: #fff; }
.stage-tile:active { transform: translateY(3px); box-shadow: none; }
.stage-tile.active { background: var(--ink); color: var(--panel-hi); }
.stage-tile.active .idx { color: #a5a59e; }
.stage-tile .active-tag {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: var(--orange); color: #fff;
  font-size: 9px; font-weight: 800; letter-spacing: 1px;
  padding: 1px 7px; border-radius: 0; white-space: nowrap;
}
.stage-tile .dot {
  width: 14px; height: 14px; border-radius: 50%;
  margin: 0 auto 6px;
  border: 2px solid rgba(0,0,0,.18);
}
.stage-tile.active .dot { border-color: rgba(255,255,255,.4); }
.stage-tile .dpi { font: 800 15px/1.1 ui-monospace, "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.stage-tile .idx { font-size: 9px; letter-spacing: 1px; color: var(--ink-soft); margin-top: 3px; }

.empty {
  grid-column: 1 / -1;
  border: 2px dashed #b9b9b2; border-radius: 0;
  padding: 20px; text-align: center;
  font-size: 11.5px; color: var(--ink-soft);
}

/* ---------- 编辑行 ---------- */

.dpi-editor { display: flex; flex-direction: column; gap: 6px; }
.dpi-row {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-hi);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 5px 9px;
}
.dpi-row .lbl { width: 46px; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--ink-soft); }
.dpi-row input[type="number"] { width: 84px; }
.dpi-row .cur-mark { margin-left: auto; font-size: 9.5px; font-weight: 800; letter-spacing: 1px; color: var(--orange); }

.hexin {
  background: #fff; border: 1.5px solid var(--ink);
  color: var(--ink); border-radius: 2px;
  font: 600 12px ui-monospace, "Cascadia Mono", Consolas, monospace;
  padding: 5px 7px;
}
.hexin:focus { outline: 2px solid var(--orange); outline-offset: 0; }
.wided { flex: 1; min-width: 240px; }

input[type="color"] {
  width: 34px; height: 26px;
  border: 1.5px solid var(--ink); border-radius: 5px;
  background: #fff; padding: 1px; cursor: pointer; border-radius: 0;
}

/* ---------- 回报率 ---------- */

.rate-row { display: flex; align-items: center; gap: 10px; }
.seg-row { display: inline-flex; gap: 6px; }
.key-seg { padding: 7px 13px; }
.key-seg.active { background: var(--orange); color: #fff; }
.rate-unit { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--ink-soft); }

/* ---------- LCD 显示屏 ---------- */

.lcd {
  background: var(--lcd-bg);
  color: var(--lcd-fg);
  border-radius: 0;
  border: 2px solid var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.lcd-batt {
  display: inline-flex; align-items: baseline; gap: 3px;
  padding: 7px 12px;
}
.lcd-label { font-size: 9px; letter-spacing: 1.5px; color: var(--lcd-dim); margin-right: 5px; }
.lcd-num { font-size: 20px; font-weight: 700; color: var(--orange); font-variant-numeric: tabular-nums; }
.lcd-unit { font-size: 10px; color: var(--lcd-dim); }

.batt-body { display: flex; gap: 16px; align-items: stretch; }
.lcd-big {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 18px; min-width: 148px;
}
.lcd-big .lcd-num { font-size: 42px; }
.lcd-track { width: 100%; height: 8px; background: #3a382f; border-radius: 4px; overflow: hidden; }
.lcd-bar { height: 100%; width: calc(var(--pct, 0) * 1%); background: var(--orange); transition: width .4s; }

.batt-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
#battery-history { border: 2px solid var(--ink); border-radius: 8px; background: var(--lcd-bg); max-width: 100%; }

.chip {
  align-self: flex-start;
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  background: var(--panel-hi); border: 1.5px solid var(--ink);
  border-radius: 0; padding: 3px 8px; color: var(--ink-soft);
}
.chip.ok { background: var(--green); border-color: var(--green); color: #fff; }
.chip.warn { background: #ffd23f; border-color: #ffd23f; color: var(--ink); }
.chip.err { background: #c81e00; border-color: #c81e00; color: #fff; }

/* ---------- 设备 ---------- */

.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.kv dt { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--ink-soft); }
.kv dd { margin: 0; font: 600 11.5px ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; }

.collections { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; line-height: 1.8; }
.collections .col { border-bottom: 1px dashed #b9b9b2; padding: 2px 0; }
.collections .col:last-child { border-bottom: 0; }
.collections .tag { color: var(--blue); font-weight: 700; }

/* ---------- 监听 ---------- */

.lcd-log {
  height: 180px; overflow: auto;
  padding: 10px 12px; margin: 0;
  font-size: 10.5px; line-height: 1.7;
  white-space: pre-wrap; color: #b8d8a8;
}

.chk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--ink); font-weight: 700; letter-spacing: .5px; }
.chk input { accent-color: var(--orange); }

/* ---------- 折叠 / 控制台 ---------- */

details.fold { margin-top: 14px; }
details.fold summary {
  cursor: pointer; list-style: none;
  font-size: 10px; font-weight: 800; letter-spacing: 1.8px; color: var(--ink-soft);
  padding: 4px 0;
}
details.fold summary:hover { color: var(--ink); }
details.fold[open] summary { margin-bottom: 8px; }

details.fold-panel > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px;
}
details.fold-panel > summary::-webkit-details-marker { display: none; }
details.fold-panel > summary .panel-title { color: var(--ink-soft); }
details.fold-panel[open] > summary { padding-bottom: 10px; margin-bottom: 12px; border-bottom: var(--line); }
details.fold-panel[open] > summary .panel-title { color: var(--ink); }

.console-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.console-row label { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--ink-soft); }

.sel {
  background: var(--panel-hi); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 2px;
  font: 600 11px "Helvetica Neue", Arial, "Microsoft YaHei UI", sans-serif;
  padding: 5px 6px;
}

.foot { text-align: center; padding: 6px 0 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #a5a59e; border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- keymap（改键） ---- */
.keymap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 780px) { .keymap-grid { grid-template-columns: 1fr; } }
.km-row {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-hi);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 5px 9px;
}
.km-row .lbl { width: 78px; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--ink-soft); flex: none; }
.km-row .sel { flex: 1 1 auto; min-width: 0; }
.km-row .muted.small { font-size: 9px; }
.stage-tile.disabled { opacity: .45; }
.stage-tile.disabled .dpi { color: var(--ink-soft); }
