:root {
  --bg: #06060d;
  --surface: #0d0d1a;
  --card: #111122;
  --border: rgba(0, 200, 255, 0.15);
  --blue: #00c8ff;
  --blue-dim: rgba(0, 200, 255, 0.08);
  --blue-glow: rgba(0, 200, 255, 0.25);
  --text: #dde4ff;
  --muted: #5a6080;
  --danger: #ff4466;
  --green: #22cc66;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}

header {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
}

.logo { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: var(--blue); }

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

.version-badge {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s;
}
.back-btn:hover { color: var(--text); }
.back-btn.hidden { visibility: hidden; }

.main { width: 100%; max-width: 480px; }

/* Home */
.home-title { font-size: 42px; font-weight: 800; letter-spacing: -1.5px; line-height: 1.1; margin-bottom: 28px; }

.btn-row { display: flex; gap: 12px; margin-bottom: 12px; }

.btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
}
.btn-primary { background: var(--blue); color: #000; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }

/* Join */
.join-wrapper { display: flex; flex-direction: column; gap: 16px; }

.code-input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  padding: 18px;
  width: 100%;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.2s;
}
.code-input:focus { border-color: var(--blue); }
.code-input::placeholder { color: var(--muted); letter-spacing: 4px; font-weight: 400; font-size: 16px; }

/* Room */
.room-code-display {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}
.room-label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin-bottom: 10px; }
.room-code { font-size: 36px; font-weight: 800; letter-spacing: 8px; color: var(--blue); margin-bottom: 16px; }
.qr-container { display: flex; justify-content: center; margin-bottom: 16px; }
.qr-container canvas { border-radius: 8px; display: block; }

.copy-btn {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
}
.copy-btn:hover { background: var(--blue-glow); }

.peers-section { margin-bottom: 20px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin-bottom: 10px; }
.peers-list { display: flex; flex-direction: column; gap: 8px; }

.peer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.peer-name { font-size: 14px; font-weight: 600; }
.peer-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.reconnecting-status { font-size: 12px; color: var(--muted); font-style: italic; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; box-shadow: 0 0 6px var(--green); }

.no-peers {
  color: var(--muted);
  font-size: 14px;
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.room-error {
  color: var(--danger);
  font-size: 14px;
  padding: 14px 16px;
  text-align: center;
  background: rgba(255, 68, 102, 0.06);
  border: 1px solid rgba(255, 68, 102, 0.25);
  border-radius: 10px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
  position: relative;
}
.drop-zone.has-peers { border-color: rgba(0, 200, 255, 0.3); }
.drop-zone.has-peers:hover, .drop-zone.dragging { background: var(--blue-dim); border-color: var(--blue); }
.drop-zone.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.drop-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.6; }
.drop-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.drop-sub { font-size: 13px; color: var(--muted); }
#file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Transfers */
.transfers { display: flex; flex-direction: column; gap: 10px; }

.transfer-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.transfer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.transfer-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.transfer-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.transfer-size { font-size: 12px; color: var(--muted); white-space: nowrap; }
.btn-cancel-xfer { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0 2px; line-height: 1; transition: color 0.15s; }
.btn-cancel-xfer:hover { color: var(--danger); }

.transfer-thumb {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  margin: 8px 0;
  display: block;
  background: var(--surface);
}
.transfer-peer { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.progress-bar { height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 2px; transition: width 0.15s; box-shadow: 0 0 8px var(--blue-glow); }

.transfer-footer { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; justify-content: space-between; align-items: center; }
.transfer-done { color: var(--green); }
.transfer-error { color: var(--danger); }

.batch-done {
  border-color: rgba(0, 200, 255, 0.3);
  background: var(--blue-dim);
}

.download-btn {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s;
}
.download-btn:hover { background: var(--blue-glow); }

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }

.request-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.request-from { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.request-from strong { color: var(--text); }
.request-filename { font-size: 18px; font-weight: 700; margin-bottom: 6px; word-break: break-all; }
.request-filesize { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.request-actions { display: flex; gap: 10px; }

.btn-accept { flex: 1; padding: 12px; background: var(--blue); color: #000; font-weight: 700; font-size: 15px; border: none; border-radius: 10px; cursor: pointer; transition: filter 0.18s; }
.btn-accept:hover { filter: brightness(1.1); }
.btn-decline { flex: 1; padding: 12px; background: var(--card); color: var(--danger); font-weight: 600; font-size: 15px; border: 1px solid rgba(255, 68, 102, 0.3); border-radius: 10px; cursor: pointer; transition: background 0.18s; }
.btn-decline:hover { background: rgba(255, 68, 102, 0.1); }

.view { display: none; }
.view.active { display: block; }

.scan-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.scan-overlay.hidden { display: none; }
#scan-video { width: 100%; max-width: 480px; max-height: 60vh; object-fit: cover; border-radius: 12px; }
.scan-aim {
  position: absolute;
  width: 200px;
  height: 200px;
  border: 2px solid var(--blue);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  pointer-events: none;
}
.scan-error-msg {
  color: var(--text);
  text-align: center;
  font-size: 16px;
  line-height: 1.5;
  max-width: 300px;
  margin-bottom: 8px;
}
.scan-error-msg .scan-error-icon {
  display: block;
  font-size: 48px;
  margin-bottom: 16px;
}
.scan-error-msg.hidden { display: none; }
.btn-scan-close {
  margin-top: 32px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.hidden { display: none !important; }

.nickname-row {
  margin-bottom: 16px;
}

.nickname-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.nickname-input:focus { border-color: var(--blue); }
.nickname-input::placeholder { color: var(--muted); font-weight: 400; }

.lobby-bar {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-public {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s;
  width: 100%;
}
.btn-public:hover { background: var(--blue-glow); }
.btn-public.active {
  background: var(--blue);
  color: #000;
  border-color: var(--blue);
}

#lobby-section { margin-bottom: 20px; }

.lobby-list { display: flex; flex-direction: column; gap: 8px; }

.lobby-peer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lobby-peer-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.lobby-peer-card.nearby { border-color: rgba(0, 200, 255, 0.4); background: var(--blue-dim); }

.nearby-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue);
  background: rgba(0, 200, 255, 0.15);
  border: 1px solid rgba(0, 200, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
}

.nearby-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--blue);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0, 200, 255, 0.2);
  z-index: 200;
  white-space: nowrap;
  font-size: 14px;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.nearby-toast-connect {
  background: var(--blue);
  color: #000;
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.nearby-toast-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
}

.share-banner {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--blue);
  margin-bottom: 16px;
  text-align: center;
}

.btn-connect {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.18s;
}
.btn-connect:hover { background: var(--blue-glow); }
.btn-connect:disabled { opacity: 0.4; cursor: not-allowed; }

.text-send-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.text-send-bar.disabled { opacity: 0.4; pointer-events: none; }

.text-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
.text-input:focus { border-color: var(--blue); }
.text-input::placeholder { color: var(--muted); }

.btn-send-text {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s;
}
.btn-send-text:hover { background: var(--blue-glow); }

.text-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.text-item-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.text-item-body {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
}
.text-item-actions { margin-top: 8px; }
.btn-copy-text {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: color 0.18s;
}
.btn-copy-text:hover { color: var(--blue); }

.qr-fullscreen {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: pointer;
}
.qr-fullscreen.hidden { display: none; }
.qr-fullscreen canvas {
  width: min(85vw, 75vh);
  height: min(85vw, 75vh);
  border-radius: 12px;
}
.qr-fullscreen-hint { margin-top: 20px; color: #888; font-size: 14px; }

#qr-canvas { cursor: pointer; border-radius: 8px; transition: opacity 0.15s; }
#qr-canvas:hover { opacity: 0.85; }

.auto-accept-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  cursor: pointer;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.auto-accept-label { font-size: 13px; color: var(--muted); user-select: none; }

.toggle-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-thumb {
  display: block;
  width: 38px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 11px;
  transition: background 0.2s;
  position: relative;
}
.toggle-thumb::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-input:checked + .toggle-thumb {
  background: var(--blue);
}
.toggle-input:checked + .toggle-thumb::after {
  transform: translateX(16px);
  background: #000;
}

.btn-share-link {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.btn-share-link:hover { color: var(--blue); border-color: var(--blue); }

.share-link-box {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}
.share-link-box.hidden { display: none; }
.share-link-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  padding: 8px 10px;
  outline: none;
  min-width: 0;
}
.btn-copy-share {
  background: var(--blue-dim);
  border: 1px solid var(--border);
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s;
}
.btn-copy-share:hover { background: var(--blue-glow); }

.share-receive-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 16px 0;
}
.share-receive-icon { font-size: 40px; margin-bottom: 4px; opacity: 0.5; }
.share-receive-name { font-size: 20px; font-weight: 700; word-break: break-all; }
.share-receive-meta { font-size: 13px; color: var(--muted); }
.share-receive-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  margin: 4px 0 8px;
}
