/* Minimalistic terminal-ish look. Pure black background, monospace. */
:root {
  --bg: #0b0b0b;
  --fg: #e6e6e6;
  --muted: #7a7a7a;
  --accent: #8ad7ff;
  --ghost: #a78bfa;
  --shout: #fbbf24;
  --error: #ff7a7a;
  --line: #1d1d1d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 16px;
  line-height: 1.5;
  height: 100%;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.25rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

h1,
h2 {
  font-weight: normal;
  margin: 0.5rem 0;
}

h1 {
  /* Header in Space Mono (the body/mono face) rather than the cursive
     Playwrite NL display font — keeps the header understated and
     terminal-ish, matching the Flutter app's AppBar. Space Mono only ships
     400/700, so use 700 for a crisp bold (no synthetic bolding). */
  font-family: 'Space Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: rgba(230, 230, 230, 0.85);
}

#title-row {
  margin-top: 0.25rem;
}

#title-row h1 {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--error);
}

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

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

input {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 0.5rem 0.6rem;
  font: inherit;
  border-radius: 4px;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--fg);
  color: var(--bg);
  border: 0;
  padding: 0.65rem 1.2rem;
  margin-top: 0.75rem;
  font: inherit;
  font-weight: normal;
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
}

.chat-form button,
#shout-form button {
  margin-top: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

button:active {
  opacity: 0.8;
}

button.link {
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 400;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#people li {
  padding: 0.6rem 0.2rem 0.6rem calc(0.85rem - 2px);
  border-bottom: 1px solid var(--line);
  border-left: 2px solid var(--line);
  cursor: pointer;
}

#people li:last-child {
  border-bottom: none;
}

#people li:hover {
  background: #131313;
}

.person-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.person-info {
  flex: 1;
  min-width: 0;
}

.person-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#people .nick {
  font-weight: normal;
}

#people .bio {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.4rem;
}

#people .hint {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  margin-left: auto;
}

.preview {
  color: var(--fg);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.2rem;
  opacity: 0.7;
}

.badge {
  background: var(--shout);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  min-width: 1.1rem;
  text-align: center;
}

/* Inline chat widget */
.chat-widget {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.chat-header {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 1.4rem;
  cursor: pointer;
  user-select: none;
}

.chat-header:hover {
  background: #131313;
}

.chat-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 0.4rem;
}

.chat-blocked-banner {
  margin-top: 0.5rem;
  padding: 0.4rem 0.5rem;
  color: var(--error);
  font-size: 0.9rem;
  border: 1px solid var(--error);
  border-radius: 4px;
  text-align: center;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.chat-form input {
  flex: 1;
}

.messages {
  max-height: 40vh;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.messages li {
  padding: 0.15rem 0;
}

#people .messages li {
  border-bottom: none;
}

/* Dim other people when a chat is open */
#people.has-active-chat>li {
  opacity: 0.4;
}

#people.has-active-chat>li.active {
  opacity: 1;
  background: #0f0f0f;
  border-left-color: var(--shout);
}

.messages li.me {
  color: var(--fg);
}

.messages li.them {
  color: var(--muted);
}

.messages li.system {
  color: var(--muted);
  font-style: italic;
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  /* Reserve one row of vertical space so transitions between
     connecting/reconnecting/empty don't reflow everything below. */
  min-height: 1.3rem;
}

li.ghost {
  opacity: 0.5;
}

/* "You" block — collapsed identity + shout, set apart from the
   nearby list with an accent left bar and a tiny `you` tag so the
   user's own surface doesn't blend in with peers. */
#me-block {
  position: relative;
  padding: 0.5rem 0.75rem 0.6rem calc(0.85rem - 2px);
  margin: 0.75rem 0 1.5rem 0;
  border-left: 2px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: #0f1418;
  border-radius: 0 4px 0 0;
}

#me-block[hidden] {
  display: none;
}

#me-tag {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  opacity: 0.7;
  margin-bottom: 0.2rem;
}

/* Profile bar */
#profile-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

#profile-summary {
  color: var(--fg);
  font-weight: normal;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Actions ([edit] / [shout]) stacked vertically on the right of the profile
   row, matching the Flutter app's YOU strip. */
#profile-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  flex-shrink: 0;
}

#profile-actions .btn-small {
  text-align: center;
}

.btn-small {
  font-size: 0.8rem;
  padding: 0.1rem 0.4rem;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  cursor: pointer;
  vertical-align: baseline;
  margin-top: 0;
}

.btn-small:hover {
  color: var(--fg);
  border-color: var(--fg);
}

/* Shouts — one per user, attached to presence. The [shout] trigger lives in
   #profile-actions (top-right); this bar holds the active text / editing form
   as a sub-line directly under the profile summary (mirrors how a peer's
   .person-shout sits under their nick in the nearby list). */
#shout-bar {
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Collapse the sub-line entirely when there's no active shout and we're not
   editing (both children hidden) so it doesn't add a stray gap. */
#shout-bar:not(:has(> :not([hidden]))) {
  margin-top: 0;
}

/* The [shout] trigger sits in #profile-actions: an understated amber
   affordance, mirroring the Flutter app's amber "shout" text button. */
#shout-open {
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--shout);
}

#shout-open:hover {
  border-color: var(--shout);
  color: var(--shout);
}

#shout-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#shout-form input:focus {
  border-color: var(--shout);
}

#shout-form[hidden] {
  display: none;
}

#shout-form input {
  flex: 1;
}

#shout-current {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

#shout-current[hidden] {
  display: none;
}

#shout-current-text {
  flex: 1;
  color: var(--shout);
  font-size: 0.9rem;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Edit/clear sit at the end without a border so they read as quiet
   secondary actions next to the amber text. */
#shout-current .btn-small {
  border-color: transparent;
}

/* Shout displayed under a person's nick in the nearby list. */
.person-shout {
  color: var(--shout);
  font-size: 0.9rem;
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-shout .shout-age {
  font-size: 0.75rem;
}

/* Shout banner at the top of the inline chat widget. */
.chat-shout-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--shout);
  font-size: 0.9rem;
}

#nearby-section h2 {
  margin-top: 0.5rem;
}

#stats {
  font-size: 0.8rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}