:root {
  --bg-start: #fffaf3;
  --bg-end: #d8ccc1;
  --accent: #ff6441;
  --text-main: #2e2a27;
  --text-sub: #645c56;
  --card-bg: rgba(255, 255, 255, 0.78);
  --ok: #2f9e44;
  --error: #c92a2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(720px, 100%);
  background: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(35, 23, 16, 0.1);
  backdrop-filter: blur(4px);
  padding: 28px 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 100, 65, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.eyebrow-row .eyebrow {
  margin-bottom: 0;
}

.lang-pill {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
}

.lang-pill-btn {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  background: transparent;
  color: var(--text-sub);
}

.lang-pill-btn.active {
  background: #fff;
  color: var(--text-main);
  font-weight: 600;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(22px, 3.2vw, 30px);
  line-height: 1.25;
}

.subtitle {
  margin: 0 0 18px;
  color: var(--text-sub);
  line-height: 1.65;
}

.steps {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.steps li {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.55;
  color: var(--text-main);
}

.steps strong {
  color: var(--accent);
}

.status {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 12px;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--error);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

button {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#flashBtn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

#manualUploadBtn {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main);
}

#selectPortBtn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

#selectPortBtn.needs-attention {
  animation: select-port-pulse 0.9s ease-in-out 2;
}

#cancelFlashBtn {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main);
}

#copyHelpBtn {
  display: none;
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main);
}

#restartBtn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.progress-wrap {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s linear;
}

.progress-text {
  margin: 8px 0 0;
  color: var(--text-sub);
  font-size: 14px;
}

.log {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  min-height: 140px;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.hidden-debug {
  display: none;
}

.hidden {
  display: none;
}

.tips {
  margin-top: 14px;
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.7;
}

.onboarding-progress {
  margin: 0 0 14px;
  color: var(--text-sub);
  font-size: 14px;
}

.step-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.support-block {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.support-block-title {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.support-block-copy {
  margin: 0 0 10px;
  color: var(--text-main);
  line-height: 1.6;
}

.support-block-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.support-block-link:hover {
  text-decoration: none;
}

.step-card.hidden {
  display: none;
}

.step-title {
  margin: 0 0 8px;
  font-size: 18px;
}

.step-desc {
  margin: 0;
  color: var(--text-sub);
  line-height: 1.65;
}

.step-illustration {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 12px auto 0;
  border-radius: 12px;
}

.nav-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main);
}

.nav-btn.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

@keyframes select-port-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 100, 65, 0.2);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 100, 65, 0.45);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 100, 65, 0.2);
  }
}

.browser-error {
  text-align: center;
  padding: 40px 20px;
}

.browser-error h2 {
  color: var(--error);
  margin: 0 0 12px;
}

.browser-error p {
  color: var(--text-sub);
  margin: 0 0 20px;
  line-height: 1.65;
}

.browser-error a {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  padding: 32px 24px;
  width: min(480px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(35, 23, 16, 0.2);
  text-align: center;
}

.modal-content h2 {
  margin: 0 0 16px;
  font-size: 24px;
  color: var(--accent);
}

.modal-content p {
  margin: 0 0 24px;
  color: var(--text-sub);
  line-height: 1.65;
  white-space: pre-line;
}

#completionConfirmBtn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 12px 32px;
  min-width: 200px;
}

#completionConfirmBtn:hover:not(:disabled) {
  opacity: 0.9;
}
