/* chat.css -- layout, rows, sheets/drawers, and the hand-written Prism
   theme for /chat. Loaded after /app.css (shared tokens: --bg, --panel,
   --ink, --amber, --mono, .btn, .chip, .seal, .word). Chat's CSP has no
   `style-src 'unsafe-inline'`, so nothing here is ever set via
   `setAttribute("style", …)` from JS -- only class toggles and
   `el.style.setProperty()` for the few custom properties below
   (chat-ui.md S3.2/S6.3). */

* { box-sizing: border-box; }
html, body { height: 100%; }

body.chat {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- product nav (chat-ui.md S2.3; mirrors index.html's header) --------- */
.prodnav { display: flex; gap: 4px; font-size: 12px; }
.prodnav a {
  color: var(--dim);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.prodnav a.on { color: var(--amber); border-color: var(--line); }
.prodnav a:hover { color: var(--ink); }

/* ---------- shell grid (chat-ui.md S4.1) ---------- */
.chat-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  /* First rows are banners (main.js's two-genesis banner, M5's history-
     conflict banner, M5's storage-quota warn bar): "auto" so each costs
     nothing when hidden (a `hidden` element has no box, so an empty auto
     track collapses to 0) and grows to fit its copy when shown. */
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  /* "swarn side", not "swarn swarn": a named grid area must be a single
     rectangle (CSS Grid's own rule), and `side` already has to span every
     row from `head` through `comp` for the members aside to render as one
     unbroken column -- "swarn swarn" would split `side` into two
     disconnected pieces (rows 3 and 5, with row 4 not naming it at all),
     which browsers silently reject as invalid and drop the WHOLE
     grid-template-areas declaration, not just this row. Caught by a live
     browser run: chrome's computed style showed grid-template-areas as
     "none" and every named-area child fell back to implicit auto-
     placement, which is what produced the overlapping header this
     deliverable's own screenshot caught. `swarn` keeping to the LEFT
     column only (leaving `side` to continue on the right) is honest too --
     the storage warning is about THIS room's messages, not the member
     list beside them. */
  grid-template-areas:
    "banner banner"
    "hconflict hconflict"
    "head side"
    "swarn side"
    "list side"
    "comp side";
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  --kb: 0px;
}

.chat-side-collapsed .chat-shell { grid-template-columns: minmax(0, 1fr) 0px; }
.chat-side-collapsed .chat-side { display: none; }

/* ---------- header ---------- */
.chat-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  /* Landscape on a notched phone: keep the header clear of the side cutout.
     env() is 0 on desktop, so this is a no-op there. */
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 52px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.chat-head .brand { font-weight: 800; font-size: 18px; color: var(--amber); flex-shrink: 0; }
.chat-head .brand .cursor { animation: chat-blink 1.2s steps(1) infinite; }
@keyframes chat-blink { 50% { opacity: 0; } }

.chat-room-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chat-head .spacer { flex: 1; min-width: 8px; }

.chat-drawer-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
}

/* ---------- message list ---------- */
.chat-list {
  grid-area: list;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none; /* manual scroll anchoring is a later wave's job */
  padding: 12px 16px 8px;
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  touch-action: pan-y;
}

.msg-window {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 78ch; /* the text column cap (chat-ui.md S4.1); code/images may run wider */
}

/* ---------- day dividers / unread marker ---------- */
.day-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 14px 0 8px;
}
.day-divider::before,
.day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.unread-marker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  height: 1px;
  background: var(--amber);
  position: relative;
}
/* An author `display:` beats the UA stylesheet's `[hidden]{display:none}`
   -- the M8 `.dm-compose-banner` lesson, and this rule is load-bearing,
   not hygiene: roomview.js#noteAttention drops the divider by setting
   `hidden` rather than rebuilding the list, so without this line the
   divider would stay on screen after the messages under it were read. */
.unread-marker[hidden] { display: none; }
.unread-marker span {
  margin-left: auto;
  background: var(--amber);
  color: #14100a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  transform: translateY(-50%);
}

/* ---------- message rows (chat-ui.md S5.1) ---------- */
.msg-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  padding: 3px 0;
  animation: row-in 160ms ease-out both;
  position: relative; /* M4: anchors .row-actions */
}
@media (prefers-reduced-motion: reduce) { .msg-row { animation: none; } }
@keyframes row-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

.msg-gutter { position: relative; min-height: 1em; }
.msg-gutter-time {
  display: none;
  position: absolute;
  left: -2px;
  top: 2px;
  font-size: 9.5px;
  color: var(--dim);
  white-space: nowrap;
}
.msg-row.grouped:hover .msg-gutter-time,
.msg-row.grouped:focus-within .msg-gutter-time { display: block; }

.msg-main { min-width: 0; }

.msg-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 2px; }
.fp-emoji { font-size: 14px; cursor: help; }
.msg-name { font-weight: 600; font-size: 12.5px; color: var(--ink); }
.msg-name.mine { color: var(--amber); }
.msg-time { font-size: 10.5px; color: var(--dim); }
.msg-time.skewed { color: var(--amber); }

.msg-row.mine .msg-body { color: var(--ink); }

.msg-body { font-size: 13.5px; overflow-wrap: anywhere; }
.msg-body p { margin: 2px 0; }
.msg-body ul, .msg-body ol { margin: 4px 0; padding-left: 22px; }
.msg-body li { margin: 1px 0; }
.msg-body blockquote {
  margin: 6px 0;
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--teal);
  color: var(--dim);
}
.msg-body code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.92em;
}
.msg-body pre {
  margin: 6px 0;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  max-width: 100%;
}
.msg-body pre code {
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  font-size: 12.5px;
  line-height: 1.6;
}
.msg-body .mention { color: var(--teal); background: rgba(77, 208, 225, 0.12); border-radius: 3px; padding: 0 3px; }
.msg-body a { color: var(--teal); }
.msg-note { margin-top: 4px; font-size: 10.5px; color: var(--dim); font-style: italic; }

/* code-block collapse (chat-ui.md S5.3) */
.msg-body pre.code-clamped.clamp-active {
  max-height: calc(12 * 1.6em + 20px);
  overflow: hidden;
  position: relative;
}
.msg-body pre.code-clamped.clamp-active::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 28px;
  background: linear-gradient(180deg, transparent, #05070b);
}
.code-more, .msg-more {
  display: block;
  margin: 4px 0 8px;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.code-more:hover, .msg-more:hover { color: var(--ink); border-color: var(--teal); }

/* long-message collapse */
.msg-body-clamp.clamp-active {
  max-height: calc(12 * 1.55em);
  overflow: hidden;
  position: relative;
}
.msg-body-clamp.clamp-active::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 32px;
  background: linear-gradient(180deg, transparent, var(--bg));
}

/* link warning/blocked chips (chat-ui.md S5.5) */
.md-link-chip {
  font-size: 10.5px;
  color: var(--dim);
  white-space: nowrap;
}
.md-link-warn { color: var(--amber); }
.md-link-blocked { color: var(--dim); }
.md-link-blocked .md-link-chip { color: var(--amber); }

/* search highlight (text.js#mark(), chat-ui.md S8.3) */
mark { background: var(--amber-soft); color: var(--ink); border-radius: 2px; padding: 0 1px; }

/* ---------- Prism theme, hand-written against the yink palette
   (chat-ui.md S5.4) -- not a vendored Prism theme. ---------- */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata { color: var(--dim); font-style: italic; }

.token.string,
.token.char,
.token.attr-value,
.token.template-string { color: var(--teal); }

.token.number,
.token.boolean,
.token.constant { color: var(--green); }

.token.keyword,
.token.selector,
.token.important,
.token.atrule { color: var(--amber); }

.token.function,
.token.class-name,
.token.tag { color: #e8b4ff; }

.token.operator,
.token.punctuation,
.token.entity { color: var(--dim); }

.token.property,
.token.attr-name,
.token.variable { color: #9fd0ff; }

.token.deleted { color: var(--red); }
.token.inserted { color: var(--green); }
.token.regex { color: var(--teal); }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* ---------- system lines (IRC-style, chat-ui.md S5.7) ---------- */
.sys-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--dim);
}
.sys-dot { color: var(--amber); }
.sys-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sys-time { font-size: 10px; color: var(--dim); margin-left: auto; }
.sys-line.tombstone { font-style: italic; }

/* ---------- M3: coalesced runs (row.js, chat-ui.md S5.7 / S8.4) ----------
   Two mechanisms, two classes, same visual language as .sys-line above:
   banned-collapse (S8.4, everyone can disclose) and sys-collapse (S5.7,
   tidiness in a busy room). `.banned-run-detail`/`.sys-run-detail` hold the
   expanded individual rows -- indented slightly so the summary line above
   them still reads as what it is, a header for what follows. */
.sys-disclosure {
  background: none;
  border: none;
  padding: 0 2px;
  font: inherit;
  font-size: 11px;
  color: var(--amber);
  cursor: pointer;
  text-decoration: underline dotted;
}
.sys-disclosure:hover { color: var(--ink); }
.banned-collapse .sys-text, .sys-collapse .sys-text { color: var(--dim); }
.banned-run-detail, .sys-run-detail { margin-left: 18px; }
.banned-run-detail[hidden], .sys-run-detail[hidden] { display: none; }

/* ---------- composer (static in this wave; composer.js wires it later) --------- */
.chat-comp {
  grid-area: comp;
  padding: 8px 16px;
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px) + var(--kb, 0px));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.composer-typing { font-size: 11px; color: var(--dim); min-height: 16px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 160px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}
.composer-row textarea:disabled { opacity: 0.55; }
.composer-row textarea:focus { outline: none; border-color: var(--amber); }
.composer-note { font-size: 10.5px; color: var(--dim); margin-top: 4px; }

/* ---------- members side panel / drawer (chat-ui.md S4.2) ---------- */
.chat-side {
  grid-area: side;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 14px;
  padding-left: calc(14px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
  min-width: 0;
}
.side-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.side-title { font-size: 11px; letter-spacing: 2px; color: var(--dim); text-transform: uppercase; }
.side-empty { color: var(--dim); font-size: 12px; line-height: 1.6; }

/* ---------- generic sheet/dialog + backdrop (toast.js#sheet(), chat-ui.md S4.5) --------- */
.chat-sheet {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, 0.7);
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  z-index: 60;
}
.chat-sheet.open { display: flex; }
.sheet-box {
  width: min(400px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 18px 20px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  animation: sheet-in 180ms ease-out both;
}
@media (prefers-reduced-motion: reduce) { .sheet-box { animation: none; } }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet-title { font-size: 11px; letter-spacing: 2px; color: var(--dim); text-transform: uppercase; flex: 1; }
.sheet-warn {
  margin: 0 0 14px;
  padding: 8px 10px;
  border: 1px solid var(--amber);
  border-radius: 6px;
  color: var(--amber);
  font-size: 11.5px;
  background: var(--amber-soft);
}
.sheet-note { color: var(--dim); font-size: 11.5px; line-height: 1.6; }
.sheet-note.dim { opacity: 0.75; margin-top: 14px; }
.sheet-section { margin: 14px 0; }
.sheet-section h3 { margin: 0 0 8px; font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }

/* link display (chat-ui.md S7.5.3: host-truncated by default) */
.sheet-link {
  font-size: 12px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
  margin: 0 0 8px;
}
.sheet-link.full { margin-top: 8px; margin-bottom: 0; }
.sheet-link[hidden] { display: none; }

/* gated QR (chat-ui.md S7.5.4: hidden until a second press, 60s auto-hide) */
.qr-reveal { margin-top: 10px; display: flex; align-items: center; gap: 14px; }
.qr-reveal[hidden] { display: none; }
.qr-side-note { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.qr-countdown { font-size: 11px; color: var(--dim); margin: 0; }

/* ---------- confirm dialog (toast.js#confirm()) ---------- */
.chat-confirm {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}
.chat-confirm-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  max-width: 440px;
}
.chat-confirm-title { font-weight: 700; margin-bottom: 8px; }
.chat-confirm-body { color: var(--dim); font-size: 12.5px; line-height: 1.7; margin-bottom: 16px; }
.chat-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- toast ---------- */
#chatToast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--panel-2);
  border: 1px solid var(--amber);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 200;
  max-width: 90vw;
}
#chatToast.show { transform: translate(-50%, 0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { #chatToast { transition: none; } }

/* ---------- responsive: mobile (< 900px), chat-ui.md S4.2 ---------- */
@media (max-width: 899px) {
  .chat-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "banner"
      "hconflict"
      "head"
      "swarn"
      "list"
      "comp";
  }
  .chat-head { min-height: 48px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .chat-drawer-toggle { display: inline-flex; }
  .chat-room-name { max-width: 45vw; }
  /* The header packs brand + prodnav + seal + badge + member-count + search +
     invite into one non-wrapping row (~849px of content). At phone width the
     old `overflow:hidden` silently clipped the tail -- search and invite fell
     off the right edge, untappable. On mobile drop the desktop chrome that is
     reachable elsewhere (the yink wordmark, the pair|chat nav, and the member
     count, which the ☰ drawer already shows) and let the rest wrap instead of
     clip, so every control stays on screen. Desktop (>=900px) is untouched. */
  .chat-head { flex-wrap: wrap; overflow: visible; }
  .chat-head .brand,
  .chat-head .prodnav,
  .chat-head #memberCount { display: none; }

  .chat-side {
    grid-area: unset;
    position: fixed;
    inset: 0 25vw 0 0;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    border-left: none;
    border-right: 1px solid var(--line);
  }
  .chat-side.open { transform: none; }
  @media (prefers-reduced-motion: reduce) { .chat-side { transition: none; } }

  .sheet-box { width: 100%; border-left: none; border-top: 1px solid var(--line); }
  .chat-sheet { align-items: flex-end; justify-content: stretch; }

  /* Dim + dismiss surface behind the drawer (shell.js toggles [hidden]).
     Sits just under .chat-side (z-index 70) so the panel stays interactive
     while a tap anywhere else closes it. */
  .chat-scrim {
    position: fixed;
    inset: 0;
    z-index: 69;
    background: rgba(11, 14, 20, 0.6);
  }
  @media (prefers-reduced-motion: no-preference) {
    .chat-scrim { animation: chat-scrim-in 0.2s ease-out; }
  }
}
@keyframes chat-scrim-in { from { opacity: 0; } to { opacity: 1; } }
/* Never a scrim on desktop: the members list is a persistent panel there, not
   an overlay, so even if [hidden] were cleared it must stay inert. */
.chat-scrim[hidden] { display: none; }
@media (min-width: 900px) { .chat-scrim { display: none; } }

/* every interactive element is >= 44x44 css px on touch (chat-ui.md S4.2) */
@media (pointer: coarse) {
  .chat-drawer-toggle, .code-more, .msg-more { min-height: 44px; min-width: 44px; }
  /* member rows are a tap target (open the member detail); reaction picker
     cells were ~28px emoji hit areas. (mobile Phase 0; .btn floor lives in
     app.css, which /chat also loads, so #btnSend/#btnAttach/search/invite are
     already covered there.) */
  .member-row { min-height: 44px; }
  .react-pick { min-height: 44px; min-width: 44px; }
}

/* ---------- join gate + chat home (main.js, chat-ui.md S2.4) ----------
   Fixed full-viewport overlay, shown until a room is actually joined; the
   chat shell underneath starts `hidden` (plain HTML attribute) and main.js
   flips the two. Panels reuse app.css's `.panel`/`.words`/`.word`/`.hint`/
   `input[type=text]` rather than inventing a second visual language. */
.chat-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}
.chat-gate[hidden] { display: none; }
.gate-panel { max-width: 440px; width: 100%; }
.gate-copy { color: var(--dim); font-size: 12.5px; line-height: 1.7; margin: 0 0 16px; }
.gate-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 14px 0 6px;
}
.gate-seal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.gate-seal-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.hint.warn { color: var(--amber); }

/* Text-styled buttons (real <button>s, not inert <p>s -- keyboard/focus
   come for free) used for the restore/save-identity gate actions. */
.gate-link {
  display: block;
  margin-top: 12px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--dim);
  opacity: 0.75;
  cursor: pointer;
  text-align: left;
}
.gate-link:hover { color: var(--ink); opacity: 1; }

/* ---------- "your rooms" (roomlist.js, chat-ui.md S2.5) ---------- */
.gate-roomlist { margin-top: 18px; }
.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.room-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
span.room-row-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
button.room-row-name {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  color: var(--amber);
  text-decoration: underline dotted;
}
.room-row-meta { font-size: 10.5px; color: var(--dim); }
.room-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn.small.ok { border-color: var(--green); color: var(--green); }
.room-empty { color: var(--dim); font-size: 12px; margin-top: 14px; }

/* ---------- connection badge, honest states beyond the static "relayed" default ---------- */
.badge.off { color: var(--dim); border-color: var(--line); }
.badge.err { color: var(--red); border-color: var(--red); }
/* M2's two new rungs. Green is "this one never touches yink.io"; amber is
   "it still leaves this machine over someone else's link". Neither is a
   security claim -- every rung carries the same sealed envelope. */
.badge.direct { color: var(--green); border-color: var(--green); }
.badge.assist { color: var(--amber); border-color: var(--amber); }

/* ---------- member list (members.js) ---------- */
.member-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.member-row:hover { border-color: var(--line); background: var(--panel-2); }

/* ---------- presence dots (chat-ui.md S5.9): shape AND hue together,
   never colour alone (S4.5) -- p2p/me is a FILLED dot, the two relay
   states are HOLLOW rings that differ by border style (solid vs dashed),
   offline is a dim hollow ring. `title` on the element (set in members.js)
   carries the exact tooltip copy from S5.9's table. ---------- */
.member-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  cursor: help;
  background: transparent;
  border: 2px solid var(--dim);
}
.member-dot.p2p, .member-dot.me { background: var(--green); border-color: var(--green); }
.member-dot.relay-peer { background: transparent; border-color: var(--amber); }
/* relay-do: same hue as relay-peer, DASHED border -- the shape difference
   that keeps "reached through a person" and "reached through yink.io"
   apart without relying on the tooltip alone. */
.member-dot.relay-do { background: transparent; border-style: dashed; border-color: var(--amber); }
.member-dot.offline { background: transparent; border-color: var(--line); }

.member-name { font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-name.me { color: var(--amber); }
.member-presence { font-size: 10px; color: var(--dim); }
.member-detail {
  margin: 2px 4px 8px 29px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.7;
}
.member-detail .fp-long { color: var(--ink); font-size: 13px; letter-spacing: 1px; }
.member-detail .fork-note { color: var(--amber); }
.member-empty { color: var(--dim); font-size: 12px; line-height: 1.6; margin-top: 8px; }

/* ---------- M3: membership status + provenance (members.js, chat-ui.md
   S7.3) -- status other than "active" replaces the connectivity dot with a
   status-only glyph (chat-ui.md S4.5: shape AND colour together, never
   colour alone), since "are they online" stops being the relevant question
   once someone has left/been revoked/been banned. ---------- */
.member-dot.left { background: transparent; border-color: var(--line); }
.member-dot.revoked { background: transparent; border-style: dotted; border-color: var(--amber); }
.member-dot.banned { background: var(--red); border-color: var(--red); }
.member-row.status-left, .member-row.status-revoked, .member-row.status-banned { opacity: 0.6; }
.member-status-tag { font-size: 10px; color: var(--dim); }
.member-status-tag.banned { color: var(--red); }
.member-chain { color: var(--ink); line-height: 1.7; }
.member-chain .chain-arrow { color: var(--dim); padding: 0 3px; }
.member-detail .btn.small { margin-right: 6px; margin-top: 4px; }
.member-detail .btn.small.danger { border-color: var(--red); color: var(--red); }

/* ---------- jump-to-bottom FAB (roomview.js, chat-ui.md S8.2.6) ---------- */
.chat-list { position: relative; }
.jump-bottom {
  position: absolute;
  right: 16px;
  bottom: 12px;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.jump-bottom[hidden] { display: none; }

/* ---------- two-genesis banner (main.js, chat-protocol.md S9.6 / M3
   contract S7.5) -- persistent and non-dismissable, so no `.open`/close
   toggle: `hidden` (the HTML attribute) is the only state it has. ---------- */
.foreign-banner {
  grid-area: banner;
  padding: 10px 16px;
  background: var(--amber-soft);
  border-bottom: 2px solid var(--amber);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.6;
}
.foreign-banner[hidden] { display: none; }
.foreign-banner-title { font-weight: 700; color: var(--amber); margin-bottom: 4px; }
.foreign-banner-body { margin: 0 0 8px; max-width: 78ch; color: var(--ink); }
.foreign-banner-row { display: flex; align-items: center; gap: 10px; margin: 3px 0; }
.foreign-banner-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  min-width: 150px;
}
.foreign-banner-fp { font-size: 12.5px; letter-spacing: 0.5px; }
.foreign-banner-list { display: flex; flex-direction: column; gap: 3px; margin: 2px 0 0 160px; }
.foreign-banner-item { font-size: 12px; }

/* ---------- history-disputed banner (roomview.js, m5-contracts.md S5.1,
   chat-storage.md S8.3 step 7) -- same persistent/non-dismissable posture
   as .foreign-banner just above, deliberately styled in the SAME amber
   language: both are "don't trust this without comparing out of band"
   states, not routine errors. ---------- */
.history-conflict-banner {
  grid-area: hconflict;
  padding: 10px 16px;
  background: var(--amber-soft);
  border-bottom: 2px solid var(--amber);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.6;
}
.history-conflict-banner[hidden] { display: none; }
.history-conflict-title { font-weight: 700; color: var(--amber); margin-bottom: 4px; }
.history-conflict-body { margin: 0 0 8px; max-width: 78ch; color: var(--ink); }

/* ---------- the audio-join codec frame (tone.js, m2-contracts.md S8a) ----
   It has nothing to show -- it is a codec, not a UI -- but it must still be
   in the layout: `display: none` is not a documented guarantee that a frame
   loads and runs, and this one has to. Zero-sized, transparent, inert. */
.tone-frame {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---------- M3: form controls (mint form, policy form) -- app.css defines
   no select/checkbox styling at all (it has none to reuse), and these two
   controls appear nowhere outside /chat, so they're scoped here rather than
   widening app.css's shared surface for the pair page too. ---------- */
select {
  display: block;
  width: 100%;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12.5px;
  margin-bottom: 4px;
}
select:focus { border-color: var(--amber); outline: none; }
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
  margin: 10px 0;
  cursor: pointer;
}
.check-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--amber); }

/* ---------- M3: invites (invites.js, chat-ui.md S7.5 sections 7-8) ---------- */
.invite-form-row { display: flex; gap: 10px; }
.invite-form-field { flex: 1; min-width: 0; }
.invite-reveal { margin-top: 12px; }
.invite-reveal[hidden] { display: none; }
.invite-list-title { margin-top: 16px !important; }
.invite-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 11.5px;
}
.invite-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.invite-row-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.invite-row-meta { font-size: 10.5px; color: var(--dim); }
.invite-row-status { font-size: 10.5px; }
.invite-row-status.revoked { color: var(--red); }
.invite-row-status.expired { color: var(--dim); }
.invite-row-status.outstanding { color: var(--green); }
.invite-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.invite-empty { color: var(--dim); font-size: 12px; margin-top: 6px; }
.sheet-note.dim { color: var(--dim); }
#btnToggleOpenDoor.on { border-color: var(--amber); color: var(--amber); }

/* ---------- M3: policy (invites.js, chat-ui.md S7.2) ---------- */
.policy-block[hidden] { display: none; }
.policy-form { margin-top: 10px; }
.policy-form[hidden] { display: none; }
.operator-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.operator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11.5px;
}
.operator-row.creator { opacity: 0.75; }
.operator-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- M3: revocation-preview / ban confirm bodies (toast.js#confirm(),
   built by invites.js/members.js) ---------- */
.confirm-blast-radius { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.confirm-blast-radius .count { color: var(--amber); font-weight: 700; }

/* ======================================================================
   M4: files & media (m4-contracts.md S5) -- attachments, the lightbox,
   edits, reactions, the row-action toolbar, and the composer's attach/
   edit surfaces. ====================================================== */

/* ---------- row actions: react / edit / delete (row.js, chat-ui.md S4.2) --
   Default: a small floating toolbar at the row's top-right, hidden until
   hover/focus (matching S4.2's own hover-toolbar sketch). On a device
   that can't hover (`(hover: none)`, i.e. touch) it is unconditionally
   visible instead, laid out as a static row below the message -- "no
   hover-only affordance exists anywhere" (S4.2) kept a cheaper way than
   the long-press bottom sheet the fuller spec sketches; see row.js's own
   comment for the scope reduction this is. ---------- */
.row-actions {
  position: absolute;
  top: -6px;
  right: 4px;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms;
  z-index: 2;
}
.msg-row:hover .row-actions,
.msg-row:focus-within .row-actions { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .row-actions { transition: none; } }

.row-action {
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}
.row-action:hover { background: var(--panel); }
.row-action-danger:hover { color: var(--red); }

@media (hover: none) {
  .row-actions {
    position: static;
    grid-column: 1 / -1;
    opacity: 1;
    pointer-events: auto;
    align-self: flex-start;
    margin: 4px 0 0 22px; /* roughly under the gutter, above the body */
    background: none;
    border: none;
    padding: 0;
  }
  .row-action { min-height: 32px; min-width: 32px; }
}

/* ---------- edits (row.js, chat-ui.md S5.9) ---------- */
.msg-body-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.edit-chip {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 10.5px;
  color: var(--dim);
  cursor: pointer;
  text-decoration: underline dotted;
  flex-shrink: 0;
}
.edit-chip:hover { color: var(--ink); }
.edit-popover-head { font-weight: 700; margin-bottom: 10px; }
.edit-popover-version { padding: 8px 0; border-top: 1px solid var(--line); }
.edit-popover-version:first-of-type { border-top: none; }
.edit-popover-time { display: block; font-size: 10.5px; color: var(--dim); margin-bottom: 3px; }
.edit-popover-body { font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }

/* ---------- reactions: pills + picker (row.js, chat-ui.md S5.9) ---------- */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.react-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--ink);
  cursor: pointer;
}
.react-pill:hover { border-color: var(--teal); }
.react-pill.mine { border-color: var(--amber); color: var(--amber); }

.react-picker {
  position: fixed;
  left: var(--x, 0);
  top: var(--y, 0);
  z-index: 65;
  width: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
.react-picker[hidden] { display: none; }
.react-picker input {
  width: 100%;
  margin-bottom: 8px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
}
.react-picker input:focus { outline: none; border-color: var(--amber); }
.react-picker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.react-pick {
  background: none;
  border: none;
  border-radius: 5px;
  font-size: 18px;
  line-height: 1;
  padding: 5px 0;
  cursor: pointer;
}
.react-pick:hover { background: var(--panel-2); }
.react-pick.mine { background: var(--amber-soft); }

/* ---------- attachments: shared row chrome (row.js, chat-ui.md S8.1) ---------- */
.msg-attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 420px; }

.att-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.att-row.att-error { border-color: var(--red); }
.att-row.att-offline { opacity: 0.65; }
.att-icon { font-size: 18px; line-height: 1.3; }
.att-main { min-width: 0; flex: 1; }
.att-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* chat-ui.md S6.5's double-extension chip. Deliberately NOT inside
   .att-name: that rule ellipsises, and a warning a long filename can
   truncate away is worse than none. Own line, amber, never shrinks. */
.att-warn { font-size: 11px; color: var(--amber); margin-top: 2px; font-weight: 600; }
.att-state { font-size: 11px; color: var(--dim); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.att-row.att-error .att-state { color: var(--red); }
.att-verified { color: var(--green); }
.att-media { display: block; margin-top: 6px; max-width: 100%; border-radius: 6px; }

.att-missing { opacity: 0.7; }
.att-missing .att-state { font-style: italic; }

/* m5-contracts.md S5.5: a retracted offer, distinct from a missing one --
   same dimmed treatment as .att-missing (neither is actionable) but its
   own class so the two are never accidentally targeted by one selector
   if their rendering needs to diverge later. */
.att-retracted { opacity: 0.7; }
.att-retracted .att-state { font-style: italic; }

.att-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  margin-top: 4px;
  width: 100%;
}
.att-progress[hidden] { display: none; }
.att-progress-fill { height: 100%; width: 0; background: var(--teal); transition: width 150ms; }
@media (prefers-reduced-motion: reduce) { .att-progress-fill { transition: none; } }

/* ---------- inline images (row.js, chat-ui.md S5.3/S8.1) --------------
   `--ar` is set via CSSOM (el.style.setProperty), never a style
   attribute (chat-ui.md S3.2/S6.3) -- space is reserved from the offer's
   intrinsic `dm` BEFORE the full image ever lands, so the list doesn't
   shift. `touch-action: pinch-zoom` lives on the LIGHTBOX's stage, not
   here -- an inline thumbnail is not the pinch-zoom surface, the opened
   lightbox is (m4-contracts.md S5.4). ---------- */
.att-image-frame {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: var(--ar, 4 / 3);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.att-image-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(10px) saturate(1.1);
  transform: scale(1.08); /* hides the blur's soft edge */
}
.att-image-full {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05070b;
  cursor: zoom-in;
}
.att-image-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 20, 0.45);
  color: #fff;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}
.att-image-overlay[hidden] { display: none; }
.att-image-overlay.att-offline { background: rgba(11, 14, 20, 0.6); }
.att-image-overlay.att-error { background: rgba(90, 20, 20, 0.55); }
.att-image-caption[hidden] { display: none; }

/* ---------- pending attachments (attach.js, chat-ui.md S8.1) ---------- */
.pending-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.pending-attachments[hidden] { display: none; }
.pending-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 6px 3px 3px;
  font-size: 11.5px;
  max-width: 220px;
}
.pending-chip-thumb { width: 22px; height: 22px; border-radius: 999px; object-fit: cover; flex-shrink: 0; }
.pending-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.pending-chip-size { color: var(--dim); flex-shrink: 0; }
.pending-chip-remove {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0 2px;
  font-size: 12px;
  flex-shrink: 0;
}
.pending-chip-remove:hover { color: var(--red); }

/* ---------- composer: attach button + edit banner (composer.js) -------- */
#btnAttach { flex-shrink: 0; font-size: 15px; padding: 0 10px; align-self: flex-end; height: 40px; }
.composer-edit-banner {
  font-size: 11px;
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 16px;
}
.composer-edit-banner[hidden] { display: none; }
.composer-edit-banner button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--dim);
  text-decoration: underline dotted;
  cursor: pointer;
}
.composer-edit-banner button:hover { color: var(--ink); }

/* ---------- lightbox (lightbox.js, chat-ui.md S8.1/S5.4) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 7, 11, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox-box {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: pinch-zoom;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  z-index: 2;
}
.lightbox-nav {
  background: rgba(11, 14, 20, 0.6);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 2;
}
.lightbox-nav[hidden] { visibility: hidden; }
.lightbox-toolbar { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; }
.lightbox-caption { overflow-wrap: anywhere; max-width: 50vw; }

@media (pointer: coarse) {
  .lightbox-close, .lightbox-nav, .row-action, .pending-chip-remove { min-height: 44px; min-width: 44px; }
}

/* ---------- storage manager (m5-contracts.md S5.4, storage-ui.js) ---------- */

/* Same destructive-action language as .member-detail .btn.small.danger
   (chat-ui.md's ban button) but not scoped to that one container -- the
   leave-and-delete action here is the second place in this document an
   irreversible, room-affecting click needs to read as one at a glance. */
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.12); }

.storage-warn-bar {
  grid-area: swarn;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--amber-soft);
  border-bottom: 1px solid var(--amber);
  color: var(--ink);
  font-size: 12.5px;
}
.storage-warn-bar[hidden] { display: none; }
.storage-warn-bar span { flex: 1; min-width: 0; }

/* ---------- scroll-back banner (roomview.js, m5-contracts.md S5.1) ------
   Sits at the top of the message pane's OWN scroller (grid-area: list is
   .chat-list itself; this is a normal in-flow child of it, not a grid
   area of its own), so it scrolls with the messages rather than pinning
   above them -- correct for "there is more above this" copy, which stops
   being true the moment the reader scrolls back down past it. */
.scrollback-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--dim);
  text-align: center;
  justify-content: center;
}
.scrollback-banner[hidden] { display: none; }
.scrollback-banner.scrollback-fail { color: var(--amber); }

.storage-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin: 6px 0 10px;
}
.storage-bar-fill { height: 100%; background: var(--teal); }
.storage-bar.over-soft .storage-bar-fill { background: var(--amber); }
.storage-bar.over-hard .storage-bar-fill { background: var(--red); }

#storageRoomList .room-row-meta { display: block; }

/* M6 (m6-contracts.md S7.3/S7.4): the "free up space" tier 3/4 blocks,
   storage-ui.js#buildEvictTierBlock. A light rule between them (not a full
   .sheet-section, which would add its own heading rhythm) is enough to
   read as two distinct actions rather than one long paragraph. */
.evict-tier { padding: 10px 0; border-top: 1px solid var(--line); }
.evict-tier:first-child { border-top: none; padding-top: 0; }

/* ---------- M5 phase B: search overlay (m5-contracts.md S15.1, chat-ui.md
   S8.3). Reuses .chat-sheet/.sheet-box's own show/hide convention
   (search.js's own comment on open()/close() explains why the native
   `hidden` attribute is never touched here) -- this just adds the parts
   specific to a search panel, not a settings sheet. ---------- */
.search-box { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.search-input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}
.search-input:focus { outline: 1px solid var(--teal); outline-offset: -1px; }
.search-results { overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.search-empty, .search-loading { color: var(--dim); font-size: 12px; padding: 8px 2px; }
.search-day {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 10px 0 2px;
}
.search-chip {
  display: inline-block;
  font-size: 11px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  margin: 0 4px 4px 0;
}
/* has:file/has:image are parsed but not enforced (search.js's own
   comment on UNENFORCED_HAS) -- dashed + dimmer than an ordinary chip, so
   it never reads as an active filter that silently does nothing. */
.search-chip-unenforced { opacity: 0.55; border-style: dashed; }
.search-hit {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  background: var(--panel-2);
}
.search-hit:hover, .search-hit:focus-visible { border-color: var(--teal); }
.search-hit-head { display: flex; align-items: baseline; gap: 8px; font-size: 11px; color: var(--dim); }
.search-hit-author { color: var(--ink); font-weight: 600; }
.search-hit-day { flex: 1; }
.search-hit-badge { font-size: 10px; }
.search-hit-badge.search-hit-local, .search-hit-badge.search-hit-ledger { color: var(--green); }
.search-hit-badge.search-hit-signature { color: var(--amber); }
.search-hit-snippet { font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.search-hit-snippet.dim { color: var(--dim); font-style: italic; }

/* ---------- M5 phase B: the dm card (m5-contracts.md S15.2, chat-ui.md
   S8.5). "Amber-bordered, not a plain message" -- the spec's own words for
   the RECIPIENT's actionable card; the sender's own waiting/status card
   and every other member's plain line reuse the same visual family at a
   lower emphasis, so the amber border reads as "this one wants something
   from you" rather than "a dm happened". ---------- */
.dm-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 4px 0;
  font-size: 12px;
}
.dm-card-incoming.dm-card-waiting { border-color: var(--amber); background: var(--amber-soft); }
.dm-card-head { display: flex; align-items: baseline; gap: 6px; }
.dm-card-head > span:first-child { color: var(--amber); }
.dm-card-body { margin: 6px 0; color: var(--ink); }
.dm-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.dm-card-note { font-size: 11px; margin-top: 4px; }
.dm-card-note.dim { color: var(--dim); }
.dm-card-time { margin-left: auto; font-size: 10px; color: var(--dim); }
.dm-card-unknown { color: var(--dim); font-style: italic; }
.dm-card-declined, .dm-card-expired { opacity: 0.65; }

/* ---------- M8: the text DM row (m8-contracts.md §4.4, R68) ------------
   Deliberately NOT a .msg-row variant, and deliberately not a separate
   pane either. R68: a DM lives inline in the transcript because §6.16
   requires the room to know one happened, and a private-looking inbox
   would show the reader a stronger promise than the protocol makes. So it
   must look different enough from a room message that nobody mistakes one
   for the other -- a left amber rule and a tinted ground -- while sitting
   in the same column, at its real ledger position, under the visibility
   note that says what the room can see. -------------------------------- */
.dm-text-row {
  border-left: 2px solid var(--amber);
  background: var(--amber-soft);
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
  margin: 4px 0;
}
.dm-text-head { display: flex; align-items: baseline; gap: 6px; font-size: 11px; }
.dm-text-lock { color: var(--amber); }
.dm-text-who { color: var(--dim); font-weight: 600; }
.dm-text-time { margin-left: auto; font-size: 10px; color: var(--dim); }
.dm-text-note { font-size: 11px; margin-top: 4px; }
.dm-text-note.dim { color: var(--dim); }
/* R70: a stated failure, never a blank row. Dimmed and italic so it reads
   as the app explaining itself rather than as someone's message. */
.dm-text-failure { color: var(--dim); font-style: italic; margin: 4px 0; font-size: 12px; }
.dm-text-unreadable, .dm-text-lost, .dm-text-malformed { background: transparent; border-left-color: var(--line); }

/* ---------- M8: the composer's private mode (m8-contracts.md §4.5) ----- */
.dm-compose-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 11px;
}
/* An author `display:` beats the UA stylesheet's `[hidden]{display:none}`,
   so a flex banner marked `hidden` in the markup ships PERMANENTLY
   VISIBLE. .composer-edit-banner above already carries this exact guard;
   omitting it here put a "private to" banner on every composer with no
   recipient behind it. Caught by opening the page, not by any suite --
   nothing in a unit test can see a CSS cascade. */
.dm-compose-banner[hidden] { display: none; }
.dm-compose-banner .dm-compose-to { color: var(--amber); font-weight: 700; }
.dm-compose-banner .dm-compose-note { color: var(--dim); }
.dm-compose-banner .dm-compose-exit {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
}
.dm-compose-banner .dm-compose-exit:hover { color: var(--ink); }
.dm-compose-count { font-size: 10px; color: var(--dim); }
.dm-compose-count.over { color: var(--amber); font-weight: 700; }

/* ---------- M5 phase B: "jump to a node" flash (chat-ui.md S8.2.7) ------ */
.jump-flash { animation: jump-flash-anim 600ms ease-out; }
@keyframes jump-flash-anim {
  from { background: var(--amber-soft); }
  to { background: transparent; }
}
@media (prefers-reduced-motion: reduce) { .jump-flash { animation: none; } }
