:root {
  --ink: #0A1120;
  --surface: #121C33;
  --surface2: #1B2846;
  --line: rgba(139,164,214,0.14);
  --text: #E9EEFA;
  --muted: #8CA0C6;
  --magenta: #FF2E88;
  --cyan: #00E1FF;
  --amber: #FFB020;
  --violet: #8C6BFF;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}
a { color: var(--cyan); }

::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(140,107,255,0.4); border-radius: 4px; }

/* ---------- Tile gradients (6 deterministic variants) ---------- */
.tile-1 { background: linear-gradient(135deg, var(--magenta), var(--violet)); }
.tile-2 { background: linear-gradient(135deg, var(--cyan), var(--violet)); }
.tile-3 { background: linear-gradient(135deg, var(--amber), var(--magenta)); }
.tile-4 { background: linear-gradient(135deg, var(--violet), #3F8CFF); }
.tile-5 { background: linear-gradient(135deg, #14D6C4, var(--cyan)); }
.tile-6 { background: linear-gradient(135deg, var(--magenta), var(--amber)); }

/* ---------- Geo badge (signature avatar) ---------- */
.geo-badge-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.geo-badge {
  position: relative; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  color: #fff; font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.35);
  overflow: hidden;
}
.geo-badge::before {
  content: ""; position: absolute; inset: 0; opacity: .25;
  background-image:
    linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 25% 25%;
}
.geo-badge .pin {
  position: absolute; bottom: -4px; right: -4px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
.geo-coords { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--muted); white-space: nowrap; }

/* ---------- Auth screen ---------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,46,136,0.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0,225,255,0.12), transparent 40%),
    var(--ink);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px;
}
.auth-logo { display: flex; align-items: center; gap: 8px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 22px; letter-spacing: -0.5px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---------- Neon wordmark ---------- */
.brand-text {
  color: var(--text);
  -webkit-text-stroke: 0.4px var(--cyan);
  text-stroke: 0.4px var(--cyan);
  text-shadow:
    0 0 2px var(--cyan),
    0 0 5px var(--cyan),
    0 0 9px var(--magenta);
  animation: neon-flicker 3.2s infinite ease-in-out;
}
@keyframes neon-flicker {
  0%, 96%, 100% {
    text-shadow:
      0 0 2px var(--cyan), 0 0 5px var(--cyan),
      0 0 9px var(--magenta);
  }
  97% {
    text-shadow: 0 0 1px var(--cyan);
  }
}
.auth-tagline { color: var(--muted); font-size: 13px; margin: 6px 0 20px; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 8px 0; border: none; background: transparent; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 700;
}
.auth-tab.active { background: var(--ink); color: var(--cyan); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 13px;
}
.btn-primary {
  margin-top: 6px; padding: 10px 0; border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--magenta), var(--violet));
  color: #fff; font-size: 13.5px; font-weight: 700;
}
.auth-error { color: var(--magenta); font-size: 12px; min-height: 16px; }

/* ---------- App shell ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20; background: rgba(10,17,32,0.9);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topnav-inner {
  max-width: 1160px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: -0.5px; flex-shrink: 0; }
.brand { cursor: pointer; text-decoration: none; }
.brand:hover .brand-text { opacity: .8; }
.auth-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; justify-content: center; margin-bottom: 4px; }
.search-box { flex: 1; min-width: 0; max-width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.search-box input { background: transparent; border: none; color: var(--text); font-size: 13px; width: 100%; outline: none; }
.topnav-tabs { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.nav-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
  background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.nav-btn span { display: none; }
.nav-btn.active { background: var(--surface2); color: var(--cyan); }
.nav-btn-icon { font-size: 16px; padding: 8px; }
.nav-btn-icon:hover { color: var(--cyan); background: var(--surface2); }

.layout { max-width: 1160px; margin: 0 auto; padding: 20px 16px 64px; display: grid; grid-template-columns: 220px 1fr 260px; gap: 20px; }
.layout.no-right { grid-template-columns: 220px 1fr; }
.left-rail, .right-rail { display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.section-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.6px; text-transform: uppercase; margin-bottom: 10px; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; color: var(--muted); }

.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.3px; }
.pill-violet { background: rgba(140,107,255,0.18); color: var(--violet); }
.pill-cyan { background: rgba(0,225,255,0.14); color: var(--cyan); }
.pill-amber { background: rgba(255,176,32,0.16); color: var(--amber); }

.btn-ghost {
  width: 100%; padding: 7px 0; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--cyan); font-size: 12px; font-weight: 700;
}
.btn-gradient {
  padding: 8px 16px; border-radius: 999px; border: none; color: #fff; font-size: 12.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--magenta), var(--violet));
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-toggled { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* ---------- Feed ---------- */
.live-strip { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 4px; }
.live-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.pulse { animation: pulse-ring 2s infinite; border-radius: 10px; }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(0,225,255,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(0,225,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,225,255,0); }
}

.composer-row { display: flex; gap: 10px; }
.composer-row textarea {
  flex: 1; resize: none; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; color: var(--text); font-size: 13px;
}
.composer-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

.post { margin-bottom: 16px; }
.post-body { display: flex; gap: 10px; }
.post-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-name { font-weight: 700; font-size: 14px; }
.post-time { font-size: 12px; color: var(--muted); margin-left: auto; }
.post-role { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.post-content { font-size: 14px; line-height: 1.55; margin: 0 0 12px; white-space: pre-wrap; }
.post-actions { display: flex; gap: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.action-btn { display: flex; align-items: center; gap: 6px; background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.action-btn.liked { color: var(--magenta); }
.comments-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.comment-row { font-size: 13px; }
.comment-row b { font-weight: 700; }
.comment-row span { color: var(--muted); }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--text); font-size: 12.5px; }

/* ---------- Auth footer note ---------- */
.auth-footer {
  margin-top: 18px; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.6;
}
.auth-footer a { color: var(--muted); text-decoration: underline; }
.auth-footer a:hover { color: var(--cyan); }

/* ---------- Site footer ---------- */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 20px 24px; margin-top: auto;
}
.site-footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px;
  justify-content: space-between;
}
.site-footer-brand { display: flex; align-items: center; gap: 8px; }
.logo-mark-sm {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.site-footer-links { display: flex; flex-wrap: wrap; gap: 16px; }
.site-footer-links a { color: var(--muted); font-size: 12px; text-decoration: none; }
.site-footer-links a:hover { color: var(--cyan); }
.site-footer-copy { font-size: 11px; color: var(--muted); }

/* ---------- Network / events grids ---------- */
h2.view-title { font-family: 'Space Grotesk', sans-serif; font-size: 22px; margin: 0; }
p.view-sub { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.person-card { text-align: center; }
.person-card .person-name { margin-top: 10px; font-weight: 700; font-size: 14px; }
.person-card .person-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.person-card .geo-badge-wrap { justify-content: center; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); color: var(--muted); font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; letter-spacing: 0;
}
.btn-danger {
  background: rgba(255,46,136,0.15) !important; border: 1px solid rgba(255,46,136,0.3) !important;
  color: var(--magenta) !important;
}
.btn-danger:hover { background: rgba(255,46,136,0.28) !important; }

.event-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.event-icon { width: 52px; height: 52px; border-radius: 12px; background: linear-gradient(135deg, var(--amber), var(--magenta)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 22px; }
.event-info { flex: 1; min-width: 160px; }
.event-title { font-weight: 700; font-size: 14px; }
.event-meta { font-size: 12px; color: var(--muted); }
.btn-signout {
  padding: 8px 18px; border-radius: 8px; border: 1px solid rgba(255,68,85,.35);
  background: transparent; color: #ff4455; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn-signout:hover { background: rgba(255,68,85,.1); }
.btn-delete {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-delete:hover { border-color: var(--magenta); color: var(--magenta); }
.new-event-form input {
  width: 100%; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; color: var(--text); font-size: 13px; margin-bottom: 8px; display: block;
}

/* ---------- Messages ---------- */
.messages-card { padding: 0; overflow: hidden; }
.messages-grid { display: grid; grid-template-columns: 220px 1fr; min-height: 420px; }
.contact-list { border-right: 1px solid var(--line); }
.contact-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px; border: none;
  background: transparent; text-align: left; color: var(--text);
}
.contact-item.active { background: var(--surface2); }
.contact-name { font-size: 12.5px; font-weight: 700; }
.contact-last { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.thread-pane { display: flex; flex-direction: column; }
.thread-header { padding: 12px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.thread-back { display: none; background: none; border: none; color: var(--cyan); font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; }
.thread-body { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 360px; }
.bubble { padding: 8px 12px; border-radius: 12px; font-size: 13px; max-width: 75%; color: #fff; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, var(--magenta), var(--violet)); }
.bubble.them { align-self: flex-start; background: var(--surface2); }
.thread-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: center; }
.thread-input-row input { flex: 1; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 13px; }
.send-btn { width: 36px; height: 36px; border-radius: 8px; border: none; background: linear-gradient(135deg, var(--cyan), var(--violet)); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; cursor: pointer; }
.attach-btn {
  width: 36px; height: 36px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.attach-btn:hover { background: var(--surface); }
.attach-preview {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--surface2); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.attach-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-clear { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; flex-shrink: 0; }
.attach-clear:hover { color: var(--magenta); }

/* Mobile: single-column messaging */
@media (max-width: 600px) {
  .messages-grid { grid-template-columns: 1fr; min-height: 520px; }
  .contact-list { border-right: none; border-bottom: 1px solid var(--line); }
  .contact-list.mobile-hidden { display: none; }
  .thread-pane.mobile-hidden { display: none; }
  .thread-back { display: inline-flex; }
  .thread-body { max-height: calc(100vh - 280px); }
  .msg-media { max-width: 100%; }
}

/* Media in messages */
.msg-media { max-width: 220px; max-height: 200px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble { flex-direction: column; }

/* ---------- Profile ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile-name { font-weight: 700; font-size: 20px; font-family: 'Space Grotesk', sans-serif; }
.profile-meta { color: var(--muted); font-size: 13px; }
.profile-coords { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--cyan); margin-top: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.stat-card { text-align: center; }
.stat-value { font-size: 22px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--cyan); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.profile-edit textarea, .profile-edit input {
  width: 100%; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; color: var(--text); font-size: 13px; margin-bottom: 8px;
}
.profile-edit textarea { resize: vertical; min-height: 70px; }
.latlong-row { display: flex; gap: 8px; }
.latlong-row input { flex: 1; }
.latlong-row .btn-ghost { width: auto; padding: 8px 12px; flex-shrink: 0; }

/* Profile avatar with photo upload overlay */
.profile-avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.avatar-change-btn {
  position: absolute; bottom: -4px; right: -4px; width: 26px; height: 26px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  cursor: pointer; z-index: 2;
}
.avatar-change-btn:hover { background: var(--surface); }
.avatar-remove-btn {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  background: var(--magenta); border: none; border-radius: 50%;
  color: #fff; font-size: 10px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}

/* Photo badge variant */
.geo-badge-photo { border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }

.empty-state { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 50;
}

@media (min-width: 860px) {
  .nav-btn span { display: inline; }
  .search-box { max-width: 280px; }
}
@media (max-width: 600px) {
  .search-box { display: none; }
}
@media (max-width: 880px) {
  .layout, .layout.no-right { grid-template-columns: 1fr !important; }
  .left-rail { order: 2; }
  .right-rail { order: 3; }
  main { order: 1; }
}
