:root {
  --ink: #1B1C22;
  --ink-2: #55596A;
  --muted: #9BA0AD;
  --ph: #B6BAC6;
  --line: #EBEDF3;
  --line-2: #E8EAF1;
  --line-3: #EEF0F5;
  --seg: #EDEFF4;
  --page: #FBFBFE;
  --violet: #7B5CF3;
  --violet-soft: #EFE8FD;
  --violet-ico: #A78BFA;
  --magenta: #C94CE0;
  --magenta-soft: #FBEAFD;
  --magenta-ico: #D06AE8;
  --ok: #16A34A;
  --warn: #D97706;
  --bad: #DC2626;
  --radius-card: 18px;
  --radius-field: 14px;
  --font-sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* §2.1 点阵网格背景层（不透明度约 0.5） */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle, #DFE1EC 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.55;
}

.mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

/* §2.1 主面板：max-width 1128px 居中，白底，左右 1px #EEF0F5，圆角 20px */
.portal-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1128px;
  margin: 0 auto 44px;
  background: #FFFFFF;
  border-left: 1px solid var(--line-3);
  border-right: 1px solid var(--line-3);
  border-bottom: 1px solid var(--line-3);
  border-radius: 0 0 20px 20px;
  box-shadow: 0 1px 2px rgba(17, 19, 32, 0.04), 0 16px 48px rgba(38, 28, 92, 0.06);
  overflow: hidden;
}

.portal-shell::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #6366F1 0%, #8B5CF6 50%, #C94CE0 100%);
}

@media (min-width: 1220px) {
  .portal-shell {
    margin-top: 20px;
    border-top: 1px solid var(--line-3);
    border-radius: 20px;
  }
}

/* §2.2 页头：高 104px，底 1px #EDEFF4 分隔线 */
.portal-header {
  min-height: 104px;
  padding: 18px 50px 18px 57px;
  border-bottom: 1px solid #EDEFF4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sparkle-icon {
  flex-shrink: 0;
}

.portal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
  line-height: 1.25;
}

/* 右侧单通道胶囊徽标（已移除 3个月代开） */
.mode-badge {
  height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F5FF 100%);
  border: 1px solid #E3DCFC;
  color: #3D31B8;
  font-size: 17px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(123, 92, 243, 0.08);
  user-select: none;
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16A34A;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}

.seg-emoji {
  font-size: 19px;
  line-height: 1;
}

/* §2.1 & §2.3 内容区：左右内边距 50px，首卡距分隔线 52px */
.portal-body {
  padding: 52px 50px 46px;
}

/* §2.3 步骤卡片通用规格 */
.step-card {
  background: #FFFFFF;
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(17, 19, 32, 0.03), 0 8px 24px rgba(17, 19, 32, 0.03);
  padding: 27px 38px 34px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.step-card:focus-within {
  border-color: #DCD4FA;
  box-shadow: 0 4px 28px rgba(123, 92, 243, 0.07);
}

.step-card-2:focus-within {
  border-color: #F0CEFA;
  box-shadow: 0 4px 28px rgba(201, 76, 224, 0.07);
}

.step-card + .step-card {
  margin-top: 37px;
}

/* 视觉顺序：卡头(1) → 输入区(2) → 脚注(3)；DOM 顺序保持输入框在粘贴按钮之前以契合 Tab 流 */
.card-head {
  order: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.field-section {
  order: 2;
  margin-top: 19px;
}

.card-foot {
  order: 3;
  margin-top: 22px;
  font-size: 14.5px;
  color: #7E8596;
  line-height: 1.4;
}

.card-foot-right {
  display: flex;
  justify-content: flex-end;
}

.card-foot-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* 步骤徽标 34x34 / 圆角 10px / 15px 700 */
.step-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-badge-1 {
  background: var(--violet-soft);
  color: var(--violet);
  border: 1px solid #DFD2FC;
}

.step-badge-2 {
  background: var(--magenta-soft);
  color: var(--magenta);
  border: 1px solid #F2CEFA;
}

.head-icon {
  flex-shrink: 0;
}

.head-icon-1 {
  color: var(--violet-ico);
}

.head-icon-2 {
  color: var(--magenta-ico);
}

.card-title {
  margin: 0;
  font-size: 19.5px;
  font-weight: 700;
  color: #1A1B21;
  line-height: 1.3;
}

/* 右侧粘贴动作按钮 */
.paste-action {
  margin-left: auto;
  padding: 6px 8px;
  margin-right: -8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.paste-action-1 {
  color: var(--violet);
}

.paste-action-1:hover {
  background: rgba(123, 92, 243, 0.08);
}

.paste-action-2 {
  color: var(--magenta);
}

.paste-action-2:hover {
  background: rgba(201, 76, 224, 0.08);
}

.paste-action:focus-visible,
.submit-btn:focus-visible,
.retry-btn:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

/* 输入框壳层与占位符覆盖层 */
.input-shell {
  position: relative;
  width: 100%;
}

.field-input {
  width: 100%;
  border-radius: var(--radius-field);
  border: 1px solid var(--line-2);
  background: #FFFFFF;
  padding: 20px 22px;
  font-size: 19px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.field-key {
  height: 83px;
  padding-right: 132px;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.field-link {
  height: 160px;
  resize: none;
  font-family: var(--font-mono);
  font-size: 17.5px;
  line-height: 1.55;
  word-break: break-all;
}

.field-input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(123, 92, 243, 0.11);
}

.step-card-2 .field-input:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(201, 76, 224, 0.11);
}

.field-input.is-invalid {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.field-input:disabled {
  background: #F8F9FC;
  color: var(--ink-2);
  cursor: not-allowed;
}

/* §2.3 混排占位文本覆盖层 */
.ph {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  user-select: none;
  color: var(--ph);
  font-family: var(--font-sans);
  font-size: 19px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ph .mono {
  font-family: var(--font-mono);
  letter-spacing: 0.2px;
}

.ph-multiline {
  top: 21px;
  transform: none;
  white-space: normal;
  line-height: 1.58;
}

/* 输入框右侧绿色剩余次数徽标（§11 #2） */
.quota-badge {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: #DCFCE7;
  border: 1px solid #BBF7D0;
  color: #15803D;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

/* §11 #9 内联提示行（12.5px） */
.inline-feedback {
  min-height: 0;
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--bad);
}

.inline-feedback:empty {
  margin-top: 0;
}

.inline-feedback.is-ok {
  color: var(--ok);
}

.inline-feedback.is-warn {
  color: var(--warn);
}

.inline-feedback.is-error {
  color: var(--bad);
}

/* §2.4 主提交按钮 */
.submit-row {
  margin-top: 34px;
}

.submit-btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(90deg, #7B5CF3 0%, #A855F7 100%);
  color: #FFFFFF;
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(123, 92, 243, 0.24);
  transition: transform 0.14s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(123, 92, 243, 0.30);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled {
  background: #E7E9F1;
  color: #A8ADBB;
  box-shadow: none;
  cursor: not-allowed;
}

.submit-feedback {
  text-align: center;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.2px solid rgba(255, 255, 255, 0.38);
  border-top-color: #FFFFFF;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* §2.4 & §11 结果区与事件时间线 */
.result-card {
  margin-top: 28px;
  padding: 24px 28px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: #FAFBFD;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.result-status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-running {
  background: var(--violet);
  box-shadow: 0 0 0 4px rgba(123, 92, 243, 0.16);
}

.status-success {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16);
}

.status-failed {
  background: var(--bad);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16);
}

.result-stage-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.order-id-chip {
  padding: 4px 10px;
  border-radius: 8px;
  background: #EEF0F6;
  color: var(--ink-2);
  font-size: 13px;
}

.progress-track {
  margin-top: 16px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #E7E9F2;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7B5CF3 0%, #C94CE0 100%);
  transition: width 0.35s ease, background-color 0.25s ease;
}

.progress-fill.is-success {
  background: var(--ok);
}

.progress-fill.is-failed {
  background: var(--bad);
}

.terminal-banner {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.terminal-banner.is-success {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #14532D;
}

.terminal-banner.is-failed {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #7F1D1D;
}

.terminal-headline {
  font-size: 15px;
  font-weight: 700;
}

.terminal-sub {
  margin-top: 4px;
  font-size: 13px;
  opacity: 0.9;
}

.retry-btn {
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid #FCA5A5;
  background: #FFFFFF;
  color: var(--bad);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.retry-btn:hover:not(:disabled) {
  background: #FEE2E2;
}

.event-timeline {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.event-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  animation: fadeUp 0.24s ease both;
}

.event-time {
  color: var(--muted);
  font-size: 12.5px;
  flex-shrink: 0;
}

.event-item.level-ok .event-msg {
  color: var(--ok);
  font-weight: 600;
}

.event-item.level-error .event-msg {
  color: var(--bad);
  font-weight: 600;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* §12 #22 响应式适配：1280 / 平板 / 390px 手机端零溢出、卡片不挤压 */
@media (max-width: 900px) {
  .portal-header {
    padding: 16px 24px;
    flex-wrap: wrap;
    min-height: auto;
  }

  .portal-body {
    padding: 28px 24px 36px;
  }

  .step-card {
    padding: 22px 22px 26px;
  }
}

@media (max-width: 600px) {
  .portal-header {
    padding: 16px 16px;
    gap: 12px;
  }

  .portal-title {
    font-size: 20px;
  }

  .mode-badge {
    height: 40px;
    padding: 0 14px;
    font-size: 14.5px;
  }

  .portal-body {
    padding: 20px 16px 30px;
  }

  .step-card {
    padding: 18px 16px 22px;
  }

  .step-card + .step-card {
    margin-top: 20px;
  }

  .card-head {
    gap: 8px;
    flex-wrap: wrap;
  }

  .card-title {
    font-size: 16.5px;
  }

  .paste-action {
    font-size: 14px;
    padding: 4px 6px;
  }

  .field-input {
    padding: 16px 14px;
    font-size: 15.5px;
  }

  .field-key {
    height: 64px;
    padding-right: 98px;
  }

  .field-link {
    height: 136px;
    font-size: 14.5px;
  }

  .ph {
    left: 14px;
    right: 14px;
    font-size: 14.5px;
  }

  .ph-multiline {
    top: 16px;
  }

  .quota-badge {
    right: 10px;
    padding: 3px 8px;
    font-size: 12px;
  }

  .card-foot {
    margin-top: 16px;
    font-size: 13px;
  }
}
