:root {
  --bg: #050507;
  --ink: #e9e8e4;
  --muted: #8a8d94;
  --dim: #565961;
  --line: rgba(255, 255, 255, 0.08);
  --panel: rgba(10, 11, 14, 0.72);
  --accent: #f4f4f2;
  --warn: #f2a38f;
  --font: ui-monospace, "Cascadia Mono", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --gutter: clamp(16px, 2.6vw, 32px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--muted);
  font: 11px/1.55 var(--font);
  letter-spacing: 0.02em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: manipulation;
}

button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
b { color: var(--ink); font-weight: 500; }
.dim { color: var(--dim); }
[hidden] { display: none !important; }

.link {
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.link:hover, .link:focus-visible { color: var(--ink); border-color: var(--muted); outline: none; }

.error { color: var(--warn); margin: 6px 0 0; }

.tag {
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid rgba(242, 196, 109, 0.35);
  border-radius: 3px;
  color: #d9b36a;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---- header ---------------------------------------------------------------- */

.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: var(--gutter);
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
h1 {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.28em;
}
.top-right { display: flex; gap: 18px; align-items: baseline; }

.live { display: inline-flex; align-items: center; gap: 7px; text-transform: lowercase; }
.live i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dim);
}
.live[data-state="live"] i {
  background: #9fe3c1;
  box-shadow: 0 0 8px #9fe3c1;
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.35; } }

/* ---- centre notes ------------------------------------------------------------- */

.empty {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 2;
  pointer-events: none;
  animation: fadein 3s ease both;
}
@keyframes fadein { from { opacity: 0; } }

.synthetic-note {
  position: fixed;
  top: calc(var(--gutter) + 22px);
  left: var(--gutter);
  margin: 0;
  z-index: 2;
  padding: 2px 8px;
  border: 1px dashed rgba(242, 196, 109, 0.4);
  border-radius: 3px;
  color: #d9b36a;
  background: rgba(5, 5, 7, 0.7);
}

.tooltip {
  position: fixed;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(8, 9, 12, 0.88);
  backdrop-filter: blur(6px);
  pointer-events: none;
  white-space: nowrap;
}
.tooltip b { overflow: hidden; text-overflow: ellipsis; }
.tooltip .tag { margin: 3px 0 0; align-self: flex-start; }
.here { color: #9fe3c1; }

/* ---- footer ------------------------------------------------------------------- */

.bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 24px;
  padding: 48px var(--gutter) var(--gutter);
  background: linear-gradient(to top, rgba(5, 5, 7, 0.85), rgba(5, 5, 7, 0));
  pointer-events: none;
}
.bottom > * { pointer-events: auto; }
.bottom .spacer { pointer-events: none; }

.activity {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  color: var(--muted);
}
.activity li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48ch; }
.activity .name::before { content: "+ "; color: var(--dim); }

.stats { display: flex; gap: 22px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; font-size: 9.5px; }
.stats dd { margin: 0; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }

.action { text-align: center; max-width: 420px; }
.caption { margin: 10px 0 0; color: var(--dim); }

.join {
  padding: 10px 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 10.5px;
  transition: border-color .4s, background .4s, box-shadow .4s;
}
.join:hover, .join:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.12);
}
.join:disabled { opacity: 0.5; cursor: progress; }
.mine { margin: 0; display: flex; gap: 14px; justify-content: center; align-items: baseline; }

/* ---- chat ------------------------------------------------------------------------- */

.chat {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 3;
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.chat-head {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: none;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 9.5px;
  color: var(--muted);
}
.chat-head #chat-count { text-transform: none; letter-spacing: 0.02em; color: #9fe3c1; }
.chev { margin-left: auto; width: 7px; height: 7px; border: solid var(--dim); border-width: 0 1px 1px 0; transform: rotate(-135deg); transition: transform .3s; }
.chat[data-open="true"] .chev { transform: rotate(45deg); }
.chat-body { display: none; padding: 0 12px 12px; }
.chat[data-open="true"] .chat-body { display: block; }

.messages {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  min-height: 48px;
  max-height: min(34vh, 300px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.messages li { overflow-wrap: anywhere; color: #b9bbc0; }
.messages li:first-child { margin-top: auto; }
.messages time { margin-right: 7px; font-size: 9.5px; }
.messages .name { margin-right: 7px; color: var(--ink); }
.messages .quiet { text-align: center; padding: 20px 0; }

.composer { display: flex; gap: 6px; margin-top: 10px; }
.composer input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
}
.composer input:focus { outline: none; border-color: rgba(255, 255, 255, 0.25); }
.composer input:disabled { opacity: 0.55; }
.composer button, .account button[type="submit"], .account .secondary {
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}
.composer button:disabled { opacity: 0.35; cursor: default; }
.account .secondary { background: none; color: var(--muted); }

/* ---- account dialog ------------------------------------------------------------------ */

.account {
  width: min(380px, calc(100vw - 32px));
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0c0f;
  color: var(--muted);
}
.account::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }
.account h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.24em;
}
.account p { margin: 0 0 14px; line-height: 1.7; }
.close-row { display: flex; justify-content: flex-end; margin: -4px -4px 0 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.stack label.inline, .sizes label { flex-direction: row; align-items: center; gap: 6px; }
.stack input:not([type]), .stack input[type="password"] {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #050507;
  color: var(--ink);
}
.stack input:focus { outline: none; border-color: rgba(255, 255, 255, 0.28); }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; margin-bottom: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.sizes { gap: 16px; }
input[type="radio"], input[type="checkbox"] { accent-color: #d9d9d4; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch span {
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  outline: 1px solid transparent;
  outline-offset: 3px;
  transition: outline-color .2s;
}
.swatch input:checked + span { outline-color: rgba(255, 255, 255, 0.7); }
.swatch input:focus-visible + span { outline-color: #9fd3f2; }

/* ---- small screens ------------------------------------------------------------------ */

@media (max-width: 760px) {
  .brand .dim { display: none; }
  .synthetic-note { top: calc(var(--gutter) + 24px); right: var(--gutter); text-align: center; }

  .bottom {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 14px;
    padding-bottom: calc(var(--gutter) + 44px + env(safe-area-inset-bottom));
  }
  .bottom .spacer, .activity { display: none; }
  .presence { order: 2; }
  .stats { gap: 18px; }
  .stats dd { font-size: 13px; text-align: center; }
  .stats dt { font-size: 9px; text-align: center; }

  /* chat becomes a bottom sheet */
  .chat {
    left: 0; right: 0; bottom: 0;
    width: auto;
    border-radius: 10px 10px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .chat-head { padding: 13px var(--gutter); }
  .chat-body { padding: 0 var(--gutter) 14px; }
  .messages { max-height: 46vh; }
  .composer input { font-size: 16px; } /* prevents iOS zoom on focus */
}

@media (prefers-reduced-motion: reduce) {
  .live[data-state="live"] i { animation: none; }
}
