/* The chatroom's theme: plain pages for signing in, and one full-screen
   room. Light and dark follow the device, unless the chat page's Look
   choice set data-theme on the root. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d1f24;
  --muted: #646a76;
  --line: #e2e5ea;
  --accent: #3d5afe;
  --accent-text: #ffffff;
  --mine: #eef1ff;
  --ok: #1e9e5a;
  --bad: #c62828;
  --radius: 10px;
  /* Name colors, each readable on the page in its own scheme. */
  --me: #3d5afe;
  --c0: #b71c1c; --c1: #ad1457; --c2: #6a1b9a; --c3: #37474f;
  --c4: #00695c; --c5: #2e7d32; --c6: #8a5a00; --c7: #bf360c;
  --c8: #4e342e; --c9: #00727c; --c10: #6b6300;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c;
    --panel: #1d2027;
    --text: #e8eaef;
    --muted: #9aa1ad;
    --line: #2c3039;
    --accent: #7b8cff;
    --accent-text: #0e1016;
    --mine: #232946;
    --ok: #4cc38a;
    --bad: #ff6b6b;
    --me: #7b8cff;
    --c0: #ff8a80; --c1: #f48fb1; --c2: #ce93d8; --c3: #b0bec5;
    --c4: #80cbc4; --c5: #a5d6a7; --c6: #ffcc80; --c7: #ffab91;
    --c8: #bcaaa4; --c9: #80deea; --c10: #e6ee9c;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171c;
  --panel: #1d2027;
  --text: #e8eaef;
  --muted: #9aa1ad;
  --line: #2c3039;
  --accent: #7b8cff;
  --accent-text: #0e1016;
  --mine: #232946;
  --ok: #4cc38a;
  --bad: #ff6b6b;
  --me: #7b8cff;
  --c0: #ff8a80; --c1: #f48fb1; --c2: #ce93d8; --c3: #b0bec5;
  --c4: #80cbc4; --c5: #a5d6a7; --c6: #ffcc80; --c7: #ffab91;
  --c8: #bcaaa4; --c9: #80deea; --c10: #e6ee9c;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  padding: 0.6em 1.1em;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.quiet, .button.quiet { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.muted { color: var(--muted); }

/* The plain pages. */
body.plain { min-height: 100vh; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
}
.top nav a { margin-left: 1rem; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.card {
  max-width: 28rem; margin: 2rem max(0.75rem, env(safe-area-inset-left)); padding: 1.5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
@media (min-width: 30rem) { .card { margin: 2rem auto; } }
.card h1 { margin-top: 0; font-size: 1.5rem; }
.lead { font-size: 1.1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.button {
  display: inline-block; padding: 0.6em 1.1em; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none;
}
.stack { display: grid; gap: 0.9rem; }
.stack label { display: grid; gap: 0.3rem; font-weight: 600; }
.stack small { font-weight: 400; color: var(--muted); }
/* The hint under a new password. */
.stack small.strength { display: block; margin-top: -0.4rem; font-size: 0.85rem; }
.stack small.strength.weak { color: var(--bad); }
.stack small.strength.strong { color: var(--ok); }
.stack input, .stack select, .stack textarea, .dir-search input {
  width: 100%; padding: 0.65em 0.75em; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.error { color: var(--bad); }
.notice { color: var(--ok); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* The chatroom: the whole screen, as tall as what is visible. */
body.room { overflow: hidden; overscroll-behavior: none; }
.app {
  position: fixed; left: 0; right: 0; top: var(--app-top, 0);
  height: var(--app-h, 100dvh);
  display: flex; flex-direction: column;
  background: var(--panel);
}
.bar {
  flex: none; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem max(0.9rem, env(safe-area-inset-right)) 0.55rem max(0.9rem, env(safe-area-inset-left));
  padding-top: max(0.55rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.room-name { flex: 1 1 auto; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 3rem; }
.conn { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.conn.ok { color: var(--ok); }
.conn.bad { color: var(--bad); }
.conn::before { content: "●"; margin-right: 0.3em; }
.people-toggle {
  margin-left: auto; padding: 0.35em 0.8em; font-size: 0.9rem;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.account-link { font-size: 0.9rem; white-space: nowrap; }
.count {
  display: inline-block; min-width: 1.4em; padding: 0 0.35em; border-radius: 999px;
  background: var(--ok); color: #fff; font-size: 0.8em; text-align: center;
}
.body { flex: 1; min-height: 0; display: flex; position: relative; }
.talk { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.log {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 0.5rem 0;
}
.older { display: block; margin: 0.5rem auto; background: transparent; color: var(--accent); border: 1px solid var(--line); font-size: 0.85rem; }
.start { text-align: center; color: var(--muted); font-size: 0.85rem; }
.messages { list-style: none; margin: 0; padding: 0; }
.msg { padding: 0.35rem max(1rem, env(safe-area-inset-left)) 0.1rem; overflow-wrap: anywhere; }
.msg.cont { padding-top: 0.05rem; }
.msg.cont .head { display: none; }
.msg:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.head { display: flex; align-items: baseline; gap: 0.5rem; }
.who { font-weight: 700; }
.mine .who { color: var(--accent); }
.head time { font-size: 0.75rem; color: var(--muted); }
.text { white-space: pre-wrap; }
.text code { font-family: ui-monospace, monospace; font-size: 0.9em; background: var(--bg); padding: 0 0.25em; border-radius: 4px; }
.msg.pending .text { opacity: 0.55; }
.msg.failed .text { color: var(--bad); }
.msg { position: relative; }
.msg.gone .text { color: var(--muted); font-style: italic; }
.text .edited { font-size: 0.75rem; color: var(--muted); }
.acts {
  display: none; position: absolute; right: max(0.5rem, env(safe-area-inset-right)); top: 0.1rem;
  gap: 0.25rem; padding: 0.1rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel, var(--bg));
}
.acts button { padding: 0.1rem 0.5rem; font-size: 0.75rem; background: transparent; color: var(--accent); border: 0; }
.acts button.del { color: var(--bad); }
.acts .pick { display: flex; gap: 0.1rem; }
.acts .pick button { font-size: 1.1rem; padding: 0 0.25rem; color: inherit; }
.reacts { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.2rem 0 0.1rem; grid-column: 2 / -1; }
.react {
  padding: 0.05rem 0.45rem; font-size: 0.8rem; border-radius: 999px; line-height: 1.5;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
}
.react.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
@media (hover: hover) { .msg:hover .acts, .msg:focus-within .acts { display: flex; } }
.msg.show-acts .acts { display: flex; }
form.edit { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.2rem 0; grid-column: 2 / -1; }
form.edit textarea { flex: 1 1 100%; font: inherit; padding: 0.4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
form.edit button { padding: 0.2rem 0.8rem; font-size: 0.85rem; }
.retry {
  display: block; margin-top: 0.2rem; padding: 0; background: none;
  color: var(--bad); font-size: 0.8rem; font-weight: 600;
}
.pill {
  position: absolute; left: 50%; bottom: 0.8rem; transform: translateX(-50%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); border-radius: 999px; font-size: 0.85rem;
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 0.5rem); } }
.people {
  flex: none; width: 15rem; overflow-y: auto;
  border-left: 1px solid var(--line); padding: 0.75rem 1rem;
  padding-right: max(1rem, env(safe-area-inset-right));
  background: var(--panel);
}
.people h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 0.5rem; }
.online { list-style: none; margin: 0; padding: 0; }
.online li { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; min-width: 0; }
.online li span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .dot { background: transparent; border: 1px solid var(--muted, #888); }
.recent .ago { color: var(--muted, #888); font-size: 0.85em; }
/* Conversations: the chatroom, then private messages, newest first. */
.convs { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.convs button, .online button {
  display: flex; align-items: center; gap: 0.5rem; min-width: 0;
  padding: 0.3rem 0.45rem; margin: 0 -0.45rem; width: calc(100% + 0.9rem);
  background: transparent; color: var(--text); border: 0; border-radius: 6px;
  font: inherit; text-align: left; cursor: pointer;
}
.convs button:hover, .online button:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.convs button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); font-weight: 700; }
.convs .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convs .has-unread .label { font-weight: 700; }
.count.unread { background: var(--bad); margin-left: 0.3em; }
.count.at { background: var(--accent); color: var(--accent-text); margin-left: 0.3em; }
.mention { color: var(--accent); font-weight: 600; }
.mention.me { background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 4px; padding: 0 0.15em; }
.msg.mentions-me { box-shadow: inset 3px 0 0 var(--accent); }
.online button { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.online button .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online .role { margin-left: auto; flex: none; font-size: 0.7rem; line-height: 1; padding: 0.15rem 0.35rem; border-radius: 0.6rem; border: 1px solid currentColor; opacity: 0.75; text-transform: lowercase; }
.online .role-owner, .online .role-admin { color: var(--accent); opacity: 1; }
.hint { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--muted); }
.convs + .browse { margin: -0.75rem 0 1.25rem; }
.browse {
  padding: 0.25em 0.7em; font-size: 0.85rem; font-weight: 600;
  background: transparent; color: var(--accent); border: 1px solid var(--line);
}
#no-dms { margin: -1rem 0 1.25rem; }
.leave {
  padding: 0.2em 0.6em; font-size: 0.8rem; font-weight: 600;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
select.alerts { width: auto; max-width: 9.5rem; border-radius: 6px; cursor: pointer; }
select.alerts option { color: var(--text); background: var(--panel); }
/* Where the unread messages begin, and the way up to it. */
.msg.first-new { margin-top: 1.1rem; }
.msg.first-new::before {
  content: "New"; position: absolute; left: 0; right: 0; top: -0.75rem;
  border-top: 1px solid var(--accent); text-align: right; padding-right: 1rem;
  font-size: 0.7rem; font-weight: 700; line-height: 1.1; color: var(--accent);
}
.pill.jump { top: 0.6rem; bottom: auto; }

/* The rooms directory, over the messages. */
.directory {
  position: absolute; inset: 0; z-index: 1; overflow-y: auto;
  background: var(--panel); padding: 0.75rem max(1rem, env(safe-area-inset-left));
}
.directory[hidden] { display: none; }
.dir-list.found li { display: block; padding: 0; }
.dir-list.found button { display: flex; flex-direction: column; align-items: stretch; gap: 0.15em; width: 100%; text-align: left; font-size: 0.95rem; padding: 0.6em 0.8em; background: transparent; color: var(--text); border: 0; border-radius: 0; }
.dir-list.found button:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.found .where { font-weight: 700; }
.found .when { font-size: 0.8rem; color: var(--muted); }
.found .said { overflow-wrap: anywhere; }
.found mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; border-radius: 3px; }
.dir-list.found button.unsave { display: inline-block; width: auto; margin: 0 0.8em 0.6em; padding: 0.2em 0.7em; font-size: 0.85rem; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.msg.flash { background: color-mix(in srgb, var(--accent) 16%, transparent); transition: background 0.6s; }
.dir-head { display: flex; align-items: center; justify-content: space-between; }
.dir-head h2 { margin: 0; font-size: 1.1rem; }
.dir-buttons { display: flex; gap: 0.4rem; }
/* The room's topic and the way to what it is about and what is pinned. */
.room-info {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); min-height: 2rem;
}
.room-info[hidden] { display: none; }
.room-topic { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-open { margin-left: auto; padding: 0.1rem 0.6rem; font-size: 0.8rem; background: transparent; color: var(--accent); border: 1px solid var(--line); }
.room-about { white-space: pre-wrap; overflow-wrap: anywhere; }
.room-edit { margin: 0.75rem 0; }
.pins { padding: 0; }
/* An account that waits to be confirmed reads, and is told why it can't post. */
.unconfirmed {
  margin: 0; padding: 0.45rem max(1rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted);
}
.unconfirmed[hidden] { display: none; }
.confirm { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; margin: 1rem 0; }
.confirm h2 { margin-top: 0; }
.pins .acts { display: flex; }
.dir-close { background: transparent; color: var(--text); border: 1px solid var(--line); font-size: 0.85rem; }
.dir-search { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.dir-search input { flex: 1; min-width: 0; }
.dir-cats { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.dir-cats button {
  padding: 0.2em 0.7em; font-size: 0.85rem; background: transparent;
  color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.dir-cats button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.dir-list { list-style: none; margin: 0; padding: 0; }
.dir-list li {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0;
  border-bottom: 1px solid var(--line); min-width: 0;
}
.dir-list .about { flex: 1; min-width: 0; }
.dir-list .name { font-weight: 700; overflow-wrap: anywhere; }
.dir-list .topic { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.dir-list .people-n { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.dir-list button { font-size: 0.85rem; padding: 0.3em 0.8em; }
.dir-list .empty { color: var(--muted); border: 0; }
.dir-make { margin-top: 1rem; }
.dir-make summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.dir-make form { margin-top: 0.75rem; max-width: 28rem; }
.dir-make .error { color: var(--bad); margin: 0; }
.drawer-links { margin-top: 1.5rem; font-size: 0.9rem; }
@media (min-width: 761px) { .drawer-links { display: none; } }
.dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--ok); }
.dot.away { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.typing {
  position: absolute; bottom: 100%; left: max(0.75rem, env(safe-area-inset-left)); margin: 0;
  padding: 0.1rem 0.5rem; font-size: 0.8rem; color: var(--muted);
  background: var(--panel); border-radius: 6px 6px 0 0; pointer-events: none;
  max-width: calc(100% - 1.5rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scrim { display: none; }
.composer {
  flex: none; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; position: relative;
  padding: 0.6rem max(0.75rem, env(safe-area-inset-right)) max(0.6rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: var(--panel);
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; max-height: 160px; overflow-y: hidden;
  padding: 0.6em 0.75em; font-size: 16px; line-height: 1.35;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.send { flex: none; min-height: 2.6rem; }

/* Formatting and emoji, above the message box. */
.tools { flex-basis: 100%; display: flex; align-items: center; gap: 0.25rem; margin-bottom: -0.15rem; }
.tools button {
  min-width: 2rem; padding: 0.15em 0.5em; font-size: 0.9rem; line-height: 1.4;
  background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 6px;
}
.tools button:hover, .tools button[aria-expanded="true"] { border-color: var(--line); background: var(--bg); }
.tools-hint { margin-left: auto; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 760px) { .tools-hint { display: none; } }
.emoji-panel, .suggest {
  position: absolute; left: max(0.75rem, env(safe-area-inset-left)); bottom: 100%; z-index: 4;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.emoji-panel { width: min(22rem, calc(100% - 1.5rem)); padding: 0.4rem; margin-bottom: 0.3rem; }
.emoji-panel[hidden], .suggest[hidden] { display: none; }
.emoji-tabs { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-bottom: 0.3rem; }
.emoji-tabs button {
  padding: 0.15em 0.55em; font-size: 0.75rem; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
}
.emoji-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.1rem, 1fr)); max-height: 13rem; overflow-y: auto; }
.emoji-grid button {
  padding: 0.15rem 0; font-size: 1.35rem; line-height: 1.5; background: transparent;
  border: 0; border-radius: 6px;
}
.emoji-grid button:hover, .emoji-grid button:focus-visible { background: var(--bg); }
.suggest { list-style: none; margin: 0 0 0.3rem; padding: 0.25rem; min-width: 14rem; max-width: calc(100% - 1.5rem); }
.suggest li { padding: 0.3rem 0.5rem; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.suggest .glyph { font-size: 1.2rem; margin-right: 0.5rem; }

/* Classic: one line a message, the name in bold and a colon, then the text.
   Every message has its name; long lines wrap under the text. The time
   shows on hover, or on a tap on a phone. */
.classic .msg {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 0.4em; align-items: baseline;
  padding: 0.1rem max(1rem, env(safe-area-inset-right)) 0.1rem max(1rem, env(safe-area-inset-left));
}
.classic .msg .head, .classic .msg.cont .head { display: contents; }
.classic .who { grid-column: 1; grid-row: 1; max-width: min(12em, 38vw); overflow-wrap: anywhere; }
.classic .who::after { content: ":"; color: var(--text); font-weight: 700; }
.classic .text { grid-column: 2; grid-row: 1; }
.classic .head time { display: none; grid-column: 3; grid-row: 1; white-space: nowrap; }
.classic .msg.show-time time { display: block; }
@media (hover: hover) { .classic .msg:hover time { display: block; } }
.classic .retry { grid-column: 2; }
.classic [data-c="me"] { color: var(--me); }
.classic [data-c="0"] { color: var(--c0); }
.classic [data-c="1"] { color: var(--c1); }
.classic [data-c="2"] { color: var(--c2); }
.classic [data-c="3"] { color: var(--c3); }
.classic [data-c="4"] { color: var(--c4); }
.classic [data-c="5"] { color: var(--c5); }
.classic [data-c="6"] { color: var(--c6); }
.classic [data-c="7"] { color: var(--c7); }
.classic [data-c="8"] { color: var(--c8); }
.classic [data-c="9"] { color: var(--c9); }
.classic [data-c="10"] { color: var(--c10); }
.classic .online [data-c] { font-weight: 600; }

/* Threads: replies to one message, beside the conversation on a wide
   screen and over the whole screen on a phone. */
.thread {
  flex: none; width: min(26rem, 42vw); min-height: 0; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: var(--panel);
}
.thread[hidden] { display: none; }
.thread-head {
  flex: none; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem max(0.9rem, env(safe-area-inset-right)) 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.thread-head h2 { margin: 0 auto 0 0; font-size: 1rem; }
.thread-head button {
  padding: 0.25em 0.7em; font-size: 0.85rem; font-weight: 600;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.thread-head button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.thread-parent { border-bottom: 1px solid var(--line); padding-bottom: 0.35rem; margin-bottom: 0.35rem; }
.replies-link {
  display: inline-flex; align-items: center; gap: 0.4rem; justify-self: start; grid-column: 2 / -1;
  margin: 0.2rem 0 0.1rem; padding: 0.1rem 0.55rem; font-size: 0.8rem; font-weight: 600;
  background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 6px;
}
.replies-link time { font-weight: 400; color: var(--muted); }
.in-thread { margin-left: 0.4rem; padding: 0; background: none; border: 0; color: var(--accent); font-size: 0.75rem; white-space: nowrap; }
#chat:not(.classic) #messages > .msg.reply { display: none; }
@media (max-width: 760px) {
  .thread {
    position: fixed; left: 0; right: 0; top: var(--app-top, 0); height: var(--app-h, 100dvh);
    width: auto; z-index: 6; border-left: 0;
  }
  .thread-head { padding-top: max(0.55rem, env(safe-area-inset-top)); }
}

/* The layout switch, under who is online. */
.layout { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 1.5rem; font-size: 0.85rem; }
.layout-label { color: var(--muted); margin-right: 0.2rem; }
.layout + .layout { margin-top: 0.6rem; }
.layout button {
  padding: 0.25em 0.7em; font-size: 0.85rem; font-weight: 600;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.layout button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* A narrow screen: who is online is a drawer from the right. */
@media (max-width: 760px) {
  .account-link { display: none; }
  .bar { gap: 0.45rem; }
  /* The drawer counts unread conversations; who is online is inside it. */
  .people-toggle #online-count { display: none; }
  .people-toggle { margin-left: 0; flex: none; }
  .bar .leave, .bar select.alerts { flex: none; padding-left: 0.5em; padding-right: 0.5em; }
  select.alerts { max-width: 7.5rem; }
  .people {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 3;
    width: min(80vw, 18rem);
    transform: translateX(100%); transition: transform 0.2s ease;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  }
  .people.open { transform: none; }
  .scrim { display: block; position: absolute; inset: 0; z-index: 2; background: rgba(0, 0, 0, 0.3); }
  .scrim[hidden] { display: none; }
  .conn { font-size: 0; }
  .conn::before { font-size: 0.8rem; margin: 0; }
}
@media (min-width: 761px) {
  .people-toggle { display: none; }
  .bar .conn { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .people { transition: none; }
  .pill { animation: none; }
}

/* The profile card a name opens. */
.profile { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; width: min(26rem, calc(100vw - 2rem)); background: var(--panel); color: var(--text); }
.profile::backdrop { background: #0006; }
.profile-top { display: flex; align-items: center; gap: 0.8rem; }
.profile-top h2 { flex: 1; margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.profile-pic { width: 3.5rem; height: 3.5rem; border-radius: 50%; object-fit: cover; }
.profile-fields { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 0.9rem; margin: 1rem 0 0; }
.profile-fields dt { font-weight: 600; color: var(--muted); }
.profile-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile .actions { margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.profile button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
#report-form label { display: block; margin: 0.8rem 0 0.3rem; }
#report-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 0.4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.msg .who[role="button"] { cursor: pointer; }
.msg .who[role="button"]:hover, .msg .who[role="button"]:focus-visible { text-decoration: underline; }
.stack textarea { font-family: inherit; resize: vertical; }
.check span { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; }

/* Invitations and a private room's list. */
.invite-list { list-style: none; margin: 0 0 0.8rem; padding: 0; display: grid; gap: 0.35rem; }
.invite-list li { display: flex; align-items: center; gap: 0.5rem; }
.invite-list .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-list button { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.link-make { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; margin-bottom: 0.5rem; }
.link-make label { display: grid; gap: 0.2rem; font-size: 0.85rem; }
.link-new { display: flex; gap: 0.5rem; }
.link-new input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.8rem; }
.invite-list .link-about { white-space: normal; font-size: 0.85rem; }
#invites li { flex-wrap: wrap; }
#invites .label { flex-basis: 100%; }
.profile h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1rem 0 0.4rem; }

/* The account page's picture. */
.picture-edit { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; margin: 0 0 1.2rem; }
.picture-edit .picture { width: 6rem; height: 6rem; border-radius: 50%; object-fit: cover; }
.picture-edit .picture.none { display: inline-block; border: 1px dashed currentColor; opacity: 0.4; }
.picture-edit form.stack { flex: 1; min-width: 14rem; }

/* Files in messages: a picture shown small, anything else a download. */
.text .shot { display: block; margin-top: 0.25rem; max-width: min(320px, 100%); }
.text .shot img { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); }
.text a.file { display: inline-block; padding: 0.2em 0.6em; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; overflow-wrap: anywhere; }

/* Someone I muted: their message folded until asked. */
.msg .unfold { padding: 0; background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; font-style: italic; cursor: pointer; }
.msg.hushed .reacts, .msg.hushed .replies-link { display: none; }
@media (pointer: coarse) {
  .msg .unfold, .link-make button, .link-make select, .link-new button, .link-new input { min-height: 44px; }
}
/* A picture, opened over the chat. */
.viewer {
  width: 100vw; max-width: 100vw; height: var(--app-h, 100dvh); max-height: none; margin: 0;
  top: var(--app-top, 0); padding: 0; border: 0; background: #000e; color: #fff;
}
.viewer::backdrop { background: #000c; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer-bar {
  flex: none; display: flex; align-items: center; gap: 0.5rem;
  padding: max(0.4rem, env(safe-area-inset-top)) max(0.6rem, env(safe-area-inset-right)) 0.4rem max(0.6rem, env(safe-area-inset-left));
}
.viewer-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.viewer-bar a, .viewer-bar button {
  min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 0.8rem; background: transparent; color: #fff; border: 1px solid #fff6; border-radius: 8px; font: inherit; text-decoration: none;
}
.viewer-pic {
  flex: 1; min-height: 0; overflow: auto; touch-action: pinch-zoom pan-x pan-y;
  display: flex; align-items: center; justify-content: center;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.viewer-pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-pic.full { display: block; }
.viewer-pic.full img { max-width: none; max-height: none; }

/* Dialogs fit above an on-screen keyboard and scroll inside. */
.profile { max-height: calc(var(--app-h, 100dvh) - 2rem); overflow-y: auto; overscroll-behavior: contain; }
/* Panels that reach the bottom of the screen clear the home indicator. */
.people, .directory { padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
/* A hover colour stays after a tap on a touch screen: hover only where there is one. */
@media (hover: none) { .msg:hover { background: transparent; } }

/* Touch: everything that can be tapped is at least 44 px high. */
@media (pointer: coarse) {
  .people-toggle, .older, .browse, .leave, .room-open, .dir-close, .dir-cats button,
  .dir-list button, .layout button, .thread-head button, .invite-list button,
  .profile .actions button, .profile .actions a, .profile-top button, form.edit button, .send, select.alerts,
  .emoji-tabs button, .replies-link, .retry {
    min-height: 44px;
  }
  .convs button, .online button { min-height: 44px; padding-top: 0.4rem; padding-bottom: 0.4rem; }
  .tools button { min-height: 44px; min-width: 44px; }
  .tools { margin-bottom: 0; }
  .acts { top: -0.6rem; gap: 0; padding: 0; }
  .acts button { min-height: 44px; min-width: 44px; padding: 0 0.6rem; font-size: 0.85rem; }
  .acts .pick button { min-width: 40px; font-size: 1.25rem; }
  .react { min-height: 44px; padding: 0.2rem 0.7rem; font-size: 0.9rem; }
  .reacts { gap: 0.4rem; }
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .emoji-grid button { min-height: 44px; }
  .suggest li { padding: 0.6rem 0.6rem; }
  .in-thread { min-height: 32px; padding: 0 0.3rem; }
  .text a.file { min-height: 44px; padding: 0.6em 0.8em; }
  .dir-list.found button { min-height: 44px; }
  .dir-list.found button.unsave { min-height: 44px; padding: 0 1em; }
  .drawer-links a { display: inline-block; padding: 0.75rem 0; }
  .bar .brand { display: inline-flex; align-items: center; min-height: 44px; }
  .top nav a, .top .brand { display: inline-block; padding: 0.6rem 0; }
}

/* A removed account's name, and its deleted messages nobody replied to. */
li.msg.vanished { display: none; }
[data-account].left, .classic [data-account].left { color: var(--muted); font-weight: 400; font-style: italic; }
/* Desktop alerts the browser blocks for this site. */
#notify.blocked { text-decoration: line-through; opacity: 0.7; }
