:root {
  --bg-start: #eef2ff;
  --bg-end: #dbeafe;
  --card-bg: rgba(255, 255, 255, 0.85);
  --ink: #1e2433;
  --muted: #6b7280;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --success: #22c55e;
  --danger: #ef4444;
  --radius-lg: 28px;
  --radius-md: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-start: #0f172a;
    --bg-end: #1e1b4b;
    --card-bg: rgba(23, 25, 35, 0.82);
    --ink: #eef1f8;
    --muted: #9aa3b5;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.22);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 50% 0%, var(--bg-end), var(--bg-start));
  background-attachment: fixed;
}

.footer {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--card-bg);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 60px -20px rgba(30, 41, 59, 0.25);
  padding: 32px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.refresh-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.refresh-btn:hover {
  background: rgba(59, 130, 246, 0.3);
}

.refresh-btn:active {
  transform: scale(0.9) rotate(-40deg);
}

.brand {
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.error-banner {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.85rem;
  text-align: center;
}

.radar-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.radar {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  animation: pulse 2.4s ease-out infinite;
}

.ring-2 {
  animation-delay: 0.6s;
}

.ring-3 {
  animation-delay: 1.2s;
}

@keyframes pulse {
  0% {
    transform: scale(0.55);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

body[data-state='connected'] .radar-ring,
body[data-state='drag-over'] .radar-ring,
body[data-state='transferring'] .radar-ring {
  animation: none;
  opacity: 0;
}

.radar-core {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--accent), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px -8px rgba(59, 130, 246, 0.55);
}

.room-code {
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s ease;
}

body[data-state='connected'] .status-dot,
body[data-state='drag-over'] .status-dot,
body[data-state='transferring'] .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

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

.copy-btn {
  position: relative;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.copy-btn:active {
  transform: scale(0.97);
}

.copy-feedback {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  /* Fixed (not theme-swapping) colors — --ink flips to near-white in dark
     mode, which would otherwise wash this out to near-invisible text. */
  background: #16181f;
  color: #f8fafc;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-code {
  width: 148px;
  height: 148px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 18px -8px rgba(30, 41, 59, 0.35);
}

.qr-code svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

body[data-state='connected'] .qr-panel,
body[data-state='drag-over'] .qr-panel,
body[data-state='transferring'] .qr-panel {
  display: none;
}

.drop-zone {
  display: none;
  border: 2px dashed rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-md);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

body[data-state='connected'] .drop-zone,
body[data-state='drag-over'] .drop-zone,
body[data-state='transferring'] .drop-zone {
  display: block;
}

.drop-zone.drag-over,
body[data-state='drag-over'] .drop-zone {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.drop-zone-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.transfer-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(148, 163, 184, 0.1);
}

.transfer-icon {
  color: var(--accent);
  font-weight: 700;
}

.transfer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transfer-size {
  color: var(--muted);
}

.transfer-bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.transfer-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

.transfer-row.complete .transfer-bar-fill {
  background: var(--success);
  width: 100% !important;
}

.transfer-row.complete .transfer-pct {
  color: var(--success);
}

@media (max-width: 420px) {
  .card {
    padding: 24px 18px;
  }

  .radar {
    width: 168px;
    height: 168px;
  }

  .radar-core {
    width: 110px;
    height: 110px;
  }

  .room-code {
    font-size: 1.15rem;
  }
}
