:root {
  /* 4pt spacing scale */
  --space-2xs: 0.25rem;   /* 4 */
  --space-xs: 0.5rem;     /* 8 */
  --space-sm: 0.75rem;    /* 12 */
  --space-md: 1rem;       /* 16 */
  --space-lg: 1.5rem;     /* 24 */
  --space-xl: 2rem;       /* 32 */
  --space-2xl: 3rem;      /* 48 */
  --space-page: clamp(1rem, 2.5vw, 1.75rem);
  --touch-min: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --bg-app: #eef3f8;
  --bg-header: #172a46;
  --bg-header-soft: #223a5e;
  --bg-surface: #f4f8fc;
  --bg-panel: #fbfcfe;
  --border: #d7e0ea;
  --border-strong: #b8c7d8;
  --accent: #1f5eff;
  --accent-hover: #174ad6;
  --accent-soft: #eef4ff;
  --accent-ring: rgba(31, 94, 255, 0.16);
  --accent-warm: #f0b84a;
  --success: #177245;
  --success-bg: #eaf8f0;
  --success-border: #9dceb0;
  --danger: #b42318;
  --danger-bg: #fdecec;
  --busy-bg: #fff7e6;
  --busy-fg: #8a4b00;
  --text-heading: #132238;
  --text-body: #26364a;
  --text-muted: #667589;
  --text-on-dark: #f7faff;
  --text-on-dark-muted: #c8d7ee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(23, 42, 70, 0.04), 0 10px 24px rgba(23, 42, 70, 0.06);
  --font-sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --page-max: 880px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --z-sticky: 20;
  --picker-h: 3.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--text-body);
  background:
    radial-gradient(900px 380px at 8% -8%, rgba(31, 94, 255, 0.1), transparent 55%),
    radial-gradient(700px 320px at 100% 0%, rgba(23, 42, 70, 0.08), transparent 50%),
    linear-gradient(180deg, #e8eef6 0%, var(--bg-app) 42%, #e9f0f7 100%);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(31, 94, 255, 0.12);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding:
    calc(var(--space-md) + var(--safe-top))
    var(--space-page)
    calc(var(--space-2xl) + var(--safe-bottom));
}

/* —— Header：与下方卡片同宽 —— */
.hero {
  position: relative;
  overflow: hidden;
  color: var(--text-on-dark);
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  border-radius: var(--radius);
  background:
    radial-gradient(560px 220px at 92% -10%, rgba(79, 140, 255, 0.28), transparent 60%),
    linear-gradient(155deg, var(--bg-header) 0%, var(--bg-header-soft) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow), 0 14px 28px rgba(23, 42, 70, 0.16);
  animation: rise 0.55s var(--ease-out) both;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 78%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.hero-logout {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-on-dark-muted);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  transition: color 0.15s var(--ease-out), background 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.hero-logout:hover,
.hero-logout:focus-visible {
  color: var(--text-on-dark);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  outline: none;
}

.hero-brand {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
}

.hero-mark-wrap {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-top: 0.15rem;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 8px 18px rgba(0, 0, 0, 0.14);
}

.hero-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.hero-copy {
  min-width: 0;
  flex: 1;
}

.brand {
  margin: 0;
  max-width: 14em;
  font-size: clamp(1.55rem, 3.4vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-on-dark);
  line-height: 1.18;
}

.tagline {
  margin: var(--space-sm) 0 0;
  max-width: 34em;
  color: var(--text-on-dark-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.steps {
  --step-num-size: 1.9rem;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  position: relative;
}

/* 连线：仅连接第 1 圆心到第 3 圆心，不露两头 */
.steps::before {
  content: "";
  position: absolute;
  left: calc(100% / 6);
  right: calc(100% / 6);
  top: calc(var(--step-num-size) / 2);
  height: 2px;
  margin-top: -1px;
  background: rgba(255, 255, 255, 0.22);
  z-index: 0;
  pointer-events: none;
}

.step {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: 0;
  color: #b8c9de;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: var(--step-num-size);
  height: var(--step-num-size);
  border-radius: 999px;
  /* 不透明底，挡住贯穿数字的连线 */
  background: #1c3354;
  border: 2px solid rgba(255, 255, 255, 0.22);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #e8f0fa;
  box-shadow: 0 0 0 4px #1a2f4a;
}

.step-text {
  letter-spacing: 0.02em;
}

.step.is-active {
  color: var(--text-on-dark);
}

.step.is-active .step-num {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.28);
}

.step.is-done {
  color: #b8e6c9;
}

.step.is-done .step-num {
  background: #2f8f5b;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(47, 143, 91, 0.22);
}

/* —— Main：区块间距拉开节奏 —— */
.main {
  padding: var(--space-lg) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  animation: rise 0.65s 0.06s var(--ease-out) both;
}

.flow {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* 区块：只保留一层容器，避免卡片套卡片 */
.block {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-lg) var(--space-lg) var(--space-xl);
}

.block-primary {
  padding: var(--space-xl);
}

.block-quiet {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  box-shadow: none;
}

.block-result {
  border-color: var(--success-border);
  background: linear-gradient(180deg, #f1faf4 0%, var(--bg-panel) 48%);
  animation: rise 0.45s var(--ease-out) both;
}

.block-head {
  margin: 0 0 var(--space-lg);
}

.block-primary .block-head {
  margin-bottom: var(--space-xl);
}

.quiet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-md);
  margin-bottom: var(--space-md);
}

.block-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: 0.01em;
}

.block-desc {
  margin: var(--space-2xs) 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.quiet-head .block-desc {
  margin: 0;
}

.block-foot {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px dashed var(--border);
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* —— Upload：两列对比，内部紧密、列间留白 —— */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-xl) var(--space-lg);
}

.upload-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
}

.upload-item.is-ready .upload-zone,
.upload-item.is-ready .server-b-controls select {
  border-style: solid;
  border-color: var(--success-border);
  background: #f7fcf9;
}

.upload-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 1.75rem;
}

.upload-meta-b {
  justify-content: space-between;
  gap: var(--space-xs);
  flex-wrap: nowrap;
}

.upload-meta-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.upload-tag {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #1f4fbf;
  background: var(--accent-soft);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.upload-tag-b {
  color: #176a7a;
  background: #e8f6f8;
}

.upload-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-heading);
}

.file-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-zone {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  height: var(--picker-h);
  min-height: var(--picker-h);
  margin: 0;
  padding: 0 var(--space-md);
  box-sizing: border-box;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.file-field.has-file .upload-zone {
  border-style: solid;
  border-color: var(--accent);
}

.upload-icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent-soft), #e7f3f7);
  box-shadow: inset 0 0 0 1px var(--border);
  position: relative;
}

.upload-icon::after {
  content: "";
  position: absolute;
  inset: 0.38rem 0.45rem 0.28rem;
  border: 1.5px solid #3a6fd8;
  border-radius: 2px;
  border-top-width: 4px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.file-field.has-file .file-name {
  color: var(--text-body);
  font-weight: 600;
}

.upload-action {
  font-size: 0.8rem;
  font-weight: 700;
  color: #28579a;
  background: var(--accent-soft);
  padding: var(--space-2xs) var(--space-sm);
  border-radius: 6px;
  white-space: nowrap;
}

/* —— Config：左右分栏用分割线，不用内嵌卡片 —— */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-xl) var(--space-lg);
}

.config-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}

@media (min-width: 640px) {
  .config-col + .config-col {
    padding-left: var(--space-lg);
    border-left: 1px solid var(--border);
  }
}

.config-col-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.field-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-heading);
}

select,
.col-input {
  width: 100%;
  min-height: var(--touch-min);
  font: inherit;
  font-size: 1rem; /* iOS 避免聚焦自动放大 */
  color: var(--text-body);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.col-input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

select:hover,
.col-input:hover {
  border-color: var(--border-strong);
}

select:focus,
.col-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

select:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* —— Flags：轻量勾选，减小视觉噪声 —— */
.flags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-xs) var(--space-md);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
  min-height: var(--touch-min);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.9rem;
  color: var(--text-body);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
  touch-action: manipulation;
}

.check:hover {
  background: rgba(31, 94, 255, 0.04);
}

.check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.check:has(input:checked) {
  color: var(--text-heading);
  font-weight: 600;
}

/* —— Actions —— */
.actions {
  position: sticky;
  bottom: max(var(--space-sm), var(--safe-bottom));
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-xs);
  background: rgba(251, 252, 254, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  padding: var(--space-md) var(--space-lg);
}

.actions-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
  flex: 1;
}

.btn-primary {
  appearance: none;
  border: none;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  min-height: var(--touch-min);
  padding: 0.7rem 1.35rem;
  box-shadow: 0 6px 16px rgba(31, 94, 255, 0.28);
  transition: background 0.15s ease, transform 0.12s var(--ease-out), box-shadow 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  touch-action: manipulation;
}

.btn-primary[hidden],
.btn-secondary[hidden],
.btn-download[hidden] {
  display: none !important;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: #8ea6d8;
  box-shadow: none;
  cursor: not-allowed;
}

.progress {
  flex: 1;
  max-width: 160px;
  height: 6px;
  border-radius: 999px;
  background: #e5ecf5;
  overflow: hidden;
}

.progress-bar {
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #4f8cff);
  animation: progress-slide 1.1s ease-in-out infinite;
}

.status {
  flex-shrink: 0;
  max-width: min(52%, 22rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 700;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 8px;
  background: var(--accent-soft);
  color: #28579a;
}

.status[data-kind="busy"] {
  background: var(--busy-bg);
  color: var(--busy-fg);
}

.status[data-kind="ok"] {
  background: var(--success-bg);
  color: var(--success);
}

.status[data-kind="error"] {
  background: var(--danger-bg);
  color: var(--danger);
  white-space: normal;
  max-width: min(60%, 28rem);
}

/* —— Result —— */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
  margin: 0 0 var(--space-lg);
}

.stats div {
  padding: var(--space-sm) 0;
  border-top: 1px solid var(--border);
}

.stats dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stats dd {
  margin: var(--space-2xs) 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.result-actions {
  display: flex;
  gap: var(--space-sm);
}

.btn-download {
  width: fit-content;
}

/* —— B 表来源切换（标题行） —— */
.source-tabs {
  display: inline-flex;
  flex-shrink: 0;
  gap: 1px;
  padding: 1px;
  margin: 0;
  background: #e8eef6;
  border-radius: 6px;
}

.source-tab {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}

.source-tab:hover {
  color: var(--text-heading);
}

.source-tab.is-active {
  background: #fff;
  color: var(--text-heading);
  box-shadow: 0 1px 2px rgba(23, 42, 70, 0.08);
}

.b-source {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
}

.b-source[hidden] {
  display: none !important;
}

.server-b-controls {
  display: flex;
  gap: var(--space-xs);
  align-items: stretch;
  min-width: 0;
  height: var(--picker-h);
}

.server-b-controls select {
  flex: 1;
  min-width: 0;
  height: 100%;
  min-height: 0;
  padding: 0 var(--space-md);
  box-sizing: border-box;
  font-size: 0.88rem;
  line-height: 1.2;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-muted);
}

.server-b-controls select:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.server-b-controls select:focus {
  border-color: var(--accent);
  background: #fff;
  color: var(--text-body);
}

.btn-refresh {
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
  padding: 0 0.65rem;
  box-sizing: border-box;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* —— 结果弹窗 —— */
body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(var(--space-md), var(--safe-top))
    max(var(--space-md), var(--safe-right))
    max(var(--space-md), var(--safe-bottom))
    max(var(--space-md), var(--safe-left));
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 34, 56, 0.48);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  width: min(420px, 100%);
  max-height: min(86vh, 640px);
  overflow: auto;
  padding: var(--space-lg);
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 24px 48px rgba(23, 42, 70, 0.22);
  animation: modal-in 0.28s var(--ease-out) both;
}

.modal[data-kind="ok"] .modal-title {
  color: var(--success);
}

.modal[data-kind="error"] .modal-title {
  color: var(--danger);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

.modal-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -6px -8px 0 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: var(--accent-soft);
  color: var(--text-heading);
  outline: none;
}

.modal-msg {
  margin: 0 0 var(--space-md);
  color: var(--text-body);
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-stats {
  margin-bottom: var(--space-md);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.btn-secondary {
  min-height: var(--touch-min);
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-heading);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* —— 悬停提示（对齐桌面版 ToolTip） —— */
[data-tip] {
  cursor: help;
}

.app-tooltip {
  position: fixed;
  z-index: 200;
  max-width: min(380px, calc(100vw - 24px));
  padding: 0.55rem 0.7rem;
  border: 1px solid #c9c7a8;
  border-radius: 6px;
  background: #ffffe8;
  color: #26364a;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 20px rgba(23, 42, 70, 0.14);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.app-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: none) {
  [data-tip] {
    cursor: inherit;
  }

  .btn-primary:hover:not(:disabled) {
    transform: none;
  }

  .upload-zone:hover {
    box-shadow: none;
  }

  .upload-zone:active {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .source-tab:active {
    color: var(--text-heading);
  }

  .btn-primary:active:not(:disabled) {
    background: var(--accent-hover);
  }

  .btn-secondary:active {
    background: var(--accent-soft);
  }
}

/* —— Footer —— */
.footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: var(--space-lg);
  padding: var(--space-sm) 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

@keyframes rise {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

/* —— 平板：保留双列，收紧留白 —— */
@media (min-width: 641px) and (max-width: 900px) {
  .main {
    padding-top: var(--space-lg);
  }

  .block,
  .block-primary {
    padding: var(--space-lg);
  }

  .upload-grid,
  .config-grid {
    gap: var(--space-lg);
  }
}

/* —— 手机竖屏 —— */
@media (max-width: 640px) {
  .page {
    padding:
      calc(var(--space-sm) + var(--safe-top))
      max(var(--space-sm), var(--safe-left))
      calc(1.5rem + var(--safe-bottom))
      max(var(--space-sm), var(--safe-right));
  }

  .hero {
    padding: var(--space-md) var(--space-md) var(--space-sm);
    border-radius: 12px;
  }

  .hero-inner {
    gap: var(--space-sm);
  }

  .hero-brand {
    gap: var(--space-sm);
    align-items: center;
  }

  .hero-mark-wrap {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    margin-top: 0;
  }

  .hero-mark {
    width: 28px;
    height: 28px;
  }

  .brand {
    font-size: clamp(1.15rem, 5.2vw, 1.35rem);
    max-width: none;
    letter-spacing: 0;
  }

  .tagline {
    font-size: 0.8rem;
    margin-top: var(--space-2xs);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .steps {
    --step-num-size: 1.6rem;
    margin-top: var(--space-2xs);
  }

  .step {
    min-height: 0;
    padding: 0;
    gap: 0.35rem;
  }

  .step-text {
    font-size: 0.7rem;
  }

  .main {
    padding: var(--space-sm) 0 0;
    gap: var(--space-sm);
  }

  .flow {
    gap: var(--space-sm);
  }

  .block,
  .block-primary {
    padding: var(--space-md);
    border-radius: 12px;
  }

  .block-quiet {
    padding: var(--space-sm) var(--space-md);
  }

  .block-head,
  .block-primary .block-head {
    margin-bottom: var(--space-sm);
  }

  .block-title {
    font-size: 1rem;
  }

  .block-desc {
    font-size: 0.82rem;
  }

  .quiet-head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2xs);
    margin-bottom: var(--space-sm);
  }

  .upload-grid,
  .config-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .flags {
    grid-template-columns: 1fr;
    gap: var(--space-2xs);
  }

  .upload-meta-b {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: var(--space-sm);
    min-height: 0;
  }

  .source-tabs {
    width: 100%;
    display: flex;
    padding: 3px;
    border-radius: 10px;
  }

  .source-tab {
    flex: 1;
    min-height: 40px;
    padding: 0 0.4rem;
    font-size: 0.8rem;
    border-radius: 8px;
  }

  .check {
    min-height: var(--touch-min);
    padding: var(--space-sm) var(--space-xs);
    border-radius: 8px;
    align-items: center;
  }

  .check input {
    width: 1.2rem;
    height: 1.2rem;
  }

  .hint {
    font-size: 0.78rem;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .upload-zone {
    height: auto;
    min-height: 0;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon name"
      "action action";
    gap: var(--space-sm);
    padding: var(--space-md);
  }

  .upload-zone .upload-icon {
    grid-area: icon;
  }

  .upload-zone .file-name {
    grid-area: name;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    font-size: 0.88rem;
  }

  .upload-zone .upload-action {
    grid-area: action;
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.75rem var(--space-md);
    min-height: var(--touch-min);
    line-height: 1.3;
    box-sizing: border-box;
    font-size: 0.9rem;
  }

  .server-b-controls {
    height: auto;
    flex-wrap: nowrap;
    gap: var(--space-sm);
  }

  .server-b-controls select,
  .btn-refresh {
    height: auto;
    min-height: var(--touch-min);
    font-size: 16px;
  }

  .btn-refresh {
    padding: 0 0.85rem;
    min-width: 4.2rem;
  }

  select,
  .col-input {
    font-size: 16px;
    min-height: var(--touch-min);
  }

  .field-inline {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .col-input {
    text-align: center;
  }

  .actions {
    position: sticky;
    left: auto;
    right: auto;
    top: auto;
    bottom: max(0.5rem, var(--safe-bottom));
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    margin: var(--space-sm) 0 0;
    padding: var(--space-sm) var(--space-md);
    border-radius: 14px;
    box-shadow: 0 -4px 24px rgba(23, 42, 70, 0.12), var(--shadow);
  }

  .actions-left {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .progress {
    max-width: none;
    order: 2;
  }

  .status,
  .status[data-kind="busy"],
  .status[data-kind="ok"],
  .status[data-kind="error"] {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    flex-shrink: 1;
    align-self: stretch;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
    padding: var(--space-sm);
    font-size: 0.82rem;
  }

  .btn-primary {
    width: 100%;
    min-height: 48px;
    font-size: 1.02rem;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .stats div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
  }

  .stats dd {
    font-size: 1.35rem;
    margin: 0;
  }

  .result-actions {
    flex-direction: column;
  }

  .btn-download {
    width: 100%;
  }

  .modal {
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    max-width: none;
    max-height: min(88vh, 640px);
    border-radius: 18px 18px 0 0;
    padding:
      var(--space-lg)
      max(var(--space-md), var(--safe-right))
      calc(var(--space-lg) + var(--safe-bottom))
      max(var(--space-md), var(--safe-left));
    animation: modal-sheet-in 0.28s var(--ease-out) both;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn-primary,
  .modal-actions .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .modal-close {
    width: 44px;
    height: 44px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2xs);
    margin-top: var(--space-md);
    padding: var(--space-sm) 0 0;
    font-size: 0.72rem;
  }
}

@keyframes modal-sheet-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* —— 超窄屏（小屏手机） —— */
@media (max-width: 380px) {
  .brand {
    font-size: 1.22rem;
  }

  .field-inline {
    grid-template-columns: 1fr;
  }

  .step-text {
    font-size: 0.68rem;
  }
}

/* —— 横屏矮屏：压缩顶栏，优先内容 —— */
@media (max-height: 480px) and (orientation: landscape) {
  .hero {
    padding: var(--space-sm) var(--space-md);
  }

  .hero-inner {
    gap: var(--space-sm);
  }

  .tagline {
    display: none;
  }

  .steps {
    display: none;
  }

  .main {
    padding-top: var(--space-sm);
    gap: var(--space-sm);
  }

  .flow {
    gap: var(--space-sm);
  }

  .block,
  .block-primary,
  .block-quiet {
    padding: var(--space-sm) var(--space-md);
  }

  .block-head,
  .block-primary .block-head {
    margin-bottom: var(--space-sm);
  }

  .page {
    padding-bottom: calc(1.5rem + var(--safe-bottom));
  }
}

/* 触控设备样式见上方 @media (hover: none) */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* —— 登录页 —— */
.login-body {
  min-height: 100vh;
  min-height: 100dvh;
}

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--space-lg) + var(--safe-top))
    var(--space-page)
    calc(var(--space-lg) + var(--safe-bottom));
}

.login-card {
  width: min(100%, 22rem);
  padding: var(--space-xl) var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-sm);
}

.login-mark {
  display: block;
  margin: 0 auto var(--space-sm);
  border-radius: 10px;
}

.login-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-heading);
  letter-spacing: 0.02em;
}

.login-sub {
  margin: var(--space-2xs) 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.login-error {
  margin: 0;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.88rem;
  text-align: center;
}

.login-input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-body);
  font: inherit;
  font-size: 16px;
}

.login-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.login-submit {
  width: 100%;
  margin-top: var(--space-xs);
  justify-content: center;
}

@media (max-width: 640px) {
  .hero-logout {
    top: -0.15rem;
    right: -0.15rem;
    font-size: 0.72rem;
    padding: 0.3rem 0.55rem;
  }
}

