@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #0e0f14;
  --surface: #16181f;
  --surface2: #1e2029;
  --border: #2a2d38;
  --accent: #4ade80;
  --accent2: #22d3ee;
  --danger: #f87171;
  --warn: #fbbf24;
  --text: #f0f1f5;
  --text2: #8b90a0;
  --text3: #5a5f72;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

#app { display: flex; flex-direction: column; min-height: 100vh; }

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 8px 8px;
  background: none; border: none; color: var(--text3);
  font-size: 11px; font-family: inherit; cursor: pointer;
  transition: color 0.15s;
}
.nav-btn.active, .nav-btn:hover { color: var(--accent); }
.nav-btn .nav-icon { font-size: 20px; margin-bottom: 2px; }

.main-content {
  flex: 1;
  padding: 16px 16px 80px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

#screen-join .main-content {
  display: flex; flex-direction: column;
  justify-content: center; min-height: 100vh;
  padding-bottom: 24px;
}

.logo {
  text-align: center; margin-bottom: 40px;
}
.logo-icon { font-size: 56px; }
.logo h1 {
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.logo p { color: var(--text2); font-size: 14px; margin-top: 4px; }

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

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 6px;
}

input[type="text"], input[type="number"] {
  width: 100%;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; font-size: 16px;
  padding: 12px 14px;
  transition: border-color 0.15s;
  outline: none;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent);
}

.pair-token-display {
  font-family: 'DM Mono', monospace;
  font-size: 28px; font-weight: 500;
  letter-spacing: 8px; text-align: center;
  color: var(--accent); background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; margin: 8px 0;
}

.token-hint { font-size: 12px; color: var(--text3); text-align: center; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 6px; min-height: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 12px 20px;
  border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #0a0f0a;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border-radius: var(--radius-sm);
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-ghost { background: none; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text3); }
.btn-send { background: var(--accent2); color: #050f14; padding: 8px 14px; font-size: 13px; }
.btn-send:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }

.status-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  margin-bottom: 16px; font-size: 13px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); animation: pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.status-nick { font-weight: 600; color: var(--accent); }
.status-token {
  font-family: 'DM Mono', monospace; font-size: 13px;
  color: var(--accent2); margin-left: auto;
  letter-spacing: 2px;
}

#accuracy-indicator { font-size: 11px; color: var(--text3); }
#location-status { font-size: 12px; color: var(--warn); min-height: 16px; }

.nearby-list { display: flex; flex-direction: column; gap: 10px; }
.empty-msg { color: var(--text3); text-align: center; padding: 32px 0; font-size: 14px; }

.user-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s;
}
.user-card:hover { border-color: var(--accent2); }
.user-card-info { display: flex; flex-direction: column; gap: 2px; }
.user-nick { font-weight: 600; font-size: 15px; }
.user-dist { font-size: 13px; color: var(--accent); }
.user-accuracy { font-size: 11px; color: var(--text3); }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.overlay.active { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 400px;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 10px; margin-top: 20px; }
.modal-footer .btn { flex: 1; }

.pair-confirm-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  margin: 12px 0; text-align: center;
}
.pair-confirm-box .label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.pair-confirm-box .code {
  font-family: 'DM Mono', monospace; font-size: 24px; font-weight: 500;
  letter-spacing: 6px; color: var(--warn);
}

.file-list-item {
  font-size: 13px; color: var(--text2); padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.file-list-item:last-child { border-bottom: none; }
#send-file-info { font-size: 12px; color: var(--accent); margin-top: 8px; }

.transfer-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.transfer-role-badge {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; color: var(--accent2);
  text-transform: uppercase; letter-spacing: 0.05em;
}
#transfer-status { font-size: 15px; font-weight: 500; color: var(--text2); }

.progress-section { margin-bottom: 20px; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text3); margin-bottom: 6px;
}
.progress-bar {
  height: 8px; background: var(--surface2); border-radius: 4px;
  overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px; transition: width 0.2s;
}
#transfer-speed { font-size: 13px; color: var(--text3); font-family: 'DM Mono', monospace; }

.transfer-files-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.transfer-file-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.tfi-name { font-size: 13px; font-weight: 500; display: block; margin-bottom: 4px; word-break: break-all; }
.tfi-size { font-size: 11px; color: var(--text3); }
.tfi-bar { height: 4px; background: var(--border); border-radius: 2px; margin: 6px 0; }
.tfi-bar-fill { height: 100%; background: var(--accent2); border-radius: 2px; transition: width 0.2s; }
.tfi-status { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; }

.transfer-actions { display: flex; gap: 10px; }
#transfer-fallback-btn { display: none; }

.room-row { display: flex; gap: 10px; margin-bottom: 12px; }
.room-row input { flex: 1; }

.room-file-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.rf-name { flex: 1; font-size: 13px; font-weight: 500; word-break: break-all; min-width: 0; }
.rf-size { font-size: 12px; color: var(--text3); white-space: nowrap; }
.rf-nick { font-size: 11px; color: var(--text3); }
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

#room-mode-hint { display: none; margin-top: 8px; }

#toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - 32px); max-width: 360px; pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(-8px);
  transition: all 0.3s; pointer-events: auto;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: var(--accent); color: var(--accent); }
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-warn { border-color: var(--warn); color: var(--warn); }
.toast-info { color: var(--text); }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text3); font-size: 12px; margin: 16px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

@media (min-width: 480px) {
  .main-content { padding: 24px 24px 88px; }
}
