:root {
  --bg: #0f1115;
  --panel: #181b22;
  --line: #2a2f3a;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #4da3ff;
  --danger: #ff5a5f;
  --ok: #3ccf8e;
  --warn: #ffb547;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 22px; margin: 16px 0 8px; }
.warn { margin: 0 0 12px; color: var(--warn); font-weight: 600; }
.help { margin: 10px 0 0; color: var(--muted); }

fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 8px 12px 12px; }
legend { color: var(--muted); padding: 0 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.chips span {
  display: inline-flex; align-items: center; min-height: 52px;
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px;
}
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: #001428; font-weight: 600; }
.chips input:focus-visible + span { outline: 3px solid var(--text); outline-offset: 2px; }

.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.check { display: flex; gap: 10px; align-items: center; min-height: 52px; }
.check input { width: 28px; height: 28px; }
.range { display: flex; gap: 10px; align-items: center; }
.range input { width: 220px; height: 32px; }

.controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 4px 0 8px; }
.btn {
  font: inherit; font-weight: 700; color: var(--text);
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 18px; min-height: 56px; cursor: pointer; touch-action: manipulation;
}
.btn.big { min-height: 88px; font-size: 26px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.35; cursor: default; }
#start { background: var(--accent); border-color: var(--accent); color: #001428; }
#stop { background: var(--danger); border-color: var(--danger); color: #2a0002; }
#send, #recoverSend { background: var(--ok); border-color: var(--ok); color: #00261a; }

.status { min-height: 1.4em; color: var(--muted); margin: 0 0 12px; font-size: 20px; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.m { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.k { display: block; color: var(--muted); font-size: 15px; }
.v { display: block; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

.banner { background: #2a2210; border: 1px solid var(--warn); border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.banner p { margin: 0 0 10px; }

.result pre, .env pre {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 16px;
}
.env { margin-top: 12px; }
.env summary { cursor: pointer; color: var(--muted); min-height: 48px; display: flex; align-items: center; }
.foot { color: var(--muted); font-size: 14px; }

@media (max-width: 800px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr; }
}
