:root {
  --bg: #070a0f;
  --panel: #0d131a;
  --panel-2: #131a23;
  --border: #1c232e;
  --text: #dde3ec;
  --muted: #76808f;
  --accent: #3b6ef6;
  --ok: #37b981;
  --warn: #e0a13c;
  --err: #e2564f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: .3px;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  transition: background .2s;
}
.dot.starting { background: var(--warn); }
.dot.awaiting_login, .dot.awaiting_pair { background: var(--warn); }
.dot.paired { background: var(--ok); }
.dot.error { background: var(--err); }
.dot.closed { background: var(--muted); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
  gap: 16px;
  padding: 16px 20px 28px;
  align-items: start;
}

.stage {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #0b0d11;
  outline: none;
  cursor: default;
}

canvas:focus { box-shadow: inset 0 0 0 2px var(--accent); }

.hint {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.status-line {
  font-size: 15px;
  margin-bottom: 4px;
}

.status-sub { color: var(--muted); font-size: 12px; }

ol.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}
ol.steps li { margin: 6px 0; }
ol.steps li.active { color: var(--text); }
ol.steps li.done { color: var(--ok); }

.log {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 190px;
  overflow-y: auto;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}
.log li { padding: 1px 0; white-space: pre-wrap; word-break: break-all; }

.kv {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}
.kv dt { color: var(--muted); }
.kv dd {
  margin: 0;
  font-family: Consolas, monospace;
  word-break: break-all;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: linear-gradient(135deg, #3b6ef6, #8a5cf6);
  border-color: transparent;
  color: #fff;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.hidden { display: none !important; }

.banner {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.banner.warn { border-color: #5a4a1e; background: #241d10; color: #e8cf97; }
.banner.err { border-color: #5a2222; background: #261414; color: #f0a8a8; }

code.token {
  font-family: Consolas, monospace;
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

/* ---------- 直连模式表单 ---------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); }

input, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.rows { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.row-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px; background: var(--panel-2); border-radius: 6px;
  font-family: Consolas, monospace; font-size: 12px;
}
pre.log { background: var(--panel-2); border-radius: 7px; padding: 10px; margin: 0; max-height: 260px; overflow: auto; }

/* ---------- 控制台 ---------- */

main.console {
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  align-items: start;
}
.col-left, .col-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.mapwrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}
.mapwrap canvas { display: block; width: 100%; height: auto; background: #0b0d11; }
.map-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px; text-align: center; font-size: 13px;
  color: var(--muted); background: rgba(15, 17, 21, .78);
}

.server-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.server-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.server-item.active { border-color: var(--accent); background: var(--panel-2); }
.server-main { display: flex; flex-direction: column; min-width: 0; }
.server-main strong { font-size: 13px; }
.server-main span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.icon { padding: 2px 7px; font-size: 11px; }

.team-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.team-item { display: flex; justify-content: space-between; padding: 5px 8px; border-radius: 6px; background: var(--panel-2); font-size: 13px; }
.team-item.alive { border-left: 3px solid var(--ok); }
.team-item.dead { border-left: 3px solid var(--err); opacity: .85; }
.team-item.offline { border-left: 3px solid #4b5563; opacity: .6; }
.team-item .meta { color: var(--muted); font-size: 11px; }

.badge { background: var(--panel-2); border-radius: 10px; padding: 0 6px; font-size: 11px; color: var(--muted); }
.chat-log { max-height: 150px; overflow-y: auto; font-size: 12px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.chat-line { color: var(--muted); }
.chat-line.fail { color: var(--err); }
.empty { color: var(--muted); font-size: 12px; padding: 6px 0; list-style: none; }
.stack { display: flex; flex-direction: column; gap: 0; }

@media (max-width: 1200px) {
  main.console { grid-template-columns: 1fr; }
}

/* ---------- 登录页 ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-card {
  width: 340px;
  padding: 26px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
}

.login-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.login-card .field { margin-bottom: 12px; }

.login-card button[type="submit"] {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  font-size: 14px;
}

.login-error {
  margin-top: 12px;
  min-height: 18px;
  color: var(--err);
  font-size: 12px;
}

.logout {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0 4px;
}
.logout:hover { color: var(--text); }
