:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e4e9f1;
  --text: #182230;
  --muted: #667085;
  --accent: #2563eb;
  --accent-soft: #eef4ff;
  --danger: #dc2626;
  --radius: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 22px; background: #0f172a; color: #fff; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; background: #2563eb;
  display: grid; place-items: center; font-weight: 900; font-size: 16px;
}
.topbar h1 { margin: 0; font-size: 16px; letter-spacing: .3px; }
.topbar p { margin: 2px 0 0; color: #94a3b8; font-size: 11px; }
.pair { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pair input {
  width: 118px; height: 34px; border: 1px solid #334155; border-radius: 9px;
  background: #1e293b; color: #fff; padding: 0 10px; font-size: 12px;
}
.pair button, .actions button, .settings-actions button, .panel-head button {
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid #d0d7e2;
  background: #fff; color: #344054; font-weight: 700; font-size: 12px; cursor: pointer;
}
.pair button,
.actions .primary,
.settings-actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.account { color: #cbd5e1; font-size: 12px; font-weight: 700; }

/* 布局 */
.dashboard {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px; max-width: 1320px; margin: 0 auto; padding: 16px 20px 32px;
}
.col-7 { grid-column: span 7; }
.col-5 { grid-column: span 5; }
.col-12 { grid-column: span 12; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; font-size: 14px; }
.panel-head button { height: 30px; padding: 0 10px; font-size: 11px; }

/* 角色 */
.character-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.name { font-size: 26px; font-weight: 900; letter-spacing: .5px; }
.meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.pill {
  display: inline-block; padding: 4px 9px; border-radius: 999px;
  background: var(--accent-soft); color: #1d4ed8; font-size: 11px; font-weight: 700;
}
.bars { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.stat {
  display: grid; grid-template-columns: 34px 1fr 48px; gap: 8px;
  align-items: center; font-size: 11px; font-weight: 700;
}
.bar { height: 10px; border-radius: 999px; background: #edf1f7; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; }
.stat.hp .bar i { background: #ef4444; }
.stat.mp .bar i { background: #3b82f6; }
.stat.exp .bar i { background: #eab308; }
.numbers { margin-top: 10px; color: var(--muted); font-size: 12px; }
.level-eta { margin-top: 5px; color: #2563eb; font-size: 12px; font-weight: 700; }

/* 状态 */
.status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  background: #f2f4f7; color: #667085; font-size: 10px; font-weight: 700;
}
.badge.ok { background: #e7f8f0; color: #087a55; }
.badge.err { background: #fff0f0; color: #b42318; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.55; }
.ocr-state {
  margin: 6px 0 8px; padding: 6px 8px; border-radius: 8px;
  background: #f8fafc; color: #475467; font-size: 11px; font-weight: 700;
}
.ocr-raw { margin: 0 0 8px; font-size: 11px; color: var(--muted); }
.ocr-raw summary { cursor: pointer; font-weight: 700; }
.ocr-raw pre {
  margin: 6px 0 0; padding: 8px; max-height: 160px; overflow: auto;
  background: #0f172a; color: #dbe4f0; border-radius: 8px;
  font-size: 10px; line-height: 1.5; white-space: pre-wrap;
}
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tip {
  margin-top: 12px; padding: 8px 10px; border-radius: 9px;
  background: #f8fafc; color: #64748b; font-size: 11px;
}

/* 按键设置 */
.settings-card { padding: 14px 16px 16px; }
.settings-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.settings-toggle {
  height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: #475467; font-size: 11px; font-weight: 700; cursor: pointer;
}
.settings-card.collapsed .settings-actions,
.settings-card.collapsed .key-grid,
.settings-card.collapsed .settings-head p { display: none; }
.settings-card.collapsed { padding-bottom: 14px; }
.settings-card.collapsed .settings-head { margin-bottom: 0; }
.settings-head h2 { margin: 0; font-size: 14px; }
.settings-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode-select {
  height: 34px; min-width: 150px; border: 1px solid var(--border); border-radius: 9px;
  padding: 0 9px; background: #fff; font-size: 12px; font-weight: 700; color: #344054;
}
.key-grid { display: flex; flex-direction: column; gap: 12px; }
.key-section {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  background: #fbfcfe;
}
.key-section h3 {
  margin: 0 0 10px; font-size: 12px; color: #344054;
  display: flex; align-items: center; gap: 8px;
}
.key-section h3::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.field-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--muted); font-weight: 700; }
.field input[type="number"], .field select {
  height: 30px; padding: 3px 7px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 12px; font-weight: 600;
}
.field input[type="number"] { width: 74px; }
.key-select {
  height: 30px; padding: 3px 7px; border: 1px solid #c7d7f5; border-radius: 8px;
  background: var(--accent-soft); color: #1d4ed8; font-size: 12px; font-weight: 800;
}
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: #344054; }

/* 实时画面 */
.preview-card { display: flex; flex-direction: column; }
#viewWrap {
  margin-top: 4px; border-radius: 12px; overflow: hidden; background: #0f172a;
}
#viewImage { display: block; width: 100%; max-height: 360px; object-fit: contain; }
.preview-placeholder {
  display: grid; place-items: center; min-height: 150px; margin-top: 4px;
  border: 1px dashed #cbd5e1; border-radius: 12px; color: var(--muted); font-size: 12px;
}

/* 拾取记录 */
.loot-list {
  display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px;
}
.loot-item {
  padding: 5px 9px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: #f2f4f7; color: #475467;
}
.loot-item.scroll { background: #f3e8ff; color: #7e22ce; }

/* 测谎记录 */
.vision-card { display: flex; flex-direction: column; }
.vision-list {
  display: flex; flex-direction: column; gap: 6px; min-height: 120px;
  max-height: 300px; overflow: auto; padding: 2px 0;
}
.vision-event {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 9px; border-radius: 9px; font-size: 12px;
  background: #f8fafc; color: #475467;
}
.vision-time { color: #98a2b3; font-size: 11px; font-variant-numeric: tabular-nums; }
.vision-event.success { background: #e9f9f1; color: #087a55; font-weight: 800; }
.vision-event.failed { background: #fff0f0; color: #b42318; font-weight: 800; }
.vision-event.detected { background: #f2f4f7; color: #667085; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  .col-7, .col-5, .col-12 { grid-column: span 12; }
  .dashboard { padding: 12px; gap: 10px; }
  .topbar { padding: 10px 14px; }
  .name { font-size: 22px; }
  .settings-head { flex-direction: column; }
  .settings-actions { width: 100%; }
  .mode-select { flex: 1; min-width: 120px; }
}
