:root {
  --bg: #15201b;
  --bg-dot: rgba(255,255,255,0.035);
  --panel: #1c2a23;
  --panel-alt: #24352b;
  --border: #33463a;
  --text: #ece7da;
  --text-dim: #93a596;
  --accent: #f2b84b;
  --accent-ink: #1b1405;
  --link: #8fd2a0;
  --danger: #e08a6f;
  --radius: 14px;
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'IBM Plex Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(var(--bg-dot) 1px, transparent 1px) 0 0/22px 22px,
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  margin: 0 auto;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.nick-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-family: var(--font-body);
  cursor: pointer;
}

.nick-btn strong {
  color: var(--accent);
  font-weight: 600;
}

.nick-btn:hover { border-color: var(--accent); }

/* ---------- inline nick editor ---------- */

.nick-editor {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.nick-editor.hidden { display: none; }

.nick-editor input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.nick-editor button {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- feed ---------- */

#feed {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 78%;
}

.msg-head {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 3px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.msg-time {
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.72rem;
}

.msg-bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  padding: 9px 13px;
  line-height: 1.45;
  word-break: break-word;
  font-size: 0.96rem;
}

.msg-bubble img {
  display: block;
  max-width: 260px;
  max-height: 260px;
  border-radius: 10px;
  margin-top: 6px;
  cursor: zoom-in;
}

.msg-bubble video {
  display: block;
  max-width: 320px;
  max-height: 320px;
  border-radius: 10px;
  margin-top: 6px;
}

.msg-bubble a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: rgba(143,210,160,0.4);
}

.map-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  text-decoration: none !important;
  color: var(--text) !important;
}

.map-chip:hover { border-color: var(--accent); }

.msg.system {
  align-self: center;
  max-width: 90%;
}

.msg.system .msg-bubble {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
  padding: 2px 8px;
}

/* per-user nick colors, hashed */
.u0 { color: #f2b84b; }
.u1 { color: #8fd2a0; }
.u2 { color: #7fb3d9; }
.u3 { color: #e08a6f; }
.u4 { color: #c99bdb; }
.u5 { color: #d9c26a; }

/* ---------- composer ---------- */

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

#text-input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 16px;
}

#text-input:focus, .nick-editor input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.send-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:active { transform: scale(0.97); }

.upload-status {
  padding: 0 18px 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.upload-status.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  #feed { scroll-behavior: auto; }
}

@media (max-width: 480px) {
  .msg { max-width: 90%; }
  .topbar { padding: 12px 14px; }
  .online { display: none; }
}
