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

:root {
  --bg: #07070f;
  --surface: rgba(255,255,255,0.06);
  --surface-hover: rgba(255,255,255,0.11);
  --border: rgba(255,255,255,0.1);
  --accent: #6366f1;
  --accent-dim: rgba(99,102,241,0.2);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 18px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99,102,241,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(168,85,247,0.1) 0%, transparent 60%);
  animation: bgpulse 8s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes bgpulse {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

/* Header */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 48px 24px 32px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 0.95rem;
}

/* Main content */
main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  padding: 0 24px 120px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Peer grid */
#peer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  width: 100%;
}

/* Empty state */
#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
}

#empty-state svg {
  opacity: 0.3;
}

#empty-state p {
  font-size: 1rem;
  max-width: 280px;
  line-height: 1.6;
}

/* Peer card */
.peer-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  overflow: hidden;
  min-height: 160px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.peer-card:hover {
  background: var(--surface-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(99,102,241,0.2);
}

.peer-card:active {
  transform: translateY(-2px);
}

.peer-icon {
  width: 56px;
  height: 56px;
  color: var(--accent);
  flex-shrink: 0;
}

.peer-name {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
  color: var(--text);
}

/* Transfer overlay */
.peer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7,7,15,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius);
}

.peer-overlay .status-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--accent-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Progress bar */
.progress-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-dim);
  border-radius: 0 0 var(--radius) var(--radius);
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
  transition: width 0.1s ease;
  width: 0%;
}

/* Done / error state icon */
.state-icon {
  font-size: 2rem;
}

/* Toast container */
#toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
  align-items: center;
}

.toast {
  background: rgba(30,30,50,0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 0.875rem;
  color: var(--text);
  pointer-events: auto;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideup 0.3s ease;
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes slideup {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast.fadeout {
  animation: fadeout 0.4s ease forwards;
}

@keyframes fadeout {
  to { opacity: 0; transform: translateY(8px); }
}

/* Status bar */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: rgba(7,7,15,0.8);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.version {
  position: absolute;
  left: 16px;
  font-size: 0.7rem;
  color: rgba(148,163,184,0.4);
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.status-dot.offline {
  background: var(--error);
}

/* File input hidden */
#file-input { display: none; }

@media (max-width: 480px) {
  header { padding: 32px 16px 24px; }
  header h1 { font-size: 1.6rem; }
  #peer-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  main { padding: 0 16px 100px; }
}
