/* Layout + components. Colors come only from theme.css tokens. */

.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;
}
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--ink); padding: var(--space-2) var(--space-3);
}
.skip-link:focus { left: var(--space-2); z-index: 100; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-on-dark);
  border-radius: var(--radius-sm); padding: 8px 12px; min-height: 36px;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--cyan) 88%, #fff), var(--cyan-dim, var(--cyan)));
  color: #041018; border-color: color-mix(in oklab, var(--cyan) 60%, #000);
  box-shadow: 0 0 16px color-mix(in oklab, var(--cyan) 28%, transparent);
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--cyan) 35%, transparent),
              0 0 20px color-mix(in oklab, var(--cyan) 40%, transparent);
}
.btn:hover:not(:disabled):not(.primary):not(.ghost) {
  background: var(--elevated, var(--surface));
  border-color: var(--line-strong, var(--line));
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-on-dark); }
.btn.ghost:hover:not(:disabled) { color: var(--ink); background: var(--elevated, var(--surface)); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-page {
  min-height: 100vh; display: grid; grid-template-rows: auto 1fr; place-items: center; padding: 0 var(--space-5) var(--space-5);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in oklab, var(--cyan) 22%, transparent), transparent),
    radial-gradient(ellipse 45% 35% at 100% 100%, color-mix(in oklab, var(--amber) 12%, transparent), transparent),
    var(--paper);
}
.auth-topbar {
  width: calc(100% + 2 * var(--space-5));
  margin-left: calc(-1 * var(--space-5));
}
.auth-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--cyan) 45%, var(--line));
  border-radius: var(--radius-lg); padding: var(--space-6);
  box-shadow: var(--panel-shadow);
}
.app-topbar {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 38px; padding: 6px var(--space-4);
  background: var(--surface); color: var(--ink-on-dark);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 var(--bevel-lo);
  font-size: 13px; line-height: 1;
}
.app-shell > .app-topbar {
  grid-column: 1 / -1; grid-row: 1;
}
.app-shell > .object-rail,
.app-shell > .ws-strip,
.app-shell > .channel-rail,
.app-shell > .conversation,
.app-shell > .right-pane,
.app-shell > .ledger-drawer {
  grid-row: 2;
  min-height: 0;
}
.app-shell > .object-rail,
.app-shell > .conversation { overflow: hidden; }
.app-shell > .channel-rail,
.app-shell > .right-pane,
.app-shell > .ledger-drawer { overflow: hidden; }
.app-brand {
  color: var(--ink-on-dark); text-decoration: none;
  font-family: var(--font-display); font-size: 15px; font-weight: 750;
  letter-spacing: -0.01em;
}
.app-brand:hover { color: var(--ink-on-dark); }
.app-topbar-sep { color: var(--ink-3); user-select: none; }
.app-version { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.beta-badge {
  color: #ff2a2a; font-size: 10px; font-weight: 900;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 8px; line-height: 1;
  border: 1px solid color-mix(in oklab, #ff2a2a 70%, #000);
  border-radius: 999px;
  background: color-mix(in oklab, #ff2a2a 14%, var(--surface));
  box-shadow: 0 0 12px color-mix(in oklab, #ff2a2a 35%, transparent);
}
.app-topbar-spacer { flex: 1 1 auto; }
.app-topbar-admin {
  font: inherit; font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; text-decoration: none;
  color: #041018; background: var(--cyan);
  border: 1px solid color-mix(in oklab, var(--cyan) 50%, #000);
  border-radius: 999px; padding: 5px 12px; line-height: 1;
  box-shadow: 0 0 12px color-mix(in oklab, var(--cyan) 35%, transparent);
}
.app-topbar-admin:hover { color: #041018; filter: brightness(1.08); }
.app-topbar-admin.ghost {
  background: transparent; color: var(--ink-on-dark);
  border-color: var(--line-strong);
  box-shadow: none;
}
.app-topbar-admin.ghost:hover { background: var(--elevated); color: var(--ink); }

.app-topbar-user {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 0; max-width: 18rem;
  padding: 3px 8px; border-radius: 999px;
  background: var(--elevated); border: 1px solid var(--line-strong, var(--line));
  color: var(--ink-on-dark); font-size: 12px; font-weight: 650;
  line-height: 1; white-space: nowrap; text-decoration: none;
}
.app-topbar-user[hidden] { display: none !important; }
.app-user-name {
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
  color: var(--ink-on-dark); font-weight: 700;
}
.app-user-admin {
  flex: 0 0 auto; font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: #041018; background: var(--cyan);
  border-radius: 999px; padding: 3px 7px; line-height: 1;
}
.app-user-admin[hidden] { display: none !important; }
.app-topbar-logout {
  flex: 0 0 auto; margin: 0; font: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer;
  color: var(--ink-on-dark); background: transparent;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 999px; padding: 5px 10px; line-height: 1;
}
.app-topbar-logout:hover { background: var(--elevated); color: var(--ink); }
.app-topbar-admin[hidden] { display: none !important; }


.wordmark {
  font-family: var(--font-display); font-weight: 750; font-size: 22px;
  color: var(--cyan); margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
  text-shadow: 0 0 18px color-mix(in oklab, var(--cyan) 45%, transparent);
}
.wordmark::after {
  content: "";
  display: inline-block; width: 0.55em; height: 0.9em; margin-left: 0.28em;
  vertical-align: -0.08em;
  background: var(--amber);
  clip-path: polygon(40% 0, 100% 0, 60% 42%, 100% 42%, 28% 100%, 48% 55%, 0 55%);
  filter: drop-shadow(0 0 6px color-mix(in oklab, var(--amber) 55%, transparent));
}
.auth-card h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 25px;
  margin: 0 0 var(--space-4);
}
.stack { display: grid; gap: var(--space-4); }
.stack label { display: grid; gap: var(--space-2); color: var(--ink-2); font-size: 13px; }
.stack input {
  font: inherit; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink);
}
.stack input:hover { border-color: var(--line-strong, var(--line)); }
.stack input:focus {
  border-color: var(--cyan); outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--cyan) 28%, transparent);
}
.form-error {
  background: color-mix(in oklab, var(--error) 12%, var(--surface));
  color: var(--error); padding: var(--space-3); border-radius: var(--radius-md);
  font-size: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--object-rail) var(--ws-strip) var(--rail) 1fr;
  min-height: 100vh; height: 100vh; overflow: hidden;
  grid-template-rows: auto 1fr;
}

/* Reserved left strip for future object tree — placeholder only */
.object-rail {
  background: color-mix(in oklab, var(--sunken) 92%, #061018);
  border-right: 1px solid color-mix(in oklab, var(--cyan) 32%, var(--line));
  box-shadow: inset -1px 0 0 var(--bevel-hi, rgba(255,255,255,0.04));
  display: flex; flex-direction: column; align-items: stretch;
  justify-content: flex-start;
  padding: 0; min-width: 0; overflow: hidden;
  position: relative;
  color: var(--ink-on-dark);
}
.object-tree-root {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
.object-tree {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden; font-size: 12px;
}
.object-tree-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 6px;
  border-bottom: 1px solid color-mix(in oklab, var(--cyan) 22%, var(--line));
  background: color-mix(in oklab, var(--surface) 70%, #041018);
}
.object-tree-title {
  font-size: 10px; font-weight: 850; letter-spacing: 0.14em;
  color: var(--cyan); text-shadow: 0 0 8px color-mix(in oklab, var(--cyan) 40%, transparent);
}
.object-tree-status {
  padding: 6px 10px; font-size: 11px; color: #ff8a8a;
  border-top: 1px solid var(--line);
}
.object-tree-list {
  list-style: none; margin: 0; padding: 0;
}
.object-tree > .object-tree-list {
  flex: 1; min-height: 0; overflow: auto;
  padding: 4px 0 8px;
}
.object-tree-node { margin: 0; padding: 0; }
.object-tree-empty {
  padding: 8px 10px; color: var(--ink-3); font-size: 11px;
}
.object-tree-row {
  display: grid;
  grid-template-columns: 18px 14px minmax(0, 1fr);
  align-items: center; gap: 2px;
  padding: 3px 6px 3px calc(6px + var(--depth, 0) * 10px);
  margin: 1px 4px; border-radius: 4px;
  border: 1px solid transparent;
  color: var(--ink-on-dark);
  cursor: pointer; user-select: none;
  transition: background 0.12s var(--ease, ease), border-color 0.12s var(--ease, ease);
}
.object-tree-row:hover {
  background: color-mix(in oklab, var(--cyan) 12%, transparent);
  border-color: color-mix(in oklab, var(--cyan) 28%, transparent);
}
.object-tree-row:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 1px;
}
.object-tree-node.is-selected > .object-tree-row {
  background: color-mix(in oklab, var(--cyan) 18%, var(--surface));
  border-color: color-mix(in oklab, var(--cyan) 55%, var(--line));
  box-shadow: 0 0 10px color-mix(in oklab, var(--cyan) 22%, transparent);
  color: #e8fbff;
}
.object-tree-twist {
  width: 18px; height: 18px; padding: 0; margin: 0;
  border: 0; background: transparent; color: var(--cyan);
  font-size: 10px; line-height: 1; cursor: pointer;
}
.object-tree-twist.is-leaf { visibility: hidden; pointer-events: none; }
.object-tree-badge {
  font-size: 10px; font-weight: 800; color: var(--amber, #F4C542);
  text-align: center;
}
.object-tree-node[data-terminal="1"] .object-tree-badge { color: var(--cyan); }
.object-tree-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 650; letter-spacing: 0.01em;
}
@keyframes object-tree-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
.object-tree.is-loading .object-tree-title {
  animation: object-tree-pulse 1.2s ease-in-out infinite;
}


.ws-strip {
  background: var(--sunken); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-4) 0; gap: var(--space-3);
}
.ws-dot {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--wire-tint); border: 2px solid var(--wire);
}
.ws-dot.active { box-shadow: 0 0 0 3px color-mix(in oklab, var(--wire) 35%, transparent); }
.ws-me { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }

.channel-rail {
  background: var(--surface);
  border-right: 1px solid color-mix(in oklab, var(--cyan) 22%, var(--line));
  box-shadow: inset 0 1px 0 var(--bevel-hi, rgba(255,255,255,0.04));
  padding: var(--space-4); overflow: auto;
}
.rail-item { color: var(--ink-2); }
.rail-item.selected { color: var(--ink-on-light); }
.rail-section h2 {
  margin: 0 0 var(--space-3); font-size: 12px; font-weight: 600;
  color: var(--ink-3); letter-spacing: 0.02em;
}
.rail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: var(--space-3);
}
.rail-section-head h2 { margin: 0; }
.rail-actions { display: inline-flex; gap: 2px; }
.rail-action {
  min-height: 28px; padding: 2px 8px; font-size: 12px; font-weight: 700;
  color: var(--ink-on-dark);
}
.rail-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md); color: var(--ink-on-dark);
  text-decoration: none; min-height: 0; cursor: pointer; border: 0;
  background: transparent; font: inherit; width: 100%; text-align: left;
}
.rail-item .rail-icon {
  flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px;
  border-radius: 4px;
  background: var(--item-wire, var(--wire));
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--item-wire, var(--wire)) 35%, transparent);
  position: relative;
}
.rail-item .rail-icon::after {
  content: ""; position: absolute; inset: 4px;
  border-radius: 2px; background: var(--sunken); opacity: 0.55;
}
.rail-item.kind-scribe .rail-icon::after,
.rail-item.kind-ledger .rail-icon::after {
  inset: 3px 5px 3px 5px; border-radius: 1px;
}
.rail-item.kind-thread .rail-icon {
  border-radius: 50%;
}
.rail-item .rail-text {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1;
}
.rail-item .rail-name {
  font-size: 13px; font-weight: 650; color: inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-item .rail-desc {
  font-size: 11px; font-weight: 500; line-height: 1.25;
  color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.rail-item.selected .rail-desc {
  color: color-mix(in oklab, var(--ink-on-light) 72%, transparent);
}
.rail-item .dot { display: none; }
/* The selected path is the only rail icon with motion. Keep the signal slow and soft;
   unlike a notification blink, it should read as a quiet “you are here” marker. */
.rail-item .rail-icon.is-active {
  z-index: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .rail-item .rail-icon.is-active {
    animation: rail-active-path 3.6s ease-in-out infinite;
    will-change: transform, box-shadow, filter;
  }
}
@keyframes rail-active-path {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 0 1px color-mix(in oklab, var(--item-wire, var(--wire)) 40%, transparent),
      0 0 7px color-mix(in oklab, var(--item-wire, var(--wire)) 34%, transparent);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.045);
    box-shadow:
      0 0 0 2px color-mix(in oklab, var(--item-wire, var(--wire)) 52%, transparent),
      0 0 13px color-mix(in oklab, var(--item-wire, var(--wire)) 48%, transparent);
    filter: brightness(1.1);
  }
}

.rail-item.selected {
  /* Selected rows are light chips on the dark rail: use dark ink. */
  background: var(--item-tint, var(--selected-chip-bg));
  color: var(--ink-on-light);
  font-weight: 600;
}
.rail-item:hover { background: var(--sunken); }
.rail-item.selected:hover {
  background: var(--item-tint, var(--selected-chip-bg));
  color: var(--ink-on-light);
}

.conversation {
  /* Flex column: header/tabs fixed, messages scroll, composer pinned to pane bottom.
     Root cause of "composer gone until F11": grid 1fr min=auto let tall bubbles
     grow the messages row and push composer below the viewport. */
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.channel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2); padding: var(--space-2) var(--space-4);
  flex-wrap: nowrap;
  background: var(--elevated, var(--surface));
  border-bottom: 1px solid color-mix(in oklab, var(--cyan) 22%, var(--line));
  box-shadow: inset 0 -1px 0 var(--bevel-lo, rgba(0,0,0,0.35)),
              0 0 18px color-mix(in oklab, var(--cyan) 6%, transparent);
  position: relative;
}
.channel-title { display: flex; align-items: center; gap: var(--space-3); min-width: 0; flex: 1 1 15rem; }
.wire-bar {
  width: 4px; align-self: stretch; border-radius: 2px;
  background: var(--wire); flex: 0 0 auto;
}
.channel-header h1 {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.channel-meta {
  color: var(--ink-3); font-size: 12px; font-family: var(--font-mono);
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
  flex: 0 1 auto; min-width: 0; white-space: nowrap;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--space-3) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
}
/* Chat bubbles — avatar LEFT of bubble; prefer @username labels from JS. */
.msg {
  max-width: min(72ch, 100%);
  width: 100%;
  align-self: stretch;
}
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  background: color-mix(in oklab, var(--cyan) 18%, var(--sunken));
  color: var(--ink-on-dark);
  border: 1px solid color-mix(in oklab, var(--cyan) 40%, var(--line));
  font-size: 12px; font-weight: 800; font-family: var(--font-display);
  box-shadow: 0 0 0 1px var(--bevel-lo);
  margin-top: 2px;
}
.msg-avatar.is-emoji {
  font-size: 18px; font-weight: 400; line-height: 1;
  background: var(--elevated); border-color: var(--line-strong);
}
.msg-main {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0; flex: 1 1 auto;
  max-width: calc(100% - 46px);
}
.msg-group-meta {
  display: flex; align-items: baseline; gap: var(--space-2);
  padding: 0 2px; margin: 0 0 1px;
}
.msg-name {
  font-weight: 700; font-size: 13px; color: var(--ink-on-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-time { color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.msg-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 6px;
  /* Distinct from --paper/#07090E chat background; near-white text (hard contrast). */
  background: #1E2638;
  color: var(--ink-on-dark);
  border: 1px solid #4A5870;
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 6px 18px rgba(0, 0, 0, 0.34);
}
.msg.is-mine .msg-bubble {
  background: color-mix(in oklab, var(--cyan) 20%, #1E2638);
  border-color: color-mix(in oklab, var(--cyan) 50%, #4A5870);
  border-radius: 16px 16px 6px 16px;
  box-shadow: inset 0 1px 0 var(--bevel-hi),
    0 0 16px color-mix(in oklab, var(--cyan) 14%, transparent);
}
.msg.is-other .msg-bubble {
  background: #222A3C;
  border-color: #556480;
}
.msg-body {
  font-size: 15px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--ink-on-dark);
  padding: 0;
}
.msg.pending { opacity: 0.65; }
/* Quiet system / notice lines — readable on dark, not fake user bubbles. */
.msg.system,
.msg.notice {
  text-align: center;
  color: var(--ink-on-dark);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  max-width: min(48ch, 92%);
  align-self: center;
  padding: 6px 14px;
  margin: 4px auto;
  border-radius: 999px;
  background: color-mix(in oklab, #1E2638 88%, transparent);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.msg.system .msg-row,
.msg.notice .msg-row { display: none; }
.msg.bot .msg-bubble {
  background: color-mix(in oklab, var(--wire, var(--cyan)) 14%, var(--sunken));
  border-left: 3px solid var(--wire, var(--cyan));
  border-radius: 6px 16px 16px 16px;
}
.msg.bot .msg-avatar {
  background: color-mix(in oklab, var(--wire, var(--cyan)) 22%, var(--sunken));
  border-color: var(--wire, var(--cyan));
}

.typing {
  padding: 0 var(--space-5) var(--space-2); color: var(--ink-3); font-size: 13px;
  display: flex; align-items: center; gap: var(--space-2);
}
.typing .dots::before { content: "•••"; letter-spacing: 2px; }

.channel-header,
.thread-tabs,
.typing,
.composer {
  flex: 0 0 auto;
}
.composer {
  display: flex; gap: var(--space-2); align-items: flex-end;
  padding: var(--space-2) var(--space-4) var(--space-3);
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 160px;
  font: inherit; font-size: 15px; line-height: 1.5;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink);
}
.composer textarea:focus {
  border-color: var(--cyan); outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--cyan) 28%, transparent),
              0 0 16px color-mix(in oklab, var(--cyan) 15%, transparent);
}

.composer-link {
  display: inline-grid; place-items: center;
  padding: 10px 12px; min-width: 40px; min-height: 40px;
  color: var(--ink-2); flex: 0 0 auto;
  cursor: pointer; font-weight: 700; font-size: 13px;
}
.composer-link:hover:not(:disabled) {
  color: var(--ink); background: var(--sunken);
}
.composer-mic {
  display: inline-grid; place-items: center;
  padding: 10px; min-width: 40px; min-height: 40px;
  color: var(--ink-2); flex: 0 0 auto;
  cursor: pointer;
}
.composer-mic:disabled {
  cursor: not-allowed;
}
.composer-mic .icon {
  width: 20px; height: 20px; display: block;
}
.composer-mic:hover:not(:disabled) {
  color: var(--ink); background: var(--sunken);
}
.composer-mic.is-recording {
  position: relative;
  color: var(--error);
  background: color-mix(in oklab, var(--error) 8%, var(--surface));
  border-color: color-mix(in oklab, var(--error) 35%, var(--line));
}
.composer-mic.is-recording .icon { display: none; }
.composer-mic.is-recording::before {
  content: "REC";
  display: block;
  font-size: 12px; font-weight: 900; letter-spacing: 0.08em;
  line-height: 20px;
}
.composer-mic.is-recording:hover:not(:disabled) {
  color: var(--error);
  background: color-mix(in oklab, var(--error) 13%, var(--surface));
}
.mic-help-wrap {
  position: relative; flex: 0 0 auto;
}
.mic-help-toggle {
  min-width: 40px; min-height: 40px; padding: 8px; font-weight: 700;
  color: var(--ink-2);
}
.mic-help-toggle:hover { color: var(--ink); background: var(--sunken); }
.mic-help-menu[hidden] { display: none !important; }
.mic-help-wrap[hidden] { display: none !important; }
.mic-help-menu {
  position: absolute; z-index: 20; right: 0; bottom: calc(100% + var(--space-2));
  width: min(360px, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-3); border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-popover, 0 10px 30px color-mix(in oklab, var(--ink) 18%, transparent));
  font-size: 13px; line-height: 1.45;
}
.mic-help-menu strong { display: block; margin-bottom: var(--space-2); font-size: 15px; }
.mic-help-menu p { margin: var(--space-2) 0 0; }
.mic-help-menu code {
  padding: 1px 3px; border-radius: 3px; background: var(--sunken);
  overflow-wrap: anywhere;
}
.mic-help-secure { color: var(--ink-2); }
@media (prefers-reduced-motion: no-preference) {
  .composer-mic.is-recording::before {
    animation: mic-rec-pulse 1.4s ease-in-out infinite;
  }
}
@keyframes mic-rec-pulse {
  0%, 100% { opacity: 0.58; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* Compact popout (§17.4) */
.app-shell.is-compact {
  grid-template-columns: 1fr;
}
.app-shell.is-compact > .app-topbar {
  min-height: 34px; padding: 5px 10px;
}
.app-shell.is-compact .object-rail,
.app-shell.is-compact .ws-strip,
.app-shell.is-compact .channel-rail { display: none; }
.app-shell.is-compact .channel-header {
  background: var(--wire); color: var(--accent-ink, #0a0c10); border-bottom: 0; min-height: 40px;
  padding: 8px 12px;
}
.app-shell.is-compact .channel-header h1 { color: inherit; font-size: 16px; }
.app-shell.is-compact .wire-bar { display: none; }
.app-shell.is-compact .channel-meta { color: color-mix(in oklab, var(--accent-ink, #0a0c10) 75%, transparent); }
.app-shell.is-compact .composer { padding: var(--space-2); }
.app-shell.is-compact .messages { padding: var(--space-3); }
.app-shell.is-compact .composer .btn.primary,
.app-shell.is-compact .composer-mic {
  padding: 10px; min-width: 40px;
}

@media (max-width: 900px) {
  .app-shell:not(.is-compact) {
    grid-template-columns: var(--object-rail) var(--ws-strip) 1fr;
  }
  .app-shell:not(.is-compact) .channel-rail {
    position: absolute; z-index: 5;
    left: calc(var(--object-rail) + var(--ws-strip)); top: 0; bottom: 0;
    width: min(var(--rail), 80vw);
    box-shadow: 0 8px 24px color-mix(in oklab, #000 45%, transparent);
  }
}

/* Admin control center (§10.1 / §17.4) */
.admin-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
.admin-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--surface);
  color: var(--ink-on-dark);
}
.admin-nav {
  grid-row: 2;
  background: var(--sunken); border-right: 1px solid var(--line);
  padding: var(--space-3) var(--space-3);
  display: flex; flex-direction: column; gap: 4px;
}
.admin-eyebrow {
  margin: 0 0 var(--space-2); font-size: 11px; color: var(--ink-2); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.admin-link {
  display: block; padding: 6px 10px; border-radius: var(--radius-md);
  color: var(--ink-2); text-decoration: none; min-height: 36px;
  line-height: 24px; font-size: 14px;
}
.admin-link:hover { background: var(--surface); color: var(--ink); }
.admin-link.active { background: var(--wire-tint); color: var(--wire-ink); font-weight: 600; }
.admin-nav-foot { margin-top: auto; padding-top: var(--space-4); }
.admin-main {
  grid-row: 2;
  max-width: 1120px; padding: var(--space-4) var(--space-4);
}
.admin-main h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  margin: 0 0 var(--space-2); color: var(--ink);
}
.admin-main h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  margin: 0 0 var(--space-3); color: var(--ink);
}
.admin-main h3 { font-size: 14px; margin: var(--space-4) 0 var(--space-2); color: var(--ink); }
.context-line {
  margin: 0 0 var(--space-3); font-size: 13px; color: var(--ink-2);
}
.admin-panel {
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--cyan) 28%, var(--line));
  border-radius: var(--radius-lg); padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--panel-shadow);
}
.admin-form { max-width: 440px; }
.admin-form label { display: grid; gap: 4px; margin-bottom: var(--space-3); color: var(--ink); font-size: 13px; }
.admin-form label > span { color: var(--ink-2); font-weight: 600; }
.admin-form select, .admin-form input[type="text"], .admin-form input[type="email"] {
  font: inherit; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink);
  width: 100%;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line);
  vertical-align: top; color: var(--ink);
}
.admin-table th { color: var(--ink-3); font-weight: 600; font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.admin-table .detail { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font-size: 12px; }
.flash {
  background: color-mix(in oklab, var(--ok) 14%, var(--surface));
  color: var(--ink); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); margin-bottom: var(--space-4);
}
.hint, .muted { color: var(--ink-3); font-size: 13px; }
.muted a { color: var(--accent); }
.empty { color: var(--ink-3); font-size: 14px; }
.stat-row { display: flex; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  min-width: 140px;
}
.stat-n { font-family: var(--font-display); font-size: 31px; font-weight: 700; }
.stat-l { color: var(--ink-3); font-size: 13px; }
.invite-once {
  background: var(--wire-tint); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  color: var(--ink);
}
.invite-once p { margin: 0 0 var(--space-2); color: var(--ink); font-size: 14px; }
.invite-link {
  display: block; margin: var(--space-2) 0; word-break: break-all;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink);
}
.invite-once .btn { margin-top: var(--space-2); }
.check { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--ink); }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin-list a { color: var(--ink); text-decoration: none; }
.crumb { color: var(--ink-3); font-size: 13px; margin: 0 0 var(--space-3); }
.crumb a { color: var(--ink-2); }
.wire-swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  background: var(--wire); vertical-align: middle; margin-right: 6px;
}
.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.inline { display: inline; }
.stack-tight { display: inline-flex; gap: var(--space-2); align-items: center; }
.stack-tight input { font: inherit; font-size: 13px; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink); min-width: 160px; }
.btn.danger, .btn.ghost.danger { color: var(--error); }
.danger-zone { border-color: color-mix(in oklab, var(--error) 35%, var(--line)); }
.admin-filter { display: flex; gap: var(--space-3); align-items: end; margin-bottom: var(--space-4); }
.admin-filter label { display: grid; gap: var(--space-2); font-size: 13px; color: var(--ink-2); }
.admin-filter input {
  font: inherit; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink);
}
fieldset { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); }
legend { padding: 0 var(--space-2); color: var(--ink-2); font-size: 13px; }
@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .admin-topbar { grid-row: 1; }
  .admin-nav { grid-row: 2; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .admin-main { grid-row: 3; }
  .admin-nav-foot { margin-top: 0; margin-left: auto; }
}

/* —— Invite-token peek (read-only) —— */
.peek-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
.peek-shell > .app-topbar { grid-column: 1 / -1; }
.peek-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-on-dark); background: color-mix(in oklab, var(--cyan) 22%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--cyan) 45%, var(--line));
  border-radius: 999px; padding: 3px 8px; line-height: 1;
}
.peek-rail {
  grid-row: 2; background: var(--sunken); border-right: 1px solid var(--line);
  padding: var(--space-3); overflow: auto;
}
.peek-rail h2 {
  margin: 0 0 var(--space-2); font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.peek-conversation {
  grid-row: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg);
}
.peek-conversation .messages { flex: 1 1 auto; overflow: auto; padding: var(--space-3) var(--space-4); }
.peek-composer-locked {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line); background: var(--surface);
  color: var(--ink);
}
.peek-cta { margin: 0; flex: 1 1 220px; font-size: 14px; color: var(--ink); }
.peek-cta-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.peek-empty { padding: var(--space-4); color: var(--ink-2); }
.peek-main { grid-column: 1 / -1; grid-row: 2; display: grid; place-items: center; padding: var(--space-5); }
.peek-panel {
  max-width: 420px; width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5);
  color: var(--ink);
}
.peek-ch.rail-item {
  width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--ink-2); cursor: pointer; padding: 8px 10px; border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 8px; font: inherit;
}
.peek-ch.rail-item:hover { background: var(--surface); color: var(--ink); }
.peek-ch.rail-item.active {
  background: var(--wire-tint); color: var(--wire-ink); font-weight: 600;
}
.wire-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--wire); flex: 0 0 auto;
}
.rail-label { color: inherit; }
@media (max-width: 720px) {
  .peek-shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .peek-rail { grid-row: 2; border-right: 0; border-bottom: 1px solid var(--line); }
  .peek-conversation { grid-row: 3; }
}

/* P4 — telemetry explorer + apps */
.key-once {
  background: color-mix(in oklab, var(--warn, #c90) 14%, var(--surface));
  word-break: break-all;
}
.telem-tail {
  max-height: 420px; overflow: auto; background: var(--sunken);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-3); font-size: 12px; line-height: 1.45;
}
.telem-line { padding: 2px 0; border-bottom: 1px solid color-mix(in oklab, var(--line) 50%, transparent); }
.status-pill {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; text-transform: lowercase;
}
.status-ok { background: color-mix(in oklab, var(--ok, #2a7) 18%, var(--surface)); color: var(--ok, #2a7); }
.status-stopped { background: color-mix(in oklab, var(--error) 14%, var(--surface)); color: var(--error); }
.status-unknown { background: var(--sunken); color: var(--ink-3); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.ink-3 { color: var(--ink-3); font-size: 13px; }
.msg.bot, .msg[data-type="alert"] {
  /* alert/bot already use .bot; keep wire edge from theme */
}

/* —— Right pane: Artifacts | Ledger (Phase 1 layout cut) —— */
.app-shell.has-ledger,
.app-shell.has-right-pane {
  /* phone chat column + fluid right pane */
  grid-template-columns: var(--object-rail) var(--ws-strip) var(--rail) var(--chat-col) minmax(240px, 1fr);
}
.app-shell.has-ledger:not(.ledger-open):not(.right-open),
.app-shell.has-right-pane:not(.right-open):not(.ledger-open) {
  grid-template-columns: var(--object-rail) var(--ws-strip) var(--rail) 1fr 0;
}
.right-pane {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-drawer, 0 0 24px color-mix(in oklab, var(--ink) 8%, transparent));
}
.right-pane[hidden] { display: none; }
.app-shell.right-open .right-pane[hidden],
.app-shell.ledger-open .right-pane[hidden] { display: flex; }

.right-pane-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
  flex: 0 0 auto;
}
.right-tab {
  appearance: none; margin: 0; font: inherit;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 6px 12px; min-height: 32px; border-radius: 999px;
  border: 1px solid var(--line-strong, var(--line));
  background: var(--paper); color: var(--ink-on-dark);
  cursor: pointer;
}
.right-tab:hover { border-color: var(--cyan); color: var(--ink); }
.right-tab.active,
.right-tab[aria-selected="true"] {
  background: color-mix(in oklab, var(--cyan) 22%, var(--paper));
  border-color: var(--cyan);
  color: var(--ink-on-dark);
  box-shadow: 0 0 12px color-mix(in oklab, var(--cyan) 25%, transparent);
}
.right-pane-close {
  margin-left: auto; font-size: 18px; line-height: 1;
  min-width: 36px; min-height: 36px; padding: 0 8px;
  color: var(--ink-on-dark);
}
.right-pane-body {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
.artifacts-panel,
.ledger-panel {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
.artifacts-panel[hidden],
.ledger-panel[hidden] { display: none !important; }

.artifacts-empty {
  padding: var(--space-5) var(--space-4);
  color: var(--ink-on-dark);
}
.artifacts-empty h2 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--ink-on-dark);
}
.artifacts-empty p {
  margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-2);
  max-width: 36ch;
}
.artifacts-view {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
.artifacts-view[hidden] { display: none !important; }
.artifact-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--elevated, var(--surface));
  flex: 0 0 auto;
}
.artifact-kind {
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cyan); padding: 2px 8px; border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--cyan) 45%, var(--line));
  background: color-mix(in oklab, var(--cyan) 12%, var(--paper));
}
.artifact-url {
  flex: 1 1 12rem; min-width: 0;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--ink-on-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.artifact-toolbar .btn { font-size: 12px; padding: 4px 10px; min-height: 32px; }
.artifact-subtabs {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}
.artifact-subtab {
  appearance: none; margin: 0; font: inherit;
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 11px; min-height: 28px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--ink-on-dark);
  cursor: pointer;
}
.artifact-subtab:hover { border-color: var(--cyan); }
.artifact-subtab.active,
.artifact-subtab[aria-selected="true"] {
  background: color-mix(in oklab, var(--amber) 18%, var(--paper));
  border-color: var(--amber);
  color: var(--ink-on-dark);
  box-shadow: 0 0 10px color-mix(in oklab, var(--amber) 22%, transparent);
}
.artifact-panes {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden; background: var(--paper);
}
.artifact-pane {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
.artifact-pane[hidden] { display: none !important; }
.artifact-ai-panel {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4);
  color: var(--ink-on-dark);
  overflow: auto;
  background: var(--surface);
}
.artifact-ai-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
}
.artifact-ai-head h3 {
  margin: 0;
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--ink-on-dark);
}
.artifact-ai-status {
  margin: 0;
  font-size: 12px; font-weight: 650;
  color: var(--ink-on-dark);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #1E2638;
  border: 1px solid var(--line-strong);
}
.artifact-ai-status[data-kind="loading"] { color: var(--cyan); border-color: color-mix(in oklab, var(--cyan) 40%, var(--line-strong)); }
.artifact-ai-status[data-kind="error"] { color: #FFB4BA; border-color: color-mix(in oklab, var(--accent) 45%, var(--line-strong)); }
.artifact-ai-body {
  margin: 0;
  font-size: 14px; line-height: 1.55;
  color: var(--ink-on-dark);
  white-space: pre-wrap;
  max-width: 48ch;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #1A2233;
  border: 1px solid var(--line-strong);
  min-height: 4.5em;
}
.artifact-ai-body:empty { display: none; }
.artifact-ai-body.placeholder {
  color: var(--ink-2);
  font-size: 13px;
}
.artifact-ai-meta {
  margin: 0;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-2);
  word-break: break-all;
}
.artifact-frame-wrap {
  flex: 1 1 auto; min-height: 0; background: var(--paper);
  display: flex; align-items: stretch; justify-content: center;
  overflow: auto;
}
.artifact-frame {
  width: 100%; height: 100%; min-height: 280px; border: 0;
  background: #0a0c10;
}
.artifact-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  margin: auto; display: block;
  background: var(--sunken);
}
.artifact-fallback {
  margin: auto; padding: var(--space-5); text-align: center;
  color: #F4F7FF; max-width: 42ch;
  background: #121821;
  border: 1px solid #3A455C;
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 0 0 1px #0A0C10, 0 12px 32px rgba(0,0,0,0.45);
}
.artifact-fallback-icon {
  font-size: 28px; line-height: 1; margin-bottom: 10px;
  color: var(--amber, #F5C542);
}
.artifact-fallback h3 {
  margin: 0 0 8px;
  font-family: var(--font-display); font-size: 16px; font-weight: 800;
  color: #FFFFFF;
}
.artifact-fallback p {
  margin: 0 0 10px;
  color: #C5D0E6; font-size: 13px; line-height: 1.45;
}
.artifact-fallback-url { margin-top: 4px !important; }
.artifact-fallback a {
  color: #7EE0FF; font-weight: 700; text-decoration: underline;
  text-underline-offset: 2px;
}
.artifact-fallback a:hover { color: #B8F0FF; }
.artifact-screenshot-stub {
  margin-top: 14px; padding: 18px 12px;
  border: 1px dashed #4A5670; border-radius: 8px;
  background: #0A0C10;
  color: #8B97B0; font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* Narrow phone-proportioned chat column when right pane open */
.app-shell.right-open .conversation,
.app-shell.ledger-open .conversation {
  max-width: none;
}
.app-shell.right-open .messages,
.app-shell.ledger-open .messages {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.app-shell.right-open .msg,
.app-shell.ledger-open .msg {
  max-width: 100%;
}
.msg-body a.msg-link {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.msg-body a.msg-link:hover {
  color: var(--ink);
  text-shadow: 0 0 8px color-mix(in oklab, var(--cyan) 35%, transparent);
}

.ledger-drawer,
.ledger-panel {
  background: var(--surface);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}
.ledger-drawer[hidden] { display: none; }
.app-shell.ledger-open .ledger-drawer[hidden] { display: flex; }
.ledger-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
}
.ledger-header h2 {
  margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 700;
}
.ledger-header-actions {
  display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto;
}
.ledger-src-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3); cursor: pointer; user-select: none;
  padding: 2px 6px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.ledger-src-toggle:hover { color: var(--ink-2); border-color: var(--line); }
.ledger-src-toggle input {
  width: 14px; height: 14px; accent-color: var(--cyan); margin: 0; cursor: pointer;
}
.ledger-coverage {
  margin: 4px 0 0; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.ledger-filters {
  display: flex; gap: 6px; padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-on-dark);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  font: inherit;
}
.chip.active, .chip[aria-selected="true"] {
  background: var(--wire-tint); border-color: var(--wire); color: var(--ink-on-dark); font-weight: 600;
}
.ledger-list {
  overflow: auto; padding: var(--space-3) var(--space-4) var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-4);
}

/* —— Ledger metrics strip + importance badge (HUD) —— */
.ledger-metrics {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 8px var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
}
.ledger-metrics[hidden] { display: none !important; }
.ledger-metric {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
  font-variant-numeric: tabular-nums;
}
.ledger-metric-n {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 600;
  color: var(--cyan);
  text-shadow: 0 0 8px color-mix(in oklab, var(--cyan) 35%, transparent);
}
.ledger-metric-l {
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-2); font-weight: 600;
}
.ledger-metric[data-k="proposed"] .ledger-metric-n { color: var(--amber); text-shadow: 0 0 8px color-mix(in oklab, var(--amber) 30%, transparent); }
.ledger-metric[data-k="contested"] .ledger-metric-n { color: var(--error); text-shadow: 0 0 8px color-mix(in oklab, var(--error) 28%, transparent); }
.fact-importance {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.fact-importance.imp-low {
  color: var(--ink-2);
  background: var(--sunken);
}
.fact-importance.imp-med {
  color: var(--amber);
  background: color-mix(in oklab, var(--amber) 16%, transparent);
  border-color: color-mix(in oklab, var(--amber) 45%, var(--line));
}
.fact-importance.imp-high {
  color: var(--cyan);
  background: color-mix(in oklab, var(--cyan) 16%, transparent);
  border-color: color-mix(in oklab, var(--cyan) 50%, var(--line));
  text-shadow: 0 0 6px color-mix(in oklab, var(--cyan) 25%, transparent);
}
.fact-row.is-proposed {
  border-color: color-mix(in oklab, var(--amber) 35%, var(--line));
  background: color-mix(in oklab, var(--amber) 4%, var(--paper));
}
.fact-statement { color: var(--ink-on-dark); }
.fact-kind { color: var(--ink-2); }

.ledger-group h3 {
  margin: 0 0 var(--space-2); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3);
}
.fact-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm, 6px);
  padding: 6px 8px; background: var(--paper);
  display: grid; gap: 4px;
  transition: background 1.2s var(--ease, cubic-bezier(.2,.8,.2,1));
}
.fact-row.is-new { background: var(--wire-tint); }
/* Keep fact statements legible; express low confidence with metadata, not opacity. */
.fact-row.is-muted { opacity: 1; }
.fact-row.is-muted .fact-meta { color: var(--ink-2); }
.fact-row.is-proposed { border-style: dashed; }
.fact-head {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
}
.fact-kind {
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 5px;
  flex: 1 1 auto; min-width: 0;
}
.fact-kind .check { color: var(--ok, #2f9e44); font-size: 13px; }
.fact-tools {
  display: inline-flex; align-items: center; gap: 4px;
  flex: 0 0 auto; margin-left: auto;
}
.fact-tool {
  appearance: none; margin: 0;
  font: inherit; font-size: 11px; font-weight: 600; line-height: 1.15;
  padding: 2px 7px; min-height: 0;
  border-radius: 4px; border: 1px solid var(--line-strong);
  background: var(--sunken); color: var(--cyan);
  cursor: pointer; white-space: nowrap;
}
.fact-tool:hover {
  color: #F0F4FF; background: color-mix(in oklab, var(--cyan) 22%, var(--sunken));
  border-color: var(--cyan);
}
.fact-statement {
  /* Ledger rows are dark panels; facts stay near-white, never dark-gray. */
  font-size: 13px; line-height: 1.3; color: var(--ledger-fact-ink, var(--ink-on-dark));
}
.fact-meta {
  font-size: 11px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.fact-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.fact-actions .btn { font-size: 11px; padding: 2px 7px; min-height: 0; }
/* Legacy class kept for any leftover refs */
.fact-sources {
  background: none; border: 0; padding: 0; color: var(--cyan);
  font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline;
}
.msg.highlight-source .msg-bubble {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--cyan) 28%, transparent),
    0 0 22px color-mix(in oklab, var(--cyan) 35%, transparent);
}
.msg.highlight-source .msg-avatar {
  box-shadow: 0 0 0 2px var(--cyan), 0 0 14px color-mix(in oklab, var(--cyan) 40%, transparent);
}
.app-shell.is-compact.has-ledger,
.app-shell.is-compact.has-right-pane {
  grid-template-columns: 1fr;
}
.app-shell.is-compact .ledger-drawer,
.app-shell.is-compact .right-pane { display: none !important; }
@media (max-width: 960px) {
  .app-shell.has-ledger,
  .app-shell.has-ledger.ledger-open,
  .app-shell.has-right-pane,
  .app-shell.has-right-pane.right-open {
    grid-template-columns: var(--object-rail) var(--ws-strip) var(--rail) 1fr;
  }
  .right-pane,
  .ledger-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(max(var(--drawer), 280px), 100vw);
    z-index: 40;
  }
}

/* —— Thread tabs (§17.5 / P5c) —— */
.thread-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  min-height: 2rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
.thread-tabs-scroll {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
.thread-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 0.35rem 0.7rem;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.thread-tab:hover { color: var(--ink-on-dark); background: var(--sunken); }
.thread-tab.active {
  color: var(--ink-on-dark);
  font-weight: 750;
}
.thread-tab.active::after {
  content: "";
  position: absolute;
  left: 0.45rem; right: 0.45rem; bottom: 0;
  height: 2px;
  background: var(--wire, var(--cyan));
  border-radius: 2px;
  box-shadow: 0 0 8px color-mix(in oklab, var(--wire, var(--cyan)) 45%, transparent);
}
.thread-tab.is-subtopic {
  color: var(--ink-on-dark);
}
.thread-tab.is-subtopic::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; margin-right: 6px;
  border-radius: 50%;
  background: var(--wire, var(--cyan));
  box-shadow: 0 0 6px color-mix(in oklab, var(--wire, var(--cyan)) 50%, transparent);
  vertical-align: 1px;
}
.thread-suggest {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--sunken);
  font-size: 0.75rem;
  color: var(--ink-2);
  max-width: 22rem;
}
.thread-suggest strong { color: var(--ink); font-weight: 600; }
.thread-suggest .btn { font-size: 0.75rem; padding: 0.15rem 0.55rem; }

/* Contested fact marker */
.fact-row.contested { border-left: 3px solid var(--warn, #c9842b); }
.fact-row .contested-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--warn, #c9842b) 18%, transparent);
  color: var(--warn, #c9842b);
  font-size: 0.7rem;
  font-weight: 600;
}
.fact-annotations {
  margin: 0.4rem 0 0.2rem 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--ink-2);
}
.fact-annotations li { margin: 0.2rem 0; }
.fact-ann-kind {
  font-weight: 600;
  text-transform: capitalize;
  margin-right: 0.35rem;
  color: var(--ink);
}
.fact-ann-composer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0 0.2rem 1.5rem;
  align-items: center;
}
.fact-ann-composer select,
.fact-ann-composer input {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--sunken);
  color: var(--ink);
}
.fact-ann-composer input[type="text"] { flex: 1; min-width: 8rem; }


/* —— Presence chips under selected channel in the Channels rail —— */
.rail-channel {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 2px;
}
.rail-item .rail-caret {
  flex: 0 0 auto; margin-left: auto; align-self: center;
  font-size: 11px; font-weight: 700; opacity: 0.7;
  color: inherit; padding-left: 4px;
}
.rail-participants {
  list-style: none; margin: 0 0 6px 0; padding: 4px 0 2px 28px;
  display: grid; gap: 4px;
}
.rail-participants-empty {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  padding: 2px 4px;
}
/* Presence = compact BUTTON; fill color IS the status (no tiny dots). */
button.presence-chip {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0; margin: 0; min-height: 22px; height: 22px; padding: 0 10px;
  border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.01em;
  white-space: nowrap; cursor: default; line-height: 1;
  background: #1A2230;
  color: #F0F4FF;
  border-color: #6b7280;
  box-shadow: none;
  max-width: 100%;
}
.rail-participants button.presence-chip {
  width: 100%;
  justify-content: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.presence-chip .presence-name {
  color: inherit; font-weight: 700;
}
/* Hide status dots — chip fill carries online/offline. */
button.presence-chip .dot { display: none !important; }
/* OFFLINE: grayed chrome, NAME still near-white (hard contrast on dark). */
button.presence-chip.is-offline {
  background: #4B5563;
  color: #F3F4F6;
  border-color: #6B7280;
  opacity: 1;
  box-shadow: none;
}
/* ONLINE (peers + self fill): bright GREEN → dark readable name. */
button.presence-chip.is-online,
button.presence-chip.is-idle {
  background: #00E676;
  color: #04140A;
  border-color: #00FF88;
  box-shadow: 0 0 10px 1px rgba(0, 230, 118, 0.45);
  cursor: default;
}
/* SELF: same green/gray fill, bright high-contrast OUTLINE ring so you spot yourself. */
button.presence-chip.self.is-online,
button.presence-chip.self.is-idle {
  outline: 3px solid #FFFFFF;
  outline-offset: 3px;
  box-shadow:
    0 0 0 5px rgba(0, 229, 255, 0.98),
    0 0 18px 3px rgba(0, 229, 255, 0.72);
}
button.presence-chip.self.is-offline {
  outline: 3px solid #FFFFFF;
  outline-offset: 3px;
  box-shadow:
    0 0 0 5px rgba(0, 229, 255, 0.82),
    0 0 14px 2px rgba(0, 229, 255, 0.48);
}
/* Click-to-ping peer chips */
button.presence-chip.can-ping {
  cursor: pointer;
}
button.presence-chip.can-ping:hover:not(:disabled) {
  filter: brightness(1.08);
}
button.presence-chip:disabled {
  opacity: 1; /* never wash out names */
  cursor: default;
}
button.presence-chip:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.buzz-toast {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%);
  z-index: 20; max-width: min(420px, calc(100% - 24px));
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--wire);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px color-mix(in oklab, #000 18%, transparent);
  color: var(--ink); font-size: 14px;
}
.buzz-toast[hidden] { display: none !important; }
.buzz-toast .buzz-actions { display: flex; gap: var(--space-2); margin-left: auto; }
.app-shell.is-compact .buzz-toast { top: 44px; }
@media (prefers-reduced-motion: no-preference) {
  .buzz-toast:not([hidden]) {
    animation: buzz-in var(--dur) var(--ease);
  }
}
@keyframes buzz-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}


/* —— Ledger extraction countdown (spaceship HUD) —— */
.ledger-clock {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 6px 14px 6px 12px;
  min-height: 36px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--cyan) 10%, var(--elevated)) 0%, var(--sunken) 100%);
  border: 1px solid color-mix(in oklab, var(--cyan) 55%, var(--line));
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    inset 0 -1px 0 var(--bevel-lo),
    0 0 12px color-mix(in oklab, var(--cyan) 28%, transparent),
    0 0 2px var(--cyan);
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
  overflow: hidden;
}
.ledger-clock[hidden] { display: none !important; }
.ledger-clock-bezel {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0 2px,
      color-mix(in oklab, var(--cyan) 6%, transparent) 2px 3px
    );
  opacity: 0.45;
  mix-blend-mode: screen;
}
.ledger-clock-tag {
  position: relative;
  font-size: 10px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 8px color-mix(in oklab, var(--cyan) 70%, transparent);
  letter-spacing: 0.14em;
}
.ledger-clock-digits {
  position: relative;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: #F4FCFF;
  text-shadow:
    0 0 6px color-mix(in oklab, var(--cyan) 80%, transparent),
    0 0 18px color-mix(in oklab, var(--cyan) 45%, transparent);
  min-width: 4.2ch;
  text-align: center;
}
.ledger-clock-hint {
  position: relative;
  font-size: 10px;
  font-weight: 600;
  color: var(--amber);
  text-shadow: 0 0 8px color-mix(in oklab, var(--amber) 55%, transparent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  max-width: 14ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-clock.is-low {
  border-color: color-mix(in oklab, var(--amber) 70%, var(--line));
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    0 0 16px color-mix(in oklab, var(--amber) 35%, transparent),
    0 0 2px var(--amber);
}
.ledger-clock.is-low .ledger-clock-digits {
  color: #FFF6E0;
  text-shadow:
    0 0 6px color-mix(in oklab, var(--amber) 85%, transparent),
    0 0 18px color-mix(in oklab, var(--amber) 50%, transparent);
}
.ledger-clock.is-low .ledger-clock-tag { color: var(--amber); }
.ledger-clock.is-extracting {
  border-color: color-mix(in oklab, var(--accent) 65%, var(--line));
  box-shadow:
    inset 0 1px 0 var(--bevel-hi),
    0 0 18px color-mix(in oklab, var(--accent) 40%, transparent),
    0 0 3px var(--accent);
}
.ledger-clock.is-extracting .ledger-clock-digits,
.ledger-clock.is-extracting .ledger-clock-tag {
  color: #FFE8EC;
  text-shadow:
    0 0 8px color-mix(in oklab, var(--accent) 80%, transparent),
    0 0 20px color-mix(in oklab, var(--accent) 45%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .ledger-clock:not([hidden]):not(.is-extracting) .ledger-clock-digits {
    animation: ledger-clock-pulse 1.1s ease-in-out infinite;
  }
  .ledger-clock.is-low:not(.is-extracting) .ledger-clock-digits {
    animation: ledger-clock-pulse-fast 0.55s ease-in-out infinite;
  }
  .ledger-clock.is-extracting .ledger-clock-digits {
    animation: ledger-clock-extract 0.4s steps(2, end) infinite;
  }
  .ledger-clock:not([hidden]) .ledger-clock-bezel {
    animation: ledger-scan 2.4s linear infinite;
  }
}
@keyframes ledger-clock-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.82; transform: scale(1.03); }
}
@keyframes ledger-clock-pulse-fast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes ledger-clock-extract {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes ledger-scan {
  from { background-position: 0 0; }
  to { background-position: 0 12px; }
}
.app-shell.is-compact .ledger-clock {
  padding: 4px 10px;
  min-height: 30px;
  gap: 8px;
}
.app-shell.is-compact .ledger-clock-digits { font-size: 18px; }
.app-shell.is-compact .ledger-clock-hint { display: none; }

/* Message Mark as fact — lightweight hover control + context menu */
.msg { position: relative; }
.msg-tools {
  position: absolute; top: 0; right: 0;
  display: flex; gap: 4px;
  opacity: 0; pointer-events: none;
  transition: opacity 120ms ease;
}
.msg:hover .msg-tools,
.msg:focus-within .msg-tools,
.msg.is-fact-queued .msg-tools {
  opacity: 1; pointer-events: auto;
}
.msg-fact-btn {
  appearance: none; margin: 0;
  font: inherit; font-size: 11px; font-weight: 600; line-height: 1.15;
  padding: 2px 7px; min-height: 0;
  border-radius: 4px; border: 1px solid var(--line-strong);
  background: var(--sunken); color: var(--cyan);
  cursor: pointer; white-space: nowrap;
}
.msg-fact-btn:hover, .msg-fact-btn:focus-visible {
  color: #F0F4FF;
  background: color-mix(in oklab, var(--cyan) 22%, var(--sunken));
  border-color: var(--cyan); outline: none;
}
.msg.is-fact-queued {
  outline: 1px dashed color-mix(in oklab, var(--cyan) 55%, var(--line));
  border-radius: 8px;
}
.msg.is-fact-queued .msg-fact-btn {
  border-color: var(--cyan); color: var(--cyan);
}
@media (hover: none) {
  .msg-tools { opacity: 0.85; pointer-events: auto; }
}

/* Message context menu — Mark as fact */
.msg-ctx-menu {
  position: fixed; z-index: 40; min-width: 160px;
  padding: var(--space-1); border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-popover, 0 10px 30px color-mix(in oklab, var(--ink) 18%, transparent));
}
.msg-ctx-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.msg-ctx-item:hover, .msg-ctx-item:focus-visible {
  background: var(--sunken); outline: none;
}


/* Quiet ledger countdown: readable status, no HUD spectacle. */
.ledger-clock {
  gap: 0;
  margin-left: 0;
  padding: 2px 6px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  letter-spacing: 0.02em;
}
.ledger-clock-bezel,
.ledger-clock-tag,
.ledger-clock-hint { display: none; }
.ledger-clock-digits {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  text-shadow: none;
}
.ledger-clock.is-low,
.ledger-clock.is-extracting {
  border-color: var(--line-strong);
  box-shadow: none;
}
.ledger-clock.is-low .ledger-clock-digits,
.ledger-clock.is-extracting .ledger-clock-digits {
  color: var(--ink-2);
  text-shadow: none;
}
@media (prefers-reduced-motion: no-preference) {
  .ledger-clock:not([hidden]) .ledger-clock-digits,
  .ledger-clock:not([hidden]) .ledger-clock-bezel {
    animation: none !important;
  }
}
.app-shell.is-compact .ledger-clock {
  padding: 2px 6px;
  min-height: 0;
  gap: 0;
}
.app-shell.is-compact .ledger-clock-digits { font-size: 14px; }


/* —— App dialogs (create path / invite) —— */
.app-dialog {
  border: 1px solid color-mix(in oklab, var(--cyan) 40%, var(--line));
  border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink-on-dark);
  padding: 0; max-width: min(420px, calc(100vw - 24px));
  box-shadow: var(--panel-shadow);
}
.app-dialog::backdrop {
  background: color-mix(in oklab, #000 55%, transparent);
}
.app-dialog-form {
  display: grid; gap: var(--space-3);
  padding: var(--space-5);
}
.app-dialog-form h2 {
  margin: 0; font-family: var(--font-display); font-size: 18px;
}
.app-dialog-form label {
  display: grid; gap: 6px; font-size: 12px; color: var(--ink-2); font-weight: 600;
}
.app-dialog-form input,
.app-dialog-form select {
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink);
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.invite-result {
  display: grid; gap: 8px;
  padding: 10px; border-radius: var(--radius-md);
  background: var(--sunken); border: 1px solid var(--line);
}

/* —— Trajectory HUD (admin stub) —— */
.traj-hud { color: var(--ink-on-dark); }
.traj-top {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--space-5);
}
.traj-eyebrow {
  margin: 0 0 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.16em;
  color: var(--cyan); text-shadow: 0 0 10px color-mix(in oklab, var(--cyan) 50%, transparent);
}
.traj-title {
  margin: 0; font-family: var(--font-display); font-size: 28px; font-weight: 750;
  letter-spacing: -0.02em;
}
.traj-sub { margin: 8px 0 0; max-width: 52ch; color: var(--ink-2); font-size: 14px; }
.traj-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.traj-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--sunken);
}
.traj-badge.ok { color: #04140A; background: #00E676; border-color: #00FF88; }
.traj-badge.warn { color: #1A1000; background: #FFB020; border-color: #FFC95A; }
.traj-badge.cyan { color: #041018; background: var(--cyan); border-color: var(--cyan-dim); }
.traj-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.traj-span-2 { grid-column: span 2; }
.traj-panel {
  background: var(--elevated, var(--surface));
  border: 1px solid color-mix(in oklab, var(--cyan) 28%, var(--line));
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 0 18px color-mix(in oklab, var(--cyan) 8%, transparent);
}
.traj-panel h2 {
  margin: 0 0 var(--space-3); font-size: 13px; font-weight: 750;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink);
}
.traj-fake {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--amber); margin-left: 8px;
}
.traj-orbit { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.traj-meters { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.traj-meters li {
  display: grid; grid-template-columns: 7.5rem 1fr auto; gap: 8px; align-items: center;
  font-size: 12px; color: var(--ink-2);
}
.traj-meters b { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 2.5rem; text-align: right; }
.traj-bar {
  height: 8px; border-radius: 999px; background: var(--sunken); border: 1px solid var(--line);
  overflow: hidden;
}
.traj-bar i {
  display: block; height: 100%; width: var(--w, 40%);
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  box-shadow: 0 0 10px color-mix(in oklab, var(--cyan) 45%, transparent);
}
.traj-bar.ok i { background: linear-gradient(90deg, #00A854, #00E676); }
.traj-bar.warn i { background: linear-gradient(90deg, #D4890A, #FFB020); }
.traj-attitude {
  position: relative; height: 140px; border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, #0b1520, #05070B 70%);
  border: 1px solid var(--line); overflow: hidden;
}
.traj-ring {
  position: absolute; inset: 24px; border-radius: 50%;
  border: 2px solid color-mix(in oklab, var(--cyan) 55%, transparent);
  box-shadow: 0 0 18px color-mix(in oklab, var(--cyan) 25%, transparent);
}
.traj-cross {
  position: absolute; left: 50%; top: 50%; width: 70%; height: 70%;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(var(--cyan), var(--cyan)) center/100% 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) center/1px 100% no-repeat;
  opacity: 0.55;
}
.traj-pitch, .traj-yaw {
  position: absolute; font-family: var(--font-mono); font-size: 11px; color: #F0F4FF;
}
.traj-pitch { left: 12px; top: 12px; }
.traj-yaw { right: 12px; bottom: 12px; }
.traj-footnote { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); }
.traj-heat { display: grid; gap: 10px; }
.traj-heat-row {
  display: grid; grid-template-columns: 6rem 1fr auto; gap: 10px; align-items: center;
  font-size: 12px; color: var(--ink-2);
}
.traj-heat-row b { color: var(--ink); text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em; }
.traj-spark {
  height: 10px; border-radius: 999px;
  background: repeating-linear-gradient(
    90deg,
    var(--cyan) 0 6px,
    transparent 6px 10px
  );
  width: calc(var(--n, 4) * 10px);
  max-width: 100%;
  box-shadow: 0 0 10px color-mix(in oklab, var(--cyan) 35%, transparent);
}
.traj-links { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 960px) {
  .traj-grid { grid-template-columns: 1fr; }
  .traj-span-2 { grid-column: auto; }
}

/* login password show/hide */
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 46px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--ink) 8%, var(--sunken));
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.password-toggle:hover {
  border-color: var(--cyan);
  color: #fff;
  background: color-mix(in oklab, var(--cyan) 22%, var(--sunken));
}
.password-toggle:focus-visible {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--cyan) 28%, transparent);
}
.password-toggle-icon {
  width: 18px;
  height: 18px;
  display: block;
}
.password-toggle[aria-pressed="true"] {
  border-color: var(--cyan);
  color: #fff;
  background: color-mix(in oklab, var(--cyan) 30%, var(--sunken));
}

/* Profile — display name, global username, optional emoji avatar (photo later). */
.profile-card { max-width: 420px; }
.profile-avatar {
  width: 64px; height: 64px; display: grid; place-items: center;
  margin-bottom: var(--space-4); border-radius: 50%;
  background: var(--wire-tint); color: var(--wire-ink);
  border: 2px solid var(--cyan); font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  box-shadow: 0 0 18px color-mix(in oklab, var(--cyan) 28%, transparent);
}
.profile-facts { display: grid; gap: var(--space-3); margin: var(--space-5) 0; }
.profile-facts div { display: grid; gap: 4px; }
.profile-facts dt { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.profile-facts dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.profile-hint { margin: calc(var(--space-2) * -1) 0 var(--space-2); font-size: 12px; }
.form-ok {
  margin: 0 0 var(--space-3); padding: var(--space-3);
  border-radius: var(--radius-sm); background: color-mix(in oklab, var(--ok) 18%, var(--sunken));
  color: var(--ink-on-dark); border: 1px solid color-mix(in oklab, var(--ok) 40%, var(--line));
  font-size: 13px;
}
.emoji-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: calc(var(--space-2) * -1) 0 var(--space-3); }
.emoji-pick {
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink-on-dark);
  border-radius: var(--radius-sm); padding: 4px 8px; cursor: pointer; font-size: 16px; line-height: 1.2;
}
.emoji-pick:hover { border-color: var(--cyan); }
.emoji-pick-clear { font-size: 12px; color: var(--ink-3); }

/* Right pane horizontal resize — vanilla CSS var drag (--chat-col). */
.right-pane { position: relative; }
.pane-resize-handle {
  position: absolute; left: 0; top: 0; bottom: 0; width: 6px; z-index: 2;
  cursor: col-resize; touch-action: none;
  background: transparent;
}
.pane-resize-handle::after {
  content: ""; position: absolute; left: 2px; top: 30%; bottom: 30%; width: 2px;
  border-radius: 1px; background: color-mix(in oklab, var(--cyan) 35%, var(--line));
  opacity: 0.55; transition: opacity 0.15s ease, background 0.15s ease;
}
.pane-resize-handle:hover::after,
.pane-resize-handle:focus-visible::after,
body.is-resizing-pane .pane-resize-handle::after {
  opacity: 1; background: var(--cyan);
}
body.is-resizing-pane { cursor: col-resize; user-select: none; }
body.is-resizing-pane * { cursor: col-resize !important; }


/* —— Subtopic election (Artifacts AI + left rail) —— */
.context-focus {
  flex: 0 0 auto;
  margin: 0;
  padding: 5px 12px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em;
  line-height: 1.25;
  color: var(--ink-on-dark);
  background: color-mix(in oklab, var(--cyan) 14%, var(--surface));
  border-bottom: 1px solid color-mix(in oklab, var(--cyan) 35%, var(--line));
  box-shadow: inset 3px 0 0 var(--wire, var(--cyan));
}
.context-focus[hidden] { display: none !important; }
.artifact-subtopics {
  margin-top: var(--space-3);
  padding: 12px;
  border: 1px solid #4A5870;
  border-radius: var(--radius-md);
  background: #0C1018;
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.artifact-subtopics h4 {
  margin: 0 0 4px;
  font-size: 13px; font-weight: 800;
  color: var(--ink-on-dark);
  letter-spacing: 0.01em;
}
.artifact-subtopics-hint {
  margin: 0 0 10px;
  font-size: 12px; line-height: 1.35; color: var(--ink-2);
}
.artifact-subtopics-empty {
  margin: 0 0 8px;
  padding: 8px 10px;
  font-size: 12.5px; font-weight: 650;
  color: var(--ink-on-dark);
  background: #1A2233;
  border: 1px dashed #4A5870;
  border-radius: var(--radius-sm);
}
.artifact-subtopics-empty[hidden] { display: none !important; }
.artifact-subtopic-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px;
}
.artifact-subtopic-item {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #556480;
  border-radius: 12px;
  background: #1E2638;
  color: var(--ink-on-dark);
  box-shadow: inset 0 1px 0 var(--bevel-hi), 0 4px 14px rgba(0, 0, 0, 0.28);
}
.artifact-subtopic-text {
  display: grid; gap: 4px; min-width: 0; flex: 1 1 auto;
  color: var(--ink-on-dark); font-size: 13px; line-height: 1.35;
}
.artifact-subtopic-text strong {
  font-size: 13.5px; font-weight: 800;
  color: var(--ink-on-dark);
}
.artifact-subtopic-why {
  display: block; font-size: 12px; line-height: 1.4; color: var(--ink-2);
}
.artifact-subtopic-actions {
  display: inline-flex; gap: 6px; flex: 0 0 auto; align-items: center;
}
.artifact-subtopic-actions .btn {
  font-size: 12px; padding: 5px 10px; min-height: 30px;
}
.artifact-subtopic-actions .btn.dismiss {
  border: 1px solid var(--line-strong, var(--line));
  background: transparent;
  color: var(--ink-on-dark);
}
.artifact-subtopic-actions .btn.dismiss:hover:not(:disabled) {
  border-color: var(--cyan);
  background: color-mix(in oklab, var(--cyan) 10%, var(--surface));
  color: var(--ink-on-dark);
}
.artifact-subtopic-note {
  list-style: none;
  margin: 2px 0 0;
  font-size: 12px; font-weight: 650; line-height: 1.35;
  color: var(--ink-2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--amber) 10%, #1A2233);
  border: 1px solid color-mix(in oklab, var(--amber) 35%, var(--line));
}
.rail-subtopics {
  list-style: none; margin: 2px 0 6px; padding: 0 0 0 14px;
  display: grid; gap: 2px;
  border-left: 1px solid color-mix(in oklab, var(--item-wire, var(--wire)) 45%, var(--line));
  margin-left: 14px;
}
.rail-item.rail-subtopic {
  padding: 5px 8px 5px 8px;
  font-size: 12px;
  color: var(--ink-on-dark);
  border-left: 2px solid var(--item-wire, var(--wire));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.rail-item.rail-subtopic .rail-name { font-weight: 700; color: inherit; }
.rail-item.rail-subtopic .rail-desc {
  font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 700;
}
.rail-item.rail-subtopic.selected {
  color: var(--ink-on-light);
  background: var(--item-tint, var(--selected-chip-bg));
}
.elect-subtopic-blurb {
  margin: 0;
  font-size: 12.5px; line-height: 1.4;
  color: var(--ink-2);
}
.elect-subtopic-blurb strong { color: var(--ink-on-dark); font-weight: 750; }
.elect-subtopic-name {
  margin: 0;
  font-size: 16px; font-weight: 800;
  color: var(--ink-on-dark);
  line-height: 1.25;
}
.elect-subtopic-why {
  margin: 0;
  font-size: 13px; line-height: 1.4; color: var(--ink-2);
}
.elect-members {
  border: 1px solid #4A5870;
  border-radius: var(--radius-md);
  padding: 10px 12px 12px;
  margin: 0;
  background: #0C1018;
}
.elect-members legend {
  padding: 0 6px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-on-dark);
}
.elect-members-hint {
  margin: 0 0 8px;
  font-size: 12px; color: var(--ink-2); line-height: 1.35;
}
.elect-members-list {
  display: grid; gap: 6px; max-height: 220px; overflow: auto;
}
.elect-members-empty {
  margin: 8px 0 0;
  padding: 8px 10px;
  font-size: 12.5px; font-weight: 650;
  color: var(--ink-on-dark);
  background: #1A2233;
  border: 1px dashed #4A5870;
  border-radius: var(--radius-sm);
}
.elect-members-empty[hidden] { display: none !important; }
.app-dialog-form .elect-member-row,
.elect-member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: #1A2233;
  font-size: 13px; font-weight: 650;
  color: var(--ink-on-dark);
  cursor: pointer;
}
.app-dialog-form .elect-member-row:hover,
.elect-member-row:hover {
  border-color: color-mix(in oklab, var(--cyan) 40%, var(--line));
}
.app-dialog-form .elect-member-row input,
.elect-member-row input {
  width: 16px; height: 16px; flex: 0 0 auto;
  accent-color: var(--wire, var(--cyan));
}
.elect-member-name {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-on-dark);
}
.elect-member-role {
  flex: 0 0 auto;
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  color: var(--ink-on-dark);
  border: 1px solid #4A5870;
  background: color-mix(in oklab, var(--cyan) 12%, #10141C);
}
#elect-subtopic-err:not([hidden]) {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--accent) 45%, var(--line));
  background: color-mix(in oklab, var(--accent) 12%, #1A2233);
  color: #FFB4BA;
  font-size: 12.5px; font-weight: 700;
}

.object-tree-head { justify-content: space-between; }
.object-tree-add {
  width: 22px; height: 22px; padding: 0; border-radius: 4px;
  border: 1px solid color-mix(in oklab, var(--cyan) 45%, var(--line));
  background: color-mix(in oklab, var(--cyan) 16%, transparent);
  color: var(--cyan); font-weight: 800; cursor: pointer; line-height: 1;
}
.object-tree-add:hover { filter: brightness(1.15); }
.object-tree-actions {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px 6px 6px;
  border-bottom: 1px solid color-mix(in oklab, var(--cyan) 18%, var(--line));
}
.object-tree-act {
  font: inherit; font-size: 10px; font-weight: 750; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 3px 6px; border-radius: 3px;
  border: 1px solid color-mix(in oklab, var(--amber, #F4C542) 40%, var(--line));
  background: color-mix(in oklab, var(--amber, #F4C542) 12%, transparent);
  color: #ffe9a8; cursor: pointer;
}
.object-tree-act:hover { filter: brightness(1.1); }
.object-tree-node[data-kind="repo"] .object-tree-badge { color: #7dffb3; }
.object-tree-node[data-kind="repo_tree"] .object-tree-badge,
.object-tree-node[data-kind="repo_blob"] .object-tree-badge { color: #9ad7ff; }
.object-tree-dialog {
  border: 1px solid color-mix(in oklab, var(--cyan) 40%, var(--line));
  border-radius: 8px; padding: 0; background: var(--surface); color: var(--ink-on-dark);
  box-shadow: var(--panel-shadow, 0 12px 40px rgba(0,0,0,0.45));
  max-width: min(420px, 92vw);
}
.object-tree-dialog::backdrop { background: rgba(0,0,0,0.55); }
.object-tree-dialog-form { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.object-tree-dialog-form h3 { margin: 0; font-size: 14px; color: var(--ink-on-dark); }
.object-tree-dialog-hint { margin: 0; font-size: 11px; color: var(--ink-2); }
.object-tree-dialog-form input {
  font: inherit; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink-on-dark);
}
.object-tree-dialog-err { margin: 0; color: #ff8a8a; font-size: 12px; }
.object-tree-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Live metric cards (telemetry API v1) ───────────────────────────────
   Dark HUD tile: big number + inline SVG sparkline. Animation is CSS only:
   one pulse per hub update (.mc-tick, class re-added by JS) and a slow LIVE
   dot. No JS animation loops. */
.msg.metric-card-msg { align-self: flex-start; max-width: min(360px, 96%); margin: 6px var(--space-5); }
.metric-card {
  --mc: var(--cyan);
  position: relative;
  padding: 10px 14px 8px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--mc);
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in oklab, var(--mc) 8%, var(--sunken)), var(--sunken));
  color: var(--ink-on-dark);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.metric-card[data-state="breach"] { --mc: var(--accent); }
.metric-card[data-state="nodata"], .metric-card.ended { --mc: var(--ink-3); }
.metric-card.ended { opacity: 0.6; }
.mc-head { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.04em; color: var(--ink-2); }
.mc-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--ink-on-dark); }
.mc-live { font-size: 10px; text-transform: uppercase; color: var(--mc); position: relative; padding-left: 12px; }
.mc-live::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--mc);
  animation: mc-live-dot 2.4s ease-in-out infinite;
}
.metric-card.ended .mc-live::before, .metric-card[data-state="nodata"] .mc-live::before { animation: none; opacity: 0.4; }
.mc-remove { background: none; border: 0; color: var(--ink-3); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.mc-remove:hover { color: var(--ink-on-dark); }
.mc-value { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--ink-on-dark); }
.mc-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.mc-spark { display: block; width: 100%; height: 28px; margin-top: 4px; overflow: visible; }
.mc-line { fill: none; stroke: var(--mc); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mc-area { fill: color-mix(in oklab, var(--mc) 16%, transparent); stroke: none; }
.mc-dot { fill: var(--mc); }
.metric-card.mc-tick .mc-value { animation: mc-tick 0.9s ease-out 1; }
.metric-card.mc-tick .mc-line { animation: mc-draw 0.9s ease-out 1; }
@keyframes mc-tick { 0% { color: var(--mc); text-shadow: 0 0 10px var(--mc); } 100% { color: var(--ink-on-dark); text-shadow: 0 0 0 transparent; } }
@keyframes mc-draw { 0% { opacity: 0.35; } 100% { opacity: 1; } }
@keyframes mc-live-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
@media (prefers-reduced-motion: reduce) {
  .mc-live::before, .metric-card.mc-tick .mc-value, .metric-card.mc-tick .mc-line { animation: none; }
}
.admin-spark { display: block; }
.admin-spark polyline { fill: none; stroke: var(--cyan); stroke-width: 1.5; stroke-linejoin: round; }
