:root {
  --bg: #f5f6fb;
  --glow-a: #e9e6ff;
  --glow-b: #e0f3ff;
  --card: #ffffff;
  --ink: #14161f;
  --muted: #6a7186;
  --line: #e6e8f1;
  --field: #f4f5fa;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eeeeff;
  --ok: #0b9b70;
  --danger: #dc3d43;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(20, 22, 31, .05), 0 14px 40px rgba(20, 22, 31, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c11;
    --glow-a: #1a1730;
    --glow-b: #101f2c;
    --card: #14161d;
    --ink: #f3f4f8;
    --muted: #98a0b4;
    --line: #252937;
    --field: #1b1e28;
    --accent: #7d78ff;
    --accent-ink: #0a0a12;
    --accent-soft: #1e1f3b;
    --ok: #34d399;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 15% -12%, var(--glow-a) 0%, transparent 62%),
    radial-gradient(900px 540px at 108% 4%, var(--glow-b) 0%, transparent 58%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: max(30px, env(safe-area-inset-top)) 16px 40px;
}

.top { text-align: center; margin-bottom: 20px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .02em;
}
.brand svg { width: 26px; height: 26px; color: var(--accent); }

.tag {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--field);
  border-radius: 13px;
  margin-bottom: 18px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(20, 22, 31, .10);
}

.panel { display: none; }
.panel.active { display: block; }

.view { display: none; }
.view.active { display: block; animation: rise .22s ease both; }

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

/* 选择文件 */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 40px 18px;
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  background: var(--field);
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.drop:hover, .drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop.over { transform: scale(.995); }

.drop-icon {
  width: 34px;
  height: 34px;
  color: var(--accent);
  margin-bottom: 2px;
}

.drop strong { font-size: 15.5px; font-weight: 600; }
.drop span { font-size: 13px; color: var(--muted); }

.hint {
  margin: 14px 2px 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

/* 取件码 */
.code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 12px 20px;
  background: var(--accent-soft);
  border-radius: 16px;
  margin-bottom: 12px;
}

.code-box .label {
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--muted);
  text-transform: uppercase;
}

.code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(34px, 11.5vw, 46px);
  font-weight: 600;
  letter-spacing: .16em;
  text-indent: .16em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

.link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.link-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--field);
  color: var(--muted);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.link-row .btn { width: auto; flex: none; padding: 0 14px; height: 40px; font-size: 13.5px; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  padding: 12px 14px;
  background: var(--field);
  border-radius: 12px;
  margin-bottom: 12px;
}
.status:empty { display: none; }
.status.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.status.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }

/* 文件卡片 */
.filecard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 12px;
  min-width: 0;
}
.filecard:empty { display: none; }
.filecard[hidden] { display: none; }

.filecard .ficon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.filecard .ficon svg { width: 18px; height: 18px; }

.filecard .fmeta { min-width: 0; }
.filecard .fname {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filecard .fsize { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 进度 */
.progress { margin: 4px 0 14px; }

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--field);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  transition: width .14s linear;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta .pct { color: var(--ink); font-weight: 700; font-size: 13px; }
.meta .eta:empty, .meta .speed:empty { display: none; }

/* 按钮 */
.btn {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .18s ease, transform .12s ease, opacity .18s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn[hidden] { display: none; }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--field); filter: none; }

.btn.danger.ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }

.btn.sm {
  width: auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12.5px;
}

/* 接收输入 */
.code-label {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 12px;
}

.code-input {
  display: block;
  width: 100%;
  height: 62px;
  margin-bottom: 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: clamp(24px, 8vw, 30px);
  letter-spacing: .28em;
  text-indent: .28em;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .18s ease, background .18s ease;
}
.code-input::placeholder { color: var(--muted); opacity: .45; }
.code-input:focus { border-color: var(--accent); background: var(--card); }

#recv-room .status { margin-bottom: 14px; }
#acceptBtn { margin-bottom: 12px; }
#recvCancel { margin-top: 2px; }
#sendCancel { margin-top: 2px; }

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.foot .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
}

.spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: rotate .8s linear infinite;
  flex: none;
}
@keyframes rotate { to { transform: rotate(360deg); } }

@media (max-width: 380px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .card { padding: 12px; }
  .drop { padding: 32px 12px; }
}
