/* Gal — visual design.
   A conversation surface should recede; the writing is the content. The palette
   stays near-neutral so that participant colours, which carry real meaning
   (who wrote what, whose caret is where), are the only saturated things. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #d0d5dd;
  --text: #16191d;
  --text-dim: #666e7a;
  /* Was #98a0ac, about 2.6:1 on white — below WCAG AA and below even the
     large-text threshold. It is not decoration: timestamps, file sizes, the
     "Reply…" placeholder and the Reply/Privately/Delete labels are all drawn in
     it. 4.8:1 here, still a step lighter than --text-dim. */
  --text-faint: #6b7383;
  --accent: #2f6df6;
  --accent-soft: #e8f0fe;
  --danger: #d3453b;
  /* Dark enough to carry white text at 4.5:1, which the obvious amber is not.
     The offline banner is small bold text and is the only thing wearing it. */
  --warn: #8a5a12;
  --unread: #2f6df6;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 4%);
  --shadow-2: 0 8px 28px rgb(16 24 40 / 12%), 0 2px 6px rgb(16 24 40 / 6%);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --sidebar-width: 336px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #171a1f;
    --surface-2: #1e2229;
    --border: #262b33;
    --border-strong: #333a45;
    --text: #e7eaef;
    --text-dim: #9aa3b0;
    /* Was #6b7480, 3.8:1 on the dark surface. 5.3:1. */
    --text-faint: #838b98;
    --accent: #5b8dff;
    --accent-soft: #1b2a49;
    --danger: #f0736a;
    --warn: #a06a15;
    --unread: #5b8dff;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-2: 0 12px 32px rgb(0 0 0 / 55%);
  }
}

* {
  box-sizing: border-box;
}

/* Honour the system setting. There is an infinite pulse on the offline dot and
   another on the upload spinner, and cards in the comment margin slide to their
   new positions — all of which is motion nobody asked this page for. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* `select` belongs here too: without it the mode picker is the only control on
   the page drawn in the browser's default UI font. */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.booting {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--text-faint);
}

/* --- buttons --- */

.btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.07);
}

.btn.ghost {
  border-color: var(--border-strong);
  color: var(--text-dim);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.link {
  color: var(--text-dim);
  padding: 4px 6px;
  font-weight: 400;
}

.btn.link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.btn.wide {
  width: 100%;
  padding: 9px 12px;
}

.field {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* --- sign in --- */

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-form {
  width: min(370px, 100%);
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: var(--surface);
  padding: 34px 30px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}

.auth-logo {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.02em;
}

.auth-tagline {
  margin: -6px 0 12px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  min-height: 1em;
}

/* Signing in through an identity provider. Drawn only when the server has one
   configured, so these rules go unused on most deployments. */
.auth-provider {
  display: grid;
  gap: 10px;
}

/* "or", with a rule through it. The lines are borders on pseudo-elements
   rather than a background image, so they follow the theme's own colour in
   both light and dark. */
.auth-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.auth-or::before,
.auth-or::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* --- layout --- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 15.5px;
}

.brand-mark {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  position: relative;
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.45;
}

.search-row {
  padding: 4px 12px 8px;
}

.search-input {
  width: 100%;
  padding: 7px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.filters {
  display: flex;
  gap: 4px;
  padding: 0 12px 8px;
}

.filter {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}

.filter:hover {
  background: var(--surface-2);
}

.filter.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* --- inbox --- */

.inbox {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.inbox-label {
  padding: 8px 8px 4px;
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inbox-row {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 1px;
}

.inbox-row:hover {
  background: var(--surface-2);
}

.inbox-row.active {
  background: var(--accent-soft);
}

.inbox-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.faces {
  display: flex;
  flex-shrink: 0;
}

.faces .avatar + .avatar {
  margin-left: -7px;
}

.inbox-title {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.inbox-row.unread .inbox-title {
  font-weight: 650;
}

.inbox-time {
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.inbox-snippet {
  color: var(--text-dim);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 2px;
  margin-top: 1px;
}

/* The unread badge is positioned over this line; leave it room rather than
   letting it sit on top of the words. */
.inbox-row.unread .inbox-snippet {
  padding-right: 34px;
}

.inbox-snippet mark {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: inherit;
  border-radius: 2px;
}

.badge {
  position: absolute;
  right: 10px;
  bottom: 8px;
  background: var(--unread);
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
  padding: 0 6px;
  border-radius: 9px;
  line-height: 17px;
}

/* A muted wave keeps its place in the list and gives up its emphasis: the
   title stops going bold on unread, and the row says why rather than leaving
   a missing badge to be read as "nothing happened here". */
.inbox-row.muted .inbox-title {
  font-weight: 500;
}

.muted-mark {
  flex: none;
  font-size: 10.5px;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 15px;
}

/* Where a search hit landed. Long enough to find with the eye after the scroll
   settles, then gone — it marks a message, it does not select one. */
.blip.revealed {
  animation: reveal 2.4s ease-out;
}

@keyframes reveal {
  0%,
  55% {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
  }
  100% {
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blip.revealed {
    animation-duration: 1ms;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

/* A mention is a name, drawn as one. Not a link: it goes nowhere, and dressing
   it as something clickable would promise a profile page that does not exist. */
.mention {
  color: var(--accent);
  font-weight: 550;
  border-radius: 4px;
  padding: 0 2px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

/* Being named is the whole point of the feature, so it has to be findable by
   eye in a long message rather than merely present. */
.mention-you {
  color: #fff;
  background: var(--accent);
}

.mention-picker {
  position: fixed;
  z-index: 250;
  min-width: 220px;
  max-width: 320px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.mention-option.active,
.mention-option:hover {
  background: var(--accent-soft);
}

.mention-name {
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mention-handle {
  color: var(--text-faint);
  margin-left: auto;
  white-space: nowrap;
}

.empty-note {
  padding: 22px 12px;
  color: var(--text-faint);
  text-align: center;
  font-size: 13px;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
}

.me {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.me-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status-dot.online {
  background: #22a06b;
}

.status-dot.offline {
  background: #e0a030;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* --- wave pane --- */

.wave-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.empty-wave {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  max-width: 340px;
  padding: 24px;
}

.empty-wave h2 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--text);
}

.empty-wave p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.wave-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.wave-head-main {
  min-width: 0;
  flex: 1;
}

.wave-title {
  margin: 0;
  min-width: 0;
}

.wave-title-button {
  display: block;
  max-width: 100%;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.015em;
  cursor: text;
  border-radius: 5px;
  padding: 1px 4px;
  margin-left: -4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wave-title-button:hover {
  background: var(--surface-2);
}

/* The avatar carries the picture; the button carries the behaviour. */
.participant-button {
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 50%;
  line-height: 0;
}

.wave-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.participants {
  display: flex;
  align-items: center;
  gap: 3px;
}

.presence {
  display: flex;
  align-items: center;
  gap: 5px;
}

.presence-label {
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.add-participant {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-left: 3px;
}

.add-participant:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wave-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Only meaningful when the panes share the viewport; see the media query. */
.back-to-inbox {
  display: none;
  font-size: 18px;
  line-height: 1;
  padding: 4px 11px;
  margin-right: 2px;
}

/* --- toolbar --- */

/* One toolbar, moved to whichever input holds the caret: the composer's own
   control row in a channel, the message being written in every other mode.
   `.blip-tools` and `.foot-tools` are the sockets it docks into, and both
   collapse when it is somewhere else. */

.toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.blip-tools,
.foot-tools {
  display: flex;
}

.blip-tools:empty,
.foot-tools:empty {
  display: none;
}

.blip-tools {
  margin-top: 6px;
}

.toolbar.idle {
  opacity: 0.55;
}

/* Inside a message the toolbar is chrome, not content: quiet until the message
   is being written in, which is the only time it is there at all. */
.blip-tools .toolbar {
  background: transparent;
  border-color: transparent;
  padding: 0;
  margin-left: -3px;
}

.blip-tools .tool:hover {
  background: var(--surface-2);
}

.tool {
  display: inline-grid;
  place-items: center;
  min-width: 27px;
  height: 25px;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 0 5px;
}

.tool:hover {
  background: var(--surface);
  color: var(--text);
}

.tool.active {
  background: var(--accent);
  color: #fff;
}

.tool-bold {
  font-weight: 800;
}

.tool-italic {
  font-style: italic;
  font-family: Georgia, serif;
}

.tool-underline {
  text-decoration: underline;
}

.tool-strike {
  text-decoration: line-through;
}

.tool svg {
  display: block;
}

/* --- mode --- */

.mode-select,
.mode-badge {
  font-size: 12.5px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}

.mode-badge {
  cursor: default;
}

/* A mode that restricts what people can do should look like it does. */
.mode-frozen {
  border-color: color-mix(in srgb, var(--text-faint) 60%, transparent);
  background: var(--surface-2);
}

.mode-announcement {
  border-color: color-mix(in srgb, #d08a30 55%, transparent);
}

/* --- composer --- */

/* The controls sit inside the composer's box, under the line being typed —
   close enough that reaching for bold does not mean leaving the message. */
.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 9px 8px 12px;
  box-shadow: var(--shadow-1);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong));
  box-shadow: var(--shadow-1), 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.composer-input {
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: 40vh;
  overflow-y: auto;
  min-height: 1.55em;
  padding-top: 2px;
  caret-color: var(--accent);
}

.composer-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.composer-send {
  flex-shrink: 0;
  margin-left: auto;
}

/* The toolbar's resting place beside whatever the mode offers as an input. */
.foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compose-note {
  margin: 0;
  padding: 10px 2px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  flex: 1;
}

/* The composer sits below the scroller rather than inside it, so it is always
   in reach. It has no chrome of its own — the box it holds provides that — and
   collapses entirely when a mode offers nothing to put here. */
.thread-foot {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 24px 16px;
  flex-shrink: 0;
}

.thread-foot:empty {
  display: none;
}

/* A message nobody may edit should not look like an input. */
.editor.read-only {
  caret-color: transparent;
}

.editor.read-only:empty::before {
  content: '';
}

/* --- thread --- */

.thread-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
  position: relative;
}

.thread {
  max-width: 780px;
  margin: 0 auto;
}

.blip {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 8px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-1);
  transition: border-color 140ms ease;
}

.blip::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: var(--author-color, transparent);
  opacity: 0.65;
}

/* Which message has the caret.
 *
 * This used to move the border from #e2e5ea to #d0d5dd — about two per cent of
 * luminance, which is to say invisible. The editor sets `outline: none`, so in
 * a threaded wave full of identical cards there was nothing at all telling a
 * keyboard user where their next keystroke was going to land. */
/* `:focus-within` matches every ancestor, and replies nest inside the message
   they answer — so the innermost card and every card containing it all lit up
   at once. Only the one actually holding the caret should. */
.blip:focus-within:not(:has(.blip:focus-within)) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

.blip.unread {
  border-color: color-mix(in srgb, var(--unread) 45%, var(--border));
}

.blip.not-yet {
  opacity: 0.3;
}

.blip-children {
  margin-left: 26px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.blip-children:empty {
  display: none;
}

.blip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  user-select: none;
}

.avatar.clickable {
  cursor: pointer;
}

.avatar.clickable:hover {
  filter: brightness(1.12);
}

.blip-author {
  font-weight: 600;
  font-size: 13px;
}

.blip-time {
  font-size: 11.5px;
  color: var(--text-faint);
}

.blip-contributors {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-2);
  padding: 0 5px;
  border-radius: 8px;
}

.blip-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.blip:hover .blip-actions,
.blip:focus-within .blip-actions {
  opacity: 1;
}

.blip-action {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
}

.blip-action:hover {
  background: var(--surface-2);
  color: var(--accent);
}

/* --- editor --- */

.editor {
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  padding: 1px 0 3px;
  min-height: 1.55em;
  caret-color: var(--accent);
}

.editor:empty::before {
  content: 'Write something…';
  color: var(--text-faint);
  pointer-events: none;
}

.editor a {
  color: var(--accent);
}

.editor code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}

/* --- attachments --- */

/* An embed is one indivisible character of the document, so it is `inline-block`
   rather than a block: the caret sits before it or after it, never inside. */
.embed {
  display: inline-block;
  vertical-align: bottom;
  max-width: 100%;
  color: var(--text-faint);
  user-select: none;
}

/* A picture takes its own line. Still one character of the document — the
   caret goes before it or after it — but laying it out in the middle of a
   sentence makes for a line the height of a photograph. */
.embed-image {
  display: block;
  margin: 6px 0;
}

.embed-image a {
  display: block;
  line-height: 0;
}

.embed-image img {
  max-width: min(420px, 100%);
  max-height: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  object-fit: contain;
}

.embed-file a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin: 2px 0;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.embed-file a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.embed-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.embed-size {
  color: var(--text-faint);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* A file may be dropped anywhere in a message, and it should be obvious which
   one is about to receive it. */
.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.file-picker {
  display: none;
}

/* Uploading takes long enough to need saying so. */
.toolbar.busy .tool-attach {
  color: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.toolbar.busy .tool-attach,
.toolbar.busy .file-picker {
  pointer-events: none;
}

/* --- chat --- */

/* Chat is the one mode that is not a document, and it should not look like
   one. The stack of cards becomes a channel: full-bleed rows on the page
   itself, an avatar gutter, days marked off, and a run of messages from one
   author collapsed under a single header. Everything here is scoped to
   `.chat`, so the other modes keep the card layout unchanged. */

.wave-pane.chat .thread-scroll {
  display: flex;
  flex-direction: column;
  /* Rows carry their own horizontal padding so the hover highlight can run the
     full width of the pane, the way a channel's does. */
  padding: 0;
}

/* A near-empty channel reads from the bottom, like the full one it will
   become. `margin-top: auto` rather than `justify-content`, which puts
   overflowing content out of the scroller's reach. */
.wave-pane.chat .thread {
  max-width: none;
  margin: auto 0 0;
  padding: 12px 0 8px;
  width: 100%;
}

.wave-pane.chat .thread-foot {
  max-width: none;
  padding: 4px 20px 16px;
}

.blip.chat {
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 10px;
  align-items: start;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 5px 20px 4px;
  transition: background 120ms ease;
}

/* The author stripe belongs to a card; here the avatar carries the colour. */
.blip.chat::before {
  display: none;
}

.blip.chat.grouped {
  padding-top: 1px;
  padding-bottom: 1px;
}

.blip.chat:hover,
.blip.chat:focus-within {
  background: var(--surface-2);
}

.blip.chat.unread {
  background: color-mix(in srgb, var(--unread) 7%, transparent);
  box-shadow: inset 2px 0 0 0 var(--unread);
}

.blip.chat > .blip-gutter {
  grid-column: 1;
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.blip.chat > .blip-main {
  grid-column: 2;
  min-width: 0;
}

.blip.chat > .blip-children {
  grid-column: 2;
  margin-left: 0;
}

.blip.chat .blip-head {
  align-items: baseline;
  gap: 7px;
  margin-bottom: 0;
}

.blip.chat .blip-author {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.blip.chat .blip-time {
  font-variant-numeric: tabular-nums;
}

.blip-edited {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}

/* The timestamp that stands in for the avatar on a grouped row. It keeps its
   space at all times so that revealing it on hover shifts nothing. */
.blip.chat.grouped .blip-gutter {
  padding-top: 0;
}

.blip.chat.grouped .blip-time {
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-faint);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 120ms ease;
}

.blip.chat.grouped:hover .blip-time,
.blip.chat.grouped:focus-within .blip-time {
  opacity: 1;
}

/* A message is never empty here — it is sent, not created and then filled in —
   so the editor's prompt would only ever be noise. */
.blip.chat .editor:empty::before {
  content: '';
}

/* Actions float over the row's top-right corner instead of taking a place in
   the header, which a grouped row does not have. They must not swallow clicks
   meant for the message above while invisible. */
.blip.chat > .blip-actions {
  position: absolute;
  top: -10px;
  right: 16px;
  margin-left: 0;
  padding: 2px;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  pointer-events: none;
  z-index: 2;
}

.blip.chat:hover > .blip-actions,
.blip.chat:focus-within > .blip-actions {
  pointer-events: auto;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 8px;
}

.day-sep::before,
.day-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.day-label {
  padding: 2px 11px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.channel-hash {
  color: var(--text-faint);
  font-weight: 500;
  margin-right: 2px;
}

/* --- private replies --- */

.private-thread {
  margin: 6px 0 10px;
  padding: 8px 10px 2px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.private-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

/* --- remote carets --- */

.cursor-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.remote-caret {
  position: absolute;
  width: 2px;
  border-radius: 1px;
}

.remote-caret-label {
  position: absolute;
  top: -16px;
  left: -1px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px 4px 4px 0;
  white-space: nowrap;
  opacity: 0.92;
}

/* --- playback --- */

.playback-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.playback-slider {
  flex: 1;
  accent-color: var(--accent);
}

.playback-label {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 190px;
  text-align: right;
}

/* --- dialogs --- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgb(16 24 40 / 38%);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.dialog {
  background: var(--surface);
  border-radius: 12px;
  padding: 22px;
  width: min(400px, 100%);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--border);
}

.dialog h2 {
  margin: 0 0 6px;
  font-size: 16.5px;
}

.dialog-note {
  margin: 0 0 13px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 15px;
}

/* --- toasts --- */

/* Above the conversation rather than below it: the bottom of the pane is where
   the composer lives, and a toast that lands on the box you are typing into
   hides the thing it is telling you about. */
#toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #22262e;
  color: #fff;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: var(--shadow-2);
  animation: rise 180ms ease;
  max-width: min(560px, calc(100vw - 32px));
}

.toast-error {
  background: var(--danger);
  /* The container is click-through so toasts never block the page. An error
     stays until dismissed, so it has to take the click that dismisses it. */
  pointer-events: auto;
}

.toast-close {
  flex: none;
  background: none;
  border: 0;
  color: inherit;
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 0.75;
}

.toast-close:hover {
  opacity: 1;
}

.toast-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  opacity: 1;
}

/* Says the connection is gone somewhere that cannot be missed, and — unlike the
   sidebar it replaces — somewhere that still exists on a phone. */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  padding: 7px 14px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 550;
  color: #fff;
  background: var(--warn);
  box-shadow: var(--shadow-2);
}

.offline-banner[hidden] {
  display: none;
}

.toast.leaving {
  opacity: 0;
  transition: opacity 240ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* --- comments ---
   A comment is about a phrase, so it is drawn beside the phrase rather than
   under the page. The highlight lives in the text and the card lives in the
   margin; JS keeps the two level, because only the browser knows where a line
   wrapped. */

.commented {
  background: color-mix(in srgb, #e5a83c 26%, transparent);
  border-bottom: 1px solid color-mix(in srgb, #e5a83c 70%, transparent);
  cursor: pointer;
  border-radius: 2px;
}

.commented:hover,
.commented.active {
  background: color-mix(in srgb, #e5a83c 46%, transparent);
}

/* A settled thread keeps its anchor — reopening restores it — but stops
   colouring the page, which is the point of settling it. */
.commented.resolved {
  background: none;
  border-bottom: 1px solid var(--border-strong);
}

/* A mark naming a thread this client does not have. It exists for the moment
   between marking the text and the thread being confirmed; showing a highlight
   that opens onto nothing would be worse than showing none. */
.commented.orphan {
  background: none;
  border-bottom: none;
  cursor: auto;
}

.comment-rail {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 260px;
  z-index: 4;
}

.comment-toggle {
  position: absolute;
  top: -4px;
  right: 2px;
  font-size: 12px;
}

.comment-card {
  position: absolute;
  top: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
  transition: top 160ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

/* Playback: nothing to sit beside, so the cards simply follow one another. */
.comment-rail.stacked .comment-card {
  position: static;
  margin-bottom: 8px;
}

.comment-card.active {
  border-color: color-mix(in srgb, #e5a83c 65%, var(--border));
  box-shadow: var(--shadow-2);
  cursor: auto;
}

.comment-card.resolved {
  opacity: 0.72;
}

.comment-card.detached {
  border-style: dashed;
}

.comment-card.detached .comment-detached {
  display: block;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.comment-author {
  font-weight: 600;
  font-size: 12px;
}

.comment-time {
  font-size: 11px;
  color: var(--text-faint);
}

.comment-detached {
  display: none;
  margin: 0 0 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-style: italic;
}

.comment-remark + .comment-remark {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
}

.comment-remark-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}

.comment-text {
  font-size: 13px;
  line-height: 1.45;
  min-height: 1.3em;
}

.comment-text:empty::before {
  content: 'Say something…';
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11.5px;
}

.comment-settled {
  color: var(--text-faint);
}

.comment-compose {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
}

.comment-compose-input {
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-height: 1.5em;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  caret-color: var(--accent);
}

.comment-compose-input:empty::before {
  content: 'Reply…';
  color: var(--text-faint);
  pointer-events: none;
}

.comment-send {
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 12px;
}

/* Room for the margin, opened only when there is something to put in it. The
   page stays centred in what is left. */
.wave-pane.has-comments .thread-scroll {
  padding-right: 300px;
}

/* --- narrow screens --- */

/* Too narrow for a margin: the cards become a list under the page. The layout
   pass reads `position` back and leaves the tops alone when it is static. */
@media (max-width: 1100px) {
  .wave-pane.has-comments .thread-scroll {
    padding-right: 24px;
  }

  .comment-rail {
    position: static;
    width: auto;
    max-width: 780px;
    margin: 20px auto 0;
    height: auto !important;
  }

  .comment-card {
    position: static;
    margin-bottom: 8px;
  }

  .comment-toggle {
    position: static;
    display: block;
    margin-bottom: 6px;
  }
}


@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .layout.show-inbox .sidebar {
    display: flex;
  }

  .layout.show-inbox .wave-pane {
    display: none;
  }

  .back-to-inbox {
    display: inline-flex;
  }

  /* The mode picker and the wave's buttons do not always fit on one line at
     this width; let them stack rather than run off the edge. */
  .wave-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .thread-scroll {
    padding: 14px 12px 32px;
  }

  .thread-foot {
    padding: 8px 12px 12px;
  }

  .blip-children {
    margin-left: 10px;
    padding-left: 8px;
  }

  .blip.chat,
  .day-sep {
    padding-left: 12px;
    padding-right: 12px;
  }

  .wave-pane.chat .thread-foot {
    padding: 4px 12px 12px;
  }

  .blip.chat > .blip-actions {
    right: 8px;
  }
}
