/* wysdm mock v2 — app.css: shared anatomy (SPEC-V2 §3).
   Builders 2/3: reuse these primitives; page-specific styles go in your own
   css files. Dark only, 1440x900 target. */

/* ================= base ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* literal black on html so a stale/missing tokens.css can never flash white */
html { background: #030304; }
body {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-1);
  background: var(--bg-app, #030304);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
/* press states are scoped (A8) — whole rows must not squash on click */
.tb-btn:active, .m-actions button:active,
.fr-btn:active, .cp-ic:active, .sb-plus:active, .tp-close:active { transform: scale(.94); }
/* text inputs: quiet by default — no UA chrome, no loud focus ring */
input { appearance: none; -webkit-appearance: none; font: inherit; color: inherit; background: none; border: 0; }
input:focus-visible { outline: none; }
input::placeholder { color: var(--text-3); }
a { color: var(--accent-400); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
::selection { background: var(--selection); }

/* scrollbars — thin, quiet */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

.icon { width: 18px; height: 18px; flex: none; display: block; }
.icon.sm { width: 16px; height: 16px; }

/* section headers — 11px uppercase */
.section-h {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--track-label); color: var(--text-3);
}

/* numeric alignment helper — timestamps, counters, durations */
.tnum { font-variant-numeric: tabular-nums; }

/* liquid glass — floating chrome ONLY. Never on base panels. */
.glass {
  background: var(--glass-grad), var(--glass-bg);
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: var(--edge-hi-strong), var(--shadow-3);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--bg-popover); }
}

/* ================= app frame =================
   Discord frame DNA: panels float on a near-black backdrop, each with a grey
   outline; every internal seam uses the same --line grey and every header is
   48px tall so the hairlines land on one continuous grid across panels. */
.app { position: relative; display: flex; height: 100vh; min-width: 1080px; background: var(--bg-app); }
.panel {
  flex: 1; min-width: 0; display: flex;
  margin: 8px 8px 8px 8px;
  background: var(--bg-content);
  border: 1px solid var(--line-outer); border-radius: 12px;
  overflow: hidden;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-content); }

/* main view switching (group "main") */
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

/* chat views opt in with class "ov" on the <section class="view"> — content
   scrolls beneath a glass topbar (A3). */
.view.ov { position: relative; }
.view.ov > .topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  background: var(--bg-content);                 /* solid fallback */
  border-bottom: 1px solid var(--line);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .view.ov > .topbar {
    background: var(--glass-bg-heavy);
    -webkit-backdrop-filter: var(--glass-blur-light); backdrop-filter: var(--glass-blur-light);
  }
}
.view.ov > .chat { padding-top: 64px; }

/* ================= rail (68px) ================= */
.rail {
  width: 68px; flex: none; background: transparent;  /* sits on the black backdrop */
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 8px;
  --presence-ring: var(--bg-app);
}
.rail-btn {
  position: relative; width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--text-2);
  background: var(--bg-elevated);
  box-shadow: var(--edge-hi), var(--shadow-1);
  transition: border-radius var(--t-med) var(--ease), background var(--t-fast) var(--ease),
              transform var(--t-med) var(--ease);
}
/* hover/selected = squircle morph + slight grow (no Discord white pill) */
.rail-btn:hover, .rail-btn.active { border-radius: 16px; transform: scale(1.08); }
.rail-btn:hover { color: var(--text-1); }
.rail-btn.active { color: var(--text-1); background: var(--bg-popover); }
.rail-btn:active { transform: scale(1.0); }   /* press settles back down */
.rail-btn.unread { color: var(--text-1); }    /* unread = brighter monogram + count badge */
.rail-btn.logomark { background: var(--brand); color: #fff; font-size: 21px; }
.rail-btn.logomark:hover { background: var(--brand-hover); }
.rail-btn.add { background: none; border: 1px dashed var(--border-strong); color: var(--text-3); font-size: 20px; font-weight: 400; box-shadow: none; }
.rail-btn.add:hover { color: var(--text-1); background: var(--hover); }
.rail-badge {
  position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px;
  padding: 0 4px; background: var(--count-bg); color: var(--count-fg);
  border-radius: 9px; border: 3px solid var(--bg-app);
  font-size: 10.5px; font-weight: 600; line-height: 12px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
}
.rail-sep { width: 24px; height: 1px; flex: none; background: var(--border-strong); margin: 2px 0; }

/* ================= sidebar (248px, floating panel) ================= */
.sidebar {
  width: 248px; flex: none; background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  margin: 8px 0 68px 6px;                     /* 68px: room for the floating user card */
  border: 1px solid var(--line-outer); border-radius: 12px;
  --presence-ring: var(--bg-sidebar);
}
.sb-header {
  height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600; letter-spacing: var(--track-tight);
}
.sb-header .chev { color: var(--text-3); font-size: 12px; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 8px 0 12px; }
.sb-row {
  position: relative;
  width: calc(100% - 16px); min-height: 32px; margin: 1px 8px;
  padding: 0 8px; border-radius: var(--r-md);
  display: flex; align-items: center; gap: 10px;
  color: var(--text-2); font-size: 13px;
  transition: background var(--t-fast) var(--ease);
}
/* Discord-style active pill indicator (A7) */
.sb-row.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; translate: 0 -50%;
  width: 3px; height: 16px; border-radius: 0 2px 2px 0; background: var(--text-1);
}
.sb-row:hover { background: var(--hover); color: var(--text-1); }
.sb-row.active { background: var(--selected); color: var(--text-1); }
.sb-row .icon { color: var(--text-3); }
.sb-row.active .icon, .sb-row:hover .icon { color: var(--text-2); }
.sb-row.unread { color: var(--text-1); font-weight: 500; }
.sb-row .unread-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-1); margin-left: auto; flex: none; }

/* count pill — muted red, tiny (A6) */
.count-pill {
  margin-left: auto; flex: none; min-width: 17px; height: 16px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--count-bg); color: var(--count-fg);
  font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* hover-revealed row action (A12 — used by DM rows) */
.row-x {
  display: none; margin-left: auto; flex: none;
  width: 18px; height: 18px; border-radius: var(--r-sm);
  align-items: center; justify-content: center;
  color: var(--text-3); font-size: 11px;
}
.dm-row:hover .row-x { display: flex; }
.row-x:hover { color: var(--text-1); }
.dm-row:hover .count-pill, .dm-row:hover .unread-dot { display: none; }
.sb-section {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 4px 16px;
}
.sb-section .sb-plus { color: var(--text-3); font-size: 15px; line-height: 1; padding: 0 2px; }
.sb-section .sb-plus:hover { color: var(--text-1); }

/* search pill at top of home sidebar — 48px so its hairline joins the grid */
.sb-search {
  height: 48px; flex: none; display: flex; align-items: center;
  padding: 0 8px; border-bottom: 1px solid var(--line);
}
.search-pill {
  width: 100%; height: 28px; border-radius: var(--r-sm);
  background: var(--bg-sunken); color: var(--text-3);
  font-size: 12.5px; padding: 0 8px; display: flex; align-items: center;
}
.search-pill:hover { color: var(--text-2); }

/* ================= user card (floating, spans rail + sidebar) ============
   Discord frame DNA: the user panel detaches from the sidebar and floats on
   the black backdrop, outlined like every other panel. */
.user-footer {
  position: absolute; left: 8px; bottom: 8px; z-index: 20;
  width: 314px;                     /* rail 68 + gutter 6 + sidebar 248 - left 8 */
  height: 52px;
  background: var(--bg-sidebar);
  border: 1px solid var(--line-outer); border-radius: 12px;
  box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  --presence-ring: var(--bg-sidebar);
}
.user-footer .uf-meta { flex: 1; min-width: 0; line-height: 1.25; }
.user-footer .uf-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.user-footer .uf-status { display: block; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-footer .uf-gear {
  width: 30px; height: 30px; border-radius: var(--r-md); flex: none;
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
}
.user-footer .uf-gear:hover { background: var(--hover); color: var(--text-1); text-decoration: none; }

/* ================= top bar (48px) ================= */
.topbar {
  height: 48px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; border-bottom: 1px solid var(--line);
}
.tb-icon { color: var(--text-3); display: flex; }
.tb-name { font-size: 14px; font-weight: 600; white-space: nowrap; letter-spacing: var(--track-tight); }
.tb-topic {
  font-size: 13px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
  border-left: 1px solid var(--border); padding-left: 12px; margin-left: 4px;
}
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.tb-btn {
  width: 30px; height: 30px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
}
.tb-btn:hover { color: var(--text-1); background: var(--hover); }
.tb-btn.labeled { width: auto; padding: 0 8px; gap: 6px; font-size: 12px; color: var(--text-2); }
.tb-btn.labeled.active { background: var(--selected); color: var(--text-1); }
.tb-search {
  width: 180px; height: 26px; margin: 0 6px;
  background: var(--bg-sunken); border-radius: var(--r-sm);
  color: var(--text-3); font-size: 12px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 8px;
  border: 1px solid transparent;
  cursor: text;
}
.tb-search-in {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  font: inherit; font-size: 12px; color: var(--text-1);
}
.tb-search-in::placeholder { color: var(--text-3); }
.tb-search:focus-within {
  border-color: var(--line); color: var(--text-1);
  box-shadow: 0 0 0 1px var(--focus-ring);
}
.tb-divider { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

/* ================= members panel (240px) ================= */
.members {
  width: 240px; flex: none; background: var(--bg-sidebar);
  border-left: 1px solid var(--line);
  overflow-y: auto; padding: 12px 8px;
  --presence-ring: var(--bg-sidebar);
}
.members .section-h { padding: 10px 8px 4px; display: block; }
.member-row {
  width: 100%; min-height: 44px; padding: 5px 8px; border-radius: var(--r-md);
  display: flex; align-items: center; gap: 10px;
}
.member-row:hover { background: var(--hover); }
.member-row .mr-meta { flex: 1; min-width: 0; line-height: 1.3; }
.member-row .mr-name {
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  min-width: 0; overflow: hidden; /* nothing in the fixed panel may overrun */
}
.member-row .mr-status {
  display: block;
  font-size: 11.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-row .mr-name.role-owner { color: var(--role-owner); }
.member-row .mr-name.role-core { color: var(--role-core); }
.member-row .mr-name.role-design { color: var(--role-design); }

/* ================= avatars (per-cast duotone SVG art) ================= */
.avatar {
  position: relative; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
  color: transparent;                    /* initials stay in DOM, SVG art shows */
  background: var(--av-group-a);         /* pre-JS fallback fill */
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07), inset 0 1px 0 rgba(255,255,255,.08);
  user-select: none;
}
.avatar.agent { border-radius: 28%; }    /* agents = squircle */
.avatar.sz32 { width: 32px; height: 32px; font-size: 13px; }
.avatar.sz24 { width: 24px; height: 24px; font-size: 10.5px; }
.avatar.sz16 { width: 16px; height: 16px; font-size: 8px; font-weight: 500; }

/* presence — Discord-style ring cutout in the host panel's bg color */
.presence {
  position: absolute; right: -3px; bottom: -3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--ok);
  border: 3px solid var(--presence-ring, var(--bg-sidebar));
}
.presence.working { background: var(--warn); animation: presence-pulse 2s var(--ease) infinite; }
.presence.idle { background: none; box-shadow: inset 0 0 0 2px var(--text-3); }
.presence.dnd { background: var(--danger); }
@keyframes presence-pulse { 50% { opacity: .5; } }

/* ================= badges & chips ================= */
.badge {
  display: inline-flex; align-items: center; flex: none;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; border-radius: var(--r-sm); padding: 2px 5px;
  line-height: 1.2; vertical-align: 2px;
}
.badge.agent { background: rgba(61,85,230,.20); color: var(--accent-300); }
.badge.clone { border: 1px solid var(--accent-300); color: var(--accent-300); }
.badge.space { border: 1px solid var(--border); color: var(--text-2); }
.harness { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 2px 8px; line-height: 1.5; white-space: nowrap;
}
.chip.muted { color: var(--text-3); }

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, #2136cf, #101fa0);   /* brand-hue fill, gradient-lit */
  color: #fff;
  font-size: 13px; font-weight: 500;
  border-radius: var(--r-md); padding: 6px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 1px 2px rgba(0,0,0,.40);
  transition: background var(--t-fast) var(--ease);
}
.btn:hover { background: linear-gradient(180deg, #2f45e0, #1a2ec0); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0,0,0,.30); }
.btn.sm { font-size: 12px; padding: 4px 10px; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  border-radius: var(--r-md); padding: 5px 13px;
  transition: background var(--t-fast) var(--ease);
}
.btn-ghost:hover { background: var(--hover); color: var(--text-1); text-decoration: none; }
.btn-ghost.sm { font-size: 12px; padding: 3px 9px; }

/* ================= chat / messages ================= */
.chat { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 0 8px; }
.mrow { position: relative; padding: 2px 16px 2px 72px; }
.mrow.first { margin-top: 16px; }
.mrow:hover { background: var(--hover); }
.m-av { position: absolute; left: 16px; top: 2px; }
.m-head { display: flex; align-items: center; gap: 8px; min-height: 22px; flex-wrap: wrap; }
.m-name { font-size: 15px; font-weight: 600; letter-spacing: var(--track-tight); }
.m-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.m-body { font-size: var(--fs-msg); line-height: var(--lh-msg); color: var(--text-1); max-width: 720px; }
.m-body .dim { color: var(--text-2); }
.day-divider {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  color: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-faint); }

/* NEW unread divider — accent, quiet (A10) */
.day-divider.new { color: var(--accent-400); padding: 4px 16px; }
.day-divider.new::before, .day-divider.new::after { background: rgba(107,130,244,.35); }

/* mentions + wikilinks */
.mention {
  background: var(--mention-bg); color: var(--mention-fg);
  border-radius: var(--r-sm); padding: 0 3px; font-weight: 500;
}
.wikilink { color: var(--accent-400); cursor: pointer; }
.wikilink:hover { text-decoration: underline; }

/* hover action bar (floating glass pill, top-right of message) */
.m-actions {
  position: absolute; top: -14px; right: 16px; z-index: 2;
  display: none; align-items: center;
  background: var(--glass-grad), var(--glass-bg);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--r-lg);
  box-shadow: var(--edge-hi-strong), var(--shadow-2);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .m-actions { -webkit-backdrop-filter: var(--glass-blur-light); backdrop-filter: var(--glass-blur-light); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .m-actions { background: var(--bg-popover); }
}
.mrow:hover .m-actions { display: flex; }
.m-actions button {
  width: 28px; height: 26px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 14px;
}
.m-actions button:hover { color: var(--text-1); background: var(--hover); }

/* quick reply (Discord-style curved connector + reference line) */
.reply-ref {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding-left: 58px; margin-bottom: 2px; min-height: 20px;
  font-size: 12px; color: var(--text-3); white-space: nowrap;
}
.reply-ref::before {
  content: ''; position: absolute; left: 36px; top: 9px;
  width: 17px; height: 16px;
  border-left: 1.6px solid var(--border-strong);
  border-top: 1.6px solid var(--border-strong);
  border-top-left-radius: 8px;
}
.reply-ref .rr-name { color: var(--text-2); font-weight: 500; }
.reply-ref .rr-snippet { overflow: hidden; text-overflow: ellipsis; }
/* a row with a reply reference: avatar drops to the NAME line so the
   connector reads as rising from the avatar column to the reference */
.mrow:has(> .reply-ref) .m-av { top: 24px; }

/* thread row (Slack-style) */
.thread-row {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 4px; font-size: 12.5px; color: var(--accent-400); padding: 0;
}
.thread-row:hover { text-decoration: underline; }

/* thread panel (replaces members panel, 320px) */
.thread-panel {
  width: 320px; flex: none; background: var(--bg-sidebar);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  --presence-ring: var(--bg-sidebar);
}
.thread-panel .tp-header {
  height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
}
.thread-panel .tp-close { color: var(--text-3); font-size: 14px; padding: 4px 6px; border-radius: var(--r-sm); }
.thread-panel .tp-close:hover { color: var(--text-1); background: var(--hover); }
.thread-panel .tp-body { flex: 1; overflow-y: auto; padding: 12px 0; }
.thread-panel .tp-parent { margin: 0 14px 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.thread-panel .mrow { padding-left: 56px; }
.thread-panel .m-av { left: 12px; }
.thread-panel .m-av .avatar { width: 32px; height: 32px; font-size: 13px; }  /* one size, always inline */
.thread-panel .m-name { font-size: 14px; }
.thread-panel .m-body { font-size: 14px; }
.thread-panel .tp-composer { margin: 8px 12px 20px; }  /* bottom 20px lines up with the main composer's baseline */

/* reactions */
.reactions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.rx {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 7px; border: 1px solid var(--border-faint); border-radius: var(--r-lg);
  background: var(--bg-elevated); font-size: 14px; line-height: 1.5;
  box-shadow: var(--edge-hi);
}
.rx .ct { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.rx:hover { border-color: var(--border-strong); }
.rx.own { background: var(--mention-bg); border-color: var(--accent-400); }
.rx.own .ct { color: var(--mention-fg); }

/* embeds / link cards */
.embed {
  background: var(--bg-elevated);
  border: 1px solid var(--border-faint); border-left: 2px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 10px 12px; margin-top: 6px; max-width: 460px;
  box-shadow: var(--edge-hi), var(--shadow-1);
}
.embed-title { font-size: 13.5px; font-weight: 600; color: var(--text-1); letter-spacing: var(--track-tight); }
.embed-desc { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.45; }
.embed-foot { font-size: 11px; color: var(--text-3); margin-top: 6px; }

/* generic elevated card (approval cards, hub cards, recap cards…)
   attachment rhythm: rich blocks (code/cards/approvals) 560px, link embeds 460px */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-faint); border-radius: var(--r-lg);
  padding: 12px 14px; margin-top: 6px; max-width: 560px;
  box-shadow: var(--edge-hi), var(--shadow-1);
}

/* code blocks + mono strips */
.code {
  background: var(--bg-sunken); border: 1px solid var(--border-faint);
  border-radius: var(--r-md); padding: 8px 12px; margin-top: 6px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  color: var(--text-2); max-width: 560px;
  white-space: pre; overflow-x: auto;
}
.mono-strip {
  background: var(--bg-sunken); border: 1px solid var(--border-faint);
  border-radius: var(--r-md); padding: 7px 10px; margin-top: 8px;
  font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--text-3);
}
.mono-strip b { color: var(--text-2); font-weight: 500; }

/* tool rows (Codex/Claude transcript depth — reused in session views) */
.trow {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-2);
  padding: 1px 0; width: 100%;
}
.trow .t-dot { color: var(--text-3); }
.trow .t-caret { color: var(--text-3); font-size: 10px; margin-left: 2px; display: inline-block; transition: transform var(--t-fast) var(--ease); }
.trow.open .t-caret { transform: rotate(90deg); }
button.trow:hover { color: var(--text-1); }
.tres {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-3);
  padding-left: 18px; line-height: 1.6;
}
.tmeta {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  margin-top: 6px; font-variant-numeric: tabular-nums;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-sunken); border: 1px solid var(--border-faint);
  border-radius: var(--r-md); padding: 3px 8px; margin-top: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
}
.file-chip .plus { color: var(--ok); }
.file-chip .minus { color: var(--danger); }

/* ================= knowledge primitives (index Knowledge + space Knowledge) */
.kn-body { flex: 1; min-height: 0; display: flex; }
.kn-list { width: 280px; flex: none; border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 8px; }
.kn-search {
  height: 28px; margin: 0 4px 10px; border-radius: var(--r-sm);
  background: var(--bg-sunken); border: 1px solid var(--border);
  color: var(--text-3); font-size: 12px; display: flex; align-items: center; padding: 0 8px;
}
/* the note search is a real input on every page */
input.kn-search {
  font-family: inherit; color: var(--text-1); outline: none;
  display: block; width: calc(100% - 8px);
}
input.kn-search::placeholder { color: var(--text-3); }
input.kn-search:focus { border-color: var(--focus-ring); }
.kn-row {
  width: 100%; padding: 8px 10px; border-radius: var(--r-md);
  display: block; line-height: 1.4;
}
.kn-row:hover { background: var(--hover); }
.kn-row.active { background: var(--selected); }
.kn-row .kn-title { font-size: 13px; font-weight: 500; color: var(--text-1); }
.kn-row .kn-sub { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.type-chip {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-2); padding: 1px 4px; flex: none;
}
.kn-caption { font-size: 11.5px; color: var(--text-3); padding: 12px 12px 4px; }
.kn-note { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 32px; }
.knote-body { display: none; max-width: 640px; }
.knote-body.active { display: block; }
.kn-front { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.kn-front .kn-updated { font-size: 11.5px; color: var(--text-3); }
.kn-note h1 { font-size: 20px; font-weight: 650; letter-spacing: var(--track-head); margin-bottom: 12px; }
.kn-note p, .kn-note li { font-size: 14px; line-height: 1.55; color: var(--text-2); }
.kn-note p { margin-bottom: 10px; }
.kn-note ul { margin: 0 0 10px 18px; }
.kn-note-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ---- tabs (friends tabs, knowledge list|graph modes) ---- */
.tab {
  height: 26px; padding: 0 10px; border-radius: var(--r-md);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center;
}
.tab:hover { background: var(--hover); color: var(--text-1); }
.tab.active { background: var(--selected); color: var(--text-1); box-shadow: var(--edge-hi); }

/* ---- knowledge graph: list|graph toggle + Obsidian-style canvas ---- */
.kn-modes { display: inline-flex; gap: 2px; margin-right: 6px; }

.kn-graph-pane { display: none; flex: 1; min-width: 0; min-height: 0; background: var(--bg-sunken); }
.graph-mode .kn-graph-pane { display: block; }
.graph-mode .kn-note, .graph-mode .kn-side { display: none; }
.kn-personal.graph-mode .kn-list { display: none; }

.kn-graph-svg { display: block; width: 100%; height: 100%; }
.kn-graph-svg .g-edge {
  stroke: rgba(255,255,255,.10); stroke-width: 1;
  transition: stroke var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.kn-graph-svg .g-node { cursor: pointer; transition: opacity var(--t-fast) var(--ease); }
.kn-graph-svg .g-node circle { fill: var(--text-3); transition: fill var(--t-fast) var(--ease); }
.kn-graph-svg .g-node text {
  fill: var(--text-3); font-size: 11px; text-anchor: middle;
  pointer-events: none; transition: fill var(--t-fast) var(--ease);
}
/* Obsidian signature move: hover a node -> it + neighbors brighten, rest dims */
.kn-graph-svg.dimmed .g-node:not(.hl) { opacity: .16; }
.kn-graph-svg.dimmed .g-edge:not(.hl) { opacity: .25; }
.kn-graph-svg .g-edge.hl { stroke: rgba(255,255,255,.30); }
.kn-graph-svg .g-node.hl circle { fill: var(--text-2); }
.kn-graph-svg .g-node.hl text { fill: var(--text-2); }
/* the accent ramp is reserved for the hovered node itself */
.kn-graph-svg .g-node.on circle { fill: var(--accent-400); }
.kn-graph-svg .g-node.on text { fill: var(--accent-300); }
/* nodes without a note behind them render as ghosts — dimmer, hollow
   (Obsidian shows unresolved links the same way) */
.kn-graph-svg .g-node.ghost circle,
.kn-graph-svg .g-node.ghost.on circle { fill: var(--bg-sunken); stroke: var(--text-3); stroke-width: 1; }
.kn-graph-svg .g-node.ghost text { opacity: .7; }
.kn-graph-svg .g-node.ghost.hl circle,
.kn-graph-svg .g-node.ghost.on circle { stroke: var(--text-1); }
.kn-graph-svg .g-node.ghost.on text { fill: var(--text-2); }

/* ================= composer ================= */
.composer-wrap { flex: none; padding: 4px 16px 20px; }
.composer {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-xl); min-height: 46px; padding: 0 12px;
  box-shadow: var(--edge-hi), var(--shadow-1);
}
.composer .cp-plus {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); border: 0; background: var(--active);
  font-size: 15px; line-height: 1;
}
.composer .cp-plus:hover { background: var(--selected); color: var(--text-1); }
.composer .cp-ph { flex: 1; color: var(--text-3); font-size: 14px; user-select: none; }
.composer .cp-ic { color: var(--text-3); display: flex; padding: 5px; border-radius: var(--r-sm); }
.composer .cp-ic:hover { background: var(--hover); color: var(--text-1); }
.composer.focus {           /* demoed on # dev only (S5.8) — kept quiet so the
                               approval card stays the loudest thing on the page */
  border-color: var(--focus-ring);
  box-shadow: var(--edge-hi), 0 0 0 2px var(--focus-tint), var(--shadow-1);
}
.composer-caption { font-size: 11px; color: var(--text-3); padding: 5px 4px 0; }

/* ================= chat texture (A10) ================= */
/* slim new-messages banner — glass, accent-tinted, restrained (not blurple) */
.newbar {
  position: absolute; top: 48px; left: 0; right: 0; z-index: 4;
  height: 26px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--mention-fg);
  background: linear-gradient(180deg, rgba(61,85,230,.16), rgba(61,85,230,.10));
  border-bottom: 1px solid rgba(107,130,244,.18);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .newbar { -webkit-backdrop-filter: var(--glass-blur-light); backdrop-filter: var(--glass-blur-light); }
}
.newbar button { color: var(--mention-fg); font-size: 11px; font-weight: 600; }
.newbar button:hover { color: var(--text-1); }

/* typing indicator row — reserved line above composer */
.typing-row {
  height: 20px; display: flex; align-items: center; gap: 7px;
  padding: 0 6px; font-size: 12px; color: var(--text-3);
}
.typing-row b { font-weight: 500; color: var(--text-2); }
.typing-row .tdots { display: flex; gap: 3px; }
.typing-row .tdots i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--text-3);
}
.typing-row .tdots { animation: typing-fade 1.2s var(--ease) infinite; } /* one animating element */
@keyframes typing-fade { 50% { opacity: .35; } }

/* ================= expand/collapse (0fr/1fr grid trick) ============ */
/* fr-unit transitions stall in some embedded engines — expand the track
   instantly, animate the content reveal (opacity + drift) instead */
.collapse { display: grid; grid-template-rows: 0fr; }
.collapse.open { grid-template-rows: 1fr; }
.collapse > .c-inner {
  overflow: hidden; min-height: 0;
  visibility: hidden; opacity: 0; transform: translateY(-2px); /* hidden matches aria-expanded for a11y/find-in-page */
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), visibility 0s var(--t-med);
}
.collapse.open > .c-inner {
  visibility: visible; opacity: 1; transform: none;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), visibility 0s;
}

/* generic disclosure trigger caret */
.tgl-caret { display: inline-block; font-size: 10px; color: var(--text-3); transition: transform var(--t-fast) var(--ease); }
.open > .tgl-caret, button.open .tgl-caret { transform: rotate(90deg); }

/* ================= spinner (one live element per view) ============ */
.spinner {
  width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 1.6px solid var(--border-strong); border-top-color: var(--accent-400);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= shared primitives (wysdm.* helpers) ================= */
/* toast — single transient element, bottom-center, floats above the user card.
   Shown/hidden by .show; transition only (no loop), killed by reduced-motion. */
.toast {
  position: fixed; left: 50%; bottom: 76px; z-index: 80;
  translate: -50% 4px;
  max-width: 440px; padding: 8px 14px; border-radius: var(--r-lg);
  font-size: 12.5px; color: var(--text-1); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease), translate var(--t-med) var(--ease);
}
.toast.show { opacity: 1; translate: -50% 0; }

/* popover menu — glass + shadow-3 (via .glass), positioned by wysdm.menu */
.menu {
  position: fixed; z-index: 90;
  min-width: 168px; padding: 4px;
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
}
.menu-item {
  width: 100%; padding: 6px 10px; border-radius: var(--r-md);
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
.menu-item:hover { background: var(--hover); color: var(--text-1); }

/* glass popover panels (wysdm.pop) — inbox tray, help, add-friend, api key,
   hq help / mini profile */
.pop {
  position: fixed; z-index: 90;
  min-width: 230px; max-width: 330px; padding: 8px;
  border-radius: var(--r-xl);
}
.pop-head {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3); padding: 4px 8px 6px;
}
.pop-item {
  display: block; width: 100%; padding: 7px 8px; border-radius: var(--r-md);
  font-size: 12.5px; color: var(--text-2); line-height: 1.4; text-align: left;
}
.pop-item:hover { background: var(--hover); color: var(--text-1); }
.pop-item strong { color: var(--text-1); font-weight: 600; }
.pop-card {
  background: var(--bg-sunken); border: 1px solid var(--border-faint);
  border-radius: var(--r-md); padding: 9px 10px; margin: 0 2px 8px;
  font-size: 12.5px; color: var(--text-1); line-height: 1.45;
}
.pop-card strong { font-weight: 600; }
.pop-link { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--accent-400); }
.pop-link:hover { text-decoration: underline; }
.pop-empty { padding: 6px 8px 8px; font-size: 12.5px; color: var(--text-3); }
.pop-input {
  width: 100%; height: 30px; padding: 0 9px; margin: 2px 0;
  border-radius: var(--r-md); background: var(--bg-sunken);
  border: 1px solid var(--border-faint); color: var(--text-1);
  font: inherit; font-size: 12.5px; outline: none;
}
.pop-input::placeholder { color: var(--text-3); }
.pop-input:focus { border-color: var(--focus-ring); }
.pop-kbd {
  display: flex; justify-content: space-between; align-items: center;
  gap: 18px; padding: 5px 8px; font-size: 12.5px; color: var(--text-2);
}
.pop-kbd kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.pop.emoji-pop { display: flex; gap: 2px; min-width: 0; padding: 6px; }
.pop.emoji-pop button { width: 30px; height: 30px; font-size: 16px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; }
.pop.emoji-pop button:hover { background: var(--hover); }
/* compact variant (hq) — tighter metrics, running text, close-X gutter */
.pop.compact {
  min-width: 0; max-width: 280px; padding: 10px 12px;
  border-radius: var(--r-lg); font-size: 12px; color: var(--text-2); line-height: 1.65;
}
.pop.has-x { padding-right: 26px; }
.pop h4 { font-size: 12.5px; font-weight: 600; color: var(--text-1); margin-bottom: 3px; }
.pop .kbd { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.pop .pop-x { position: absolute; top: 6px; right: 8px; color: var(--text-3); font-size: 11px; }
.pop .pop-x:hover { color: var(--text-1); }
.pop .emoji-grid { display: flex; gap: 2px; }
.pop .emoji-grid button { font-size: 16px; padding: 3px 6px; border-radius: var(--r-sm); }
.pop .emoji-grid button:hover { background: var(--hover); }
.pop .mini-prof { display: flex; gap: 10px; align-items: center; --presence-ring: var(--bg-popover); }
.pop .mini-prof .mp-name { font-weight: 600; color: var(--text-1); font-size: 13px; }
.pop .mini-prof .mp-role { font-size: 11px; color: var(--text-3); }
.pop .btn-ghost { margin-top: 8px; }

/* replying-to chip above the composer (wysdm.replyChip) */
.cp-reply {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 6px; padding: 5px 10px; border-radius: var(--r-md);
  background: var(--bg-elevated); border: 1px solid var(--border-faint);
  font-size: 12px; color: var(--text-3);
}
.cp-reply strong { color: var(--text-2); font-weight: 600; }
.cp-reply .cp-reply-snip {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cp-reply .cp-reply-x { color: var(--text-3); padding: 0 2px; flex: none; }
.cp-reply .cp-reply-x:hover { color: var(--text-1); }

/* clickable non-button rows/chips (JS adds role="button" + tabindex) */
.clickable { cursor: pointer; }

/* knowledge note editing state (wysdm.noteEditor) */
.knote-body.editing { outline: 1px dashed var(--border-strong); outline-offset: 10px; border-radius: 2px; }
.knote-body.editing:focus { outline-color: var(--accent-400); }
.kn-front .editing-chip { color: var(--accent-300); border-color: var(--accent-400); }

/* live composer input — wysdm.wireComposer swaps .cp-ph for this */
.composer .cp-input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  font: inherit; font-size: 14px; color: var(--text-1);
}
.composer .cp-input::placeholder { color: var(--text-3); }
/* focused live composer matches the demoed .focus treatment, stays quiet */
.composer:focus-within {
  border-color: var(--focus-ring);
  box-shadow: var(--edge-hi), 0 0 0 2px var(--focus-tint), var(--shadow-1);
}

/* live filter — wysdm.wireFilter hides non-matching rows */
.filter-hide { display: none !important; }

/* canonical JS hide (beats any display: flex/grid on the element) */
.hidden { display: none !important; }

/* ================= motion prefs ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
