/* Lyra board, Stage 3. Tokens and layout follow UI_DESIGN_V2.md; light and dark use one token set
   through light-dark(), driven by color-scheme (system by default, or html[data-theme]). */

/* ============================================================================
   1. Tokens
   ============================================================================ */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f7f9, #121316);
  --bg-2: light-dark(#eef0f3, #18191c);
  /* Machine and pool cards: their own tone and border, clearly apart from the agent list (#202124)
     and the page (#121316) in dark, and from white cards in light. */
  --rail: light-dark(#eceef2, #2e3035);
  --rail-hover: light-dark(#e4e7ec, #34373c);
  --rail-line: light-dark(#d3d7dd, #4a4d53);
  --card: light-dark(#ffffff, #202124);
  --raised: light-dark(#ffffff, #282a2e);
  --text: light-dark(#1f2328, #e8eaed);
  --muted: light-dark(#5f6368, #9aa0a6);
  --line: light-dark(#e3e5e8, #2f3136);
  --line-strong: light-dark(#cdd1d6, #3c4043);
  --hover: light-dark(rgba(32, 33, 36, .055), rgba(232, 234, 237, .06));
  --selected: light-dark(#e8f0fe, #2d3036);
  --accent: light-dark(#155ec4, #8ab4f8);
  --accent-text: light-dark(#ffffff, #10213d);
  --focus: light-dark(#155ec4, #8ab4f8);
  --link: light-dark(#155ec4, #8ab4f8);
  --ok: light-dark(#147231, #81c995);
  --warn: light-dark(#a35a00, #fdd663);
  --bad: light-dark(#c5221f, #f28b82);
  --hold: light-dark(#8430ce, #c58af9);
  --ok-wash: light-dark(rgba(24, 128, 56, .09), rgba(129, 201, 149, .12));
  --warn-wash: light-dark(rgba(227, 116, 0, .1), rgba(253, 214, 99, .12));
  --bad-wash: light-dark(rgba(197, 34, 31, .08), rgba(242, 139, 130, .12));
  --info-wash: light-dark(rgba(21, 94, 196, .08), rgba(138, 180, 248, .12));
  --hold-wash: light-dark(rgba(132, 48, 206, .08), rgba(197, 138, 249, .12));
  --consul-gold: light-dark(#b87b08, #facc15);
  --consul-ink: light-dark(#8f5e06, #fde68a);
  --consul-wash: light-dark(rgba(217, 159, 38, .1), rgba(250, 204, 21, .09));
  --brand-gold: #facc15;
  --brand-ink: light-dark(#8c6200, #facc15);
  --bubble-me: light-dark(#e8f0fe, #283447);
  --bubble-them: light-dark(#ffffff, #202124);
  --code: light-dark(#f1f3f4, #2a2b2f);
  --table-head: light-dark(#f1f3f4, #2a2b2f);
  --scrim: light-dark(rgba(32, 33, 36, .45), rgba(0, 0, 0, .62));
  --scroll-thumb: light-dark(rgba(32, 33, 36, .22), rgba(232, 234, 237, .2));
  --scroll-thumb-hover: light-dark(rgba(32, 33, 36, .38), rgba(232, 234, 237, .34));
  --shadow-1: light-dark(0 1px 2px rgba(32, 33, 36, .08), 0 1px 2px rgba(0, 0, 0, .4));
  --shadow-float: light-dark(0 12px 32px rgba(32, 33, 36, .16), 0 12px 32px rgba(0, 0, 0, .5));
  --imgpop-stage: #0b0c0e;
  /* Servers map (Wave 2): quiet land on a paper sea, hairline coasts and a faint graticule. */
  --map-sea: light-dark(#fafbfc, #1a1b1e);
  --map-land: light-dark(#e2e5ea, #2d2f34);
  --map-coast: light-dark(#c2c8d0, #474a50);
  --map-grid: light-dark(rgba(32, 33, 36, .07), rgba(232, 234, 237, .06));
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "KaTeX_Main", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-ctl: 8px; --r-card: 12px; --r-pill: 999px;
  --sidebar-w: 360px;
  font-family: var(--font-ui); font-size: 15px; line-height: 1.45; color: var(--text);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ============================================================================
   2. Base, scrollbars, controls
   ============================================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h3 { font-size: .9rem; margin: 1.1rem 0 .5rem; color: var(--muted); font-weight: 600; }
p { margin: 0; }
a { color: var(--link); }
kbd { font-family: var(--font-mono); font-size: .72rem; padding: .05rem .32rem; border-radius: 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--code); color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }
.error { color: var(--bad); font-size: .85rem; margin-top: .3rem; }
.error:empty { display: none; }
.wordmark { font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; color: var(--brand-ink); }
.pane-title { font-family: var(--font-display); font-weight: 400; font-size: 1.32rem; line-height: 1.2; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Thin, quiet scrollbars in both themes. */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 10px; border: 3px solid transparent;
  background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
::-webkit-scrollbar-corner { background: transparent; }

button { font: inherit; color: inherit; cursor: pointer; border-radius: var(--r-ctl); border: 1px solid transparent;
  background: transparent; padding: .42rem .85rem; min-height: 36px; touch-action: manipulation; font-weight: 500;
  transition: background-color .12s ease-out, border-color .12s ease-out, color .12s ease-out, box-shadow .12s ease-out; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; box-shadow: var(--shadow-1); }
button.primary:hover:not(:disabled) { filter: brightness(1.07); }
button.primary:active:not(:disabled) { filter: brightness(.96); }
button.ghost { color: var(--accent); border-color: var(--line-strong); background: var(--card); }
button.ghost:hover:not(:disabled) { background: var(--hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
button.danger { color: var(--bad); border-color: var(--line-strong); background: var(--card); }
button.danger:hover:not(:disabled) { background: var(--bad-wash); border-color: color-mix(in srgb, var(--bad) 45%, var(--line-strong)); }
button.quiet { color: var(--muted); padding: .3rem .55rem; min-height: 32px; }
button.quiet:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; min-height: 0; padding: 0; color: var(--muted);
  border-radius: 10px; flex: none; }
.icon-btn:hover { color: var(--text); background: var(--hover); }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: .45rem .6rem; min-height: 36px;
  transition: border-color .12s ease-out, box-shadow .12s ease-out; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea { resize: vertical; line-height: 1.45; }
label { display: grid; gap: .25rem; font-size: .82rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: .45rem; color: var(--text); font-size: .9rem; }
label.check input { width: auto; min-height: 0; accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--r-card); margin: 0; padding: .5rem .7rem .7rem; }
legend { font-size: .82rem; color: var(--muted); padding: 0 .3rem; }

.pill { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; line-height: 1.55; font-weight: 600;
  padding: 0 .5rem; border-radius: var(--r-pill); border: 1px solid var(--line-strong); color: var(--muted);
  white-space: nowrap; background: transparent; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-wash); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-wash); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-wash); }
.pill.info { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 38%, transparent); background: var(--info-wash); }
.pill.hold { color: var(--hold); border-color: color-mix(in srgb, var(--hold) 40%, transparent); background: var(--hold-wash); }
.pill.consul { color: var(--consul-ink); border-color: var(--consul-gold); background: var(--consul-wash); }
/* Detached (Stage 4B): amber outline with a hollow dot, echoing the avatar ring; never a filled
   green "online" or the grey "offline". */
.pill.detached { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: transparent; }
.pill.detached::before { content: ""; flex: none; width: .5em; height: .5em; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px currentColor; }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; padding: .15rem .6rem; border-radius: var(--r-pill);
  border: 1px solid var(--line); color: var(--muted); background: var(--card); }
.count-badge { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
  border-radius: var(--r-pill); background: var(--accent); color: var(--accent-text); font-size: .7rem; font-weight: 700;
  font-variant-numeric: tabular-nums; }
.count-badge.is-needs { background: var(--warn); color: light-dark(#ffffff, #202124); }
/* Scroll containers are also containing blocks: an absolutely positioned descendant (a visually
   hidden label, a tooltip) is clipped with the content instead of stretching the app shell. */
.scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; position: relative; }
.prov { display: inline-grid; place-items: center; flex: none; line-height: 0; }
.prov-row { display: inline-flex; align-items: center; gap: .55rem; color: var(--muted); }

/* ============================================================================
   3. Sign-in
   ============================================================================ */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--brand-gold) 10%, transparent), transparent 60%), var(--bg); }
.login-card { width: min(380px, 100%); display: grid; gap: .85rem; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 1.6rem 1.5rem 1.3rem; box-shadow: var(--shadow-float); }
.login-brand { display: flex; align-items: center; gap: .75rem; }
.login-brand .wordmark { font-size: 2.1rem; }
.login-providers { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .7rem;
  border-top: 1px solid var(--line); padding-top: .8rem; font-size: .78rem; }
.logo-slot { display: inline-grid; flex: none; line-height: 0; }
.lyra-logo { display: block; border-radius: 8px; }

/* ============================================================================
   4. App shell
   ============================================================================ */
#app { height: 100dvh; }
#main:not([hidden]) { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { flex: none; display: flex; align-items: center; gap: .5rem; min-height: 56px;
  padding: .45rem .8rem; padding-top: max(.45rem, env(safe-area-inset-top));
  padding-left: max(.8rem, env(safe-area-inset-left)); padding-right: max(.8rem, env(safe-area-inset-right));
  background: var(--bg-2); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .5rem; margin-right: .35rem; flex: none; }
.brand .wordmark { font-size: 1.5rem; line-height: 1; }
.tabs { display: flex; gap: .15rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; font-weight: 500;
  border-radius: 10px; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab.active { color: var(--text); background: var(--card); font-weight: 600; box-shadow: var(--shadow-1);
  border-color: var(--line); }
.search-trigger { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); border-color: var(--line);
  background: var(--card); min-width: 12rem; justify-content: flex-start; border-radius: 10px; }
.search-trigger .search-label { flex: 1; text-align: left; }
.search-trigger:hover { color: var(--text); border-color: var(--line-strong); }
#live { font-size: .75rem; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: .3rem; }
#live::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--line-strong); }
#live.on { color: var(--ok); }
#live.on::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-wash); }
#live.off { color: var(--warn); }
#live.off::before { background: var(--warn); }
#notifyToggle .bell-off { display: inline; }
#notifyToggle[aria-pressed="true"] { color: var(--accent); }
#notifyToggle[aria-pressed="true"] .bell-off { display: none; }

/* Theme switch: a pill track with sun and moon, the knob slides to the active theme. */
.theme-toggle { padding: 0; min-height: 0; border: 0; border-radius: var(--r-pill); flex: none; }
.tt-track { position: relative; display: flex; align-items: center; justify-content: space-between; width: 56px; height: 30px;
  padding: 0 8px; border-radius: var(--r-pill); background: var(--card); border: 1px solid var(--line-strong);
  color: var(--muted); }
.tt-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text);
  box-shadow: var(--shadow-1); transition: transform .22s cubic-bezier(.3, .7, .4, 1); }
.theme-toggle[aria-checked="true"] .tt-knob { transform: translateX(26px); background: var(--brand-gold); }
.tt-sun, .tt-moon { position: relative; z-index: 1; }
.theme-toggle[aria-checked="false"] .tt-sun { color: var(--card); }
.theme-toggle[aria-checked="true"] .tt-moon { color: #202124; }
.theme-toggle:hover .tt-track { border-color: color-mix(in srgb, var(--text) 35%, var(--line-strong)); }

.conn-banner { flex: none; display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap;
  padding: .35rem .8rem; font-size: .85rem; background: var(--warn-wash); color: var(--warn);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.conn-banner.is-ok { background: var(--ok-wash); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.conn-banner button { min-height: 30px; padding: .2rem .6rem; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem;
  padding: .6rem; padding-bottom: max(.6rem, env(safe-area-inset-bottom));
  padding-left: max(.6rem, env(safe-area-inset-left)); padding-right: max(.6rem, env(safe-area-inset-right)); }
.pane { display: none; min-height: 0; min-width: 0; }
.pane.active { display: flex; flex-direction: column; }
.pane-admin.active { display: block; }
.sidebar-toggle { display: none; }
.resizer { display: none; }

@media (min-width: 960px) {
  .layout { grid-template-columns: min(var(--sidebar-w), 42vw) minmax(0, 1fr); padding: .8rem; }
  .tab-agents { display: none; }
  .sidebar-toggle { display: inline-grid; }
  .pane-agents { display: flex; flex-direction: column; grid-column: 1; grid-row: 1; position: relative; }
  .pane.active:not(.pane-agents) { grid-column: 2; grid-row: 1; }
  .layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .layout.sidebar-collapsed .pane-agents { display: none; }
  .layout.sidebar-collapsed .pane.active:not(.pane-agents) { grid-column: 1; }
  .sidebar-toggle[aria-expanded="false"] { color: var(--accent); background: var(--info-wash); }
  /* Drag handle in the gutter right of the sidebar. */
  .resizer { display: block; position: absolute; top: 10px; bottom: 10px; right: calc(-.4rem - 5px); width: 10px; z-index: 4;
    cursor: col-resize; border-radius: 5px; touch-action: none; }
  .resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; border-radius: 2px;
    background: transparent; transition: background-color .12s ease-out; }
  .resizer:hover::after, .resizer:focus-visible::after, .resizer.is-dragging::after { background: var(--accent); }
  .resizer:focus-visible { outline: none; }
  body.is-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
}

/* ============================================================================
   5. Agents sidebar
   ============================================================================ */
.pane-agents { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); }
.pane-head { flex: none; padding: .75rem .8rem .55rem; border-bottom: 1px solid var(--line); display: grid; gap: .55rem; }
.pane-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--bg-2);
  border: 1px solid var(--line); }
.seg-btn { min-height: 30px; padding: .2rem .5rem; font-size: .85rem; color: var(--muted); border-radius: 7px; }
.seg-btn[aria-checked="true"] { background: var(--raised); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }
.quota-alert { font-size: .82rem; color: var(--bad); background: var(--bad-wash); border-radius: 8px; padding: .35rem .55rem; }
.quota-alert button { color: var(--bad); text-decoration: underline; padding: 0; min-height: 0; font-weight: 600; }
.roster { flex: 1; padding: .55rem .55rem 1rem; display: grid; align-content: start; grid-auto-rows: max-content; gap: .6rem;
  border-radius: 0 0 var(--r-card) var(--r-card); }
.roster-groups { display: grid; grid-auto-rows: max-content; gap: .6rem; min-width: 0; }
.group-title { font-size: .82rem; color: var(--muted); font-weight: 600; margin: .4rem .2rem .1rem; display: flex;
  align-items: center; gap: .4rem; }

/* Needs you: the agents waiting on the owner, first in the rail. */
.needs { border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--line)); background: var(--warn-wash);
  border-radius: var(--r-card); padding: .45rem .45rem .5rem; display: grid; gap: .25rem; }
.needs-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .1rem .35rem .2rem; }
.needs-head h3 { margin: 0; color: var(--warn); font-size: .86rem; }
.needs-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .55rem; width: 100%;
  text-align: left; padding: .35rem .45rem; border-radius: 8px; background: var(--card); border: 1px solid var(--line);
  min-height: 48px; }
.needs-item:hover { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.needs-text { min-width: 0; display: grid; }
.needs-name { font-weight: 650; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.needs-why { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.needs-item .ago { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Overflow discipline: nothing inside a rail, card or row may cross its container or a divider. */
.rail-card > *, .rail-title > *, .agent-row > *, .agent-main > *, .agent-text > *, .needs-item > *, .list-row > *,
.proj-card > *, .proj-card-top > *, .proj-card-foot > *, .conv-main > *, .stat > *, .storage-head > *, .rail-details > *,
.kv > *, .task > *, .composer-row > *, .people > * { min-width: 0; max-width: 100%; }
.rail-card .pill, .agent-line1 .pill, .agent-line2 .pill, .proj-card-top .pill, .list-row .pill {
  display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }
.rail-card .pill { width: fit-content; }
.rail-sub { overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; }
.clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-title { display: inline-flex; align-items: center; gap: .45rem; min-width: 0; max-width: 100%; }
.proj-card-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Context ring: under 30% calm, 30 to 60% normal, 60 to 80% warning, 80% and up critical. */
.ctx-ring { flex: none; display: inline-grid; place-items: center; line-height: 0; color: var(--ok); }
.ctx-ring.mid { color: var(--accent); }
.ctx-ring.warn { color: var(--warn); }
.ctx-ring.bad { color: var(--bad); }
.ctx-ring .ring-track { opacity: .22; }

/* Rail group: tall host or pool card on the left, agents on the right. */
.rail-group { display: grid; grid-template-columns: clamp(108px, 34%, 180px) minmax(0, 1fr); border: 1px solid var(--rail-line);
  border-radius: var(--r-card); overflow: hidden; background: var(--card); }
.rail-group.is-offline .rail-card { opacity: .78; }
.rail-group.single { grid-template-columns: minmax(0, 1fr); }
.rail-card { display: flex; flex-direction: column; align-items: stretch; gap: .35rem; text-align: left; border-radius: 0;
  border: 0; border-right: 1px solid var(--rail-line); background: var(--rail); padding: .55rem .5rem; min-height: 100%;
  min-width: 0; font-weight: 400; box-shadow: inset 0 1px 0 light-dark(rgba(255, 255, 255, .6), rgba(255, 255, 255, .04)); }
.rail-card:hover { background: var(--rail-hover); }
.rail-details { background: var(--card); }
.rail-name { font-weight: 650; font-size: .86rem; line-height: 1.25; min-width: 0;
  overflow-wrap: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-title { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.rail-sub { font-size: .74rem; color: var(--muted); line-height: 1.3; overflow-wrap: normal; }
.rail-gb { font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Same chevron as agent rows: rotates a quarter turn when the card is expanded. */
.rail-chev { margin-left: auto; flex: none; display: inline-grid; place-items: center; color: var(--muted); }
.rail-chev svg { transition: transform .12s ease-out; }
.rail-card[aria-expanded="true"] .rail-chev svg { transform: rotate(90deg); }
.rail-card:hover .rail-chev { color: var(--text); }

/* Remaining quota on pool cards: the primary window and the 5 h or session window. */
.quota-bars { display: grid; gap: 4px; width: 100%; min-width: 0; }
.qbar { display: grid; grid-template-columns: 2.7em minmax(0, 1fr) 2.5em; align-items: center; gap: .3rem; min-width: 0;
  font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.qbar .track { height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--line-strong) 70%, transparent); }
.qbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qbar-val { text-align: right; white-space: nowrap; }
.rail-agents { min-width: 0; display: grid; align-content: start; container-type: inline-size; }
@container (max-width: 300px) {
  .agent-handle { display: none; }   /* names and pills need the room; the handle is in the drawer and tooltip */
}
.rail-details { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: .6rem .7rem .7rem; display: grid; gap: .5rem;
  font-size: .82rem; }
.rail-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.rail-actions button { min-height: 32px; padding: .2rem .65rem; font-size: .8rem; }
.mini-meter { display: grid; gap: 2px; font-size: .68rem; color: var(--muted); }
.mini-meter .mm-top { display: flex; justify-content: space-between; gap: .3rem; }
.track { display: block; position: relative; background: var(--line); overflow: hidden; }
.fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit;
  transition: width .3s ease-out; }
.mini-meter .track { height: 5px; border-radius: 3px; }
.fill.warn { background: var(--warn); }
.fill.bad { background: var(--bad); }
.fill.ok { background: var(--ok); }
.meter { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
.meter .track { height: 7px; border-radius: 4px; }
.meter.no-label { grid-template-columns: minmax(0, 1fr) auto; }
.meter .val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .78rem; text-align: right; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: .2rem .6rem; font-size: .8rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: break-word; }
.provider-section { display: grid; gap: .5rem; }
.provider-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; text-align: left;
  width: 100%; padding: .3rem .25rem; }
.provider-head .ph-name { display: inline-flex; align-items: center; gap: .45rem; font-size: .95rem; font-weight: 650; }
.stale-note { color: var(--warn); font-size: .76rem; font-weight: 600; }

.agent { border-bottom: 1px solid var(--line); }
.agent:last-child { border-bottom: 0; }
.agent.is-consul { box-shadow: inset 3px 0 0 var(--consul-gold); background: linear-gradient(90deg, var(--consul-wash), transparent 70%); }
.agent.is-held .agent-name { color: var(--muted); }
.agent-row { display: flex; align-items: center; gap: .3rem; padding: .4rem .45rem .4rem .5rem; min-height: 52px; }
.agent-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: .55rem; text-align: left; padding: .2rem;
  border: 0; min-height: 44px; font-weight: 400; }
.agent-main:hover { background: var(--hover); }
.agent-text { min-width: 0; display: grid; gap: 1px; flex: 1; }
.agent-line1 { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.agent-name { flex: 0 1 auto; min-width: 2.5em; font-weight: 650; font-size: .9rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.agent-handle { flex: 0 100 auto; min-width: 0; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.agent-line1 .pill, .agent-line1 .prov { flex: none; }
.agent-line2 { display: flex; flex-wrap: wrap; align-items: center; gap: 2px .35rem; min-width: 0; font-size: .76rem;
  color: var(--muted); }
.agent-line2 .pill { flex: none; }
/* At least a few characters, or the details move to their own line instead of clipping to one letter. */
.agent-extra { flex: 1 1 0; min-width: min(7ch, 100%); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-chev { color: var(--muted); font-size: .8rem; flex: none; transition: transform .12s ease-out; }
.agent-main[aria-expanded="true"] .agent-chev { transform: rotate(90deg); }
.agent-details { padding: .2rem .8rem .75rem 2.95rem; display: grid; gap: .6rem; }
.rail-agents .agent-details { padding-left: .6rem; }
.rail-agents .kv { grid-template-columns: 6.4rem minmax(0, 1fr); }
.agent-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.agent-actions button { min-height: 32px; padding: .25rem .65rem; font-size: .82rem; }
.hold-note { font-size: .78rem; color: var(--hold); }

/* Floating context menus (machine aliases, Direct Message cards). */
.ctx-menu { position: fixed; z-index: 60; min-width: 200px; padding: .3rem; display: grid; gap: 1px; background: var(--raised);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-float); }
.ctx-menu button { text-align: left; min-height: 34px; padding: .35rem .65rem; border-radius: 7px; font-size: .86rem; font-weight: 500; }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--hover); outline: none; }
.conv-menu { width: min(280px, calc(100vw - 16px)); }
.ctx-section { display: grid; gap: 1px; min-width: 0; }
.ctx-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .4rem .25rem .65rem;
  font-size: .74rem; font-weight: 600; color: var(--muted); }
.ctx-item { display: flex; align-items: center; gap: .5rem; min-width: 0; width: 100%; }
.ctx-label { flex: 1; min-width: 0; }
.ctx-time, .ctx-note { flex: none; font-size: .72rem; color: var(--muted); font-weight: 400; }
.ctx-item[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.ctx-item[aria-disabled="true"]:hover { background: transparent; }
.ctx-sep { height: 1px; background: var(--line); margin: .25rem .3rem; }
.ctx-empty { font-size: .8rem; color: var(--muted); padding: .2rem .65rem .4rem; }

/* Compact pager: "< 1/N >". */
.pager { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.pager-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 6px;
  color: var(--muted); }
.pager-btn:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.pager-pos { font-size: .72rem; color: var(--muted); min-width: 2.4em; text-align: center; }

/* ============================================================================
   6. Conversations and thread
   ============================================================================ */
.pane-chats { min-height: 0; }
.chats { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; }
.conv-list-wrap, .conv-view { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); min-height: 0; }
.conv-list-wrap { padding: .75rem .55rem; }
.conv-list-wrap .pane-title { margin: 0 .25rem .5rem; }
.chats[data-view="list"] .conv-view { display: none; }
.chats[data-view="thread"] .conv-list-wrap { display: none; }
@media (min-width: 1200px) {
  .chats { grid-template-columns: 290px minmax(0, 1fr); }
  .chats[data-view] .conv-view { display: flex; }
  .chats[data-view] .conv-list-wrap { display: block; }
  .conv-back { display: none !important; }
}
.conv-list { display: grid; gap: .35rem; }
/* Groups: Pinned, Direct Message, DM Between Agents (collapsible, the last one paged). */
.conv-group { display: grid; gap: 2px; }
.conv-group-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; min-width: 0;
  padding: 0 .15rem 0 0; }
.conv-group-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: .4rem; min-height: 30px; padding: .2rem .35rem;
  font-size: .8rem; font-weight: 600; color: var(--muted); border-radius: 8px; text-align: left; }
.conv-group-toggle:hover { color: var(--text); background: var(--hover); }
.conv-group-chev { display: inline-grid; place-items: center; flex: none; }
.conv-group-chev svg { transition: transform .12s ease-out; }
.conv-group-toggle[aria-expanded="true"] .conv-group-chev svg { transform: rotate(90deg); }
.conv-group-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-group-count { flex: none; font-size: .68rem; font-weight: 600; padding: 0 .4rem; border-radius: var(--r-pill);
  background: var(--code); color: var(--muted); }
.conv-group-body { display: grid; gap: 2px; }
.conv-group[data-group="team"] .conv-row .conv-title { font-weight: 500; }   /* agent chatter stays quiet */
.conv-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.conv-row:hover { background: var(--hover); }
.conv-row.active { background: var(--selected); }
.conv-row.is-consul::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 2px;
  background: var(--consul-gold); }
.conv-main { flex: 1; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: .3rem .6rem; text-align: left; border: 0; padding: .45rem .3rem .45rem .5rem; min-height: 52px; font-weight: 400; }
.conv-text { min-width: 0; display: grid; }
.conv-title { display: flex; align-items: center; gap: .35rem; min-width: 0; font-weight: 600; font-size: .9rem; }
.conv-title span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-excerpt { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: grid; justify-items: end; gap: 3px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.conv-row.unread .conv-title { font-weight: 700; }
.conv-row.unread .conv-excerpt { color: var(--text); }
.tag-consul { font-size: .66rem; font-weight: 700; color: var(--consul-ink); border: 1px solid var(--consul-gold);
  background: var(--consul-wash); border-radius: var(--r-pill); padding: 0 .35rem; }
.conv-pin { flex: none; width: 36px; height: 36px; min-height: 0; padding: 0; display: grid; place-items: center;
  color: var(--muted); opacity: .55; }
.conv-row:hover .conv-pin, .conv-pin[aria-pressed="true"], .conv-pin:focus-visible { opacity: 1; }
.conv-pin[aria-pressed="true"] { color: var(--accent); }
.conv-empty { padding: .8rem .5rem; color: var(--muted); font-size: .88rem; }

.conv-view { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.conv-header { flex: none; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; min-height: 58px;
  border-bottom: 1px solid var(--line); }
.conv-header .conv-who { min-width: 0; display: grid; flex: 1; }
.conv-header .who-name { display: flex; align-items: center; gap: .4rem; font-weight: 650; font-size: 1.02rem; min-width: 0; }
.conv-header .who-name span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-header .who-sub { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-header.is-consul { box-shadow: inset 0 -2px 0 var(--consul-gold); }
.conv-back { flex: none; min-width: 44px; min-height: 44px; padding: 0 .5rem; color: var(--accent); }
.conv-empty-state { flex: 1; display: grid; place-items: center; text-align: center; padding: 2rem; color: var(--muted); }
.conv-empty-state .pane-title { color: var(--text); margin-bottom: .4rem; }

.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: .9rem .9rem 1.2rem; display: flex; flex-direction: column;
  gap: .7rem; overscroll-behavior: contain; }
.msg { flex: none; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: .5rem; max-width: min(760px, 92%); align-self: flex-start; }
.msg.mine { grid-template-columns: minmax(0, 1fr); align-self: flex-end; }
.bubble { min-width: 0; background: var(--bubble-them); border: 1px solid var(--line); border-radius: 14px;
  border-top-left-radius: 6px; padding: .5rem .75rem .55rem; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--bubble-me); border-color: transparent; border-top-left-radius: 14px; border-top-right-radius: 6px; }
.msg.local .bubble { opacity: .8; }
.msg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .5rem; font-size: .75rem; color: var(--muted);
  margin-bottom: .15rem; }
.msg-head strong { color: var(--text); font-size: .82rem; }
.quote { display: block; width: 100%; min-width: 0; min-height: 0; text-align: left; font: inherit; font-size: .8rem; font-weight: 400;
  color: var(--muted); background: transparent; border: 0; border-left: 3px solid var(--line-strong); border-radius: 0;
  padding: .05rem .2rem .05rem .5rem; margin: .15rem 0 .35rem; cursor: pointer; }
.quote-text { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote:hover { color: var(--text); border-left-color: var(--accent); background: transparent; }
.quote:focus-visible { outline-offset: 1px; }
.msg-body { font-size: .95rem; }
.image-strip { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.image-strip:empty { display: none; }
.image-strip img { width: 120px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
  display: block; background: var(--code); }
.msg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .2rem .5rem; margin-top: .2rem;
  font-size: .75rem; }
.msg-foot:empty { display: none; }
.msg:not(.mine) .msg-foot { justify-content: flex-start; }
.msg-foot .quiet { font-size: .76rem; min-height: 26px; padding: .1rem .35rem; }
.msg-foot .receipt { margin-top: 0; }
.msg-state { font-size: .74rem; color: var(--muted); }
.msg-state.failed { color: var(--bad); }
.msg-state.unconfirmed { color: var(--warn); }
.msg-state.cancelled { color: var(--muted); }

/* The live agent-side bubble: thinking, working or waiting for input, until the reply lands. */
/* line-clamped content has no useful intrinsic width, so live bubbles get an explicit one */
.msg.live { width: min(560px, 92%); }
.msg.live .bubble { background: var(--bubble-them); border-style: dashed; border-color: var(--line-strong); }
.msg.live.is-input_required .bubble { border-style: solid; border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px var(--info-wash); }
.msg.live.is-stale .bubble { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.msg.live .msg-head .live-tag { font-size: .7rem; color: var(--accent); font-weight: 600; }

.new-pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--composer-h, 120px) + 10px);
  z-index: 3; background: var(--accent); color: var(--accent-text); border-radius: var(--r-pill); box-shadow: var(--shadow-float);
  font-size: .82rem; font-weight: 600; padding: .3rem .9rem; min-height: 32px; }
/* Stage 4F: an older window is open. Same place as "New messages", quieter: it is a way back, not news. */
.latest-pill { display: inline-flex; align-items: center; gap: .35rem; background: var(--raised); color: var(--accent);
  border: 1px solid var(--line-strong); padding: .28rem .85rem .28rem .7rem; }
.latest-pill:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); background: var(--raised); }

/* Stage 4F: the top of a windowed thread. */
.history-edge { flex: none; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 0 0 .15rem; }
.load-earlier { display: inline-flex; align-items: center; gap: .35rem; min-height: 28px; padding: .18rem .8rem .18rem .65rem;
  font-size: .78rem; font-weight: 500; color: var(--muted); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-pill); }
.load-earlier:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: var(--card); }
.load-earlier:disabled { opacity: .8; cursor: progress; }
.history-start { display: flex; align-items: center; gap: .7rem; width: min(420px, 100%); font-size: .74rem; color: var(--muted); }
.history-start::before, .history-start::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.history-error { font-size: .74rem; color: var(--bad); }

/* A message reached by a jump (#id chip, reply quote, search result): one calm accent pulse. */
@keyframes lyra-jump-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  18% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
  70% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
  100% { box-shadow: 0 0 0 4px transparent; }
}
.msg.is-jump-target > .bubble { animation: lyra-jump-pulse 1.8s ease-out both; animation-delay: var(--jump-delay, 0ms); }

/* Stage 4F: Search chat, a compact bar under the thread header with a floating result list. */
.conv-search-btn { width: 34px; height: 34px; }
.conv-search-btn[aria-expanded="true"] { color: var(--accent); background: var(--info-wash); }
.thread-search { position: relative; flex: none; padding: .45rem .75rem; border-bottom: 1px solid var(--line); background: var(--card); }
.ts-bar { display: flex; align-items: center; gap: .45rem; min-height: 36px; padding: 0 .25rem 0 .7rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-pill); transition: border-color .12s ease-out, box-shadow .12s ease-out; }
.ts-bar:focus-within { border-color: var(--accent); background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ts-icon { flex: none; color: var(--muted); }
.ts-bar input { flex: 1; min-width: 0; min-height: 0; border: 0; padding: .3rem 0; background: transparent; box-shadow: none; }
.ts-bar input:focus { box-shadow: none; }
.ts-bar input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.ts-count { flex: none; font-size: .74rem; color: var(--muted); white-space: nowrap; }
.ts-close { width: 28px; height: 28px; border-radius: 50%; }
.ts-results { position: absolute; left: .75rem; right: .75rem; top: calc(100% - 4px); z-index: 6; list-style: none; margin: 0;
  padding: .3rem; max-height: min(52dvh, 380px); overflow-y: auto; background: var(--raised); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-float); }
.ts-item { display: grid; gap: 1px; padding: .42rem .6rem; border-radius: 8px; cursor: pointer; min-width: 0; }
.ts-item[aria-selected="true"] { background: var(--selected); }
.ts-meta { display: flex; align-items: baseline; gap: .5rem; min-width: 0; font-size: .74rem; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.ts-meta strong { color: var(--text); font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-id { margin-left: auto; }
.ts-snippet { font-size: .85rem; color: var(--text); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.ts-empty { padding: .55rem .6rem; font-size: .85rem; color: var(--muted); }
mark.hit { color: inherit; background: light-dark(rgba(250, 204, 21, .4), rgba(250, 204, 21, .24)); border-radius: 3px;
  padding: 0 .06em; }

.composer { flex: none; border-top: 1px solid var(--line); background: var(--card); padding: .55rem .7rem;
  padding-bottom: max(.55rem, env(safe-area-inset-bottom)); display: grid; gap: .4rem; }
.composer textarea { min-height: 40px; max-height: min(220px, 32dvh); resize: none; overflow-y: hidden; border-radius: 10px;
  background: var(--bg); }
.composer textarea:focus { background: var(--card); }
.composer-row { display: flex; align-items: center; gap: .5rem; }
.composer-left { display: flex; align-items: center; gap: .45rem; min-width: 0; flex-wrap: wrap; }
.composer-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.mode-pick select { width: auto; min-height: 36px; padding: .3rem 1.6rem .3rem .55rem; font-size: .85rem; }
.draft-hint { font-size: .75rem; }
.reply-to { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); background: var(--bg);
  border-radius: 8px; padding: .2rem .25rem .2rem .55rem; min-width: 0; }
.reply-to span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.staged-strip { margin-top: 0; }
.staged-image { position: relative; }
.staged-image .remove { position: absolute; top: 3px; right: 3px; min-height: 0; width: 24px; height: 24px; padding: 0;
  border-radius: 50%; background: rgba(15, 17, 20, .72); color: #fff; font-size: .8rem; line-height: 1; }
.staged-uploading { width: 120px; height: 72px; display: grid; place-items: center; font-size: .75rem; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: 8px; }
.staged-retry { font: inherit; font-size: .72rem; font-weight: 600; color: var(--warn); background: var(--warn-wash);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent); padding: .3rem; text-align: center; cursor: pointer; }
.note { font-size: .78rem; }
.read-only { flex: none; padding: .6rem .8rem; border-top: 1px solid var(--line); font-size: .85rem; }

/* Attach image: a compact paperclip icon with a tooltip that also works when it is disabled. */
.tip { position: relative; display: inline-flex; }
.tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px);
  white-space: nowrap; font-size: .74rem; font-weight: 500; padding: .3rem .55rem; border-radius: 7px; pointer-events: none;
  background: var(--text); color: var(--card); box-shadow: var(--shadow-float); opacity: 0; z-index: 20;
  transition: opacity .12s ease-out, transform .12s ease-out; }
.tip:hover::after, .tip:focus-within::after { opacity: 1; transform: translate(-50%, 0); }
.composer-left .tip:first-child::after { left: 0; transform: translate(0, 4px); }
.composer-left .tip:first-child:hover::after, .composer-left .tip:first-child:focus-within::after { transform: translate(0, 0); }
.attach-btn { width: 36px; height: 36px; border-radius: 10px; color: var(--muted); border: 1px solid transparent; }
.attach-btn:hover:not(:disabled) { color: var(--accent); background: var(--info-wash); }
.attach-btn:disabled, .attach-btn[aria-disabled="true"] { opacity: .38; cursor: not-allowed; }
.attach-btn[aria-disabled="true"]:hover { color: var(--muted); background: transparent; }
.composer-row { min-height: 36px; }
.composer-left .mode-pick select { border-radius: var(--r-pill); background: var(--bg); border-color: var(--line); }
#compose-send { border-radius: var(--r-pill); padding-left: 1.1rem; padding-right: 1.1rem; }

/* ============================================================================
   7. Projects
   ============================================================================ */
.pane-projects { min-height: 0; }
.projects { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; }
.proj-list, .proj-detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .8rem; position: relative; }
.projects[data-view="list"] .proj-detail, .projects[data-view="detail"] .proj-list { display: none; }
@media (min-width: 1200px) {          /* same breakpoint as the Chats split */
  .projects { grid-template-columns: 300px minmax(0, 1fr); }
  .projects[data-view] .proj-list, .projects[data-view] .proj-detail { display: block; }
  .proj-back { display: none !important; }
}
.proj-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.filters { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0 .7rem; }
.filter { min-height: 30px; padding: .15rem .65rem; font-size: .8rem; border-radius: var(--r-pill); border: 1px solid var(--line);
  color: var(--muted); font-weight: 500; }
.filter:hover { color: var(--text); background: var(--hover); }
.filter[aria-pressed="true"] { background: var(--selected); color: var(--text); border-color: var(--line-strong); font-weight: 600; }
.proj-card { width: 100%; text-align: left; display: grid; gap: .35rem; padding: .6rem .65rem; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: .45rem; background: var(--card); font-weight: 400; }
.proj-card:hover { background: var(--hover); }
.proj-card.active { border-color: var(--accent); background: var(--selected); }
.proj-card-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.proj-card-name { font-weight: 650; }
.proj-card-foot { display: flex; align-items: center; justify-content: space-between; gap: .4rem; font-size: .78rem; color: var(--muted); }
.count-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
.count-bar span { display: block; height: 100%; }
.count-bar .cb-done { background: var(--ok); }
.count-bar .cb-in_review { background: var(--accent); }
.count-bar .cb-in_progress { background: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.count-bar .cb-blocked { background: var(--bad); }
.count-bar .cb-cancelled { background: var(--line-strong); }
.proj-head { display: grid; gap: .5rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); margin-bottom: .6rem; }
.proj-head-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.proj-head-top .pane-title { flex: 1; min-width: 0; }
.people { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .9rem; font-size: .82rem; color: var(--muted); }
.person { display: inline-flex; align-items: center; gap: .35rem; color: var(--text); }
.avatar-row { display: inline-flex; }
.avatar-row .avatar + .avatar { margin-left: -6px; }
.avatar-row .avatar { box-shadow: 0 0 0 2px var(--card); }
.task { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) auto; align-items: center; gap: .3rem .7rem;
  grid-template-areas: "prio title side" ". desc desc" ". who who"; padding: .55rem .2rem; border-bottom: 1px solid var(--line); }
.task .prio { grid-area: prio; justify-self: start; }
.task-title { grid-area: title; font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.task-side { grid-area: side; display: flex; align-items: center; gap: .5rem; }
.task-desc { grid-area: desc; font-size: .8rem; color: var(--muted); display: grid; gap: .15rem; }
.task-blocked { color: var(--bad); font-weight: 600; }
.task-who { grid-area: who; display: flex; gap: .2rem; flex-wrap: wrap; }
.task.is-cancelled .task-title { text-decoration: line-through; color: var(--muted); }
.task.is-done .task-title { color: var(--muted); }
.proj-toolbar > button, .proj-head-top > button { flex: none; white-space: nowrap; }
@media (max-width: 640px) {
  .task { grid-template-columns: 3.8rem minmax(0, 1fr) auto; grid-template-areas: "prio title title" ". desc desc" ". who side"; }
}
.task:last-child { border-bottom: 0; }
.task-side select { width: auto; min-height: 32px; padding: .2rem 1.4rem .2rem .5rem; font-size: .82rem; }
.prio { font-size: .68rem; font-weight: 700; border-radius: 5px; padding: .05rem .3rem; border: 1px solid var(--line-strong);
  color: var(--muted); font-variant-numeric: tabular-nums; }
.prio.p2 { color: var(--warn); border-color: var(--warn); }
.prio.p3 { color: var(--bad); border-color: var(--bad); }
.task-who button { border: 0; padding: 0; min-height: 0; border-radius: 50%; }
.pick-list > div { display: grid; gap: .3rem; max-height: 220px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--text); }
.pick input { width: auto; min-height: 0; accent-color: var(--accent); }
.conflict { border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-wash);
  border-radius: 10px; padding: .6rem .75rem; display: grid; gap: .45rem; }
.conflict h3 { margin: 0; color: var(--warn); }
.conflict button { justify-self: start; }

/* ============================================================================
   8. Senate: Consul, invites, pools, server storage
   ============================================================================ */
.pane-admin { overflow-y: auto; overscroll-behavior: contain; }
.admin-wrap { max-width: 1080px; display: grid; gap: .8rem; padding-bottom: 2rem; }
.admin-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 1rem; }
.admin-section > .pane-title { margin-bottom: .4rem; }
.lede { font-size: .88rem; margin-bottom: .7rem; max-width: 70ch; }
.form-row { display: grid; gap: .6rem; align-items: end; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: .5rem 0; }
.form-row button { white-space: nowrap; }
.consul-card { display: flex; align-items: center; gap: .8rem; padding: .8rem; border-radius: var(--r-card);
  border: 1px solid var(--line); margin-bottom: .4rem; }
.consul-card.has-consul { border-color: var(--consul-gold); background: var(--consul-wash); box-shadow: inset 3px 0 0 var(--consul-gold); }
.consul-name { font-family: var(--font-display); font-size: 1.25rem; }
.list { display: grid; }
.list-row { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .7rem; padding: .5rem .1rem; border-bottom: 1px solid var(--line);
  font-size: .88rem; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 12rem; }
.list-empty { color: var(--muted); font-size: .86rem; padding: .3rem 0; }
.code-card { border: 1px solid var(--accent); border-radius: var(--r-card); padding: .8rem; display: grid; gap: .45rem; margin: .5rem 0;
  background: var(--info-wash); }
.code-card code { font-family: var(--font-mono); font-size: .9rem; overflow-wrap: anywhere; background: var(--card); padding: .45rem .55rem;
  border-radius: 6px; border: 1px solid var(--line); }
.pool-edit { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; width: 100%; }

.storage { display: grid; gap: .8rem; }
.storage-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .3rem .8rem; }
.storage-used { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.storage-used small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.storage-bar .track { height: 10px; border-radius: 5px; }
.storage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin: 0; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .65rem; background: var(--bg); display: grid; gap: .1rem; }
.stat dt { font-size: .74rem; color: var(--muted); }
.stat dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-weight: 400; font-size: .74rem; color: var(--muted); }
.storage-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }

/* ============================================================================
   9. Dialogs: quick switcher, help, details, forms
   ============================================================================ */
dialog.sheet { border: 1px solid var(--line); border-radius: 16px; background: var(--raised); color: var(--text);
  box-shadow: var(--shadow-float); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); }
dialog.sheet::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
dialog.qs { margin-top: 12vh; }
.qs-form { padding: .6rem; border-bottom: 1px solid var(--line); }
.qs-form input { border: 0; box-shadow: none; font-size: 1rem; background: transparent; }
.qs-list { list-style: none; margin: 0; padding: .35rem; max-height: min(60dvh, 420px); overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; border-radius: 8px; cursor: pointer; }
.qs-item[aria-selected="true"] { background: var(--selected); }
.qs-kind { margin-left: auto; font-size: .72rem; color: var(--muted); }
.qs-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--code); color: var(--muted);
  font-size: .8rem; flex: none; }
.qs-hint { font-size: .75rem; padding: .4rem .9rem .6rem; }
.qs-section { font-size: .72rem; font-weight: 600; color: var(--muted); padding: .55rem .55rem .2rem; margin-top: .25rem;
  border-top: 1px solid var(--line); }
.qs-section:first-child { margin-top: 0; border-top: 0; }
.qs-item .conv-text { flex: 1; min-width: 0; }
.qs-item.is-message .qs-kind { flex: none; font-variant-numeric: tabular-nums; }
dialog.help { padding: 1.1rem 1.2rem; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; margin: .9rem 0 1.1rem; font-size: .9rem; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }
.sheet-form { display: grid; gap: .7rem; padding: 1.1rem 1.2rem; }
.sheet-actions { display: flex; justify-content: flex-end; gap: .5rem; }

.lifecycle-body { display: grid; gap: .9rem; font-size: .86rem; }
.lc-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.lc-steps li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: .55rem; align-items: baseline; padding: .25rem 0;
  position: relative; }
.lc-steps li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); transform: translateY(1px); }
.lc-steps li.is-missing::before { background: transparent; border: 1.5px solid var(--line-strong); }
.lc-steps li.is-missing { color: var(--muted); }
.lc-steps time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.dur { display: grid; gap: .35rem; }
.dur-row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 5rem; gap: .6rem; align-items: center; font-size: .82rem; }
.dur-row .track { height: 6px; border-radius: 3px; }
.dur-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.dur-row.is-total { font-weight: 650; }
.dur-row.is-total .val { color: var(--text); }
.attempts { width: 100%; border-collapse: collapse; font-size: .8rem; }
.attempts th, .attempts td { text-align: left; padding: .3rem .4rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.attempts th { color: var(--muted); font-weight: 600; }

/* ============================================================================
   9b. Wave 2: toasts, control plane, group chats, Senate Servers
   ============================================================================ */

/* Toasts: the only transient floating layer; bottom right on desktop, bottom centre on phones. */
.toasts { position: fixed; z-index: 80; right: 1.2rem; bottom: max(1.2rem, env(safe-area-inset-bottom)); display: grid; gap: .4rem;
  width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .5rem; padding: .5rem .45rem .5rem .85rem; border-radius: 10px;
  background: var(--raised); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow-float); font-size: .86rem;
  animation: toast-in .16s ease-out; transition: opacity .2s ease-out; }
.toast.is-ok { box-shadow: inset 3px 0 0 var(--ok), var(--shadow-float); }
.toast.is-bad { box-shadow: inset 3px 0 0 var(--bad), var(--shadow-float); }
.toast.is-leaving { opacity: 0; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { flex: none; width: 30px; min-height: 30px; padding: 0; color: var(--muted); font-size: 1.05rem; line-height: 1; }
.toast-close:hover { color: var(--text); background: var(--hover); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* Control plane: consumer liveness, wake method and the Wake action. */
.consumer { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.consumer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.consumer.is-on .consumer-dot { background: var(--ok); }
.consumer.is-off { color: var(--muted); }
.consumer-sub { flex-basis: 100%; padding-left: calc(8px + .35rem); font-size: .9em; }
.wake-info { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; flex-wrap: wrap; }
.wake-target { font-family: var(--font-mono); font-size: .76rem; background: var(--code); padding: .02rem .35rem; border-radius: 5px;
  min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wake-btn { display: inline-flex; align-items: center; gap: .35rem; }
.wake-btn svg { flex: none; }

/* Senate sections: Governance and Servers. */
.senate-tabs { justify-self: start; display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line); }
.senate-tab { min-height: 32px; padding: .25rem .9rem; font-size: .88rem; color: var(--muted); border-radius: 7px; }
.senate-tab:hover { color: var(--text); }
.senate-tab[aria-selected="true"] { background: var(--raised); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }
.senate-panel { display: grid; gap: .8rem; }
.senate-panel[hidden] { display: none; }
.control-list { display: grid; }
.control-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 7rem) minmax(0, 8.5rem) minmax(0, 1.3fr) auto;
  align-items: center; gap: .4rem .8rem; padding: .5rem .1rem; border-bottom: 1px solid var(--line); font-size: .86rem; }
.control-row:last-child { border-bottom: 0; }
.control-row > * { min-width: 0; }
.control-who { display: flex; align-items: center; gap: .55rem; }
.control-name { display: grid; min-width: 0; line-height: 1.25; }
.control-name .muted { font-size: .78rem; }
.control-status .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.control-row .wake-btn { min-height: 32px; padding: .2rem .7rem; font-size: .82rem; }
@media (max-width: 760px) {
  .control-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who btn" "status status" "consumer consumer" "wake wake"; }
  .control-who { grid-area: who; } .control-row .wake-btn { grid-area: btn; } .control-status { grid-area: status; }
  .control-consumer { grid-area: consumer; } .control-wake { grid-area: wake; }
}

/* Project and task chats in Conversations: a square tile (people stay round), a kind tag, members. */
.group-tile { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--muted);
  background: var(--code); border: 1px solid var(--line); }
.group-tile.is-sm { width: 28px; height: 28px; border-radius: 8px; }
.conv-row.is-group .conv-main:hover .group-tile, .conv-row.is-group.active .group-tile { color: var(--text); }
.tag-group { flex: none; font-size: .66rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); padding: 0 .38rem; line-height: 1.5; }
.conv-members { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.conv-header.is-group .conv-who { flex: 1; }
.group-stack { flex: none; display: inline-flex; margin-left: auto; }
@media (max-width: 479px) { .group-stack { display: none; } }

/* Per-recipient delivery under group messages: "@alpha delivered", "@beta waiting". */
.dlv-row { display: inline-flex; flex-wrap: wrap; gap: .25rem .3rem; justify-content: flex-end; min-width: 0; }
.msg:not(.mine) .dlv-row { justify-content: flex-start; }
.dlv { display: inline-flex; align-items: center; gap: .28rem; font-size: .72rem; line-height: 1.5; color: var(--muted);
  padding: 0 .45rem 0 .38rem; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--card); max-width: 100%; }
.dlv-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.dlv-who { font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlv.is-ok .dlv-dot { background: var(--ok); }
.dlv.is-info .dlv-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); }
.dlv.is-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.dlv.is-warn .dlv-dot { background: var(--warn); }
.dlv.is-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-wash); }
.dlv.is-bad .dlv-dot { background: var(--bad); }
.dlv.is-bad .dlv-who, .dlv.is-warn .dlv-who { color: inherit; }

/* Group composer: a quiet routing hint and the @mention list above the message box. */
.composer { position: relative; }
.route-hint { display: inline-flex; align-items: center; gap: .3rem; min-width: 0; max-width: 100%; font-size: .78rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; }
.route-who { color: var(--accent); font-weight: 600; }
.route-hint[data-route="none"] { color: var(--warn); }
.route-unknown { color: var(--warn); margin-left: .2rem; overflow: hidden; text-overflow: ellipsis; }
.mention-pop { position: absolute; left: .7rem; bottom: calc(100% - .35rem); z-index: 30; list-style: none; margin: 0; padding: .3rem;
  width: min(320px, calc(100% - 1.4rem)); display: grid; gap: 1px; background: var(--raised); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-float); }
.mention-item { display: flex; align-items: center; gap: .5rem; min-height: 36px; padding: .3rem .5rem; border-radius: 7px;
  cursor: pointer; font-size: .86rem; min-width: 0; }
.mention-item[aria-selected="true"] { background: var(--selected); }
.mention-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-handle { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.mention-tag { margin-left: auto; flex: none; font-size: .68rem; color: var(--muted); border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); padding: 0 .4rem; }

/* Projects: the card opens the project, its chat button opens the project chat. */
/* Desktop: the chat button sits in the card's top-right corner, so the footer keeps the full width. */
.proj-card { position: relative; display: block; padding: 0; cursor: pointer; }
.proj-card-main { display: grid; gap: .35rem; padding: .6rem .65rem; text-align: left; border: 0; border-radius: 10px;
  background: transparent; font-weight: 400; min-width: 0; width: 100%; min-height: 0; }
.proj-card-main:hover { background: transparent; }
.proj-card-main:focus-visible { outline-offset: -2px; }
.proj-card-top { padding-right: 2.1rem; }
.proj-card > .proj-chat { position: absolute; top: .38rem; right: .38rem; width: 30px; height: 30px; }
@media (pointer: coarse), (max-width: 959px) {
  .proj-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .proj-card-top { padding-right: 0; }
  .proj-card > .proj-chat { position: static; width: 44px; height: 44px; margin: .3rem .3rem 0 0; }
}
.chat-btn { display: inline-flex; align-items: center; gap: .35rem; position: relative; }
.chat-btn svg { flex: none; }
.chat-btn.has-unread { color: var(--accent); }
.icon-btn.chat-btn .count-badge { position: absolute; top: 0; right: 0; min-width: 1rem; height: 1rem; font-size: .6rem; padding: 0 .22rem; }
.task-side .task-chat { width: 32px; height: 32px; }
.task-person { display: inline-flex; align-items: center; gap: .2rem; }
.lead-tag { font-size: .66rem; font-weight: 650; color: var(--muted); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  padding: 0 .38rem; margin-right: .25rem; line-height: 1.5; }

/* Senate Servers: offline map, filters, the node list and the selected node. */
.servers-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .3rem .7rem; margin-bottom: .3rem; }
.servers-head > button { margin-left: auto; align-self: center; }
.servers-map { position: relative; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--map-sea);
  padding: .55rem; }
.wmap { position: relative; width: 100%; aspect-ratio: 360 / 142; }
.wmap-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: calc(var(--r-card) - 3px); overflow: hidden; }
.wmap-grid line { stroke: var(--map-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.wmap-equator { stroke: var(--map-grid); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.wmap-land { fill: var(--map-land); stroke: var(--map-coast); stroke-width: .7; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.wmap-pins { position: absolute; inset: 0; }
.wmap-pin { --pin: var(--ok); position: absolute; width: 22px; height: 22px; min-height: 0; margin: -11px 0 0 -11px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.wmap-pin.is-maintenance { --pin: var(--warn); }
.wmap-pin.is-offline { --pin: var(--bad); }
.wmap-pin.is-retired { --pin: var(--muted); }
.wmap-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pin);
  box-shadow: 0 0 0 2px var(--map-sea), 0 0 0 5px color-mix(in srgb, var(--pin) 20%, transparent); transition: transform .12s ease-out; }
.wmap-pin.is-retired .wmap-dot { background: var(--map-sea); box-shadow: inset 0 0 0 2px var(--pin), 0 0 0 2px var(--map-sea); }
.wmap-pin:hover, .wmap-pin.is-hover, .wmap-pin.is-selected, .wmap-pin:focus-visible { z-index: 2; }
.wmap-pin:hover .wmap-dot, .wmap-pin.is-hover .wmap-dot, .wmap-pin:focus-visible .wmap-dot { transform: scale(1.3); }
.wmap-pin.is-selected .wmap-dot { box-shadow: 0 0 0 2px var(--map-sea), 0 0 0 4px var(--accent); }
.wmap-pin:focus-visible { outline: none; }
.wmap-tip { position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%); white-space: nowrap; font-size: .72rem;
  font-weight: 500; padding: .15rem .45rem; border-radius: 6px; background: var(--text); color: var(--card); box-shadow: var(--shadow-float);
  opacity: 0; pointer-events: none; transition: opacity .12s ease-out; }
.wmap-pin:hover .wmap-tip, .wmap-pin.is-hover .wmap-tip, .wmap-pin.is-selected .wmap-tip, .wmap-pin:focus-visible .wmap-tip { opacity: 1; }
.servers-unplaced { margin-top: .35rem; }
.servers-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .8rem; margin: .8rem 0 .3rem; }
.servers-filter { flex: 1 1 220px; max-width: 340px; }
.servers-tools .filters { margin: 0; }
.filter .sv-dot { margin-right: .35rem; }
.filter-n { margin-left: .35rem; color: var(--muted); font-weight: 500; }
.servers-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; margin-top: .4rem; align-items: start; }
@media (min-width: 1100px) { .servers-body { grid-template-columns: minmax(0, 1.55fr) minmax(250px, 1fr); } }
.servers-list { display: grid; container-type: inline-size; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.servers-list > .list-empty { padding: .7rem .8rem; }
.server-item + .server-item { border-top: 1px solid var(--line); }
.server-row { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1.3fr) minmax(0, 6.4rem) minmax(0, 1fr) minmax(0, 8.6rem);
  align-items: center; gap: .65rem; text-align: left; padding: .45rem .75rem; border: 0; border-radius: 0; font-weight: 400;
  min-height: 46px; font-size: .86rem; }
.server-row > * { min-width: 0; }
.server-row:hover, .server-row.is-hover { background: var(--hover); }
.server-row.is-selected { background: var(--selected); box-shadow: inset 3px 0 0 var(--accent); }
.sv-name { display: grid; line-height: 1.25; }
.sv-slug { font-size: .74rem; }
.sv-status { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-addr { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
@container (max-width: 520px) {
  .server-row { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .sv-where, .sv-addr { display: none; }
}
.sv-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.sv-dot.is-active { background: var(--ok); }
.sv-dot.is-maintenance { background: var(--warn); }
.sv-dot.is-offline { background: var(--bad); }
.sv-dot.is-retired { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.servers-detail { border: 1px solid var(--line); border-radius: 10px; padding: .75rem .85rem; display: grid; gap: .6rem; align-content: start;
  min-width: 0; }
.servers-detail > * { min-width: 0; }
.servers-hint { font-size: .86rem; }
.sv-detail-head { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.sv-detail-name { flex: 1; min-width: 0; margin: 0; color: var(--text); font-size: 1.02rem; font-weight: 650; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.sv-code { font-family: var(--font-mono); font-size: .78rem; background: var(--code); padding: .02rem .35rem; border-radius: 5px;
  overflow-wrap: anywhere; }
dialog input[aria-invalid="true"], dialog select[aria-invalid="true"] { border-color: var(--bad); }

/* ============================================================================
   10. Small screens, touch, motion
   ============================================================================ */
@media (max-width: 959px) {
  .search-trigger { min-width: 0; padding: .4rem .7rem; flex: 1; }
  .search-trigger kbd { display: none; }
  .tabs { gap: 0; justify-content: space-between; }
  .tab { padding: .4rem .45rem; font-size: .9rem; }
  #live { gap: 0; }
  #live .live-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0; }    /* visually hidden, still read aloud */
  .brand .wordmark { font-size: 1.3rem; }
  .brand { margin-right: 0; }
  .topbar { gap: .4rem; flex-wrap: wrap; }
  .tabs { order: 3; flex-basis: 100%; }
  #logout { padding: .4rem .6rem; }
  .messages { padding: .7rem .6rem 1rem; }
  .msg { max-width: 96%; }
  .agent-details { padding-left: .8rem; }
  .form-row > button { grid-column: 1 / -1; }   /* full-width actions on phones */
  .dur-row { grid-template-columns: 7.5rem minmax(0, 1fr) 4.2rem; }
}
@media (pointer: coarse), (max-width: 959px) {
  button, button.quiet, .tab, .seg-btn, .filter, .conv-pin, select, input:not([type="checkbox"]) { min-height: 44px; }
  .agent-actions button, .msg-foot .quiet, .conn-banner button, .task-side select, .rail-actions button,
  .ctx-menu button, .quota-alert button, .mode-pick select, .pick, .conv-group-toggle { min-height: 44px; }
  .pager-btn { width: 44px; height: 44px; }
  .task-who button { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; }
  /* 44 px hit area around the 24 px visible remove dot */
  .staged-image .remove { width: 44px; height: 44px; top: -8px; right: -8px; background: transparent; isolation: isolate; }
  .staged-image .remove::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; z-index: -1;
    background: rgba(15, 17, 20, .72); }
  .icon-btn, .conv-pin { width: 44px; height: 44px; }
  .load-earlier, .latest-pill { min-height: 44px; }
  .quote { display: flex; align-items: center; min-height: 36px; }
  .quote-text { flex: 1; }
  .ts-item { min-height: 44px; }
  .task-side .task-chat { width: 44px; height: 44px; }
  .senate-tab, .mention-item, .control-row .wake-btn, .toast-close, .server-row { min-height: 44px; }
  .toast-close { width: 44px; }
  .wmap-pin { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .theme-toggle { min-height: 44px; display: inline-grid; place-items: center; }
  input, select, textarea { font-size: max(16px, 1rem); }
  .composer textarea { font-size: 16px; }
  .composer-left, .composer-right, .agent-actions, .sheet-actions { gap: .5rem; }
}
@media (max-width: 479px) {
  .search-trigger { gap: .35rem; padding: .4rem .55rem; }
  .search-trigger .search-label { padding-right: .15rem; }
}
@media (max-width: 959px) {
  .toasts { right: auto; left: 50%; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  .toast { animation: none; }
  .msg.is-jump-target > .bubble { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
}
