:root {
  --bg-dark: #070b14;
  --bg-card: rgba(17, 25, 42, 0.85);
  --bg-card-hover: rgba(26, 37, 61, 0.92);
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-active: rgba(56, 189, 248, 0.55);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-pink: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(circle at 12% 15%, rgba(56, 189, 248, 0.12), transparent 36%),
    radial-gradient(circle at 88% 20%, rgba(99, 102, 241, 0.12), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(236, 72, 153, 0.07), transparent 42%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px 48px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.brand:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.domain-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn:hover {
  border-color: var(--border-active);
  background: rgba(30, 41, 59, 0.98);
}

.pill-btn-accent {
  background: rgba(56, 189, 248, 0.11);
  border-color: rgba(56, 189, 248, 0.32);
}

.dot, .status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  display: inline-block;
}

.dot.active, .status-dot.online {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

/* Self Bar */
.self-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 20px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
}

.self-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.self-device-icon {
  font-size: 1.15rem;
}

.privacy-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.left-col, .right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 1.08rem;
  font-weight: 700;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.badge.connected {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}

/* Peers Grid */
.peers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.peer-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(30, 41, 59, 0.65);
  border: 1.5px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
}

.peer-item:hover, .peer-item.selected {
  border-color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.11);
  transform: translateY(-2px);
}

.peer-avatar {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.25));
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.peer-meta {
  flex: 1;
  min-width: 0;
}

.peer-name {
  font-weight: 700;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  color: #6ee7b7;
  margin-top: 2px;
}

/* Empty Peers Radar */
.empty-peers {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px 12px;
}

.radar-pulse {
  position: relative;
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-core {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  z-index: 2;
}

.radar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--accent-blue);
  opacity: 0;
  animation: radarWave 2.6s infinite ease-out;
}

.radar-ring.delay-1 {
  animation-delay: 1.3s;
}

@keyframes radarWave {
  0% {
    transform: scale(0.6);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

.empty-peers h3 {
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.empty-peers p {
  font-size: 0.83rem;
  color: var(--text-muted);
  max-width: 380px;
  margin: 0 auto 12px;
}

/* Dropzone */
.dropzone {
  border: 2px dashed rgba(56, 189, 248, 0.4);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.55) 0%, rgba(30, 41, 59, 0.45) 100%);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.09);
  transform: scale(1.005);
}

.dropzone-icon-wrap {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.22));
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(56, 189, 248, 0.18);
}

.dropzone h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.dropzone-sub {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.76rem;
}

.dropzone-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Text Drop Bar */
.text-drop-bar {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.text-drop-bar input {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.text-drop-bar input:focus {
  border-color: var(--accent-blue);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.85);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--border-active);
  background: rgba(51, 65, 85, 0.85);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.32);
}

.btn-success:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-icon {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 10px 13px;
}

/* Feed / Transfers */
.feed-header-actions {
  display: flex;
  gap: 8px;
}

.transfer-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

.empty-feed {
  text-align: center;
  padding: 42px 18px;
  color: var(--text-muted);
}

.empty-feed-icon {
  font-size: 2.1rem;
  margin-bottom: 8px;
  opacity: 0.7;
}

.empty-feed p {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.empty-feed span {
  font-size: 0.82rem;
}

/* Transfer Item Card */
.transfer-item {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  animation: popIn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

.transfer-item.incoming-highlight {
  border-color: rgba(16, 185, 129, 0.55);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.11), rgba(30, 41, 59, 0.85));
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.transfer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.transfer-file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.transfer-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.transfer-title {
  font-weight: 700;
  font-size: 0.93rem;
  word-break: break-all;
}

.transfer-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.transfer-progress-wrap {
  margin-top: 10px;
}

.progress-bar-bg {
  width: 100%;
  height: 7px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-blue), var(--success));
  border-radius: 999px;
  transition: width 0.1s linear;
}

.transfer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
  justify-content: flex-end;
}

.text-drop-content {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.85);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.text-drop-content a {
  color: var(--accent-blue);
  text-decoration: underline;
}

/* Fullscreen Drag Overlay */
.drag-overlay {
  position: fixed;
  inset: 14px;
  z-index: 999;
  background: rgba(7, 11, 20, 0.88);
  backdrop-filter: blur(10px);
  border: 3px dashed var(--accent-blue);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-overlay-box {
  text-align: center;
}

.drag-overlay-icon {
  font-size: 3.5rem;
  margin-bottom: 10px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.qr-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.qr-svg-wrap {
  width: 116px;
  height: 116px;
  background: #fff;
  padding: 6px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.qr-label {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.qr-info code {
  font-size: 0.8rem;
  color: var(--accent-blue);
  word-break: break-all;
}

.room-code-controls label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.room-code-row {
  display: flex;
  gap: 8px;
}

.code-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.leave-code-wrap {
  margin-top: 12px;
  text-align: center;
}

@media (min-width: 769px) {
  .mobile-only {
    display: none;
  }
}

@media (max-width: 600px) {
  .qr-box {
    flex-direction: column;
    text-align: center;
  }
}
