/* ============================================================
 * style.css —— 苹果风视觉体系
 * ============================================================ */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --surface-3: #f0f0f3;
  --nav-bg: rgba(250, 250, 252, 0.72);

  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;

  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.12);

  --green: #34c759;
  --amber: #ff9f0a;
  --amber-soft: #fff3d6;
  --amber-text: #a85c00;
  --red: #ff3b30;
  --blue-soft: #eff4ff;

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 28px rgba(0, 0, 0, 0.05);
  --shadow-up: 0 24px 70px rgba(0, 0, 0, 0.28);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #242426;
  --surface-3: #2c2c2e;
  --nav-bg: rgba(22, 22, 24, 0.72);

  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #8e8e93;

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.18);

  --amber-soft: rgba(255, 159, 10, 0.16);
  --amber-text: #ffc76b;
  --blue-soft: rgba(10, 132, 255, 0.12);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1100px 560px at 8% -12%, rgba(0, 113, 227, 0.10), transparent 62%),
    radial-gradient(860px 460px at 102% -6%, rgba(255, 159, 10, 0.09), transparent 58%),
    var(--bg);
  background-attachment: fixed;
}

[data-theme="dark"] body {
  background:
    radial-gradient(1000px 520px at 8% -12%, rgba(10, 132, 255, 0.16), transparent 62%),
    radial-gradient(800px 440px at 102% -6%, rgba(255, 159, 10, 0.08), transparent 58%),
    var(--bg);
  background-attachment: fixed;
}

button, input, select, textarea { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* ---------------- 顶栏 ---------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  height: 100%;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0a84ff, #0058c7);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.35);
}
.logo svg { width: 17px; height: 17px; }
.brand-text em { font-style: normal; font-weight: 500; color: var(--text-2); }
.ver {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 1px 6px;
}

.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.conn-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); transition: background .2s; }
.conn-pill.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.16); }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .18s, color .18s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------------- 分段控件 ---------------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border-radius: 10px;
}
.seg-item {
  border: 0;
  background: transparent;
  padding: 6px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .18s var(--ease);
  white-space: nowrap;
}
.seg-item:hover { color: var(--text); }
.seg-item.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
}
.segmented.small .seg-item { padding: 5px 12px; font-size: 12.5px; }

/* ---------------- 主体布局 ---------------- */

.app {
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view { flex: 1; display: none; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 16px 20px 6px;
}

.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane-left { flex: 0 0 440px; }
.pane-right { flex: 1 1 0; }

.pane-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
  padding-bottom: 8px;
}

.splitter {
  flex: 0 0 14px;
  position: relative;
  cursor: col-resize;
  user-select: none;
}
.splitter span {
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background .18s;
}
.splitter:hover span, .splitter.dragging span { background: var(--accent); }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 15px 16px 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-actions { display: flex; align-items: center; gap: 6px; }

.hint {
  margin: 2px 0 10px;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ---------------- 按钮 ---------------- */

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .16s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 113, 227, 0.3);
}
.btn.primary:hover { background: var(--accent-hover); }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }

.btn.tiny {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn.danger { color: var(--red); border-color: rgba(255, 59, 48, 0.3); }
.btn.danger:hover { background: rgba(255, 59, 48, 0.08); }

.count-pill {
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--surface-3);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ---------------- 表单 ---------------- */

.field, .mini-select {
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
  min-width: 0;
}
.field:focus, .mini-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field::placeholder { color: var(--text-3); }
.field.mono { font-family: var(--mono); }
.mini-select { height: 26px; font-size: 11.5px; padding: 0 6px; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px 2px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.switch-row input { display: none; }
.switch {
  width: 38px;
  height: 22px;
  border-radius: 22px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  flex: 0 0 auto;
  transition: background .2s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform .2s var(--ease);
}
input:checked + .switch { background: var(--green); border-color: transparent; }
input:checked + .switch::after { transform: translateX(16px); }
.switch-label { flex: 0 0 auto; }
.switch-row .mini-select { margin-left: auto; }

/* ---------------- Mode 列表 ---------------- */

.mode-list { display: flex; flex-direction: column; }

.mode-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 82px 96px 24px;
  gap: 6px;
  align-items: center;
  padding: 5px 0;
}
.mode-row .idx {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.mode-row input { width: 100%; }
.mode-row .sid-label {
  font-size: 10.5px;
  color: var(--text-3);
  position: absolute;
  transform: translate(10px, -7px);
  background: var(--surface);
  padding: 0 3px;
  pointer-events: none;
}
.mode-row .sid-wrap { position: relative; }

.mini-select.mode-set {
  height: 30px;
  font-size: 11px;
  padding: 0 4px;
  width: 100%;
}
.mini-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-3);
  color: var(--text-3);
}
.mode-set.init-locked { color: var(--text-3); }
.switch-note { margin-left: auto; font-size: 10.5px; color: var(--text-3); }

/* Mode 名称下拉 */
.combo { position: relative; min-width: 0; }
.combo .mode-name { padding-right: 24px; }
.combo-btn {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.combo-btn svg { width: 9px; height: 6px; }
.combo-btn:hover { background: var(--surface-3); color: var(--text); }

.combo-menu {
  position: fixed;
  z-index: 400;
  min-width: 132px;
  max-height: 268px;
  overflow: auto;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
  animation: menuIn .14s var(--ease);
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-3px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.combo-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.combo-menu button:hover { background: var(--accent-soft); color: var(--accent); }

.row-del {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all .15s;
}
.row-del:hover { background: rgba(255, 59, 48, 0.1); color: var(--red); }

/* ---------------- 拖拽上传 ---------------- */

.dropzone {
  margin-top: 10px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s var(--ease);
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dz-icon {
  width: 34px;
  height: 34px;
  margin: 0 auto 8px;
  color: var(--accent);
  display: grid;
  place-items: center;
}
.dz-icon svg { width: 26px; height: 26px; }
.dz-title { font-size: 12.5px; color: var(--text); }
.dz-title u { color: var(--accent); text-decoration: none; }
.dz-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ---------------- Setting 卡片 ---------------- */

.setting-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.setting-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 10px;
  transition: border-color .18s, box-shadow .18s;
}
.setting-card:hover { border-color: var(--border-strong); }

.setting-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.setting-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.setting-file {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setting-card textarea {
  width: 100%;
  min-height: 92px;
  max-height: 340px;
  resize: vertical;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.setting-card textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.setting-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-3);
}

/* ---------------- 结果区 ---------------- */

.result-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.result-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.result-actions { display: flex; gap: 8px; }

.result-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  position: relative;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .26s var(--ease); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.empty {
  height: 100%;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-3);
  text-align: center;
}
.empty.hidden { display: none; }
.empty-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--text-3);
  margin-bottom: 6px;
}
.empty-mark svg { width: 26px; height: 26px; }
.empty h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty p { margin: 0; font-size: 12.5px; }

/* ---------------- 统计卡 ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
}
.stat b {
  display: block;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat span { font-size: 11.5px; color: var(--text-2); }
.stat.warn b { color: var(--amber); }
.stat.ok b { color: var(--green); }

/* ---------------- 提示条 ---------------- */

.alert {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--amber-soft);
  color: var(--amber-text);
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 10px;
}
.alert.info { background: var(--blue-soft); color: var(--accent); }
.alert b { font-weight: 600; }

/* ---------------- 分组标题 ---------------- */

.sec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 18px 0 9px;
}
.sec-title:first-child { margin-top: 0; }
.sec-title .badge {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ---------------- 寄存器网格 ---------------- */

.reg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 4px 8px;
}
.reg-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 11.5px;
  transition: background .14s;
}
.reg-item:hover { background: var(--surface-3); }
.reg-item .a { color: var(--text); }
.reg-item .v { color: var(--text-2); }
.reg-item.missing {
  background: var(--amber-soft);
  border-color: rgba(255, 159, 10, 0.28);
}
.reg-item.missing .v { color: var(--amber-text); font-family: var(--font); font-size: 11px; }
.reg-item.reset { border-color: rgba(255, 59, 48, 0.3); }

/* ---------------- 数据表 ---------------- */

.table-wrap {
  flex: 1;
  overflow: auto;
  border-top: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.data-table tbody tr:hover td { background: var(--surface-2); }

.matrix-table td, .matrix-table th { font-family: var(--mono); }
.matrix-table td:first-child, .matrix-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  font-family: var(--mono);
  font-weight: 600;
}
.matrix-table thead th:first-child { z-index: 4; background: var(--surface-2); }
.matrix-table tbody tr:hover td:first-child { background: var(--surface-2); }

.cell-missing {
  background: var(--amber-soft) !important;
  color: var(--amber-text) !important;
  text-align: center;
  font-family: var(--font) !important;
  font-size: 11.5px;
}
.cell-dash { color: var(--text-3); text-align: center; }
.cell-diff { color: var(--accent); font-weight: 600; }

/* ---------------- 常用寄存器表 ---------------- */

.info-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.info-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.info-table td:first-child { color: var(--text-2); width: 46%; }
.info-table td:last-child { font-family: var(--mono); font-size: 11.5px; }
.info-table tr:last-child td { border-bottom: 0; }

/* ---------------- 批量寄存器 ---------------- */

.batch-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

/* ---------------- 单寄存器读写面板（批量寄存器视图上部） ---------------- */
.single-reg-card {
  padding: 14px 16px;
  flex: 0 0 auto;
}
.single-reg-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 10px;
}
.sr-field { display: flex; flex-direction: column; gap: 5px; }
.sr-field > label { font-size: 10.5px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.sr-stepper { display: flex; align-items: center; gap: 0; }
.sr-stepper .field { width: 120px; text-align: center; border-radius: 0; border-left: none; border-right: none; }
.sr-stepper .step-btn {
  width: 28px; height: 32px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-1);
  cursor: pointer;
  border-radius: 8px 0 0 8px;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.sr-stepper .step-btn:last-child { border-radius: 0 8px 8px 0; }
.sr-stepper .step-btn:hover { background: var(--surface-3); }
.sr-stepper .step-btn:active { background: var(--border-strong); color: white; }
.sr-step { display: flex; flex-direction: column; gap: 5px; }
.sr-step > label { font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.sr-step .field { width: 80px; }
.sr-btns { display: flex; gap: 8px; padding-bottom: 0; }

/* 8bit 位复选框行 */
.sr-bits {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.sr-bits .bit-cell {
  display: flex; align-items: center; gap: 2px; cursor: pointer;
  font-size: 11px; color: var(--text-2); user-select: none;
}
.sr-bits .bit-cell input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0;
  cursor: pointer; accent-color: var(--accent);
}
.sr-bits .bit-cell span {
  min-width: 10px; text-align: center; font-weight: 600;
}
.sr-bits .bit-cell:first-child .bit-cell::before { content: 'MSB'; font-size: 9px; color: var(--text-3); }

.sr-result {
  margin-top: 8px;
  font-size: 11.5px;
  min-height: 16px;
  color: var(--text-3);
}
.sr-result.ok { color: var(--green); font-weight: 500; }
.sr-result.bad { color: var(--red); font-weight: 500; }
.sr-result.info { color: var(--accent); }

/* 表格选中行高亮（供单寄存器面板联动） */
.batch-table tr.selected td {
  background: var(--accent-soft) !important;
}

.batch-help { flex: 0 0 auto; padding: 14px 16px; }
.batch-help .hint { margin-bottom: 6px; }
.help-steps {
  margin: 0 0 0 18px;
  padding: 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--text-2);
}
.help-steps li::marker { color: var(--accent); font-weight: 600; }
.help-steps b { color: var(--text); font-weight: 600; }

.batch-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 15px 16px 0;
  overflow: hidden;
}

.batch-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.tool-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.tool-tip { font-size: 10.5px; color: var(--text-3); }
.tool-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-group .field { width: 132px; height: 30px; }
.tool-group.grow-1 { flex: 1; min-width: 260px; }
.field.grow-1 { flex: 1; }
.tilde { color: var(--text-3); }

.paste-area {
  width: 100%;
  box-sizing: border-box;
  min-height: 250px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.paste-area:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-tip { margin: 0 0 8px; font-size: 11.5px; line-height: 1.6; color: var(--text-3); }

.batch-table { table-layout: fixed; }
.batch-table td { padding: 4px 8px !important; }
.batch-table .cell-input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  transition: all .15s;
}
.batch-table .cell-input:hover { background: var(--surface-2); }
.batch-table .cell-input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.batch-table .cell-input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.14); }
.batch-table .idx-cell { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }

.table-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}
.table-empty.hidden { display: none; }

/* ---------------- 状态栏 ---------------- */

.statusbar {
  flex: 0 0 auto;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  font-size: 11.5px;
  color: var(--text-3);
}
.statusbar .grow { flex: 1; }
.status-tip { opacity: 0.75; }

/* ---------------- 弹窗 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease);
  z-index: 90;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -47%) scale(0.97);
  width: min(920px, calc(100vw - 40px));
  max-height: calc(100vh - 72px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-up);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .26s var(--ease);
  z-index: 100;
  overflow: hidden;
}
.modal.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.modal.narrow { width: min(680px, calc(100vw - 40px)); }

.modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.modal-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--text-3); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 20px;
}

.modal-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* 格式选择 */

.fmt-layout {
  display: grid;
  grid-template-columns: minmax(300px, 340px) 1fr;
  gap: 18px;
}
.fmt-list { display: flex; flex-direction: column; gap: 2px; }
.fmt-list .group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 10px 0 4px;
}
.fmt-list .group-label:first-child { margin-top: 0; }

.radio-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background .15s;
}
.radio-row:hover { background: var(--surface-2); }
.radio-row.sub { padding-left: 28px; }

.radio-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  flex: 0 0 auto;
  position: relative;
  transition: all .16s;
}
.radio-row input { display: none; }
.radio-row input:checked + .radio-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.check-box {
  width: 16px;
  height: 16px;
  border-radius: 4.5px;
  border: 1.5px solid var(--border-strong);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  transition: all .16s;
}
.radio-row input:checked + .check-box {
  border-color: var(--accent);
  background: var(--accent);
}
.radio-row input:checked + .check-box::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.fmt-example {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  margin-left: auto;
  white-space: nowrap;
}

.preview-box {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1e1e20;
  min-height: 300px;
}
.preview-head {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.5);
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
}
.preview-code {
  flex: 1;
  overflow: auto;
  padding: 12px;
  margin: 0;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  white-space: pre;
}

/* 人工确认 */

.confirm-mode {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
}
.confirm-mode-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}
.confirm-mode-head .badge {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 1px 8px;
}
.confirm-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 6px;
  padding: 10px 12px;
}
.confirm-row { display: flex; align-items: center; gap: 7px; }
.confirm-row .reg {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  width: 62px;
  flex: 0 0 auto;
}
.confirm-row input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  outline: none;
}
.confirm-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.fill-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-2);
}

/* ---------------- Toast ---------------- */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  background: rgba(29, 29, 31, 0.94);
  color: #fff;
  padding: 9px 17px;
  border-radius: 11px;
  font-size: 12.5px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  animation: toastIn .26s var(--ease);
  max-width: 70vw;
}
.toast.ok { background: rgba(36, 138, 61, 0.96); }
.toast.err { background: rgba(211, 47, 38, 0.96); }
.toast.out { animation: toastOut .2s forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(6px) scale(0.97); }
}

/* ---------------- 滚动条 ---------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ---------------- 补充：导出弹窗 / 批量表 ---------------- */

.radio-row.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.export-base {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-2);
}
.export-base .field { flex: 1; max-width: 340px; }

.batch-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.confirm-row input.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.14);
}

/* ---------------- v1.1：配置套数 / 联动 ---------------- */

.config-card .hint { margin-bottom: 10px; }

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.step-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all .16s var(--ease);
}
.step-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 113, 227, 0.18);
}
.step-btn:active:not(:disabled) { transform: scale(0.94); }
.step-btn:disabled { opacity: 0.32; cursor: not-allowed; }

.step-val { flex: 1; text-align: center; line-height: 1.18; }
.step-val b {
  display: block;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.step-val span { font-size: 10.5px; color: var(--text-3); }

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  cursor: pointer;
  transition: all .16s var(--ease);
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.28);
}

.mode-chip {
  flex: 0 0 auto;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
}

.usage-chip {
  flex: 0 1 auto;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
}
.usage-chip.unused {
  color: var(--text-3);
  background: var(--surface-3);
  font-weight: 500;
}

.mode-row .mode-name { font-weight: 600; }
.mode-row + .mode-row { border-top: 1px solid var(--border); }

.reg-tag {
  font-style: normal;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 59, 48, 0.1);
  color: var(--red);
  font-family: var(--font);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.reg-item.reset { background: rgba(255, 59, 48, 0.045); }

.setting-card { background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.setting-card:hover { box-shadow: 0 5px 18px rgba(0, 0, 0, 0.05); }

.btn.primary {
  background: linear-gradient(180deg, #1485f5, #0068d8);
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(0, 113, 227, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn.primary:hover { background: linear-gradient(180deg, #2b95ff, #0071e3); }
[data-theme="dark"] .btn.primary { background: linear-gradient(180deg, #2b95ff, #0a6fd8); }

.stat { background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.stat b { letter-spacing: -0.035em; }

.result-head { background: var(--surface); }
.result-body { background: linear-gradient(180deg, var(--surface), var(--surface-2) 160%); }

.setting-file { font-variant-numeric: tabular-nums; }

@media (max-width: 1080px) {
  .stepper { max-width: 420px; }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
  .workspace { flex-direction: column; padding: 12px; }
  .pane-left { flex: 0 0 auto; }
  .pane-left .pane-scroll { max-height: 46vh; }
  .splitter { display: none; }
  .pane-right { margin-top: 12px; }
  .fmt-layout { grid-template-columns: 1fr; }
  .nav-inner { gap: 12px; }
  .brand-text { display: none; }
}

/* ---------------- I2C Agent ---------------- */

.conn-pill {
  cursor: pointer;
  border: 0;
  font: inherit;
  transition: background .18s, color .18s;
}
.conn-pill:hover { background: var(--surface-3); color: var(--text); }
.conn-pill.idle i { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.conn-pill.warn i { background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 159, 10, .18); }

.agent-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin: 2px 0 12px;
}
.agent-state b { display: block; font-size: 13px; font-weight: 600; }
.agent-state .agent-sub { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-3); }
.agent-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}
.agent-state.on .agent-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 199, 89, .16); }
.agent-state.idle .agent-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.agent-state.warn .agent-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 159, 10, .18); }

.agent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 12px;
}
.agent-grid div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 11.5px;
}
.agent-grid span { color: var(--text-3); white-space: nowrap; }
.agent-grid b {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-row { display: flex; gap: 8px; margin-bottom: 8px; }
.agent-row .field { flex: 1; min-width: 0; }
.agent-note { margin: 10px 0 0; font-size: 11.5px; line-height: 1.65; color: var(--text-3); }

@media (max-width: 560px) {
  .agent-grid { grid-template-columns: 1fr; }
}

/* ---------------- I2C 读写交互 ---------------- */

.confirm-rows { grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); }
.confirm-row .read-one {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
}
.confirm-row input.from-i2c {
  border-color: rgba(10, 132, 255, .55);
  background: rgba(10, 132, 255, .04);
}

.cell-input.ok { border-color: rgba(52, 199, 89, .55); }
.cell-input.bad {
  border-color: rgba(255, 59, 48, .65);
  background: rgba(255, 59, 48, .06);
}

.diff-wrap {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.diff-table th,
.diff-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-family: var(--mono);
  white-space: nowrap;
}
.diff-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-family: inherit;
  font-weight: 500;
  color: var(--text-3);
}
.diff-table tr.same td { color: var(--text-3); }
.diff-table tr:last-child td { border-bottom: 0; }

/* ============================================================
 * v2.0 · Apple 细节打磨 / 阶段状态 / 逐 Mode 读取向导
 * ============================================================ */

.modal {
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
[data-theme="dark"] .modal { border-color: rgba(255, 255, 255, 0.08); }
.modal-backdrop {
  background: rgba(20, 20, 22, 0.42);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}

/* 顶部"等待 I2C 通讯"呼吸灯 */
@keyframes pillPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 159, 10, 0.34); }
  50% { box-shadow: 0 0 0 4px rgba(255, 159, 10, 0); }
}
.conn-pill.pulse i { animation: pillPulse 1.8s ease-out infinite; }

/* ---------------- file:// 入口提示 ---------------- */

/* 内联于页面顶部，占正常布局空间，绝不遮挡按钮 */
.entry-banner {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: none;
  align-items: center;
  gap: 10px;
  margin: 10px 20px 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.entry-banner.show { display: flex; opacity: 1; }
.entry-banner.ok { border-color: rgba(52, 199, 89, 0.35); }
[data-theme="dark"] .entry-banner {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}
.entry-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 159, 10, 0.14);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
}
.entry-banner.ok .entry-icon { background: rgba(52, 199, 89, 0.16); color: var(--green); }
.entry-text { flex: 1; min-width: 0; }
.entry-text b { font-size: 12px; font-weight: 600; }
.entry-text span { margin-left: 8px; font-size: 11.5px; color: var(--text-3); }

/* ---------------- 阶段指示 ---------------- */

.phase-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 12px;
}
.phase-step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.phase-step i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: 0 0 auto;
}
.phase-step.current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.phase-step.current i { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.phase-step.done { color: var(--text-2); background: rgba(52, 199, 89, 0.10); }
.phase-step.done i { background: var(--green); }

/* ---------------- 逐 Mode 读取向导 ---------------- */

.mode-wizard { display: flex; flex-direction: column; gap: 10px; }

.wizard-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wizard-progress {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}
.wizard-progress b {
  font-size: 22px;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.03em;
}
.wizard-progress strong { font-size: 13px; color: var(--text); font-weight: 600; }
.wizard-tools { display: flex; gap: 6px; }

.mode-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.mode-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: all .16s var(--ease);
}
.mode-chip:hover { border-color: var(--accent); color: var(--accent); }
.mode-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}
.mode-chip em { font-style: normal; font-size: 10.5px; color: var(--text-3); }
.mode-chip.active {
  background: var(--text);
  border-color: transparent;
  color: #fff;
}
.mode-chip.active i { background: #fff; }
.mode-chip.active em { color: rgba(255, 255, 255, 0.65); }
.mode-chip.partial i { background: var(--amber); }
.mode-chip.done i { background: var(--green); }
.mode-chip.failed i { background: var(--red); }

.wizard-guide {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-2);
}
.wizard-guide b { color: var(--text); }
.wz-num {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}
.wz-num:first-child { margin-left: 0; }

.wizard-readbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wizard-status { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
.wizard-status.good { color: var(--green); }
.wizard-status.bad { color: var(--red); }

.wizard-sections { max-height: 320px; overflow: auto; }
.wizard-sections .confirm-mode { margin-bottom: 0; }
.wizard-sections .confirm-mode[hidden] { display: none; }
.wz-mode-state { margin-left: auto; font-size: 11px; color: var(--text-3); }

.confirm-row.read-ok input { border-color: rgba(52, 199, 89, 0.45); }
.confirm-row.read-failed input { border-color: rgba(255, 59, 48, 0.55); background: rgba(255, 59, 48, 0.05); }
.confirm-row.read-failed .read-one { color: var(--red); }

.fill-bar { flex-wrap: wrap; }
.fill-bar .fill-note { margin-left: auto; color: var(--text-3); }

/* 向导内 I2C 连接状态条 */
.wizard-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
}
.wizard-agent .wa-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: 0 0 auto;
}
.wizard-agent.on .wa-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.16); }
.wizard-agent.warn .wa-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.16); }
.wizard-agent.bad .wa-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.14); }
.wizard-agent .wa-text { flex: 1; min-width: 0; line-height: 1.5; }
.wizard-agent .wa-text b { color: var(--text); }

/* 上一个 / 下一个 Mode：大按钮，放在最显眼的位置 */
.wizard-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.wizard-nav .wn-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .16s var(--ease);
  text-align: left;
}
.wizard-nav .wn-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.wizard-nav .wn-btn:disabled { opacity: .45; cursor: not-allowed; }
.wizard-nav .wn-btn.next { justify-content: flex-end; text-align: right; }
.wizard-nav .wn-btn b { font-weight: 600; }
.wizard-nav .wn-btn small { display: block; font-size: 10.5px; color: var(--text-3); font-weight: 400; }
.wizard-nav .wn-mid {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.wizard-nav .wn-mid b { display: block; font-size: 15px; color: var(--text); line-height: 1.2; }

/* 未完成提醒 */
.wizard-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 159, 10, 0.10);
  border: 1px solid rgba(255, 159, 10, 0.35);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-2);
}
/* 空内容或 hidden 时强制完全隐藏，不占位 */
.wizard-alert[hidden],
.wizard-alert:empty {
  display: none !important;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  height: 0;
  min-height: 0;
  overflow: hidden;
}
.wizard-alert .wa-msg { flex: 1; min-width: 0; }
.wizard-alert .wa-msg b { color: var(--text); }
.wizard-alert .btn { flex: 0 0 auto; }

.mode-chip.unread i { background: var(--border-strong); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04); }

/* ---------------- 比较结果：可展开寄存器明细 ---------------- */

.detail-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.detail-block > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.detail-block > summary::-webkit-details-marker { display: none; }
.detail-block > summary::before {
  content: '›';
  display: inline-block;
  margin-right: 2px;
  color: var(--text-3);
  font-size: 14px;
  transition: transform .18s var(--ease);
}
.detail-block[open] > summary::before { transform: rotate(90deg); }
.detail-block > summary:hover { background: var(--surface-2); }
.detail-block .dt-name { flex: 0 0 auto; }
.detail-block .dt-caret { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--text-3); }
.detail-block .reg-grid { padding: 2px 12px 12px; }
.detail-block.flash { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.goto-row { cursor: pointer; }
.goto-row:hover td { background: var(--surface-2); }
.goto-row .goto-cell { text-align: right; white-space: nowrap; font-size: 11.5px; color: var(--accent); }


/* 深色模式下按钮/胶囊的细节 */
[data-theme="dark"] .mode-chip.active { background: #f5f5f7; color: #1d1d1f; }
[data-theme="dark"] .mode-chip.active em { color: rgba(0, 0, 0, 0.55); }

/* ---------------- Agent 下载引导 ---------------- */

.agent-download {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.10), rgba(88, 86, 214, 0.08));
  border: 1px solid rgba(10, 132, 255, 0.20);
}
.agent-dl-text { flex: 1; min-width: 0; }
.agent-dl-text b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.agent-dl-text span { display: block; margin-top: 3px; font-size: 11.5px; line-height: 1.5; color: var(--text-3); }
.agent-download .btn { flex: 0 0 auto; white-space: nowrap; text-decoration: none; }


