/* ─── tokens（黑白主题，仅一处定义）────────────────────────────────
   说明：原型中的 color-mix() 在这里统一静态化（rgba / 十六进制），
   微信低版本 XWeb 内核不支持 color-mix，且经 custom property 传递时
   失败会整条失效而非回退到上一条声明，故不用。色值按白底上的
   混色结果直接给定，观感一致。 */
:root {
  --bg:      #ffffff;
  --surface: #ffffff;
  --fg:      #111111;
  --muted:   #8a8a8a;
  --border:  #ebebeb;
  --border-mid: #d6d6d6;
  --accent:  #111111;           /* 强调色即“黑”本身 */

  --accent-soft: rgba(17, 17, 17, 0.07);  /* = color-mix(accent 7%, transparent) */
  --fg-soft:     rgba(17, 17, 17, 0.06);  /* = color-mix(fg 6%, transparent) */
  --ink-hover:   #2e2e2e;                 /* = color-mix(accent 82%, white) */
  --ink-active:  #3a3a3a;                 /* = color-mix(accent 68%, white) */
  --topbar-bg:   rgba(255, 255, 255, 0.94);

  --font-display: -apple-system, BlinkMacSystemFont, "PingFang SC",
                  "HarmonyOS Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, "PingFang SC",
                  "HarmonyOS Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-h1: clamp(26px, 6.4vw, 32px);
  --fs-lead: 15px;
  --radius: 8px;
}

/* ─── base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
svg { display: block; }
button { font: inherit; cursor: pointer; background: none; border: 0; padding: 0; color: inherit; }
button:focus-visible,
.link-reset:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ─── app shell（单屏，无横向滚动）────────────────────────────── */
.app {
  min-height: 100vh;            /* 旧内核回退 */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin-inline: auto;
}

/* 缺参引导态：隐藏主按钮与格式标签，文案由 JS 替换 */
.app.is-blocked .action { display: none; }
.app.is-blocked .tags   { display: none; }

/* ─── 顶部导航 ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: 52px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding-inline: 10px;
}
.back {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  transition: background .15s ease;
}
.back:hover { background: var(--fg-soft); }
.back:active { background: var(--accent-soft); }
.topbar-title {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
}

/* ─── 主区：主视觉在上、文案与按钮靠下 ───────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 32px calc(28px + env(safe-area-inset-bottom));
}
.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding-block: 12px;
  min-height: 220px;
}

/* 入场微动效（唯一的整页动效预算主视觉） */
.stage .illo { animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.intro { text-align: center; }
.intro h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -.015em;
  margin: 0 0 10px;
}
.intro .lead {
  font-size: var(--fs-lead);
  color: var(--muted);
  margin: 0 0 18px;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}
.tag {
  padding: 4px 10px;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ─── 主按钮与状态机 ───────────────────────────────────────────── */
.action { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.btn-main {
  position: relative;
  overflow: hidden;
  width: min(88%, 300px);
  height: 52px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--surface);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s ease, transform .05s ease, color .15s ease,
              border-color .15s ease, box-shadow .15s ease;
  border: 1px solid var(--accent);
}
.btn-main:hover { background: var(--ink-hover); }
.btn-main:active { background: var(--ink-active); transform: translateY(1px); }
/* 按钮内进度条（上传中显示） */
.btn-main::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: var(--p, 0%);
  background: rgba(255, 255, 255, 0.45);
  transition: width .18s ease;
}

.btn-main:disabled { cursor: not-allowed; }
.btn-main:disabled:hover { background: var(--accent); transform: none; }

/* 成功态：反转为白底黑描边（占用别的状态样式，不与默认态重复） */
.btn-main.is-success {
  background: var(--surface);
  color: var(--fg);
}
.btn-main.is-success:hover { background: var(--accent-soft); }
.btn-main.is-success::after { display: none; }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--surface);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 状态回执（aria-live） */
.status {
  width: 100%;
  max-width: 320px;
  min-height: 22px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.status.show { display: flex; }
.status-head {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  color: var(--muted);
}
.status-head svg { flex: none; }
.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  max-width: 100%;
}
.file-size { color: var(--muted); font-family: var(--font-mono); flex: none; }
.status-error { color: var(--fg); font-weight: 600; }

.track {
  width: 100%;
  height: 3px;
  background: var(--fg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.track i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: var(--fg);
  transition: width .18s ease;
}

/* ─── 底部提示 ─────────────────────────────────────────────────── */
.footnote {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-block: 18px 4px;
}
.footnote::before {
  content: '';
  display: block;
  width: 36px;
  height: 1px;
  background: var(--border-mid);
  margin: 0 auto 12px;
}

/* ─── toast（错误提示，浮层）────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  top: 74px;
  transform: translate(-50%, -10px);
  background: var(--accent);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 30;
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 触屏设备移除 hover 底色，避免按钮在点击后残留渐变 */
@media (hover: none) {
  .back:hover, .link-reset:hover { background: inherit; }
  .btn-main:hover { background: var(--accent); }
  .btn-main:active { background: var(--ink-active); }
}
