* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #1e293bcc;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #818cf8;
  --green: #34d399;
  --red: #f87171;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #1e3a5f 0%, var(--bg) 55%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
}

.logo { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.header-actions { display: flex; gap: 8px; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #082f49;
  font-weight: 600;
  transition: transform .1s, opacity .15s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.97); }
.btn.small { padding: 7px 14px; font-size: 13px; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: transparent; border: 1px solid #7f1d1d; color: var(--red); font-weight: 500; }
.btn.danger:hover { border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.banner {
  margin: 0 20px 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #7c2d1233;
  border: 1px solid #9a3412;
  color: #fdba74;
  font-size: 13px;
  line-height: 1.7;
}

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hidden { display: none !important; }

/* ---------- 雷达页 ---------- */

.radar {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.ring {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #38bdf822;
  border-radius: 50%;
  animation: pulse 3s ease-out infinite;
}
.r1 { width: 200px; height: 200px; }
.r2 { width: 400px; height: 400px; animation-delay: .5s; }
.r3 { width: 620px; height: 620px; animation-delay: 1s; }

@keyframes pulse {
  0%   { opacity: .9; }
  50%  { opacity: .25; }
  100% { opacity: .9; }
}

.peers {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: center;
  align-items: center;
  max-width: 720px;
  padding: 20px;
}

.peer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .15s;
  animation: pop .3s ease;
}
.peer:hover { transform: translateY(-4px); }

@keyframes pop {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.peer-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a5f, #312e81);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 0 24px #38bdf844;
}

.peer-name { font-size: 13px; color: var(--text); max-width: 110px; text-align: center; }
.peer-sub { font-size: 11px; color: var(--muted); }

.radar-hint {
  position: absolute;
  bottom: 12%;
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  z-index: 1;
}

.me {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 26px;
  justify-content: center;
}

.me-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.me-name { font-weight: 600; font-size: 15px; }
.me-sub { font-size: 12px; color: var(--muted); margin-top: 3px; max-width: 480px; }

/* ---------- 传输页 ---------- */

#view-transfer { padding: 0 20px 20px; gap: 14px; max-width: 760px; width: 100%; margin: 0 auto; overflow-y: auto; }

.peer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
}

.peer-bar-info { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.link-type { font-size: 12px; color: var(--muted); }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 44px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop-zone.over { border-color: var(--accent); background: #38bdf811; }
.drop-icon { font-size: 40px; margin-bottom: 10px; }
.drop-text { font-size: 15px; }
.pick { color: var(--accent); cursor: pointer; text-decoration: underline; }
.drop-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }

.file-list { display: flex; flex-direction: column; gap: 10px; }

.file-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon { font-size: 24px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-status { font-size: 12px; color: var(--muted); margin-top: 3px; }

.progress { height: 4px; background: var(--border); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 2px; width: 0%; transition: width .2s; }
.file-item.done .progress-bar { background: var(--green); }

.file-save {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
}
.file-save:hover { border-color: var(--accent); }

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: #000a;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 34px;
  width: min(92vw, 400px);
  text-align: center;
  animation: pop .25s ease;
}

.modal h3 { font-size: 17px; margin-bottom: 10px; }
.modal p { font-size: 13px; color: var(--muted); line-height: 1.7; }

.code-display {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 10px;
  margin: 18px 0;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-indent: 10px;
}

.code-input {
  width: 100%;
  margin: 18px 0;
  padding: 13px;
  font-size: 26px;
  letter-spacing: 12px;
  text-align: center;
  text-indent: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  font-variant-numeric: tabular-nums;
}
.code-input:focus { border-color: var(--accent); }

.text-area {
  width: 100%;
  min-height: 110px;
  margin-top: 16px;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  resize: vertical;
}
.text-area:focus { border-color: var(--accent); }
.text-area.tall { min-height: 180px; }

.modal-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 4px;
  color: var(--muted);
  font-size: 12px;
}
.modal-divider::before, .modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.modal-actions .btn { min-width: 100px; }

.spinner {
  width: 30px; height: 30px;
  margin: 16px auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 22px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 30px #0008;
  animation: pop .2s ease;
  max-width: 88vw;
}

@media (max-width: 560px) {
  .peers { gap: 18px; }
  .peer-avatar { width: 60px; height: 60px; font-size: 26px; }
  .me-sub { display: none; }
  .header-actions .btn { padding: 6px 10px; font-size: 12px; }
}
