:root {
  --bg: #fff; --fg: #111; --muted: #6b6b6b; --line: #e5e5e5; --field: #f4f4f4;
  --me-bg: #111; --me-fg: #fff; --lu-bg: #efefef; --lu-fg: #111; --veil: rgb(255 255 255 / .55);
  --pad: clamp(16px, 4vw, 32px);
  --col: max(var(--pad), calc((100% - 760px) / 2));
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a; --fg: #f2f2f2; --muted: #8e8e8e; --line: #262626; --field: #161616;
    --me-bg: #f2f2f2; --me-fg: #0a0a0a; --lu-bg: #1f1f1f; --lu-fg: #f2f2f2; --veil: rgb(10 10 10 / .55);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* Header: who you're writing to */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--col) 12px;
  border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.av { position: relative; flex: none; width: 40px; height: 40px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--field); font-weight: 500; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.name { overflow: hidden; font-size: 1.0625rem; font-weight: 500; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.links { display: flex; margin-right: -10px; }
.links a { display: block; padding: 10px; }
.links svg, .ico { display: block; width: 18px; height: 18px; }
.ico { background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }

/* Feed */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#feed { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: var(--pad) var(--col); overscroll-behavior: contain; }
#feed::before { content: ""; margin-top: auto; }
#feed:empty { align-items: center; justify-content: center; }
#feed:empty::before { display: none; }
#feed:empty::after { content: "No messages yet."; color: var(--muted); }
.day { align-self: center; margin: 20px 0 8px; color: var(--muted); font-size: .75rem; letter-spacing: .02em; }
.b { max-width: min(80%, 34rem); margin-top: 3px; padding: 9px 15px; border-radius: 20px; font-size: 1.0625rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.b.start { margin-top: 14px; }
.day + .b { margin-top: 0; }
.me { align-self: flex-end; background: var(--me-bg); color: var(--me-fg); }
.lu { align-self: flex-start; background: var(--lu-bg); color: var(--lu-fg); }
.me.end { border-bottom-right-radius: 6px; }
.lu.end { border-bottom-left-radius: 6px; }
.pending { opacity: .5; }
.t { margin: 4px 6px 0; color: var(--muted); font-size: .6875rem; }
.t.me { align-self: flex-end; }
.t.lu { align-self: flex-start; }

/* Composer */
#f { padding: 10px var(--col) calc(12px + env(safe-area-inset-bottom, 0px)); }
#status { margin: 0 0 8px 18px; color: var(--muted); font-size: .8125rem; }
.pill { display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 18px; border: 1px solid var(--line); border-radius: 24px; background: var(--field); transition: border-color .2s ease; }
.pill:focus-within { border-color: var(--muted); }
#msg { flex: 1; min-width: 0; max-height: 40dvh; padding: 7px 0; border: 0; background: none; color: inherit; font: inherit; font-size: 1.0625rem; line-height: 1.4; outline: 0; resize: none; }
::placeholder { color: var(--muted); opacity: 1; }
.send { flex: none; width: 0; height: 36px; margin-left: -8px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--fg); color: var(--bg); opacity: 0; transform: scale(.5); pointer-events: none; cursor: pointer; transition: width .2s ease, margin .2s ease, opacity .2s ease, transform .2s ease; }
.send.on { width: 36px; margin-left: 0; opacity: 1; transform: none; pointer-events: auto; }

/* Captcha gate: blurred view, spinning square */
#gate {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  background: var(--veil); -webkit-backdrop-filter: blur(24px) saturate(1.3); backdrop-filter: blur(24px) saturate(1.3);
  transition: opacity .5s ease, visibility 0s;
}
#gate.done { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .5s ease, visibility 0s .5s; }
.sq { width: 56px; height: 56px; border: 1px solid var(--fg); animation: spin 1.6s cubic-bezier(.65, 0, .35, 1) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#gtxt { margin: 0; font-size: .875rem; letter-spacing: .08em; }
@media (prefers-reduced-motion: reduce) { .sq { animation: none; } #gate, .send, .pill { transition: none; } }
