:root {
  --bg: #020617;
  --bg-elevated: #020617;
  --card-bg: rgba(15, 23, 42, 0.9);
  --border-subtle: rgba(148, 163, 184, 0.3);
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.2);
  --primary-strong: rgba(59, 130, 246, 0.5);
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;
  --accent: #22c55e;
  --danger: #f97373;
  --shadow-soft: 0 24px 60px rgba(15, 23, 42, 0.8);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.25), transparent),
    radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.15), #020617);
  color: var(--text-main);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}

.header {
  width: 100%;
  max-width: 1040px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 40px;
}

.lang-switch {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.lang-switch:hover {
  background: rgba(15, 23, 42, 1);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.hero {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2.4fr);
  gap: 40px;
  align-items: center;
}

/* 进入工作区后：只显示工作区，兑换区与标题区隐藏，单列居中布局 */
.page--workspace .hero {
  grid-template-columns: 1fr;
  gap: 0;
  align-items: stretch;
  justify-items: center;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  padding-top: 8px;
}

.page--workspace .hero-text,
.page--workspace .card {
  display: none !important;
}

.page--workspace .workspace {
  display: flex !important;
  width: 100%;
}

.hero-text h1 {
  font-size: clamp(28px, 3.1vw, 38px);
  line-height: 1.2;
  margin: 0 0 18px;
}

.hero-text p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
  max-width: 34rem;
}

.card {
  background: radial-gradient(circle at top, var(--primary-soft), transparent),
    var(--card-bg);
  border-radius: 24px;
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-label {
  font-size: 13px;
  color: var(--text-soft);
}

.code-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.code-input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

.code-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.7);
  background: #020617;
}

.primary-btn {
  margin-top: 4px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow:
    0 18px 40px rgba(37, 99, 235, 0.35),
    0 0 0 1px rgba(191, 219, 254, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    filter 0.15s ease,
    opacity 0.15s ease;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 22px 45px rgba(37, 99, 235, 0.45),
    0 0 0 1px rgba(191, 219, 254, 0.35);
  filter: brightness(1.05);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    0 12px 28px rgba(37, 99, 235, 0.5),
    0 0 0 1px rgba(191, 219, 254, 0.4);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.3);
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

.link-btn {
  margin-top: 2px;
  padding: 0;
  border: none;
  background: none;
  color: #60a5fa;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: #93c5fd;
}

.status-text {
  min-height: 18px;
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.status-text--success {
  color: var(--accent);
}

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

.footer {
  margin-top: 40px;
  padding: 10px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.icp-link {
  color: inherit;
  text-decoration: none;
}

.icp-link:hover {
  text-decoration: underline;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: min(420px, 90vw);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent),
    #020617;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 26px 90px rgba(15, 23, 42, 0.95);
  padding: 20px 20px 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.close-btn {
  border: none;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  width: 26px;
  height: 26px;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.close-btn:hover {
  background: rgba(30, 64, 175, 0.6);
  color: #e5e7eb;
}

.modal-body {
  font-size: 13px;
  color: var(--text-soft);
  text-align: center;
}

.modal-contact {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.modal-contact-id {
  margin: 0;
  font-size: 13px;
  color: var(--text-main);
}

.modal-copy-btn {
  border: 1px solid var(--primary);
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.modal-copy-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #dbeafe;
  transform: translateY(-1px);
}

.modal-qrcode {
  display: block;
  width: 200px;
  max-width: 100%;
  margin: 2px auto 14px;
  border-radius: 16px;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.85);
}

/* 顶部全局提示条 */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate3d(-50%, -18px, 0);
  opacity: 0;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.9);
  pointer-events: none;
  z-index: 60;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.toast--show {
  opacity: 1;
  transform: translate3d(-50%, 0, 0);
}

.toast--success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: transparent;
}

.toast--error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: transparent;
}

/* ---------- 工作区（校验成功后显示） ---------- */
.workspace {
  grid-column: 1 / -1;
  max-width: 640px;
  margin: 0 auto;
  background: radial-gradient(circle at top, var(--primary-soft), transparent),
    var(--card-bg);
  border-radius: 24px;
  padding: 28px 26px 24px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace[hidden] {
  display: none !important;
}

.workspace-header h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}

.workspace-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.upload-zone {
  border: 2px dashed rgba(148, 163, 184, 0.5);
  border-radius: 16px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: rgba(15, 23, 42, 0.5);
}

.upload-zone:hover,
.upload-zone.is-dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.upload-zone.has-file {
  border-style: solid;
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.1);
  cursor: default;
}

.upload-placeholder {
  pointer-events: none;
}

.upload-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
}

.upload-text {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--text-main);
}

.upload-formats {
  margin: 0;
  font-size: 12px;
  color: var(--text-soft);
}

.upload-selected-name {
  margin: 10px 0 0;
  display: inline-flex;
  max-width: min(100%, 420px);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(15, 23, 42, 0.65);
  color: #bfdbfe;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-zone.has-file .upload-formats {
  display: none;
}

.upload-zone.has-file .upload-text {
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 600;
  color: #dbeafe;
}

.upload-zone.has-file .upload-selected-name {
  display: flex;
  width: min(100%, 420px);
  max-width: 100%;
  margin: 12px auto 0;
  border-radius: 12px;
  padding: 12px 16px;
  justify-content: center;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(96, 165, 250, 0.55);
  text-align: center;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #bfdbfe;
}

.discipline-selection {
  margin: 16px auto 24px;
  text-align: left;
  max-width: 420px;
  width: 100%;
}

.discipline-selection label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-main);
  font-size: 14px;
  padding-left: 2px;
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-color: var(--text-soft);
  clip-path: polygon(100% 0%, 0 0%, 50% 100%);
  pointer-events: none;
}

.discipline-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  font-size: 14px;
  background-color: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.discipline-select:hover {
  border-color: rgba(96, 165, 250, 0.8);
  background-color: rgba(15, 23, 42, 1);
}

.discipline-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
  background-color: #020617;
}

.discipline-select option {
  background-color: #0f172a;
  color: var(--text-main);
  padding: 12px;
}

.upload-status {
  min-height: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  color: var(--text-soft);
  display: none;
  border-radius: 12px;
}

.upload-status:not(:empty) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.55);
  box-shadow: inset 0 0 0 1px rgba(2, 6, 23, 0.35);
}

.upload-status:not(:empty)::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.upload-status.is-loading {
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.08);
}

.upload-status.is-loading::before {
  border: 2px solid rgba(59, 130, 246, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: upload-status-spin 0.9s linear infinite;
}

.upload-status.is-error {
  color: var(--danger);
  border-color: rgba(249, 115, 115, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.upload-status.is-error::before {
  content: "!";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.24);
  color: #fca5a5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.upload-status.is-success {
  color: var(--accent);
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.08);
}

.upload-status.is-success::before {
  content: "✓";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.confirm-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0 0;
}

.confirm-area[hidden] {
  display: none !important;
}

.file-name {
  display: none;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-top: 8px;
}

.confirm-actions .primary-btn {
  margin-top: 0;
  width: auto;
  min-width: 160px;
  margin-left: auto;
}

.secondary-btn {
  border: 1px solid rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.12);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.secondary-btn:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(96, 165, 250, 0.85);
  transform: translateY(-1px);
}

.link-btn--danger {
  color: var(--danger);
}

.link-btn--danger:hover {
  color: #fca5a5;
}

.result-area {
  margin-top: 8px;
  padding: 16px 0 0;
  border-top: 1px solid var(--border-subtle);
  animation: result-fade-in 0.24s ease;
}

.result-area[hidden] {
  display: none !important;
}

.result-label {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--text-soft);
}

.result-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-soft);
}

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

@keyframes result-fade-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-btn--outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}

.primary-btn--outline:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--text-main);
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .page {
    padding: 16px 16px 24px;
    justify-content: flex-start;
    gap: 0;
  }

  .header {
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 4px 0;
  }

  .lang-switch {
    font-size: 13px;
    padding: 7px 13px;
  }

  /* 移动端：单列布局，文字区在上方居中，卡片在下 */
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .hero-text {
    text-align: center;
    padding: 0 10px;
  }

  .card {
    border-radius: 20px;
    padding: 20px 18px 18px;
    gap: 12px;
  }

  .input-label {
    font-size: 12px;
  }

  /* 加大输入框触控高度 */
  .code-input {
    padding: 13px 14px;
    font-size: 16px; /* 防止 iOS Safari 自动缩放 */
    border-radius: 12px;
  }

  /* 加大按钮触控高度 */
  .primary-btn {
    padding: 14px 16px;
    font-size: 15px;
    border-radius: 999px;
  }

  .link-btn {
    font-size: 13px;
    padding: 4px 0;
  }

  /* 英雄区文字 */
  .hero-text h1 {
    font-size: clamp(22px, 6vw, 28px);
    margin-bottom: 12px;
  }

  .hero-text p {
    font-size: 13px;
    line-height: 1.65;
    max-width: 100%;
  }

  /* 工作区 */
  .workspace {
    padding: 20px 16px 18px;
    border-radius: 20px;
    gap: 14px;
  }

  .workspace-header h2 {
    font-size: 16px;
  }

  .workspace-header p {
    font-size: 12px;
    line-height: 1.6;
  }

  .upload-zone {
    padding: 28px 16px;
    border-radius: 14px;
  }

  .upload-icon {
    font-size: 34px;
  }

  .upload-text {
    font-size: 14px;
  }

  .upload-selected-name {
    max-width: 100%;
  }

  .upload-status:not(:empty) {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 11px;
    font-size: 12px;
  }

  /* 确认操作区：垂直堆叠，按钮全宽 */
  .confirm-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .confirm-actions .primary-btn {
    width: 100%;
    min-width: unset;
    margin-left: 0;
    order: -1; /* 移动端确认按钮置顶，方便操作 */
    padding: 14px;
    font-size: 16px;
  }

  .confirm-actions .secondary-btn {
    width: 100%;
    padding: 12px;
  }

  .confirm-actions #removeFileBtn {
    padding: 12px;
    text-align: center;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    border-radius: 999px;
    text-decoration: none;
  }

  /* 下载按钮全宽 */
  .result-actions {
    flex-direction: column;
    gap: 10px;
  }

  .result-actions .primary-btn {
    width: 100%;
    margin-top: 0;
    min-width: unset;
    padding: 13px 16px;
  }

  /* 弹窗在移动端从底部弹出 */
  .modal-backdrop {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    border-radius: 22px 22px 0 0;
    padding: 22px 20px 32px;
    max-height: 85vh;
    overflow-y: auto;
  }

  .modal-qrcode {
    width: 160px;
  }

  .modal-copy-btn {
    width: 100%;
    max-width: 260px;
    padding: 10px 14px;
  }

  .footer {
    margin-top: 24px;
  }
}

/* 小屏手机（≤390px）微调 */
@media (max-width: 390px) {
  .page {
    padding: 12px 12px 20px;
  }

  .card {
    padding: 18px 14px 16px;
  }

  .hero-text h1 {
    font-size: 20px;
  }
}

