/* SMD Chat. Tokens and rules are described in docs/STYLEGUIDE.md; /styleguide shows them rendered. */

/* ---------- Tokens ---------- */
:root {
  --color-bg: #FFFFFF;
  --color-bg-subtle: #F6F7F9;
  --color-bg-muted: #ECEEF2;
  --color-border: #E3E5EA;
  --color-text: #16181D;
  --color-text-muted: #666B77;
  --color-text-faint: #9A9FAA;
  --color-accent: #2F54EB;
  --color-accent-hover: #2445D0;
  --color-on-accent: #FFFFFF;
  --color-accent-subtle: #EEF1FE;
  --color-accent-text: #2441C7;
  --color-mention: #FFF3D1;
  --color-mention-text: #7A5300;
  --color-success: #1F7A4D;
  --color-warning: #9A6200;
  --color-danger: #C43D2B;
  --shadow-menu: 0 8px 24px rgb(22 24 29 / 0.10), 0 1px 2px rgb(22 24 29 / 0.06);

  --avatar-0-bg: #E3E9FF; --avatar-0-fg: #2441C7;
  --avatar-1-bg: #DDF3EA; --avatar-1-fg: #17694A;
  --avatar-2-bg: #F7E1EE; --avatar-2-fg: #9A2F6C;
  --avatar-3-bg: #FBE7D6; --avatar-3-fg: #9A4B10;
  --avatar-4-bg: #EAE3FB; --avatar-4-fg: #5B3DB8;
  --avatar-5-bg: #DCEFF7; --avatar-5-fg: #1D6A8C;

  --font-sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --text-xs: 12px; --leading-xs: 16px;
  --text-sm: 13px; --leading-sm: 18px;
  --text-md: 15px; --leading-md: 22px;
  --text-lg: 17px; --leading-lg: 24px;
  --text-xl: 26px; --leading-xl: 32px;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 6px; --radius-md: 10px; --radius-full: 999px;
  --sidebar-width: 248px;
  /* Conversations and pages read in one centred column; the header lines up with it. */
  --column: 820px;
  --duration: 120ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #111317;
    --color-bg-subtle: #16191E;
    --color-bg-muted: #20242B;
    --color-border: #272B33;
    --color-text: #E8EAED;
    --color-text-muted: #9AA0AB;
    --color-text-faint: #6B717C;
    --color-accent: #7C93FF;
    --color-accent-hover: #96A8FF;
    --color-on-accent: #111317;
    --color-accent-subtle: #1C2340;
    --color-accent-text: #A9B7FF;
    --color-mention: #3A2F14;
    --color-mention-text: #F2D27A;
    --color-success: #59C48D;
    --color-warning: #E8B54D;
    --color-danger: #F07A6A;
    --shadow-menu: 0 8px 24px rgb(0 0 0 / 0.45);

    --avatar-0-bg: #222B52; --avatar-0-fg: #AEBBFF;
    --avatar-1-bg: #183A2D; --avatar-1-fg: #7BD6AB;
    --avatar-2-bg: #43203A; --avatar-2-fg: #F0A3CF;
    --avatar-3-bg: #46291A; --avatar-3-fg: #F2B27F;
    --avatar-4-bg: #2E2552; --avatar-4-fg: #C3B2FF;
    --avatar-5-bg: #183747; --avatar-5-fg: #8DCFEA;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--color-bg); color: var(--color-text); font: var(--text-md) / var(--leading-md) var(--font-sans);
  -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--color-bg-muted); border-radius: 4px; padding: 1px 4px; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--color-text-muted); }
.meta { color: var(--color-text-muted); font-size: var(--text-sm); line-height: var(--leading-sm); }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }

/* ---------- Buttons and fields ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-sm); font: 500 var(--text-md) / 1 var(--font-sans); cursor: pointer;
  transition: background var(--duration), border-color var(--duration); white-space: nowrap; }
.button.primary { background: var(--color-accent); color: var(--color-on-accent); }
.button.primary:hover { background: var(--color-accent-hover); text-decoration: none; }
.button.secondary { background: var(--color-bg-muted); color: var(--color-text); }
.button.secondary:hover { border-color: var(--color-border); text-decoration: none; }
.button.small { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.button:disabled { opacity: 0.6; cursor: default; }
.text-button { background: none; border: 0; padding: 0; color: var(--color-text-muted); font: 500 var(--text-sm) / var(--leading-sm) var(--font-sans);
  cursor: pointer; }
.text-button:hover { color: var(--color-text); text-decoration: underline; }
.text-button.danger { color: var(--color-danger); }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--color-text-muted); cursor: pointer; }
.icon-button:hover { background: var(--color-bg-muted); color: var(--color-text); }

.field { display: grid; gap: var(--space-1); }
.field label, .label { font: 500 var(--text-sm) / var(--leading-sm) var(--font-sans); }
input[type="text"], input:not([type]), textarea { width: 100%; min-width: 0; font: inherit; color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); transition: border-color var(--duration); }
input:focus, textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-subtle); }
textarea { resize: vertical; }
::placeholder { color: var(--color-text-faint); }

.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full); background: var(--color-accent); color: var(--color-on-accent);
  font: 600 var(--text-xs) / 18px var(--font-sans); text-align: center; }
.tag { font: 500 var(--text-xs) / var(--leading-xs) var(--font-sans); color: var(--color-text-muted); border: 1px solid var(--color-border);
  border-radius: var(--radius-full); padding: 1px var(--space-2); }

.avatar { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font: 600 var(--text-sm) / 1 var(--font-sans);
  background: var(--av-bg); color: var(--av-fg); }
.avatar.xs { width: 20px; height: 20px; border-radius: 5px; font-size: 11px; }
.avatar.agent { border-radius: var(--radius-full); }
.agent-glyph { width: 60%; height: 60%; }
.avatar.xs .agent-glyph { width: 75%; height: 75%; }
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: var(--text-lg); }
.av-0 { --av-bg: var(--avatar-0-bg); --av-fg: var(--avatar-0-fg); }
.av-1 { --av-bg: var(--avatar-1-bg); --av-fg: var(--avatar-1-fg); }
.av-2 { --av-bg: var(--avatar-2-bg); --av-fg: var(--avatar-2-fg); }
.av-3 { --av-bg: var(--avatar-3-bg); --av-fg: var(--avatar-3-fg); }
.av-4 { --av-bg: var(--avatar-4-bg); --av-fg: var(--avatar-4-fg); }
.av-5 { --av-bg: var(--avatar-5-bg); --av-fg: var(--avatar-5-fg); }

.notice, .problem { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-sm); line-height: var(--leading-sm); }
.notice { background: color-mix(in srgb, var(--color-success) 10%, var(--color-bg)); color: var(--color-success); }
.problem { background: color-mix(in srgb, var(--color-danger) 10%, var(--color-bg)); color: var(--color-danger); }

/* ---------- App frame ---------- */
.app { height: 100%; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--color-bg-subtle); border-right: 1px solid var(--color-border); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); height: 56px; padding: 0 var(--space-4); }
.brand { font: 600 var(--text-md) / 1 var(--font-sans); color: var(--color-text); }
.brand:hover { text-decoration: none; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--color-text-muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-text-faint); }
.status[data-state="live"] .status-dot { background: var(--color-success); }
.status[data-state="polling"] { color: var(--color-warning); }
.status[data-state="polling"] .status-dot { background: var(--color-warning); }

.nav { flex: 1; overflow-y: auto; padding: 0 var(--space-2) var(--space-4); display: grid; align-content: start; gap: var(--space-4); }
.nav-section { display: grid; gap: 1px; }
.nav-label { display: flex; justify-content: space-between; align-items: baseline; padding: 0 var(--space-2) var(--space-1);
  font: 500 var(--text-xs) / var(--leading-xs) var(--font-sans); letter-spacing: 0.04em; color: var(--color-text-muted); }
.nav-label a { color: var(--color-text-muted); letter-spacing: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav-form { margin: 0; }
.nav-item { width: 100%; height: 32px; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--color-text); font: 400 var(--text-md) / 1 var(--font-sans); text-align: left; cursor: pointer;
  transition: background var(--duration); }
.nav-item:hover { background: var(--color-bg-muted); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--color-accent-subtle); color: var(--color-accent-text); }
.nav-item.unread .nav-name { font-weight: 600; }
.nav-item[aria-current="page"] .count { display: none; }
.nav-prefix { width: 20px; text-align: center; color: var(--color-text-faint); }
.nav-item[aria-current="page"] .nav-prefix { color: inherit; }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-empty { padding: var(--space-1) var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); }
.sidebar-foot { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border); }
.sidebar-foot .me-name { flex: 1; font-weight: 500; }
.scrim { display: none; }

/* ---------- Conversation ---------- */
.chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: var(--space-3); min-height: 56px;
  padding: var(--space-2) max(var(--space-5), calc((100% - var(--column)) / 2));
  border-bottom: 1px solid var(--color-border); }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title h1 { font-size: var(--text-lg); line-height: var(--leading-lg); }
.chat-title .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; }
.notices { display: grid; gap: var(--space-2); padding: 0 var(--space-5); }
/* Each row of the conversation is the column plus its gutters, centred. */
.msg, .notices, .composer, .timeline-empty { width: 100%; max-width: calc(var(--column) + 2 * var(--space-5)); margin-left: auto; margin-right: auto; }
.notices:not(:empty) { padding-top: var(--space-3); }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: 10; width: 272px; display: grid; gap: var(--space-3);
  padding: var(--space-4); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-menu); }
.menu-body hr { border: 0; border-top: 1px solid var(--color-border); margin: 0; }

.timeline { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: var(--space-4) 0; display: flex; flex-direction: column; }
/* A short conversation sits just above the composer, where the eye already is, not at the top of the screen. */
.timeline > :first-child { margin-top: auto; }
.timeline-empty { padding: var(--space-6) var(--space-5); color: var(--color-text-muted); text-align: center; }
.msg { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--space-3); padding: 6px var(--space-5) 2px;
  transition: background var(--duration); }
.msg + .msg:not(.cont) { margin-top: var(--space-2); }
.msg:hover, .msg:focus-within { background: var(--color-bg-subtle); }
.msg.arrived { animation: arrive 1.2s ease-out; }
@keyframes arrive { from { background: var(--color-accent-subtle); } to { background: transparent; } }
.msg-main { min-width: 0; display: grid; gap: 2px; }
.msg-head { display: flex; align-items: baseline; gap: var(--space-2); }
.msg-author { font-weight: 600; }
.msg-time { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--color-text-faint); }
.msg-time:hover { color: var(--color-text-muted); }
.msg-edited { font-size: var(--text-xs); color: var(--color-text-faint); }
.msg.cont { padding-top: 1px; padding-bottom: 1px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg.cont .msg-head { position: absolute; left: 0; width: calc(var(--space-5) + 36px); top: 4px; justify-content: flex-end; padding-right: 2px;
  white-space: nowrap; opacity: 0; }
.msg.cont .msg-head .msg-author, .msg.cont .msg-head .msg-edited { display: none; }
.msg.cont:hover .msg-head, .msg.cont:focus-within .msg-head { opacity: 1; }
.msg.cont .msg-time { font-size: 10.5px; letter-spacing: -0.01em; }

.msg-text { overflow-wrap: anywhere; }
.msg-text.gone { color: var(--color-text-faint); font-style: italic; }
.msg-text p { margin: 0; }
.msg-text p + p, .msg-text ul, .msg-text ol, .msg-text pre, .msg-text blockquote { margin: var(--space-1) 0 0; }
.msg-text ul, .msg-text ol { padding-left: var(--space-5); }
/* Messages sit in the timeline list, so a list in a message would otherwise draw as a nested one. */
.msg-text ul { list-style-type: disc; }
.msg-text ul ul { list-style-type: circle; }
.msg-text pre { background: var(--color-bg-muted); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); overflow-x: auto; }
.msg-text pre code { background: none; padding: 0; }
.msg-text blockquote { border-left: 2px solid var(--color-border); padding-left: var(--space-3); color: var(--color-text-muted); }
.mention { background: var(--color-mention); color: var(--color-mention-text); border-radius: 4px; padding: 0 3px; font-weight: 500; }
.mention.self { background: var(--color-accent-subtle); color: var(--color-accent-text); }

.msg-menu { position: absolute; top: 2px; right: var(--space-5); opacity: 0; transition: opacity var(--duration); }
.msg:hover .msg-menu, .msg:focus-within .msg-menu, .msg-menu[open] { opacity: 1; }
.msg-menu > summary { list-style: none; cursor: pointer; font: 500 var(--text-xs) / var(--leading-xs) var(--font-sans); color: var(--color-text-muted);
  background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 2px var(--space-2); }
.msg-menu > summary::-webkit-details-marker { display: none; }
.msg-menu[open] { position: static; grid-column: 2; margin-top: var(--space-2); }
.msg-menu[open] > summary { display: none; }
.edit-form { display: grid; gap: var(--space-2); max-width: 640px; }

/* Composer */
.composer { position: relative; padding: var(--space-3) var(--space-5) var(--space-4); }
.composer .problem { margin-bottom: var(--space-2); }
.composer-box { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg);
  transition: border-color var(--duration), box-shadow var(--duration); }
.composer-box:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-subtle); }
.composer-input { padding: var(--space-2) var(--space-2) 0; }
.composer-input textarea { display: block; width: 100%; border: 0; padding: 6px var(--space-2); resize: none; max-height: 240px; background: transparent; }
.composer-input textarea:focus { box-shadow: none; }
.composer-input textarea[hidden], .edit-form textarea[hidden] { display: none; }
/* The rich field shows the message as it will be sent, with the same styles as a sent message. */
.rich-field { position: relative; min-height: 34px; max-height: 240px; overflow-y: auto; padding: 6px var(--space-2); outline: none; cursor: text;
  overflow-wrap: anywhere; }
.rich-field.empty::before { content: attr(data-placeholder); position: absolute; color: var(--color-text-faint); pointer-events: none; }
.rich-field > :first-child { margin-top: 0; }
.rich-field a { cursor: text; }
.rich-field [contenteditable="false"] { cursor: default; }
.edit-form .rich-field { min-height: 66px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg);
  padding: var(--space-2) var(--space-3); transition: border-color var(--duration); }
.edit-form .rich-field:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-subtle); }
.composer-bar { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-2); }
.composer.enhanced .composer-bar { justify-content: space-between; }
.toolbar { display: none; align-items: center; gap: 2px; min-width: 0; }
.composer.enhanced .toolbar { display: flex; }
.composer-actions { display: flex; align-items: center; gap: var(--space-1); flex: none; }
.tool { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--color-text-muted); cursor: pointer; font: 600 var(--text-sm) / 1 var(--font-sans); transition: background var(--duration), color var(--duration); }
.tool:hover:not(:disabled) { background: var(--color-bg-muted); color: var(--color-text); }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool-glyph { font: 500 var(--text-md) / 1 var(--font-sans); }
.tool-gap { flex: none; width: 1px; height: 16px; margin: 0 var(--space-1); background: var(--color-border); }
.tool[aria-pressed="true"] { background: var(--color-accent-subtle); color: var(--color-accent-text); }
.composer-notes { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.composer-notes:has(:not([hidden])) { margin-top: var(--space-2); }
.composer-warning { color: var(--color-warning); font-size: var(--text-sm); line-height: var(--leading-sm); }
.composer-count { margin-left: auto; color: var(--color-text-muted); font-size: var(--text-xs); line-height: var(--leading-xs); font-variant-numeric: tabular-nums; }
.composer-count.over { color: var(--color-danger); font-weight: 600; }
.composer .hint { margin-top: var(--space-2); color: var(--color-text-faint); font-size: var(--text-xs); line-height: var(--leading-xs); }

.suggestions { position: absolute; z-index: 10; left: var(--space-5); bottom: calc(100% - var(--space-2)); width: min(380px, calc(100% - 2 * var(--space-5)));
  max-height: 296px; overflow-y: auto; margin: 0; padding: var(--space-1); list-style: none; background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-menu); }
.link-editor { position: absolute; z-index: 10; left: var(--space-5); bottom: calc(100% - var(--space-2)); width: min(420px, calc(100% - 2 * var(--space-5)));
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-menu); }
.link-editor[hidden] { display: none; }
.link-editor input { flex: 1; padding: var(--space-1) var(--space-2); }
.link-editor .text-button { white-space: nowrap; }
.suggestion { display: flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-2); border-radius: var(--radius-sm); cursor: pointer; }
.suggestion[aria-selected="true"] { background: var(--color-accent-subtle); color: var(--color-accent-text); }
.suggestion-name { font-weight: 500; white-space: nowrap; }
.suggestion-note { margin-left: auto; padding-left: var(--space-3); color: var(--color-text-muted); font-size: var(--text-xs); line-height: var(--leading-xs);
  text-align: right; }
.suggestion.muted-option .suggestion-name { color: var(--color-text-muted); font-weight: 400; }
.suggestion-glyph { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--color-bg-muted);
  color: var(--color-text-muted); font: 600 11px / 1 var(--font-sans); }

/* Messages on their way */
.msg.pending .msg-text { color: var(--color-text-muted); }
.msg-state { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--color-text-faint); }
.msg.failed .msg-state { color: var(--color-danger); }
.msg-status { display: flex; align-items: baseline; gap: var(--space-3); }
.msg-retry { display: flex; gap: var(--space-3); }
.draft-mark { color: var(--color-text-faint); font-size: var(--text-xs); }
.channel-link { color: var(--color-accent); font-weight: 500; }
.mention.everyone { background: var(--color-accent-subtle); color: var(--color-accent-text); }
.composer-off { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: calc(100% - 2 * var(--space-5));
  max-width: var(--column); margin: var(--space-3) auto var(--space-4);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--color-bg-subtle); color: var(--color-text-muted); }

/* ---------- Pages ---------- */
.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-5); }
.page-column { max-width: var(--column); margin: 0 auto; display: grid; gap: var(--space-6); }
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.list > li:first-child { border-top: 1px solid var(--color-border); }
.list-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list-title { font-weight: 600; color: var(--color-text); }
.explain { color: var(--color-text-muted); font-size: var(--text-sm); line-height: var(--leading-sm); max-width: 640px; }
.section-title { font-size: var(--text-md); }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); position: relative; }
.history-item { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--space-3); }
.history-version { display: grid; place-items: center; height: 24px; border-radius: var(--radius-full); background: var(--color-bg-muted);
  font: 500 var(--text-xs) / 1 var(--font-mono); color: var(--color-text-muted); }
.history-item.e-posted .history-version { background: var(--color-accent-subtle); color: var(--color-accent-text); }
.history-item.e-deleted .history-version { background: color-mix(in srgb, var(--color-danger) 14%, var(--color-bg)); color: var(--color-danger); }
.history-body { display: grid; gap: var(--space-1); min-width: 0; }
.history-type { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); }
details > summary { cursor: pointer; }
.history-body details > summary { color: var(--color-text-muted); font-size: var(--text-sm); }
.code { margin: var(--space-2) 0 0; background: var(--color-bg-subtle); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-3); overflow-x: auto; font: var(--text-xs) / var(--leading-xs) var(--font-mono); }
.quote { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) 0; }
.quote .msg:hover { background: none; }

/* ---------- Sign in ---------- */
.signin { min-height: 100%; display: grid; place-items: center; padding: var(--space-7) max(var(--space-4), env(safe-area-inset-right, 0px)) var(--space-7) max(var(--space-4), env(safe-area-inset-left, 0px)); }
.signin-card { width: 100%; max-width: 440px; display: grid; gap: var(--space-5); }
.signin-card h1 { font-size: var(--text-xl); line-height: var(--leading-xl); }
.signin-card .lede { color: var(--color-text-muted); }
.people { display: grid; gap: var(--space-2); }
.person { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); background: var(--color-bg); color: var(--color-text); font: 500 var(--text-md) / 1 var(--font-sans); cursor: pointer;
  transition: border-color var(--duration), background var(--duration); text-align: left; }
.person:hover { border-color: var(--color-accent); background: var(--color-bg-subtle); }
.person .arrow { margin-left: auto; color: var(--color-text-faint); }

/* ---------- Style guide page ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.swatch { display: grid; gap: var(--space-1); font-size: var(--text-xs); line-height: var(--leading-xs); }
.swatch code { background: none; padding: 0; color: var(--color-text-muted); }
.swatch-chip { height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }
.specimen { display: grid; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); }

/* ---------- Small screens ---------- */
@media (max-width: 768px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(85vw, 300px); transform: translateX(-100%); transition: transform 180ms ease;
    padding-top: env(safe-area-inset-top, 0px); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgb(0 0 0 / 0.32); }
  .nav-toggle { display: inline-grid; }
  .chat-head, .notices, .composer, .page-body { padding-left: max(var(--space-4), env(safe-area-inset-left, 0px)); padding-right: max(var(--space-4), env(safe-area-inset-right, 0px)); }
  .msg { padding-left: max(var(--space-4), env(safe-area-inset-left, 0px)); padding-right: max(var(--space-4), env(safe-area-inset-right, 0px)); }
  .msg.cont .msg-head { width: calc(var(--space-4) + 36px); }
  .msg-menu { right: var(--space-4); opacity: 1; }
  .composer-off { width: calc(100% - 2 * var(--space-4)); }
  .suggestions, .link-editor { left: var(--space-4); width: calc(100% - 2 * var(--space-4)); }
  .composer.enhanced .toolbar { overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
}
@media (max-width: 480px) {
  .tool-more { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .msg.arrived { animation: none; }
}
.stack { display: grid; gap: var(--space-2); }
.grow { flex: 1; }
.timeline.quote { flex: none; overflow: visible; }
