:root {
  --bg: #0d1117;
  --bg-soft: #141a22;
  --panel: #171e27;
  --panel-2: #1d2530;
  --line: #2a3441;
  --line-soft: #222b36;
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --text-faint: #5d6b7c;
  --accent: #3fb950;
  --accent-2: #2ea043;
  --blue: #4493f8;
  --amber: #d29922;
  --red: #f85149;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(700px 400px at 15% -10%, rgba(63, 185, 80, 0.09), transparent 70%),
    radial-gradient(600px 400px at 100% 0%, rgba(68, 147, 248, 0.07), transparent 70%);
  background-repeat: no-repeat;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #1f6f43, #2ea043);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(46, 160, 67, 0.28);
}

h1 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }
.sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.pill--idle .dot { background: var(--text-faint); }
.pill--wait .dot { background: var(--amber); animation: blink 1.4s infinite; }
.pill--ok { color: #9be4a8; border-color: rgba(63,185,80,.35); background: rgba(63,185,80,.1); }
.pill--ok .dot { background: var(--accent); }
.pill--relay { color: #ffd98a; border-color: rgba(210,153,34,.35); background: rgba(210,153,34,.1); }
.pill--relay .dot { background: var(--amber); }
.pill--err { color: #ffb3ae; border-color: rgba(248,81,73,.35); background: rgba(248,81,73,.1); }
.pill--err .dot { background: var(--red); }

@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- card ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.intro h2, .waiting h2, .conn-head h2 { margin: 0 0 6px; font-size: 17px; }
.intro p { margin: 0 0 22px; font-size: 13.5px; color: var(--text-dim); line-height: 1.6; }
.hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; margin: 0 0 12px; }
.hint.dim { color: var(--text-faint); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 620px) { .two-col { grid-template-columns: 1fr; } }

.pane {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 18px;
}
.pane-title { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }

/* ---------- inputs & buttons ---------- */
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0f151c;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(46,160,67,.15); }
.input::placeholder { color: var(--text-faint); }

.join-row { display: flex; gap: 8px; }
.join-row .input { text-transform: uppercase; letter-spacing: 3px; font-family: var(--mono); font-size: 15px; text-align: center; }

.btn {
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #212b36;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
  white-space: nowrap;
}
.btn:hover { background: #2a3542; border-color: #3a4655; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: #2c8f3e;
  color: #fff;
  font-weight: 600;
}
.btn--primary:hover { background: linear-gradient(180deg, #4ac35c, #31a848); }
.btn--block { width: 100%; margin-top: 4px; }
.btn--sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn--ghost { background: transparent; }

.linkbtn {
  background: none; border: none; padding: 0;
  color: var(--blue); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- advanced ---------- */
.adv { margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.adv summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-dim);
  list-style: none; user-select: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: "▸ "; color: var(--text-faint); }
.adv[open] summary::before { content: "▾ "; }
.adv-body { padding-top: 14px; display: grid; gap: 10px; }
.field { display: block; font-size: 12px; color: var(--text-dim); }
.field span { display: block; margin-bottom: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.adv-actions { display: flex; align-items: center; gap: 10px; }
.adv-actions .hint { margin: 0; }

.error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: #ffb3ae;
  font-size: 12.5px;
}

/* ---------- waiting ---------- */
.waiting { text-align: center; padding: 10px 0 4px; }

.radar {
  position: relative;
  width: 74px; height: 74px;
  margin: 0 auto 20px;
}
.radar span {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(63, 185, 80, 0.45);
  animation: ripple 2.4s ease-out infinite;
}
.radar span:nth-child(2) { animation-delay: .8s; }
.radar span:nth-child(3) { animation-delay: 1.6s; }
.radar i {
  position: absolute; left: 50%; top: 50%;
  width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(63, 185, 80, .8);
}
@keyframes ripple {
  0% { transform: scale(.18); opacity: .9; }
  100% { transform: scale(1); opacity: 0; }
}

.codebox {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 8px 0 16px;
}
.codebox code {
  font-family: var(--mono);
  font-size: 30px;
  letter-spacing: 9px;
  padding: 10px 8px 10px 17px;
  border-radius: 10px;
  background: #0f151c;
  border: 1px solid var(--line);
  color: #7ee787;
}

.linkbox { display: flex; gap: 8px; max-width: 460px; margin: 0 auto 14px; }
.linkbox .input { font-size: 12px; font-family: var(--mono); color: var(--text-dim); }

/* ---------- connected ---------- */
.conn-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 18px;
}
.conn-head .hint { margin: 0; }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 34px 20px;
  text-align: center;
  background: rgba(255,255,255,0.012);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.drop:hover, .drop:focus-visible { border-color: #3d4d5f; outline: none; }
.drop.over {
  border-color: var(--accent);
  background: rgba(63, 185, 80, 0.07);
}
.drop-icon { font-size: 26px; color: var(--text-faint); margin-bottom: 8px; }
.drop-main { font-size: 14.5px; font-weight: 600; margin-bottom: 5px; }
.drop-sub { font-size: 12.5px; color: var(--text-dim); }

/* ---------- receive sink ---------- */
.sink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: var(--panel-2);
}
.sink-body { min-width: 0; }
.sink-body strong { display: block; font-size: 12.8px; font-weight: 600; }
.sink-body .hint { margin: 3px 0 0; font-size: 12px; }
@media (max-width: 560px) {
  .sink { flex-direction: column; align-items: stretch; }
}

.lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 22px;
}
@media (max-width: 680px) { .lists { grid-template-columns: 1fr; } }

.list-col { min-width: 0; }
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-dim);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.badge {
  min-width: 20px; text-align: center;
  font-family: var(--mono); font-size: 11px;
  padding: 1px 6px; border-radius: 999px;
  background: var(--panel-2); color: var(--text-faint);
  border: 1px solid var(--line-soft);
}

.items { list-style: none; margin: 0; padding: 0; }
.items:empty::after {
  content: "—";
  display: block;
  padding: 16px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
}

.item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.item:last-child { border-bottom: none; }

.item-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 7px;
}
.item-name {
  font-size: 12.8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.item-meta { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; font-family: var(--mono); }

.bar {
  height: 4px;
  border-radius: 999px;
  background: #0f151c;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .12s linear;
}
.bar.done > i { background: var(--accent); }
.bar.fail > i { background: var(--red); width: 100% !important; }

.item-actions { margin-top: 7px; display: flex; gap: 8px; }
.item-status { font-size: 11.5px; color: var(--accent); }
.item-status.err { color: var(--red); }
.item-status.relay { color: var(--amber); }

.dl {
  display: inline-block;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 7px;
  background: rgba(68, 147, 248, .12);
  border: 1px solid rgba(68, 147, 248, .3);
  color: #8fc0ff;
  text-decoration: none;
}
.dl:hover { background: rgba(68, 147, 248, .2); }

.foot {
  margin-top: 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
}
