:root {
  --bg: #0e1117;
  --bg2: #151a23;
  --card: #1a2130;
  --line: #2a3446;
  --txt: #e6ebf5;
  --muted: #8b97ab;
  --accent: #4ade80;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --blue: #60a5fa;
}

* { box-sizing: border-box; }

/* 作者样式的 display 会压过 UA 的 [hidden]，这里显式兜底 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(1200px 700px at 15% -10%, #1b2b4d 0%, transparent 55%), var(--bg);
  color: var(--txt);
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 12px 20px;
  background: rgba(14, 17, 23, .82);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.brand h1 { margin: 0; font-size: 16px; letter-spacing: .5px; }
.brand .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; }
.pill.on .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.pill.on { color: var(--accent); border-color: #2c5c42; }
.pill .dot.busy { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.inst { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }

input, select, button { font-family: inherit; font-size: 13px; }

input[type=number], input[type=password], select {
  background: #0f141d; color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; outline: none;
}
input[type=number] { width: 76px; }
input:focus, select:focus { border-color: var(--blue); }

button {
  background: #222c3d; color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
  transition: .15s;
}
button:hover:not(:disabled) { background: #2b374b; border-color: #3c4a63; }
button:disabled { opacity: .42; cursor: not-allowed; }
button.primary { background: #1d4ed8; border-color: #2563eb; }
button.primary:hover:not(:disabled) { background: #2563eb; }
button.accent { background: #166534; border-color: #22c55e; }
button.accent:hover:not(:disabled) { background: #15803d; }
button.danger { background: #7f1d1d; border-color: #b91c1c; }
button.danger:hover:not(:disabled) { background: #991b1b; }
button.mini { padding: 4px 9px; font-size: 12px; }

/* ---------------------------------------------------------------- 布局 */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(360px, 1fr) 320px;
  gap: 14px;
  padding: 16px 20px 8px;
  align-items: start;
}
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }

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

.card {
  background: linear-gradient(180deg, rgba(26,33,48,.92), rgba(21,26,35,.92));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
}
.card h2 {
  margin: 0 0 10px; font-size: 13px; font-weight: 600;
  color: #cbd5e1; letter-spacing: .4px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.btns { display: flex; flex-wrap: wrap; gap: 7px; }
.meta { color: var(--muted); font-size: 12px; margin-top: 9px; line-height: 1.6; white-space: pre-wrap; }

/* ---------------------------------------------------------------- 画面 */
.screenwrap {
  position: relative; border-radius: 10px; overflow: hidden;
  background: #05070b; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
}
.screenwrap img { display: block; width: 100%; height: auto; cursor: crosshair; }
.screenhint {
  position: absolute; color: var(--muted); font-size: 12px;
  background: rgba(0,0,0,.45); padding: 6px 12px; border-radius: 8px;
}

/* ---------------------------------------------------------------- 地块 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.grid button {
  padding: 7px 0; font-family: Consolas, monospace; font-size: 12px;
  background: #131a26; border-radius: 6px;
}
.grid button.sel { background: #1d4ed8; border-color: #3b82f6; color: #fff; }
.grid button.done { opacity: .45; }

/* ---------------------------------------------------------------- 表单 */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.form label input, .form label select { width: 100%; }
.form label:nth-child(1) { grid-column: 1 / -1; }

.switch { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; font-weight: 400; }

/* ---------------------------------------------------------------- 队列 */
.queueadd { display: flex; gap: 6px; margin-bottom: 9px; }
.queueadd select { flex: 1; }
.queueadd input { width: 58px; }
.queue { list-style: none; margin: 0 0 9px; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow: auto; }
.queue li {
  display: flex; align-items: center; gap: 7px;
  background: #131a26; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 12px;
}
.queue .name { flex: 1; }
.queue .rounds { color: var(--muted); }
.queue li.done { opacity: .5; }
.queue li.current { border-color: var(--accent2); box-shadow: inset 0 0 0 1px #14532d; }
.queue button { padding: 1px 6px; font-size: 11px; background: #1b2432; }

/* ---------------------------------------------------------------- 日志 */
.logpanel { margin: 4px 20px 24px; }
.loghead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.loghead h2 { margin: 0; font-size: 13px; color: #cbd5e1; font-weight: 600; }
#log {
  margin: 0; height: 230px; overflow: auto;
  background: #080b11; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px; line-height: 1.65; color: #c7d2e0; white-space: pre-wrap;
}
#log .t { color: #4b5a70; margin-right: 7px; }
#log .info { color: #c7d2e0; }
#log .ok { color: var(--accent); }
#log .warn { color: var(--warn); }
#log .error { color: var(--err); }

.tokenbar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; background: #2a1f0c; border-bottom: 1px solid #4a3410;
  color: var(--warn); font-size: 13px;
}
.tokenbar input { width: 220px; }
