* { margin: 0; padding: 0; box-sizing: border-box; }

/* 明暗主题（见 html.theme-light，脚本写入 localStorage「uvk1-web-theme」） */
:root {
  color-scheme: dark;
  --bg-page: #0d1117;
  --bg-elevated: #161b22;
  --bg-input: #0d1117;
  --bg-log: #0d1117;
  --bg-muted: #21262d;
  --border-default: #21262d;
  --border-strong: #30363d;
  --text-primary: #c9d1d9;
  --text-muted: #8b949e;
  --text-subtle: #6e7681;
  --text-disabled: #484f58;
  --text-bright: #e6edf3;
  --accent: #58a6ff;
  --accent-dot-glow: rgba(88, 166, 255, 0.4);
  --btn-primary: #238636;
  --btn-primary-hover: #2ea043;
  --btn-fetch: #1f6feb;
  --btn-fetch-hover: #388bfd;
  --subtitle-gradient-end: #1c2128;
  --toast-1: #1f2630;
  --toast-2: #161b22;
  --toast-3: #131820;
  --shadow-kicker: rgba(0, 0, 0, 0.55);
  --toast-close-hover-bg: rgba(240, 246, 252, 0.08);
}

html.theme-light {
  color-scheme: light;
  --bg-page: #f6f8fa;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;
  --bg-log: #ffffff;
  --bg-muted: #eaeef2;
  --border-default: #d8dee4;
  --border-strong: #d0d7de;
  --text-primary: #1f2328;
  --text-muted: #656d76;
  --text-subtle: #59636e;
  --text-disabled: #8c959f;
  --text-bright: #1f2328;
  --accent: #0969da;
  --accent-dot-glow: rgba(9, 105, 218, 0.35);
  --btn-primary: #1a7f37;
  --btn-primary-hover: #2da44e;
  --btn-fetch: #0969da;
  --btn-fetch-hover: #0550ae;
  --subtitle-gradient-end: #eaeef2;
  --toast-1: #ffffff;
  --toast-2: #f6f8fa;
  --toast-3: #eff2f5;
  --shadow-kicker: rgba(31, 35, 40, 0.12);
  --toast-close-hover-bg: rgba(31, 35, 40, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Two-column layout */
.page-layout { display: flex; min-height: 100vh; }
.timeline-sidebar { flex: 0 0 400px; background: var(--bg-elevated); border-right: 1px solid var(--border-default); padding: 32px 24px; overflow-y: auto; position: sticky; top: 0; height: 100vh; }
/* 右侧主栏：内部 .container 为 720px 居中内容区；步骤条另按需定宽并居中 */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.container { min-width: 0; max-width: 720px; margin-left: auto; margin-right: auto; padding: 24px 32px; width: 100%; box-sizing: border-box; }
/* 仅「写频」标签激活时由 JS 为 body 添加 .writefreq-full，主栏占满右侧 */
body.writefreq-full .container { max-width: none; margin-left: 0; margin-right: 0; }
/* 写频表格较宽，隐藏右侧悬浮社交平台条以免遮挡 */
body.writefreq-full .subtitle-chips { display: none; }
.header { text-align: center; margin-bottom: 24px; max-width: 720px; margin-left: auto; margin-right: auto; }
.h1 { font-size: 1.6em; color: var(--accent); margin-bottom: 4px; }
.subtitle { font-size: 0.9em; color: var(--text-muted); text-align: center; margin-bottom: 20px; max-width: 720px; margin-left: auto; margin-right: auto; }
.subtitle-social {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.subtitle-dev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  background: linear-gradient(145deg, var(--bg-elevated) 0%, var(--subtitle-gradient-end) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.92em;
  color: var(--text-primary);
}
.subtitle-call { color: var(--accent); font-weight: 600; letter-spacing: 0.02em; }
.subtitle-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.95;
}
.subtitle-icon--lg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}
/* 社交平台标签：视口右侧纵向悬浮（脱离文档流，不占副标题区高度） */
.subtitle-chips {
  position: fixed;
  right: calc(10px + env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 9980;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: min(280px, calc(100vw - 24px));
  max-height: calc(100vh - 100px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 8px;
  margin: 0;
  box-sizing: border-box;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: 0 8px 28px var(--shadow-kicker);
}
.subtitle-chips::-webkit-scrollbar {
  width: 4px;
}
.subtitle-chips::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}
.subtitle-chip {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-muted);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  font-size: 0.82em;
  color: var(--text-primary);
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
  text-align: left;
  min-width: 0;
}
.subtitle-chip:hover {
  background: var(--subtitle-gradient-end);
  border-color: var(--border-strong);
}
.subtitle-chips .subtitle-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.subtitle-chips .subtitle-chip-label {
  font-weight: 600;
  font-size: 0.92em;
  line-height: 1.2;
  flex-shrink: 0;
  white-space: nowrap;
}
.subtitle-chips .subtitle-chip-name {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9em;
  line-height: 1.25;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subtitle-chip--douyin .subtitle-icon { color: #2dd4bf; }
.subtitle-chip--douyin .subtitle-chip-label { color: #5eead4; }
.subtitle-chip--bili .subtitle-icon { color: #fb7299; }
.subtitle-chip--bili .subtitle-chip-label { color: #f472b6; }
.subtitle-chip--redbook .subtitle-icon { color: #f87171; }
.subtitle-chip--redbook .subtitle-chip-label { color: #fca5a5; }
.subtitle-chip--weixin .subtitle-icon { color: #22c55e; }
.subtitle-chip--weixin .subtitle-chip-label { color: #4ade80; }
a.subtitle-chip {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.subtitle-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.language-selector { position: absolute; top: 16px; right: 16px; }
.language-selector select { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 8px; font-size: 0.85em; }

/* 刷机步骤条：外壳不裁切（避免提示框被上边框挡住）；横向滚动仅作用在内层 .flash-steps-scroll */
.flash-steps-bar {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  font-size: 0.85em;
  line-height: 1.45;
  overflow: visible;
}
.flash-steps-scroll {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--bg-muted);
}
/* 仅保留横向滚动条外观；纵向条宽压成 0，避免误出现纵向条 */
.flash-steps-scroll::-webkit-scrollbar {
  width: 0;
  height: 6px;
}
.flash-steps-scroll::-webkit-scrollbar-track {
  background: var(--bg-muted);
  border-radius: 3px;
}
.flash-steps-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
.flash-steps-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}
.flash-steps-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 14px;
  width: max-content;
}
.flash-steps-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.flash-steps-heading-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #f85149;
}
.flash-steps-label {
  font-weight: 700;
  color: #f85149;
}
.flash-step-index {
  font-weight: 700;
  color: #f85149;
  flex-shrink: 0;
}
.flash-steps-list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}
.flash-step-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  position: relative;
  padding: 4px 2px;
  border-radius: 6px;
  outline: none;
}
.flash-step-item:not(:first-child)::before {
  content: '→';
  color: var(--text-subtle);
  font-size: 0.85em;
  margin-right: 6px;
  user-select: none;
}
.flash-step-item:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-dot-glow);
}
.flash-step-name {
  color: var(--text-primary);
  white-space: nowrap;
}
.flash-step-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-muted);
  cursor: help;
  flex-shrink: 0;
  box-sizing: border-box;
}
/* 默认移出排版流并收起：否则长文案 span 会在步骤里折行，整条被撑高并出现纵向滚动条 */
.flash-step-tooltip {
  position: absolute;
  left: -9999px;
  top: 0;
  box-sizing: border-box;
  min-width: 200px;
  max-width: min(340px, calc(100vw - 48px));
  padding: 9px 11px;
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px var(--shadow-kicker);
  font-size: 0.92em;
  line-height: 1.45;
  color: var(--text-primary);
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 300;
}
.flash-step-tooltip.flash-step-tooltip--open {
  opacity: 1;
  visibility: visible;
}

/* Tabs */
.tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-default);
  padding-bottom: 0;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.9em;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  width: auto;
  flex: 0 0 auto;
  margin-bottom: 0;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Section */
.section { margin-bottom: 16px; }
.section label { display: block; font-size: 0.85em; color: var(--text-muted); margin-bottom: 6px; }

/* File input */
.file-input-wrapper { position: relative; }
/* 校准等：整块区域点击选择文件（input 为 wrapper 直接子元素） */
.file-input-wrapper > input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.file-input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 12px 16px;
  transition: border-color 0.2s;
}
.file-input-wrapper--dual .file-input-label {
  flex-wrap: wrap;
}
.file-input-wrapper--dual .file-name {
  flex: 1 1 120px;
  min-width: 0;
}
.file-input-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.file-input-actions .file-action-remote {
  width: auto;
  min-width: unset;
  margin-bottom: 0;
  padding: 6px 12px;
  font-size: 0.8em;
}
.file-local-trigger {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.file-input-wrapper--dual .file-local-trigger input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.file-input-label:hover { border-color: var(--accent); }
.file-input-label.has-file { border-style: solid; border-color: var(--btn-primary); }
.file-name { color: var(--text-muted); font-size: 0.9em; }
.file-name.has-file { color: var(--text-primary); }
.file-button {
  position: relative;
  z-index: 1;
  display: inline-block;
  background: var(--bg-muted);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8em;
  white-space: nowrap;
}

/* Buttons */
button { background: var(--btn-primary); color: #fff; border: 1px solid rgba(240,246,252,0.1); border-radius: 6px; padding: 12px 24px; font-size: 1em; cursor: pointer; width: 100%; transition: background 0.2s; margin-bottom: 8px; }
button:hover { background: var(--btn-primary-hover); }
button:disabled { background: var(--bg-muted); color: var(--text-disabled); cursor: not-allowed; border-color: var(--border-strong); }
.btn-secondary { background: var(--bg-muted); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--border-strong); }
.btn-fetch { background: var(--btn-fetch); }
.btn-fetch:hover { background: var(--btn-fetch-hover); }

/* Progress */
.progress-container { display: none; margin: 16px 0; }
.progress-bar { background: var(--bg-elevated); border-radius: 8px; height: 24px; overflow: hidden; position: relative; border: 1px solid var(--border-strong); }
.progress-fill { background: linear-gradient(90deg, var(--btn-primary), var(--btn-primary-hover)); height: 100%; width: 0; transition: width 0.3s; }
.progress-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 0.75em; color: #fff; font-weight: 600; }
html.theme-light .progress-label { color: var(--text-primary); }

/* Log */
.log-container { margin-top: 16px; }
.log-toggle { background: none; border: 1px solid var(--border-strong); color: var(--text-muted); padding: 6px 12px; font-size: 0.8em; width: auto; margin-bottom: 8px; }
.log {
  display: none;
  background: var(--bg-log);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.75em;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.log.visible { display: block; }
.log::-webkit-scrollbar {
  width: 6px;
}
.log::-webkit-scrollbar-track {
  background: transparent;
}
.log::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
.log::-webkit-scrollbar-thumb:hover {
  background: var(--text-disabled);
}
.log-entry { padding: 1px 0; }
.log-entry.success { color: #3fb950; }
.log-entry.error { color: #f85149; }
.log-entry.info { color: var(--text-muted); }
.log-entry.warning { color: #d29922; }

/* Info box — 与正文同宽居中（写频全宽时仍保持窄提示块） */
.info-box { background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 8px; padding: 16px; margin-top: 20px; font-size: 0.85em; color: var(--text-muted); max-width: 720px; margin-left: auto; margin-right: auto; }
.info-box strong { color: var(--text-primary); }

/* Download link */
.download-link { display: none; margin: 12px 0; text-align: center; }
.download-link a { color: var(--accent); text-decoration: none; }
.download-link a:hover { text-decoration: underline; }

/* Firmware version info */
.fw-info { background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 0.85em; }
.fw-info .fw-name { color: var(--accent); font-weight: 600; }
.fw-info .fw-size { color: var(--text-muted); }
.fw-info .fw-date { color: var(--text-muted); font-size: 0.85em; }

/* Write frequency (MR) tab */
.writefreq-lead {
  font-size: 0.95em;
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.55;
}
.writefreq-lead .writefreq-scope-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  color: #f85149;
  font-weight: 600;
}
.writefreq-lead-ico {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}
.writefreq-log-dock { margin-top: 8px; }
.writefreq-log-dock .log-container { margin-top: 0; }
.writefreq-log-dock .progress-container {
  margin-top: 8px;
  margin-bottom: 12px;
}
.log-anchor-default { display: none; }
.writefreq-toolbar { margin-bottom: 12px; }
.writefreq-toolbar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 12px;
}
.writefreq-range { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.9em; color: var(--text-muted); align-items: center; }
.writefreq-range input { width: 72px; margin-left: 6px; background: var(--bg-elevated); border: 1px solid var(--border-strong); color: var(--text-primary); border-radius: 6px; padding: 6px 8px; }
.writefreq-actions-split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 1;
  min-width: min(100%, 420px);
}
.writefreq-actions-left,
.writefreq-actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
button.btn-inline {
  width: auto;
  flex: 0 0 auto;
  min-width: unset;
  margin-bottom: 0;
  padding: 6px 12px;
  font-size: 0.875rem;
}
button.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-ico {
  display: inline-flex;
  flex-shrink: 0;
}
.btn-ico svg {
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.95;
}
.wide-scroll {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}
/* 写频横向滚动条：与左侧历史版本时间线 sidebar 同色，滚动条在表格下方（正常文档流） */
#writefreq-content .writefreq-table-scroll::-webkit-scrollbar {
  height: 6px;
}
#writefreq-content .writefreq-table-scroll::-webkit-scrollbar-track {
  background: transparent;
}
#writefreq-content .writefreq-table-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
#writefreq-content .writefreq-table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-disabled);
}
#writefreq-content .writefreq-table-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.writefreq-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 0.9em;
  color: var(--text-muted);
}
.writefreq-page-info {
  min-width: 200px;
  text-align: center;
}
#writefreq-content { width: 100%; max-width: none; box-sizing: border-box; }
.writefreq-table { width: 100%; border-collapse: collapse; font-size: 0.82em; min-width: 1200px; }
.writefreq-table th, .writefreq-table td { border: 1px solid var(--border-default); padding: 6px 8px; text-align: left; }
.writefreq-table th { background: var(--bg-elevated); color: var(--text-muted); font-weight: 600; }
.writefreq-table .th-sub { font-weight: 400; font-size: 0.85em; color: var(--text-subtle); }
.writefreq-table input,
.writefreq-table select { width: 100%; min-width: 0; background: var(--bg-input); border: 1px solid var(--border-strong); color: var(--text-primary); border-radius: 4px; padding: 6px 8px; font-size: 0.95em; }
.writefreq-table select.wf-rx-dcs,
.writefreq-table select.wf-tx-dcs { min-width: 88px; max-width: 120px; font-size: 0.8em; }
.writefreq-table td.ch-num { color: var(--text-muted); text-align: center; width: 52px; }
/* 写频表：删除列固定在表格右侧，横向滚动时始终可见 */
.writefreq-table thead th.wf-delete-th,
.writefreq-table tbody td.wf-delete-cell {
  position: sticky;
  right: 0;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  text-align: center;
  vertical-align: middle;
  padding-left: 4px;
  padding-right: 4px;
  box-sizing: border-box;
}
.writefreq-table thead th.wf-delete-th {
  z-index: 4;
  background: var(--bg-elevated);
  box-shadow: -8px 0 12px -8px var(--shadow-kicker);
}
.writefreq-table tbody td.wf-delete-cell {
  z-index: 3;
  background: var(--bg-page);
  box-shadow: -8px 0 12px -8px var(--shadow-kicker);
}
.writefreq-table .wf-row-delete-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}
.writefreq-table .wf-row-delete-btn:hover {
  color: #f85149;
  border-color: var(--border-strong);
  background: var(--bg-muted);
}
.writefreq-table .wf-row-delete-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.writefreq-table .wf-row-delete-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}
.writefreq-table th.wf-drag-th,
.writefreq-table td.wf-drag-handle {
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  text-align: center;
  vertical-align: middle;
  color: var(--text-subtle);
  cursor: grab;
  user-select: none;
  padding-left: 4px;
  padding-right: 4px;
}
.writefreq-table td.wf-drag-handle:active {
  cursor: grabbing;
}
.writefreq-sortable-ghost {
  opacity: 0.45;
  background: var(--bg-muted) !important;
}
.writefreq-sortable-chosen {
  background: var(--bg-elevated) !important;
}
.writefreq-sortable-drag {
  opacity: 0.95;
}
.writefreq-validation { font-size: 0.85em; color: #f85149; white-space: pre-wrap; }

/* 右上角主题切换（Toast 叠在其下方） */
.theme-toggle {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 9998;
  width: 42px;
  height: 42px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px var(--shadow-kicker);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.theme-toggle {
  width: 42px;
  margin-bottom: 0;
}
.theme-toggle__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: block;
}
html:not(.theme-light) .theme-toggle__icon--sun {
  display: block;
}
html:not(.theme-light) .theme-toggle__icon--moon {
  display: none;
}
html.theme-light .theme-toggle__icon--sun {
  display: none;
}
html.theme-light .theme-toggle__icon--moon {
  display: block;
}

/* 全局轻提示（替代 alert），固定在右上角 */
.app-toast-root {
  position: fixed;
  top: calc(62px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  left: auto;
  bottom: auto;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  width: min(92vw, 440px);
  max-width: calc(100vw - 24px);
}
.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px 14px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(155deg, var(--toast-1) 0%, var(--toast-2) 55%, var(--toast-3) 100%);
  box-shadow:
    0 16px 48px var(--shadow-kicker),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  opacity: 0;
  transform: translateX(18px) scale(0.98);
  transition: opacity 0.3s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.app-toast.app-toast-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}
.app-toast--warning {
  border-color: rgba(210, 153, 34, 0.55);
  box-shadow:
    0 16px 48px var(--shadow-kicker),
    0 0 0 1px rgba(210, 153, 34, 0.12) inset,
    0 0 32px rgba(158, 106, 3, 0.12);
}
.app-toast--info {
  border-color: rgba(88, 166, 255, 0.45);
  box-shadow:
    0 16px 48px var(--shadow-kicker),
    0 0 0 1px rgba(88, 166, 255, 0.1) inset,
    0 0 28px rgba(88, 166, 255, 0.1);
}
.app-toast--info .app-toast-icon {
  color: var(--accent);
}
.app-toast--success {
  border-color: rgba(63, 185, 80, 0.5);
  box-shadow:
    0 16px 48px var(--shadow-kicker),
    0 0 0 1px rgba(63, 185, 80, 0.12) inset,
    0 0 28px rgba(63, 185, 80, 0.12);
}
.app-toast--success .app-toast-icon {
  color: #3fb950;
}
.app-toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  color: #e3b341;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-toast-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}
.app-toast-body {
  flex: 1;
  min-width: 0;
}
.app-toast-msg {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-bright);
  letter-spacing: 0.01em;
  white-space: pre-wrap;
}
.app-toast-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: -6px -4px -6px 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.app-toast-close:hover {
  color: var(--text-bright);
  background: var(--toast-close-hover-bg);
}

/* 刷固件标签：设备型号安全提示弹窗 */
.flash-device-warning-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
}
.flash-device-warning-modal[hidden] {
  display: none;
}
.flash-device-warning-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 9, 0.72);
  backdrop-filter: blur(4px);
}
html.theme-light .flash-device-warning-modal__backdrop {
  background: rgba(31, 35, 40, 0.45);
}
.flash-device-warning-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  max-height: min(90vh, 520px);
  overflow: auto;
  padding: 22px 22px 20px;
  border-radius: 14px;
  border: 1px solid rgba(210, 153, 34, 0.55);
  background: linear-gradient(155deg, var(--toast-1) 0%, var(--toast-2) 55%, var(--toast-3) 100%);
  box-shadow:
    0 24px 64px var(--shadow-kicker),
    0 0 0 1px rgba(210, 153, 34, 0.15) inset,
    0 0 40px rgba(158, 106, 3, 0.14);
}
.flash-device-warning-modal__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 0 0 14px;
  line-height: 1.35;
}
.flash-device-warning-modal__text {
  margin: 0 0 20px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-primary);
}
.flash-device-warning-modal__text strong {
  color: #e3b341;
  font-weight: 600;
}
.flash-device-warning-modal__btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--btn-primary);
  color: #fff;
  transition: background 0.15s ease;
}
.flash-device-warning-modal__btn:hover {
  background: var(--btn-primary-hover);
}
.flash-device-warning-modal__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Version Timeline Sidebar */
.timeline-sidebar::-webkit-scrollbar { width: 6px; }
.timeline-sidebar::-webkit-scrollbar-track { background: transparent; }
.timeline-sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.timeline-sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-disabled); }

.timeline-title { font-size: 1em; color: var(--text-primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-default); }
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--border-strong); }
.timeline-loading { color: var(--text-disabled); font-size: 0.8em; padding: 8px 0; }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); border: 2px solid var(--bg-elevated); z-index: 1; }
.timeline-item:first-child .timeline-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent-dot-glow); }
.timeline-header { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }
.timeline-tag { color: var(--accent); font-weight: 600; font-size: 0.85em; text-decoration: none; }
.timeline-tag:hover { text-decoration: underline; }
.timeline-name { color: var(--text-primary); font-size: 0.8em; }
.timeline-date { color: var(--text-disabled); font-size: 0.7em; }
.timeline-body { color: var(--text-muted); font-size: 0.75em; line-height: 1.5; margin-top: 6px; word-break: break-word; overflow-x: auto; }
.timeline-body p { margin: 0 0 8px; }
.timeline-body p:last-child { margin-bottom: 0; }
.timeline-body h1, .timeline-body h2, .timeline-body h3, .timeline-body h4 { font-size: 1.05em; margin: 10px 0 6px; color: var(--text-primary); font-weight: 600; }
.timeline-body ul, .timeline-body ol { margin: 6px 0 8px; padding-left: 1.2em; }
.timeline-body li { margin-bottom: 4px; }
.timeline-body pre { background: var(--bg-muted); border: 1px solid var(--border-default); border-radius: 6px; padding: 8px 10px; overflow-x: auto; font-size: 0.95em; margin: 8px 0; }
.timeline-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95em; }
.timeline-body :not(pre) > code { background: var(--bg-muted); padding: 2px 5px; border-radius: 4px; }
.timeline-body blockquote { margin: 8px 0; padding: 4px 0 4px 10px; border-left: 3px solid var(--border-strong); color: var(--text-subtle); }
.timeline-body a { color: var(--accent); text-decoration: none; word-break: break-all; }
.timeline-body a:hover { text-decoration: underline; }
.timeline-body img { max-width: 100%; height: auto; border-radius: 4px; display: block; margin: 8px 0; }
.timeline-body table { border-collapse: collapse; width: 100%; font-size: 0.95em; margin: 8px 0; }
.timeline-body th, .timeline-body td { border: 1px solid var(--border-default); padding: 4px 6px; text-align: left; }
.timeline-body hr { border: none; border-top: 1px solid var(--border-default); margin: 10px 0; }
.timeline-prerelease { display: inline-block; background: #9e6a03; color: #fff; font-size: 0.6em; padding: 1px 5px; border-radius: 10px; vertical-align: middle; }

/* Footer */
.footer { text-align: center; margin-top: 24px; font-size: 0.8em; color: var(--text-disabled); max-width: 720px; margin-left: auto; margin-right: auto; }
.footer a { color: var(--accent); text-decoration: none; }

/* Status badge */
.status { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75em; font-weight: 600; }
.status.ok { background: var(--btn-primary); color: #fff; }
.status.warn { background: #9e6a03; color: #fff; }
.status.err { background: #f85149; color: #fff; }

/* Responsive */
@media (max-width: 768px) {
  .page-layout { flex-direction: column; }
  .main-column { order: 1; flex: none; width: 100%; max-width: 100%; }
  .container { max-width: 100%; padding: 16px 12px; }
  .timeline-sidebar { order: 2; flex: none; width: 100%; height: auto; position: static; border-right: none; border-top: 1px solid var(--border-default); border-bottom: none; padding: 20px; max-height: none; }
  .h1 { font-size: 1.3em; }
  .tabs { flex-wrap: wrap; }
  .tab { padding: 8px 12px; font-size: 0.8em; }
  .flash-steps-bar { padding: 10px 12px; font-size: 0.8em; }
  .flash-step-tooltip {
    max-width: calc(100vw - 32px);
  }
  /* 窄屏：右侧悬浮条改贴底，避免挡住中部表单区 */
  .subtitle-chips {
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    transform: none;
    max-height: min(42vh, 300px);
    max-width: min(260px, calc(100vw - 20px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    padding: 8px 6px;
  }
  .subtitle-chip {
    font-size: 0.78em;
    padding: 5px 8px;
  }
}
