:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-hover: #1a2333;
  --border: #243044;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

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

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

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

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  transition: background 0.2s;
}

.dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.badge {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.full-width {
  width: 100%;
}

.alert-banner {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid var(--danger);
  color: #fecaca;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.public-notice {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #dbeafe;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.84rem;
  margin-bottom: 18px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-warn-active {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.55);
}

.btn-warn-active:hover {
  background: rgba(239, 68, 68, 0.24);
}

.btn-danger-ghost {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  margin-right: auto;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.14);
}

.self-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}

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

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #1d283a;
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.name-row input {
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: var(--border);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 2px 4px;
  outline: none;
  width: 210px;
}

.name-row input:focus {
  border-bottom-color: var(--primary);
}

.hint, .muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.small {
  font-size: 0.82rem;
}

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

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.pulse-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: pulse 1.8s infinite ease-out;
}

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

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

.peer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.peer-card:hover,
.peer-card.dragover {
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

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

.peer-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.dup-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.transfers-section {
  margin-top: 28px;
}

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

.transfer-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.transfer-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

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

.transfer-stats {
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.transfer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.transfer-cancel-btn {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.transfer-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.16);
}

.progress-bar {
  width: 100%;
  height: 7px;
  background: #1f293a;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.08s linear;
}

.progress-fill.done {
  background: var(--success);
}

.progress-fill.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.qr-box {
  display: flex;
  justify-content: center;
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  align-self: center;
}

.copy-row, .room-form {
  display: flex;
  gap: 8px;
}

.room-form-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.copy-row input, .room-form input, .room-form-stack > input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.85rem;
  outline: none;
}

.room-form input:focus, .room-form-stack > input:focus {
  border-color: var(--primary);
}

.incoming-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.incoming-list li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.incoming-list li > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.incoming-list li > span.muted {
  flex-shrink: 0;
}

.incoming-list li.risky {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.incoming-warning {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid var(--danger);
  color: #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
