:root {
  --bg: #0f1220;
  --panel: #181c2f;
  --panel-2: #1f2440;
  --text: #e8eaf6;
  --muted: #8b91b3;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --ok: #2fd07a;
  --err: #ff5c7a;
  --radius: 14px;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #232a54 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.conn-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.conn-status .dot {
  width: 9px; height: 9px; border-radius: 50%; background: #f5b942;
  transition: background .3s;
}
.conn-status.online .dot { background: var(--ok); }
.conn-status.offline .dot { background: var(--err); }

main { max-width: 720px; margin: 0 auto; padding: 8px 20px 60px; display: grid; gap: 18px; }

/* Identity card */
.me-card {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: 0 8px 30px rgba(79, 140, 255, .25);
}
.me-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.2); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.me-name { font-size: 18px; font-weight: 700; }
.me-sub { font-size: 12.5px; opacity: .85; margin-top: 2px; }

/* Panels */
.panel {
  background: var(--panel); border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.05);
}
.panel h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 14px; }

/* Peer list */
.peer-list { display: flex; flex-wrap: wrap; gap: 12px; }
.empty-hint { color: var(--muted); font-size: 13.5px; line-height: 1.6; padding: 8px 2px; }
.peer {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--panel-2); border: 2px solid transparent;
  border-radius: var(--radius); padding: 14px 18px; min-width: 120px;
  cursor: pointer; transition: transform .15s, border-color .2s;
  user-select: none;
}
.peer:hover { transform: translateY(-2px); }
.peer.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.2); }
.peer.connected .peer-avatar { box-shadow: 0 0 0 3px var(--ok); }
.peer-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, #3b4371, #2b3057);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.peer-name { font-size: 13px; font-weight: 600; text-align: center; }
.peer-badge { font-size: 10.5px; color: var(--muted); }
.peer-badge.ok { color: var(--ok); }

/* PIN */
.pin-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.pin-display {
  background: var(--panel-2); border-radius: 10px; padding: 8px 16px;
  display: flex; align-items: baseline; gap: 10px;
}
.pin-display span { font-size: 24px; font-weight: 800; letter-spacing: 6px; color: var(--accent); }
.pin-display small { color: var(--muted); }
#pinInput {
  flex: 1; min-width: 160px; background: var(--panel-2); border: 1px solid rgba(255,255,255,.08);
  color: var(--text); border-radius: 10px; padding: 11px 14px; font-size: 16px;
  letter-spacing: 4px; outline: none;
}
#pinInput:focus { border-color: var(--accent); }
.pin-error { color: var(--err); font-size: 13px; min-height: 18px; }

/* Buttons */
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 11px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid rgba(255,255,255,.1); }

/* Drop zone */
.drop-zone {
  border: 2px dashed rgba(255,255,255,.18); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; transition: border-color .2s, background .2s;
}
.drop-zone .drop-icon { font-size: 36px; margin-bottom: 8px; }
.drop-zone p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.drop-zone.dragover { border-color: var(--accent); background: rgba(79,140,255,.08); }
.drop-zone.disabled { opacity: .6; }
.drop-zone.ready { border-color: rgba(47,208,122,.5); }

/* Transfers */
.transfer {
  background: var(--panel-2); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px;
}
.transfer-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13.5px; }
.transfer-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-stats { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .12s linear;
}
.transfer.done .progress-fill { background: var(--ok); }
.transfer.error .progress-fill { background: var(--err); }

/* File offer consent cards */
#offerContainer {
  position: fixed; top: 16px; right: 16px; display: grid; gap: 10px;
  z-index: 100; max-width: 340px;
}
.offer-card {
  background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
  animation: toast-in .25s ease;
}
.offer-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.offer-body { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; word-break: break-word; }
.offer-actions { display: flex; gap: 8px; }
.offer-actions .btn { padding: 8px 16px; font-size: 13px; }

/* Toasts */
#toastContainer { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 99; }
.toast {
  background: var(--panel-2); border: 1px solid rgba(255,255,255,.12);
  padding: 12px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toast-in .25s ease;
}
.toast.error { border-color: var(--err); }
.toast.success { border-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

@media (max-width: 520px) {
  .peer { min-width: 100px; padding: 12px; }
  main { padding: 8px 12px 40px; }
}
