* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #fff;
  color: #333;
  line-height: 1.5;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 92px 24px 60px;
}

/* 顶部 语言/帮助 按钮固定到视口右上角，不随内容区居中 */
.page-header {
  position: fixed;
  top: 14px;
  right: 16px;
  left: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0 16px;
  margin: 0;
  z-index: 10;
  pointer-events: none;
}

.header-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.btn {
  border: none;
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-lang {
  background: #198754;
  color: #fff;
}

.btn-help {
  background: #f0ad4e;
  color: #fff;
}

.main {
  text-align: center;
  padding-top: 8px;
}

.title {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 12px;
  color: #222;
}

.browser-tip {
  max-width: 720px;
  margin: 0 auto 28px;
  font-size: 14px;
  color: #555;
}

.btn-connect {
  display: inline-block;
  min-width: 300px;
  max-width: 360px;
  width: auto;
  margin: 0 auto 6px;
  padding: 10px 32px;
  background: #28a745;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.btn-connect-usb {
  display: inline-block;
  min-width: 300px;
  max-width: 360px;
  width: auto;
  margin: 0 auto 6px;
  padding: 10px 32px;
  background: #6c757d;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(108, 117, 125, 0.2);
}

.connect-hint {
  margin: 6px auto 24px;
  font-size: 12px;
  color: #888;
  font-style: italic;
}

.device-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 32px;
  font-size: 18px;
  color: #555;
}

#deviceStatus,
.device-meta .connected {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 17px;
  font-weight: 600;
  background: #f1f3f5;
  color: #666;
  border: 1px solid #e0e0e0;
}

#deviceStatus.connected {
  background: #28a745;
  color: #fff;
  border-color: #1e8e3e;
}

.btn-link {
  background: transparent;
  border: none;
  color: #1976d2;
  font-size: 16px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
}

.btn-link:hover {
  color: #0d47a1;
}

.hidden {
  display: none !important;
}

.upgrade-card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #eee;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 24px 24px 22px;
  text-align: left;
  margin-bottom: 24px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px;
  color: #333;
}

.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 15px;
}

.version-label {
  color: #666;
}

.version-value {
  color: #222;
  font-size: 16px;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.progress-bar {
  flex: 1;
  height: 14px;
  background: #e9ecef;
  border: 1px solid #ddd;
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #28a745, #34ce57);
  border-radius: 6px;
  transition: width 0.25s ease;
}

.progress-text {
  min-width: 42px;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  text-align: right;
}

.upgrade-actions {
  text-align: right;
  margin-bottom: 12px;
}

.btn-upgrade {
  background: #28a745;
  color: #fff;
  padding: 10px 36px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 6px;
}

.btn-upgrade:disabled {
  background: #adb5bd;
}

.upgrade-status {
  font-size: 13px;
  color: #888;
  min-height: 20px;
}

.upgrade-status.success {
  color: #28a745;
}

.upgrade-status.error {
  color: #dc3545;
}

.upgrade-status.warning {
  color: #ff9800;
}

.log-section {
  text-align: left;
  margin-top: 32px;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.log-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: #444;
}

.log-toolbar {
  display: flex;
  gap: 6px;
}

.btn-log {
  font-size: 12px;
  padding: 3px 10px;
  line-height: 1.5;
  border-radius: 6px;
  border: 1px solid #d0d7de;
  background: #f6f8fa;
  color: #24292f;
  cursor: pointer;
}

.btn-log:hover {
  background: #eaeef2;
  border-color: #afb8c1;
}

.log-box {
  background: #0f1117;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 10px 12px;
  height: 480px;
  overflow-y: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #d0d7de;
}

.log-line {
  margin: 0;
  padding: 1px 0;
  border-bottom: 1px solid #1c2128;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line:last-child {
  border-bottom: none;
}

/* 标签配色（与参考日志一致：SYS 灰 / WEB 蓝 / DEV 紫 / FW 青 / API 橙 / OK 绿 / WARN 黄 / ERROR 红 / STEP 亮蓝） */
.log-line.sys {
  color: #9aa4b2;
}

.log-line.web {
  color: #58a6ff;
}

.log-line.dev {
  color: #bc8cff;
}

.log-line.fw {
  color: #56d4dd;
}

.log-line.api {
  color: #ffa657;
}

.log-line.info {
  color: #d0d7de;
}

.log-line.ok {
  color: #3fb950;
}

.log-line.warn {
  color: #d29922;
}

.log-line.error {
  color: #f85149;
}

.log-line.step {
  color: #79c0ff;
  font-weight: 600;
}

.log-line.debug {
  color: #8b949e;
}

.log-line.blank {
  border-bottom: none;
}

@media (max-width: 600px) {
  .page {
    max-width: 100%;
    padding: 76px 16px 40px;
  }

  .page-header {
    right: 12px;
    padding: 0 12px;
  }

  .btn-connect {
    padding: 12px 20px;
  }

  .title {
    font-size: 28px;
  }

  .upgrade-card {
    padding: 24px 18px 22px;
  }

  .version-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ===================== 帮助页 ===================== */
.help-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 76px 24px 60px;
}

.help-header {
  position: relative;
  text-align: center;
  margin-bottom: 32px;
}

.help-header-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 8px;
}

.help-title {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  color: #222;
  padding-top: 4px;
}

.help-controls {
  display: flex;
  justify-content: center;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 24px;
  padding: 4px 0 18px;
}

.help-browser-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.help-browser-label {
  font-size: 13px;
  color: #8a8a8a;
  letter-spacing: 1px;
}

.help-browser-btns {
  display: flex;
  gap: 12px;
}

.help-browser-btn {
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 24px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.help-browser-btn:hover {
  border-color: #198754;
  color: #198754;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(25, 135, 84, 0.15);
}

.help-browser-btn.active {
  background: linear-gradient(135deg, #198754, #157347);
  border-color: #198754;
  color: #fff;
  box-shadow: 0 3px 10px rgba(25, 135, 84, 0.25);
}

.help-image-wrap {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.help-image,
.help-step-img {
  max-width: 640px;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: block;
  margin: 0 auto;
}

.help-step-img {
  margin-bottom: 20px;
}

.help-image-placeholder {
  color: #888;
  font-size: 14px;
  line-height: 1.8;
}

@media (max-width: 600px) {
  .help-page {
    padding: 68px 16px 40px;
  }

  .help-header-actions {
    position: static;
    justify-content: flex-end;
    margin-bottom: 12px;
  }

  .help-header {
    text-align: left;
  }

  .help-title {
    font-size: 26px;
  }

  .help-controls {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .help-browser-bar {
    width: 100%;
    justify-content: center;
  }

  .help-browser-btn {
    flex: 1;
    max-width: 220px;
  }
}

