/* Panolayer Link — Nova design system
   One source of truth for tokens, shell, components, and responsive states. */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-wght.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Panolayer "Nova" palette.
     These values are copied from the desktop app's Tailwind theme
     (wails-app/panolayer/frontend/client/src/index.css, :root) so Link reads as
     the same product and can adopt the app's Tailwind classes later without a
     second visual language. Roles, not decoration:
       background  page canvas           foreground  primary text
       card        panels/surfaces       border      hairlines
       primary     brand action (coral) selection   focus + selected state
       link        text links            status-*    agent/work state
     Change a value here only by copying it from that file. */
  --background: #f4f3f0;
  --foreground: #1c1a17;
  --card: #fbfaf7;
  --primary: #e2542f;
  --primary-foreground: #ffffff;
  --primary-grad-a: #ff6b6b;
  --primary-grad-b: #ffa97a;
  --primary-gradient: linear-gradient(60deg, #ff6b6b 0%, #ffa97a 100%);
  --secondary: #eae8e2;          /* surface, per the app's Tailwind theme */
  --secondary-foreground: #55504a;
  --muted: #eae8e2;              /* surface */
  --muted-foreground: #6f6a61;
  --border: #e4e1d9;
  --input: #e4e1d9;
  --selection: #2e7ff0;
  --selection-foreground: #ffffff;
  --link: #2e7ff0;
  --link-text: #1d5fc4;
  --ring: var(--selection);
  --destructive: #dc2626;
  --status-success: #15b07a;
  --status-warning: #d99a08;
  --status-error: #e0322f;
  --status-pending: #9aa0a6;
  --status-running: #0aa6c8;
  --sidebar: #efece6;

  /* Link's own surface names, mapped onto the roles above so existing rules keep
     working while there is exactly one source of truth. */
  --canvas: var(--background);
  --canvas-deep: #ece9e4;
  --paper: var(--card);
  --surface: var(--card);
  --surface-raised: var(--card);
  --surface-soft: #f7f6f3;
  --surface-sunken: #eae8e2;
  --ink: var(--foreground);
  --ink-soft: #3f3b36;
  /* Text uses the -foreground roles; the bare tokens are surfaces. */
  --text-muted: var(--muted-foreground);
  --text-secondary: var(--secondary-foreground);
  --line: var(--border);
  --line-soft: #ebe8e2;
  --brand: var(--primary);
  --brand-deep: #b63e21;
  --brand-soft: #fff0e9;
  --brand-gradient: var(--primary-gradient);
  --primary-hover: #c9482a;
  --primary-soft: #fff0e9;
  --selection-soft: #eaf2ff;
  --success: var(--status-success);
  /* Dark "agent reply" ground — the surface the desktop app renders agent-written
     markdown on. Values copied from the app's theme (.dark block + --agent-*):
     a palette-tinted glow over a warm off-black, never flat grey. */
  --agent-surface: #171317;
  --agent-surface-top: #201a1c;
  --agent-surface-bottom: #121014;
  --agent-surface-foreground: #f2edf2;
  --agent-code-bg: #100d12;
  --agent-code-border: color-mix(in srgb, var(--primary) 16%, #2e2836);
  --agent-inline-code: color-mix(in srgb, var(--primary) 30%, #f2edf2);
  --agent-muted: #a89ea8;
  --agent-link: #7fb0ff;
  --agent-glow-a: color-mix(in srgb, var(--primary-grad-a) 16%, transparent);
  --agent-glow-b: color-mix(in srgb, var(--primary-grad-b) 7%, transparent);
  /* Heading scale derived from --primary, exactly as the app derives it. */
  --heading-1: var(--agent-surface-foreground);
  --heading-2: color-mix(in srgb, #ffa477 82%, var(--agent-surface-foreground));
  --heading-3: color-mix(in srgb, #ffa477 42%, var(--agent-surface-foreground));
  --heading-rule: color-mix(in srgb, var(--primary) 22%, #2e2836);

  /* Text-on-tint roles: darkened so small labels on the soft washes clear 4.5:1. */
  --success-text: #0f7d57;
  --warning-text: #7a5410;
  --danger-text: #8f2f26;
  --accent-text: #b63e21;
  --success-soft: #e8f6ef;
  --warning: #94671b;
  --warning-soft: #fff6df;
  --danger: #a33b31;
  --danger-soft: #fff0ee;
  --shadow-xs: 0 1px 2px rgb(28 26 17 / 0.05);
  --shadow-sm: 0 5px 16px rgb(28 26 17 / 0.08);
  --shadow-md: 0 16px 44px rgb(28 26 17 / 0.13);
  --shadow-lg: 0 30px 80px rgb(28 26 17 / 0.18);
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  /* One inset scale. Surfaces use these instead of ad-hoc pixel values so the
     rail, panels, rows and dialogs line up on the same vertical rhythm. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --font-sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --header-height: 70px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }
html,
body { width: 100%; min-width: 0; height: 100%; }
html { background: var(--canvas); }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 70% -20%, rgb(255 255 255 / 0.9), transparent 38%),
    var(--canvas);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button,
input::placeholder,
textarea::placeholder { color: var(--text-muted); opacity: 1; }
select { color: var(--text-secondary); }
input,
select,
textarea { font: inherit; }
button,
a,
summary,
[role="button"] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--link-text); text-underline-offset: 3px; }
img,
svg { max-width: 100%; }
[hidden] { display: none !important; }
.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; }
::selection { color: var(--ink); background: #cfe2ff; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--selection);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* Typography */
h1,
h2,
h3,
h4,
p { margin-top: 0; }
h1,
h2,
h3,
h4 { color: var(--ink); letter-spacing: -0.025em; line-height: 1.16; }
h1 { font-size: clamp(24px, 2.5vw, 34px); font-weight: 720; }
h2 { margin-bottom: 10px; font-size: 22px; font-weight: 680; }
h3 { margin: 22px 0 10px; font-size: 15px; font-weight: 680; }
p { color: var(--ink-soft); }
code,
pre,
kbd,
.snippet,
.file-path,
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-secondary); }
.small { font-size: 12.5px; }
.eyebrow {
  display: inline-block;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 720;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}
.pill-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.7);
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}

/* Global controls */
button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
button {
  min-height: 36px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 620;
  box-shadow: var(--shadow-xs);
}
button:hover { border-color: #c6c0b8; background: var(--surface-soft); }
button:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: 0.48; box-shadow: none; }
input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}
input:hover,
select:hover,
textarea:hover { border-color: #c5bfb7; }
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--secondary) 50%), linear-gradient(135deg, var(--secondary) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}
input[type="color"] { min-width: 52px; padding: 5px; }
input[type="checkbox"],
input[type="radio"] { width: 17px; min-height: 17px; accent-color: var(--primary); }
label { color: var(--ink-soft); font-size: 13px; font-weight: 610; }
.field-label { display: block; margin: 16px 0 8px; color: var(--ink-soft); font-size: 13px; font-weight: 610; }
label > input,
label > select,
label > textarea { margin-top: 7px; }
fieldset {
  min-width: 0;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}
legend { padding: 0 6px; font-weight: 680; }

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 9px rgb(39 94 168 / 0.22);
}
.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.primary:disabled { background: #7289a8; }
.danger-button {
  border-color: #e7c0bb;
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: none;
}
.danger-button:hover { border-color: #dcaaa2; background: #ffe4e0; }
.text-button {
  min-height: 28px;
  padding: 3px 5px;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  box-shadow: none;
  font-size: 12px;
}
.text-button:hover { background: var(--primary-soft); }
.icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}
.icon-button:hover { border-color: var(--line-soft); background: var(--surface-sunken); color: var(--ink); }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.form-error {
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid #e7c0bb;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

/* Header */
.app-header {
  z-index: 30;
  flex: 0 0 var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
  height: var(--header-height);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--line-soft);
  background: rgb(251 250 247 / 0.9);
  backdrop-filter: blur(18px) saturate(1.2);
}
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-icon { width: 38px; height: 38px; border-radius: 12px; object-fit: contain; }
.brand-wordmark { font-size: 20px; font-weight: 670; letter-spacing: -0.035em; }
.brand-wordmark b {
  width: fit-content;
  padding-right: 1px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 760;
}
.brand-promise {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 520;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-account { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.header-account #account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.header-settings-button { border-color: var(--line-soft); background: var(--surface); }
.human-live-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 9px;
  border-color: var(--line-soft);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.72);
  color: var(--text-secondary);
  box-shadow: none;
  font-size: 11.5px;
  font-weight: 620;
}
.human-live-status:hover { background: var(--surface); border-color: var(--line); }
.human-live-status.live-connected { color: var(--success); background: var(--success-soft); border-color: #c5e7d7; }
.human-live-status.live-reconnecting { color: var(--warning); background: var(--warning-soft); border-color: #ead7a6; }
.human-live-status.live-offline { color: var(--text-secondary); background: var(--surface-sunken); }
.live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgb(163 157 149 / 0.13);
}
.human-live-status.live-connected .live-dot,
.live-status.live-connected .live-dot,
.status-live .live-dot,
.sidebar-live-card.is-connected .live-dot,
.rail-live-row.is-live .live-dot {
  background: #36a875;
  box-shadow: 0 0 0 3px rgb(54 168 117 / 0.14);
  animation: live-breathe 2.4s ease-in-out infinite;
}
.human-live-status.live-connecting .live-dot,
.human-live-status.live-reconnecting .live-dot,
.live-status.live-connecting .live-dot,
.live-status.live-reconnecting .live-dot,
.sidebar-live-card.is-connecting .live-dot,
.sidebar-live-card.is-reconnecting .live-dot,
.rail-live-row.is-connecting .live-dot,
.rail-live-row.is-reconnecting .live-dot { background: #d19a36; }
.human-live-status.live-offline .live-dot,
.live-status.live-offline .live-dot,
.live-error .live-dot,
.sidebar-live-card.is-offline .live-dot,
.rail-live-row.is-offline .live-dot { background: var(--faint); }
@keyframes live-breathe { 50% { transform: scale(0.72); box-shadow: 0 0 0 5px rgb(54 168 117 / 0.08); } }

/* Toasts */
.toasts {
  position: fixed;
  z-index: 120;
  top: 76px;
  left: 50%;
  display: grid;
  gap: 8px;
  width: min(560px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 24px;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--ink-soft);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 180ms var(--ease);
}
.toast-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 150ms ease, transform 150ms ease; }
.toast-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}
.toast-text { overflow-wrap: anywhere; }
.toast-close { border: 0; background: none; color: var(--text-muted); font-size: 15px; line-height: 1; cursor: pointer; padding: 2px; }
.toast-close:hover { color: var(--ink); }
.toast-success { border-color: #bfe0cd; }
.toast-success .toast-icon { background: #e4f4eb; color: #2f7d57; }
.toast-error { border-color: #e7c0bb; background: var(--danger-soft); color: var(--danger); }
.toast-error .toast-icon { background: #f6ded9; color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* Dialog chrome: one visible close affordance on every modal */
.dialog-close {
  position: absolute;
  z-index: 2;
  top: calc(var(--dialog-pad, 24px) + 2px);
  right: calc(var(--dialog-pad, 24px) + 2px);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.dialog-close:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.dialog-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
dialog { position: relative; }

/* Entity context menu */
.entity-menu {
  position: fixed;
  z-index: 140;
  min-width: 208px;
  max-height: min(70vh, 460px);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}
.entity-menu-heading { padding: var(--space-2) var(--space-2) var(--space-1); color: var(--text-muted); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.entity-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-soft);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.entity-menu-item:hover,
.entity-menu-item:focus-visible { background: var(--primary-soft); color: var(--accent-text); outline: none; }
.entity-menu-item.is-danger { color: var(--danger); }
.entity-menu-item.is-danger:hover { background: var(--danger-soft); }
.entity-menu-sep { height: 1px; margin: 5px 6px; background: var(--line-soft); }

/* Welcome */
#welcome {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.7fr);
  align-items: center;
  gap: clamp(42px, 8vw, 120px);
  min-height: 0;
  padding: clamp(36px, 7vw, 100px);
  overflow: auto;
}
.intro { max-width: 680px; }
.intro h1 { margin: 24px 0 20px; font-size: clamp(42px, 6vw, 78px); font-weight: 690; letter-spacing: -0.055em; }
.intro > p { max-width: 580px; color: var(--text-secondary); font-size: 17px; }
.welcome-steps { display: grid; gap: 10px; margin: 32px 0 0; padding: 0; list-style: none; color: var(--text-secondary); }
.welcome-steps li { display: flex; align-items: center; gap: 12px; }
.welcome-steps span { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand-deep); font: 10px/1 var(--font-mono); }
.signin-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}

/* Application shell */
#app {
  flex: 1;
  display: grid;
  grid-template-columns: 236px minmax(480px, 1fr) 292px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.sidebar,
.details {
  min-height: 0;
  background: rgb(247 246 243 / 0.84);
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-3) var(--space-4);
  border-right: 1px solid var(--line-soft);
}
.sidebar-section { min-width: 0; }
.spaces-section { flex: 0 0 auto; }
.topics-section { flex: 1 1 auto; min-height: 90px; overflow-y: auto; scrollbar-width: thin; }
.label-row { display: flex; align-items: center; justify-content: space-between; min-height: 30px; padding: 0 5px 4px 9px; }
.label-row h2 { margin: 0; color: var(--text-muted); font-size: 10.5px; font-weight: 740; letter-spacing: 0.11em; text-transform: uppercase; }
.label-row .icon-button { width: 30px; min-width: 30px; height: 30px; }
.label-row .icon-button:hover { color: var(--ink); background: #e9e6e1; }
.nav-stack { display: grid; gap: 3px; min-width: 0; }
.nav-stack > button,
.nav-stack > a {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
  font-size: 13px;
  font-weight: 560;
  text-align: left;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-stack > button:hover,
.nav-stack > a:hover { background: #ebe8e3; color: var(--ink); }
.nav-stack > button.selected,
.nav-stack > a.selected { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-xs); font-weight: 650; }
.archived-topics { margin-top: 8px; padding: 0 4px; }
.archived-topics > summary,
.connection-explainer > summary,
.invitation-settings > summary,
.danger-zone > summary,
details.agent-telemetry > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  list-style: none;
}
.archived-topics > summary::-webkit-details-marker,
.connection-explainer > summary::-webkit-details-marker,
.invitation-settings > summary::-webkit-details-marker,
.danger-zone > summary::-webkit-details-marker,
.agent-telemetry > summary::-webkit-details-marker { display: none; }
.chevron { width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 5px solid currentColor; transition: transform 160ms ease; }
.archived-topics[open] .chevron { transform: rotate(90deg); }
.sidebar-live-card {
  flex: 0 0 auto;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.55);
}
.sidebar-live-heading { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; font-size: 11px; }
.sidebar-live-copy { display: block; color: var(--text-secondary); font-size: 11.5px; font-weight: 570; }
.sidebar-live-help { display: block; margin-top: 5px; color: var(--text-muted); font-size: 10.5px; line-height: 1.4; }

.conversation {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
}
.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: 82px;
  padding: var(--space-4) var(--space-6) var(--space-3);
  border-bottom: 1px solid var(--line-soft);
}
.conversation-heading { min-width: 0; }
.conversation-heading .eyebrow { margin-bottom: 2px; }
.conversation-heading h1 { max-width: min(620px, 45vw); margin: 0; overflow: hidden; font-size: clamp(21px, 2vw, 28px); font-weight: 690; text-overflow: ellipsis; white-space: nowrap; }
.space-actions { position: relative; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.space-actions button { white-space: nowrap; }
.space-actions svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.space-network-button { display: inline-flex; align-items: center; gap: 7px; border-color: var(--line-soft); background: var(--surface); color: var(--text-secondary); box-shadow: none; }
.space-network-button:hover { color: var(--ink); border-color: #c8c2ba; }
.invite-header-button { display: inline-flex; align-items: center; gap: 7px; }
.more-button { border-color: var(--line-soft); background: var(--surface); }
.space-menu-wrap { position: relative; }

.menu-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  width: min(318px, calc(100vw - 24px));
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  transform-origin: top right;
  animation: menu-in 130ms var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-5px) scale(0.98); } }
.menu-label { padding: 8px 10px 6px; color: var(--text-muted); font-size: 10px; font-weight: 720; letter-spacing: 0.09em; text-transform: uppercase; }
.menu-panel button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 8px 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.menu-panel button:hover,
.menu-panel button:focus-visible { background: var(--surface-soft); }
.menu-panel button > span:last-child { display: grid; gap: 1px; }
.menu-panel strong { color: var(--ink); font-size: 12.5px; font-weight: 640; }
.menu-panel small { color: var(--text-muted); font-size: 10.5px; font-weight: 450; }
.menu-item-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-sunken); color: var(--text-secondary); font-size: 13px; }
.refresh-glyph { font-size: 17px; }
.menu-separator { height: 1px; margin: 6px 7px; background: var(--line-soft); }

.lifecycle-banner { margin: 0; padding: 9px 24px; border-bottom: 1px solid #ead7a6; background: var(--warning-soft); color: #76551b; font-size: 12px; }
.channel-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 45px;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--line-soft);
  background: rgb(251 250 247 / 0.88);
}
.tabs { display: flex; align-items: stretch; align-self: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative;
  min-height: 44px;
  padding: 0 11px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 560;
  white-space: nowrap;
}
.tabs button:hover { background: var(--surface-soft); color: var(--ink); }
.tabs button.selected { color: var(--ink); font-weight: 670; }
.tabs button.selected::after { content: ""; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 2px; border-radius: 2px 2px 0 0; background: var(--ink); }
.tabs button span { margin-right: 4px; color: var(--faint); }
.tabs button.selected span { color: var(--accent-text); }
.live-status { display: flex; align-items: center; flex: 0 0 auto; gap: 7px; color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }
.live-status.is-ready { color: var(--success); }
.presence-summary {
  min-height: 34px;
  padding: 8px 24px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: var(--surface-soft);
  color: var(--text-muted);
  box-shadow: none;
  font-size: 10.5px;
  font-weight: 570;
  text-align: left;
}
.presence-summary:hover { background: var(--surface-sunken); color: var(--ink-soft); }

.view { min-width: 0; min-height: 0; }
.messages-view { flex: 1 1 auto; overflow-y: auto; scroll-behavior: smooth; padding: var(--space-3) var(--space-6) var(--space-6); }
#files,
#context,
#work,
#agents-view,
#network { flex: 1 1 auto; overflow-y: auto; padding: var(--space-6); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
.section-heading h2,
.network-heading h2 { margin: 4px 0 0; }
.section-intro { max-width: 680px; margin-bottom: var(--space-4); }
.actions.file-upload-actions { flex-wrap: nowrap; margin: 0; }
.actions.file-upload-actions input { width: min(260px, 26vw); }
.content-panel {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.content-panel h3 { margin-top: 0; }
.document-preview,
.context-body {
  margin: 0 0 14px;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #24221f;
  color: #f3f1ed;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.context-form { display: grid; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-md); background: var(--surface); }
.context-form textarea { min-height: 110px; }
.context-form-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.context-form-footer button { justify-self: end; }
#context-size.is-near-limit { color: #b4453c; font-weight: 600; }
.context-entries { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
.context-entry { padding: var(--space-3) var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-md); background: var(--surface); }
.context-entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 12px; }
.context-entry-body { overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.context-entry-body.is-clamped { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 8; }
.context-citations { margin: 8px 0 0; padding-left: 16px; font-size: 12px; }
.context-citations q { display: block; color: var(--text-muted); }
#context-older { margin-top: 12px; }

/* Messages */
.empty { margin: 32px auto; max-width: 440px; padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius-lg); color: var(--text-muted); text-align: center; }
.entry.message-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 13px;
  margin: 0 0 4px;
  padding: 15px 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.entry.message-card:hover { border-color: var(--line-soft); background: rgb(255 255 255 / 0.62); }
.entry.message-card.highlight { border-color: #9fc3f4; background: var(--primary-soft); animation: message-highlight 1.6s ease; }
@keyframes message-highlight { 0%, 70% { background: #dcecff; } }
.avatar {
  --avatar: #8067dc;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  overflow: hidden;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--avatar);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-xs);
  color: #fff;
  font-size: 14px;
  font-weight: 760;
  line-height: 1;
}
.message-card > .avatar { width: 48px; height: 48px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-cat { padding: 4px; background: var(--avatar); }
.avatar-cat::before { content: "▱"; font-size: 23px; text-shadow: 0 1px 0 rgb(0 0 0 / 0.12); }
.avatar-cat picture { position: absolute; inset: 4px; display: block; }
.avatar-mascot { padding: 2px; background: var(--brand-soft); }
.message-content { min-width: 0; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 9px; min-width: 0; color: var(--text-muted); font-size: 11px; }
.message-content > .meta:first-child { min-height: 24px; margin-bottom: 6px; }
.message-content .meta b,
.sender-name { color: var(--ink); font-size: 12.5px; font-weight: 700; }
.sender-name { min-height: auto; padding: 0; border: 0; background: transparent; box-shadow: none; }
.sender-name:hover { color: var(--accent-text); background: transparent; }
.meta time { margin-left: 3px; }
.status {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 570;
  line-height: 1.2;
}
.body { margin: 2px 0 9px; color: var(--ink-soft); font-size: 14.5px; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.body.collapsed { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 8; }
.reply-quote {
  display: block;
  width: min(720px, 100%);
  min-height: 34px;
  margin: 5px 0 9px;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  box-shadow: none;
  font-size: 11px;
  font-weight: 490;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-quote:hover { border-color: #bfcde0; color: var(--ink); }
.message-content > .small.muted { margin: 4px 0; overflow-wrap: anywhere; }
.reply-button { min-height: 25px; padding: 3px 6px; border: 0; background: transparent; color: var(--accent-text); box-shadow: none; font-size: 11px; }
.reply-button:hover { background: var(--primary-soft); }
.message-content > .meta:last-child { margin-top: 7px; }
.receipt-pending,
.receipt-received { border-color: #d8e5d7; background: #f2f8f2; color: #426b4e; }
.receipt-thinking { border-color: #d2e0f2; background: #eef5ff; color: #35699d; }
.receipt-working { border-color: #dddcf2; background: #f2f1fb; color: #5e57a0; }
.receipt-completed { border-color: #c5e7d7; background: var(--success-soft); color: var(--success); }
.receipt-blocked { border-color: #ead7a6; background: var(--warning-soft); color: var(--warning); }

/* Compact receipt disclosure hook for app.js */
.receipt-control { position: relative; display: inline-flex; }
.receipt-trigger { min-height: 25px; padding: 3px 7px; border: 1px solid var(--line-soft); border-radius: 999px; background: var(--surface-soft); color: var(--text-secondary); box-shadow: none; font-size: 10.5px; }
.receipt-popover {
  position: absolute;
  z-index: 40;
  top: calc(100% + 7px);
  left: 0;
  display: none;
  width: min(290px, 74vw);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  color: var(--ink-soft);
  font-size: 11px;
}
.receipt-control:hover .receipt-popover,
.receipt-control:focus-within .receipt-popover { display: block; }
.receipt-popover strong { display: block; margin-bottom: 5px; color: var(--ink); }
.receipt-popover-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--line-soft); }
.receipt-popover-row:first-of-type { border-top: 0; }

/* Files, work, people */
.file-row,
.team-row,
.access-event,
.setting-row,
.connection-list > * {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line-soft);
}
.file-row:last-child,
.team-row:last-child,
.access-event:last-child,
.setting-row:last-child { border-bottom: 0; }
/* File and document rows: icon, a two-line description, one action. The whole
   row is the preview affordance, so no competing buttons sit in the middle. */
.file-row.is-clickable {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  margin: 0 calc(-1 * var(--space-2));
  border-bottom: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 120ms var(--ease);
}
.file-row.is-clickable:hover { background: var(--surface-soft); }
.file-row.is-clickable:focus-visible { outline: 2px solid var(--selection); outline-offset: -2px; }
.file-row.is-clickable:last-child { border-bottom: 0; }
.file-kind-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-secondary);
}
.file-main { min-width: 0; }
.file-main .file-path { margin: 0; color: var(--ink); font-size: 13px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; overflow: hidden; }
.entity-topics.is-inline { display: inline-flex; margin: 0; }
.file-download { flex: 0 0 auto; color: var(--text-secondary); }
.file-download:hover { color: var(--ink); background: var(--surface-sunken); }
.file-path { margin-bottom: 3px; color: var(--ink-soft); font-size: 11.5px; overflow-wrap: anywhere; }
.team-row-name { display: grid; flex: 1; min-width: 0; }
.team-row-name strong,
.team-row-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-orb { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.member-option { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface); }
.member-option + .member-option { margin-top: 6px; }
.member-option:hover { border-color: #c6c0b8; }
.connection-list { display: grid; gap: 8px; }

/* Agent cards and right rail */
.rail-agents { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-2) var(--space-3) var(--space-3); scrollbar-width: thin; }
.identity { position: relative; min-width: 0; }
.rail-agents .identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 7px;
  padding: 10px 8px;
  border-radius: 11px;
  transition: background-color 140ms ease;
}
.rail-agents .identity:hover { background: rgb(255 255 255 / 0.8); }
.agent-card-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.agent-identity-button { display: flex; align-items: center; flex: 1; min-width: 0; min-height: 44px; padding: 0; border: 0; background: transparent; box-shadow: none; text-align: left; }
.agent-identity-button:hover { background: transparent; }
.agent-identity-button:hover .avatar { transform: translateY(-1px) scale(1.035); }
.agent-identity-button .avatar { width: 52px; height: 52px; transition: transform 160ms var(--ease); }
.identity-text { display: grid; gap: 1px; min-width: 0; margin-left: 2px; }
.identity-text strong { overflow: hidden; color: var(--ink); font-size: 12.5px; font-weight: 670; text-overflow: ellipsis; white-space: nowrap; }
.identity-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-menu { width: 30px; min-width: 30px; height: 30px; min-height: 30px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); box-shadow: none; }
.agent-menu:hover { background: var(--surface-sunken); }
.presence-badge { grid-column: 1; width: fit-content; display: inline-flex; align-items: center; gap: 5px; margin-left: 60px; padding: 1px 6px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-muted); font-size: 9.5px; font-weight: 600; }
.presence-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.presence-streaming { background: var(--success-soft); color: var(--success-text); }
.presence-api_only { background: var(--primary-soft); color: var(--primary); }
.presence-offline,
.presence-never_connected { color: var(--text-muted); }
.presence-revoked { background: var(--danger-soft); color: var(--danger); }
.agent-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 7px; }
.agent-stats > div { display: grid; gap: 1px; padding: 8px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--surface-soft); }
.agent-stats strong { font-size: 15px; }
.agent-stats span { color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; }
.agent-topic-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.topic-chip { min-height: 25px; padding: 3px 7px; border-color: var(--line-soft); background: var(--surface-soft); color: var(--text-secondary); font-size: 10px; }
.agent-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.agent-telemetry { margin-top: 8px; padding-top: 4px; border-top: 1px solid var(--line-soft); }
.agent-telemetry summary { min-height: 28px; }
.agent-telemetry > div { padding: 3px 0; }
.agent-telemetry code { display: block; max-width: 100%; padding: 5px 7px; overflow: hidden; border-radius: 6px; background: var(--surface-sunken); color: var(--text-muted); font-size: 9.5px; text-overflow: ellipsis; }

.details {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--line-soft);
}
.details-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 17px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.details-heading h2 { margin: 3px 0 0; font-size: 15px; font-weight: 680; }
.details-count { color: var(--text-muted); font: 9px/1.2 var(--font-mono); letter-spacing: 0.06em; }
.rail-footer { flex: 0 0 auto; padding: 12px 16px 15px; border-top: 1px solid var(--line-soft); background: rgb(255 255 255 / 0.4); }
.rail-live-row { display: flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: 11px; }
.rail-footer p { margin: 5px 0 0; color: var(--text-muted); font-size: 10px; line-height: 1.45; }

/* Agents view */
.crew-hero { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 20px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: linear-gradient(120deg, #fff 0%, #fff8f4 100%); }
.crew-hero img { width: 88px; height: 88px; object-fit: cover; border-radius: 24px; box-shadow: var(--shadow-sm); }
.crew-hero h2 { margin: 4px 0 5px; font-size: 26px; }
.crew-hero p { max-width: 580px; margin: 0; }
.connection-explainer { margin: 12px 0 16px; padding: 0 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface); }
.connection-explainer p { margin: 3px 0 12px; font-size: 12px; }
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.agents-grid .agent-card { display: grid; padding: 15px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-xs); transition: transform 160ms var(--ease), box-shadow 160ms ease; }
.agents-grid .agent-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.agents-grid .presence-badge { margin-left: 0; }

/* Space-wide network */
.network-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 16px; }
.network-heading > div { max-width: 720px; }
.network-heading p { max-width: 650px; margin: 6px 0 0; }
.network-heading button { flex: 0 0 auto; }
#network-canvas {
  position: relative;
  height: clamp(430px, 60vh, 720px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background-color: #f8f9fb;
  background-image: radial-gradient(#cbd1d9 1px, transparent 1px);
  background-size: 20px 20px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8);
}
#network-edges,
#network-nodes { position: absolute; inset: 0; width: 100%; height: 100%; }
#network-edges { overflow: visible; pointer-events: none; }
#network-nodes { pointer-events: none; }
.network-grid-label { position: absolute; top: 14px; z-index: 2; color: var(--text-muted); font: 9px/1 var(--font-mono); letter-spacing: 0.1em; }
.network-grid-label-agents { left: 24px; }
.network-grid-label-topics { right: 24px; }
.graph-node {
  position: absolute;
  z-index: 3;
  width: 150px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  transition: opacity 180ms ease, transform 180ms var(--ease);
}
.node-core { position: relative; width: 68px; margin: 0 auto 8px; }
.node-face { display: grid; place-items: center; width: 68px; height: 68px; min-height: auto; margin: 0; padding: 0; border: 4px solid var(--surface); border-radius: 50%; background: #e8ecf2; box-shadow: 0 0 0 1px #ccd2da, var(--shadow-sm); text-align: center; transition: transform 160ms var(--ease); }
.node-core:hover .node-face,
.node-core:focus-within .node-face { transform: translateY(-2px) scale(1.045); }
.node-face .avatar { width: 58px; height: 58px; border: 0; box-shadow: none; }
.topic-symbol { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: var(--primary-soft); color: var(--primary); font-size: 27px; font-weight: 400; }
.node-name { display: block; max-width: 150px; overflow: hidden; color: var(--ink); font-size: 11.5px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.node-role { display: block; max-width: 150px; margin-top: 2px; overflow: hidden; color: var(--text-muted); font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.node-core .node-port { position: absolute; right: -10px; bottom: -2px; display: grid; place-items: center; width: 27px; min-width: 27px; height: 27px; min-height: 27px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text-secondary); box-shadow: var(--shadow-sm); font-size: 12px; pointer-events: auto; }
.node-port:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.graph-node.is-working .node-face { box-shadow: 0 0 0 2px #9ad0b8, 0 0 0 7px rgb(54 168 117 / 0.1), var(--shadow-sm); animation: agent-working 1.8s ease-in-out infinite; }
@keyframes agent-working { 50% { box-shadow: 0 0 0 2px #9ad0b8, 0 0 0 11px rgb(54 168 117 / 0.03), var(--shadow-sm); } }
.graph-node.graph-dimmed { opacity: 0.22; }
.graph-edge { fill: none; stroke: #aeb5bf; stroke-width: 1.25; opacity: 0.8; pointer-events: stroke; cursor: pointer; transition: opacity 140ms ease, stroke 140ms ease, stroke-width 140ms ease; }
#network-edges g { cursor: pointer; outline: none; }
#network-edges g:hover .graph-edge,
#network-edges g:focus-within .graph-edge { stroke: var(--primary); stroke-width: 2.2; opacity: 1; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.edge-active { stroke: #7ca7d8; stroke-dasharray: 5 5; animation: edge-pulse 1.3s linear infinite; }
.direct-edge { stroke: #78828f; }
.draft-edge { fill: none; stroke: var(--primary); stroke-width: 1.6; stroke-dasharray: 6 5; opacity: 0.9; }
.edge-selected { stroke: var(--primary); stroke-width: 2.6; opacity: 1; filter: drop-shadow(0 0 3px rgb(39 94 168 / 0.3)); }
.graph-dimmed .graph-edge:not(.graph-focused) { opacity: 0.12; }
.graph-active .graph-edge.graph-focused { opacity: 1; stroke: var(--primary); }
@keyframes edge-pulse { to { stroke-dashoffset: -20; } }
.edge-control { fill: transparent; stroke: transparent; opacity: 0; pointer-events: none; }
.network-inspector { margin-top: 12px; padding: 13px 15px; border: 1px solid var(--line-soft); border-radius: var(--radius-md); background: var(--surface); font-size: 12px; }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.inspector-heading strong { font-size: 13px; }

/* Composer */
.composer {
  flex: 0 0 auto;
  margin: 0 var(--space-5) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #d8d3cb;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 7px 22px rgb(28 26 23 / 0.06);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.composer:focus-within { border-color: #9db7d7; box-shadow: 0 0 0 3px rgb(46 127 240 / 0.09), 0 9px 25px rgb(28 26 23 / 0.07); }
.reply-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 8px; padding: 7px 9px; border-radius: 8px; background: var(--primary-soft); color: var(--text-secondary); font-size: 11px; }
.compose-meta { display: flex; align-items: center; gap: 7px; }
.compose-meta label { color: var(--text-muted); font-size: 10.5px; font-weight: 620; white-space: nowrap; }
.compose-meta select { width: auto; min-height: 28px; padding: 3px 31px 3px 8px; border-color: transparent; background-color: var(--surface-soft); color: var(--text-secondary); font-size: 10.5px; }
.compose-meta input { width: min(220px, 40vw); min-height: 28px; padding: 3px 8px; font-size: 11px; }
.composer > textarea { min-height: 66px; max-height: 210px; padding: var(--space-2) var(--space-1); border: 0; resize: none; background: transparent; color: var(--ink); font-size: 14px; box-shadow: none; }
.compose-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }
.compose-hint { color: var(--faint); font-size: 9.5px; }
.compose-actions { display: flex; align-items: center; gap: 5px; }
.attach-button { width: 32px; min-width: 32px; height: 32px; min-height: 32px; border-radius: 8px; }
.attach-button svg { width: 18px; height: 18px; }
.send-button { display: inline-flex; align-items: center; gap: 6px; min-height: 33px; padding: 6px 12px; }
.send-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Dialogs and settings */
/* A dialog is a panel, not a scroller: the padding box must clip, and the
   scrollbar has to live inside the padded content so it never escapes the
   rounded corner. `--dialog-pad` is 0 for the layout-driven settings windows
   that pad their own inner sections. */
dialog {
  --dialog-pad: 24px;
  width: min(620px, calc(100vw - 28px));
  max-height: min(86vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog[open] { display: flex; flex-direction: column; }
dialog.settings-dialog { --dialog-pad: 0px; }
dialog > form,
dialog > .dialog-scroll {
  min-height: 0;
  padding: var(--dialog-pad);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
}
dialog > form > * { flex: 0 0 auto; }
/* Slim, inset scrollbar so the panel edge stays clean. */
dialog > form::-webkit-scrollbar,
dialog > .dialog-scroll::-webkit-scrollbar { width: 11px; }
dialog > form::-webkit-scrollbar-track,
dialog > .dialog-scroll::-webkit-scrollbar-track { background: transparent; }
dialog > form::-webkit-scrollbar-thumb,
dialog > .dialog-scroll::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background-clip: content-box; background-color: #cfc9c0; }
dialog > form::-webkit-scrollbar-thumb:hover,
dialog > .dialog-scroll::-webkit-scrollbar-thumb:hover { background-color: #b5ada2; }
dialog > form,
dialog > .dialog-scroll { scrollbar-width: thin; scrollbar-color: #cfc9c0 transparent; }
dialog::backdrop { background: rgb(28 26 23 / 0.38); backdrop-filter: blur(5px); }
dialog[open] { animation: dialog-in 170ms var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
dialog h2 { margin: 0 44px 8px 0; font-size: 19px; letter-spacing: -0.01em; }
dialog h2 + p { margin-top: 0; }
dialog p { color: var(--text-secondary); }
dialog > form { display: grid; gap: 4px; }
dialog > form > label,
dialog > form > .field-label { margin-top: 10px; }
dialog > form > label + input,
dialog > form > label + textarea,
dialog > form > label + select { margin-top: 6px; }
dialog input,
dialog textarea,
dialog select { font-size: 13.5px; }
dialog:focus-visible { outline: none; }
dialog .field-help { margin: 6px 0 0; color: var(--text-muted); font-size: 11.5px; }
/* Keep the primary action reachable and unmissable on short viewports. */
dialog > form > .actions .primary { min-width: 132px; }
@media (max-width: 620px) {
  dialog { width: calc(100vw - 16px); max-height: calc(100vh - 24px); padding: 20px; }
  dialog > form > .actions { margin: 20px -20px -20px; padding: 12px 20px; bottom: -20px; }
}
dialog > form > .actions { position: sticky; bottom: calc(-1 * var(--dialog-pad)); margin: 22px calc(-1 * var(--dialog-pad)) calc(-1 * var(--dialog-pad)); padding: 14px var(--dialog-pad); border-top: 1px solid var(--line-soft); background: rgb(255 255 255 / 0.94); backdrop-filter: blur(10px); }
.modal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.modal-top h2 { margin: 5px 0 0; }
.close-button { display: grid; place-items: center; width: 34px; min-width: 34px; height: 34px; padding: 0; border-color: transparent; border-radius: 50%; background: var(--surface-soft); color: var(--text-muted); box-shadow: none; font-size: 20px; font-weight: 360; }
.close-button:hover { background: var(--surface-sunken); color: var(--ink); }
.modal-footer { position: sticky; bottom: calc(-1 * var(--dialog-pad, 24px)); display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 22px calc(-1 * var(--dialog-pad, 24px)) calc(-1 * var(--dialog-pad, 24px)); padding: 14px var(--dialog-pad, 24px); border-top: 1px solid var(--line-soft); background: rgb(255 255 255 / 0.94); backdrop-filter: blur(10px); }
.settings-dialog { width: min(840px, calc(100vw - 28px)); padding: 0; }
.settings-window { min-height: 540px; padding: 24px; }
.app-settings-dialog { width: min(920px, calc(100vw - 28px)); }
.app-settings-dialog .settings-window { min-height: min(680px, 84vh); }
.app-settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; }
.app-settings-nav { display: grid; align-content: start; gap: 5px; padding: 10px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--surface-soft); }
.app-settings-nav a { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 8px; padding: 9px; border-radius: 9px; color: var(--text-secondary); text-decoration: none; }
.app-settings-nav a:hover { background: var(--surface); color: var(--ink); }
.app-settings-nav a > span:last-child { display: grid; }
.app-settings-nav strong { font-size: 12px; }
.app-settings-nav small { color: var(--text-muted); font-size: 9.5px; }
.settings-nav-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; background: var(--surface); color: var(--primary); }
.app-settings-content { min-width: 0; display: grid; align-content: start; gap: 18px; }
.settings-section { scroll-margin-top: 16px; padding: 18px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); }
.settings-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 7px; }
.settings-section h3 { margin: 4px 0 0; font-size: 18px; }
.settings-section > p { margin-bottom: 12px; font-size: 12px; }
.connection-checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.connection-checklist > div { display: grid; gap: 2px; padding: 10px; border-radius: 9px; background: var(--surface-soft); }
.connection-checklist strong { font-size: 10.5px; }
.connection-checklist span { color: var(--text-muted); font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 8px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-secondary); font: 9px/1.2 var(--font-mono); }
.status-pill.status-live { background: var(--success-soft); color: var(--success); }
.settings-action-list { display: grid; gap: 6px; }
.settings-action {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-color: var(--line-soft);
  background: var(--surface-soft);
  box-shadow: none;
  text-align: left;
}
.settings-action:hover { border-color: #c6c0b8; background: var(--surface); }
.settings-action > span:nth-child(2) { display: grid; }
.settings-action strong { font-size: 12px; }
.settings-action small { color: var(--text-muted); font-size: 10px; }
.settings-action-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface); color: var(--primary); font-size: 15px; }
.settings-invitation-list { display: grid; gap: 7px; }
.settings-invitation-list .identity { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--surface-soft); }
.settings-invitation-list .identity > strong { flex: 1; font-size: 11.5px; }
.settings-invitation-list .identity > div { flex: 1; }
.settings-profile { display: grid; grid-template-columns: 66px minmax(0, 1fr); align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface-soft); }
.settings-profile .avatar { grid-row: 1 / span 2; width: 60px; height: 60px; }
.settings-tabs { display: flex; gap: 2px; margin: 14px 0 18px; padding-bottom: 1px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.settings-tabs button { min-height: 37px; padding: 7px 10px; border: 0; border-radius: 7px 7px 0 0; background: transparent; box-shadow: none; color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.settings-tabs button:hover { background: var(--surface-soft); color: var(--ink); }
.settings-tabs button.selected { background: var(--primary-soft); color: var(--primary); font-weight: 680; }
.setting-row { justify-content: space-between; }
.setting-copy { display: grid; flex: 1; }
.setting-copy strong { font-size: 12px; }
.setting-copy span { color: var(--text-muted); font-size: 10.5px; }
.setting-switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; }
.setting-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.setting-switch span { position: absolute; inset: 0; border-radius: 999px; background: #c9c5bf; transition: background 140ms ease; }
.setting-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform 140ms ease; }
.setting-switch input:checked + span { background: var(--primary); }
.setting-switch input:checked + span::after { transform: translateX(16px); }
.team-tools { display: flex; gap: 8px; margin-bottom: 14px; }
.team-tools input { flex: 1; }
.invitation-settings,
.danger-zone { margin-top: 16px; padding: 3px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-soft); }
.danger-zone { border-color: #ead1cd; background: #fffafa; }
.danger-zone > summary { color: var(--danger); }
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; }
.preset-row button.selected { border-color: #a9c2e5; background: var(--primary-soft); color: var(--primary); }
.access-event { align-items: flex-start; font-size: 11px; }
.character-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 7px; margin: 12px 0; }
.character-choice { display: grid; place-items: center; min-height: 64px; padding: 5px; border-color: var(--line-soft); background: var(--surface-soft); box-shadow: none; }
.character-choice:hover { border-color: #b9c8db; transform: translateY(-1px); }
.character-choice.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px rgb(46 127 240 / 0.1); }
.character-choice .avatar { width: 47px; height: 47px; }
#avatar-preview { display: grid; place-items: center; min-height: 150px; margin: 16px 0; border: 1px dashed var(--line); border-radius: 14px; background: var(--surface-soft); }
#avatar-preview .avatar { width: 98px; height: 98px; font-size: 24px; }
.expiry-editor { background: var(--surface-soft); }
.expiry-duration { display: grid; grid-template-columns: minmax(120px, 0.7fr) minmax(170px, 1fr); gap: 10px; margin-top: 10px; }
#snippet-area { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line); }
.snippet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.snippet-sub { max-width: 46ch; margin: 2px 0 0; }
#snippet {
  width: 100%;
  min-height: 168px;
  margin: var(--space-3) 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  resize: vertical;
}
.snippet-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.snippet-actions .primary { flex: 0 0 auto; }
@media (max-width: 620px) {
  .snippet-head { flex-direction: column; }
  .snippet-actions { flex-direction: column; align-items: stretch; }
  .snippet-actions .primary { width: 100%; }
}
#history-body { max-height: 420px; padding: 13px; overflow: auto; border-radius: 9px; background: var(--surface-soft); white-space: pre-wrap; font-size: 11px; }

/* Responsive shell */
@media (max-width: 1180px) {
  #app { grid-template-columns: 212px minmax(440px, 1fr) 258px; }
  .app-header { padding-inline: 18px; gap: 16px; }
  .brand-promise { max-width: 250px; }
  .toolbar { padding-inline: 19px; }
  .tabs button { padding-inline: 9px; }
  .live-status { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .rail-agents .agent-identity-button .avatar { width: 48px; height: 48px; }
  .presence-badge { margin-left: 56px; }
}
@media (max-width: 1100px) {
  #app { grid-template-columns: 210px minmax(0, 1fr); }
  .details { display: none; }
  .brand-promise { display: none; }
  .conversation-heading h1 { max-width: 42vw; }
  .agents-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (max-width: 760px) {
  :root { --header-height: 62px; }
  .app-header { padding-inline: 12px; gap: 10px; }
  .brand-icon { width: 34px; height: 34px; }
  .brand-wordmark { font-size: 18px; }
  .human-live-copy { display: none; }
  .human-live-status { width: 30px; min-width: 30px; height: 30px; min-height: 30px; padding: 0; justify-content: center; }
  .header-settings-button { display: none; }
  #app { display: flex; flex-direction: column; }
  .sidebar {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 10px;
    padding: 9px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .topics-section { max-height: 112px; }
  .sidebar-live-card { display: none; }
  .label-row { min-height: 26px; }
  .nav-stack > button,
  .nav-stack > a { min-height: 33px; padding: 6px 8px; font-size: 12px; }
  .archived-topics { display: none; }
  .conversation { flex: 1; }
  .toolbar { min-height: 66px; padding: 12px 14px 10px; gap: 10px; }
  .conversation-heading h1 { max-width: 54vw; font-size: 20px; }
  .space-network-button,
  .invite-header-button { width: 36px; min-width: 36px; padding: 0; justify-content: center; font-size: 0; }
  .space-actions button svg { width: 18px; height: 18px; }
  .channel-nav { padding-inline: 8px; }
  .live-status { display: none; }
  .tabs button { min-height: 40px; font-size: 11.5px; }
  .tabs button span { display: none; }
  .presence-summary { padding-inline: 14px; }
  .messages-view { padding: 8px 12px 16px; }
  .entry.message-card { grid-template-columns: 44px minmax(0, 1fr); gap: 9px; padding: 12px 6px; }
  .message-card > .avatar { width: 42px; height: 42px; }
  .composer { margin: 0 10px 10px; }
  .compose-hint { display: none; }
  .compose-footer { justify-content: flex-end; }
  #files,
  #context,
  #work,
  #agents-view,
  #network { padding: 16px 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .actions.file-upload-actions { width: 100%; }
  .actions.file-upload-actions input { width: 100%; }
  .crew-hero { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .crew-hero img { width: 68px; height: 68px; border-radius: 18px; }
  .crew-hero button { grid-column: 1 / -1; justify-self: start; }
  .network-heading { flex-direction: column; }
  #network-canvas { height: 480px; }
  .graph-node { width: 112px; }
  .node-core { width: 58px; margin-bottom: 6px; }
  .node-face { width: 58px; height: 58px; }
  .node-face .avatar { width: 48px; height: 48px; }
  .topic-symbol { width: 48px; height: 48px; border-radius: 14px; }
  .node-name,
  .node-role { max-width: 112px; }
  .app-settings-layout { grid-template-columns: 1fr; }
  .app-settings-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-settings-nav a { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .app-settings-nav small { display: none; }
  .settings-window { min-height: 0; padding: 18px; }
  .connection-checklist { grid-template-columns: 1fr; }
  .form-grid,
  .expiry-duration { grid-template-columns: 1fr; }
  dialog { padding: 19px; }
  dialog > form > .actions { bottom: -19px; margin: 20px -19px -19px; padding: 12px 19px; }
  .modal-footer { bottom: -19px; margin: 20px -19px -19px; padding: 12px 19px; }
  #welcome { grid-template-columns: 1fr; padding: 34px 22px; }
  .intro h1 { font-size: clamp(38px, 12vw, 62px); }
}
@media (max-width: 480px) {
  .brand-wordmark { display: none; }
  .header-account #account { max-width: 130px; overflow: hidden; }
  .tabs button { padding-inline: 8px; }
  .compose-meta label { display: none; }
  .compose-meta select { max-width: 190px; }
  .compose-meta input { width: 110px; }
  .body { font-size: 13.5px; }
  .app-settings-nav small { display: none; }
  .app-settings-nav strong { font-size: 10.5px; }
  .settings-action { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .settings-action small { display: none; }
  .modal-footer { align-items: stretch; flex-direction: column; }
  .modal-footer button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Segmented scope switch (agents: this conversation vs whole Space) */
.agents-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.segmented-option { padding: 6px 13px; border: 0; border-radius: 999px; background: none; color: var(--text-muted); font-size: 12px; cursor: pointer; }
.segmented-option.is-selected { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.segmented-option:disabled { opacity: 0.45; cursor: not-allowed; }
.segmented-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* =========================================================================
   Design refinement layer — mentions, conversation focus, touch targets
   ========================================================================= */

/* Mentions read as entities, not body text. */
.mention {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px 2px;
  border: 1px solid #cfdcf1;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.95em;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}
.body.has-mentions { line-height: 1.62; }
.mention-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px dashed #cfdcf1;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}
.mention-strip-label { margin-right: 2px; color: var(--primary); font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 9px;
  border: 1px solid #c3d5ef;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}
.mention-chip-remove { display: grid; place-items: center; width: 17px; height: 17px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--primary); font-size: 13px; line-height: 1; cursor: pointer; }
.mention-chip-remove:hover { background: #dbe8fb; }
.compose-field { position: relative; }
.mention-menu {
  position: absolute;
  z-index: 60;
  left: 10px;
  bottom: calc(100% + 6px);
  width: min(360px, 100%);
  max-height: 260px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}
.mention-option { display: flex; width: 100%; align-items: center; gap: 9px; padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; cursor: pointer; }
.mention-option:hover,
.mention-option.is-active { background: var(--primary-soft); }
.mention-option .avatar { width: 24px; height: 24px; }
.mention-option-text { display: grid; min-width: 0; }
.mention-option-text strong { font-size: 12.5px; font-weight: 600; }
.mention-option-text .small { font-size: 11px; }

/* The conversation is the frame: a quiet bar that states who and what is in it. */
.conversation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface-raised), var(--surface-soft));
  box-shadow: var(--shadow-xs);
}
.conversation-identity { display: flex; min-width: 0; align-items: center; gap: 11px; }
.conversation-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 700;
}
.conversation-bar h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.conversation-meta { margin: 2px 0 0; color: var(--text-muted); font-size: 11.5px; }
.conversation-people { display: flex; align-items: center; gap: 4px; }
.conversation-person { padding: 0; border: 2px solid var(--surface-raised); border-radius: 50%; background: none; cursor: pointer; transition: transform 120ms var(--ease), border-color 120ms var(--ease); }
.conversation-person:hover { transform: translateY(-1px); border-color: var(--primary); }
.conversation-person.is-live { border-color: #9ad0b8; }
.conversation-person .avatar { width: 26px; height: 26px; }
.conversation-more { padding: 0 4px; color: var(--text-muted); font-size: 11.5px; }
.conversation-actions { display: flex; gap: 6px; }
.conversation-actions button { font-size: 11.5px; }

/* Topic tags on shared documents and files. */
.entity-topics { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.entity-topic {
  padding: 1px 7px 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
}
.entity-topic.is-current { border-color: #c3d5ef; background: var(--primary-soft); color: var(--primary); }

@media (prefers-reduced-motion: reduce) {
  .conversation-person { transition: none; }
}

/* ---- Loading skeletons ---------------------------------------------------
   Every placeholder reserves the height of the real content it replaces, so the
   page settles once instead of reflowing as data arrives. */
.skeleton { background: var(--surface-sunken); }
.skeleton-message { height: 84px; margin-bottom: 12px; border-radius: var(--radius-md); }
.skeleton-card { height: 132px; }
.skeleton-agent { height: 46px; margin-bottom: 8px; border-radius: var(--radius-sm); }
.skeleton-row { height: 52px; margin-bottom: 8px; border-radius: var(--radius-sm); }
.skeleton-entry { height: 96px; border-radius: var(--radius-md); }
.skeleton-avatar { width: 26px; height: 26px; border-radius: 50%; }
.skeleton-title { width: 180px; height: 18px; border-radius: 6px; }
.skeleton-meta { width: 260px; height: 12px; border-radius: 6px; }
#conversation-title, #conversation-meta { display: flex; align-items: center; }
[aria-busy="true"] .skeleton:last-child { margin-bottom: 0; }

/* ---- Physical sizing pass ------------------------------------------------
   Controls converge on a 32px minimum so nothing is fiddly to hit. */
.icon-button,
.text-button,
.close-button,
.dialog-close { min-width: 32px; min-height: 32px; }
button.primary { min-height: 38px; }
.topic-chip,
.entity-topic,
.mention,
.segmented-option { min-height: 24px; }

/* ---- Hover hygiene -------------------------------------------------------
   The global button hover paints a grey surface. On bare buttons (avatars,
   graph faces, chips) that reads as a stray rectangle, so those opt out. */
.conversation-person:hover,
.conversation-person.is-live:hover { background: none; }
.conversation-person:hover { border-color: var(--primary); }
.conversation-person.is-live:hover { border-color: #6bbf95; }
.conversation-person:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.node-face:hover,
.agent-identity-button:hover,
.mention-chip-remove:hover,
.toast-close:hover { background: none; border-color: transparent; }
.mention-chip-remove:hover,
.toast-close:hover { color: var(--ink); }
.node-face:focus-visible,
.agent-identity-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Long member lists keep their heading in view while the body scrolls. */
.modal-top { position: sticky; top: calc(-1 * var(--dialog-pad, 24px)); z-index: 1; background: var(--surface-raised); padding-bottom: 10px; }
dialog.settings-dialog .modal-top { top: 0; }

/* ---- Rendered markdown ---------------------------------------------------
   Agent messages and context entries are markdown. Keep the rhythm tight, make
   code and tables scroll inside their own box, and never let a table widen the
   conversation column. */
.body.md, .context-entry-body.md { white-space: normal; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5, .md h6 { margin: 16px 0 6px; font-size: 14px; letter-spacing: -0.01em; }
.md h3 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md blockquote {
  margin: 0 0 10px;
  padding: 6px 12px;
  border-left: 2px solid var(--line);
  color: var(--text-secondary);
}
.md hr { margin: 14px 0; border: 0; border-top: 1px solid var(--line-soft); }
.md a { color: var(--link-text); text-underline-offset: 2px; }
.md code {
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: 0.92em;
}
.md-code {
  margin: 0 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #24221f;
}
.md-code-head {
  display: flex;
  padding: 5px 10px;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
  color: #d6cfc6;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.md-code pre { margin: 0; padding: 10px 12px; overflow-x: auto; }
.md-code code { padding: 0; border: 0; background: none; color: #f3f1ed; font-size: 12px; line-height: 1.55; }
.md-table { margin: 0 0 10px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.md-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.md-table th, .md-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-soft); font-weight: 640; }
.md-table tr:last-child td { border-bottom: 0; }

/* ---- Viewer page ---------------------------------------------------------
   A shared file or document is its own page: deep-linkable, back-button aware,
   and it lays out naturally on a phone instead of being boxed in a dialog. */
.document-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0 var(--space-8);
  background: var(--canvas);
}
.document-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--line-soft);
  background: rgb(251 250 247 / 0.94);
  backdrop-filter: blur(12px) saturate(1.2);
}
.document-heading { min-width: 0; }
.document-heading .eyebrow { display: block; margin-bottom: 2px; }
.document-heading h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-6);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-soft);
}
.viewer-spacer { flex: 1 1 auto; }
.viewer-search { width: min(280px, 40vw); min-height: 32px; }
.viewer-page-size { width: auto; min-height: 32px; }
.viewer-page-button { min-width: 32px; padding: 0 8px; }
.viewer-count { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.viewer-body { padding: var(--space-5) var(--space-6) var(--space-7); }
.viewer-empty { padding: var(--space-6); color: var(--text-muted); text-align: center; }
.viewer-empty.is-error { color: var(--danger-text); }
.viewer-image { display: block; max-width: 100%; margin: 0 auto; border-radius: var(--radius-sm); }
.viewer-code { margin: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #24221f; }
.viewer-code-table { border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
.viewer-line-no { padding: 0 10px 0 12px; color: #8d867d; text-align: right; user-select: none; vertical-align: top; }
.viewer-line { padding-right: 14px; color: #f3f1ed; white-space: pre; }
.viewer-truncated { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-3); }
.viewer-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.viewer-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.viewer-table th, .viewer-table td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.viewer-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); }
.viewer-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--text-secondary); font-size: 11.5px; font-weight: 650; cursor: pointer; }
.viewer-sort:hover { color: var(--ink); }
.viewer-sort-arrow { color: var(--text-muted); font-size: 10px; opacity: 0.55; }
.viewer-sort:hover .viewer-sort-arrow { opacity: 1; }
.viewer-sort-arrow.is-active { color: var(--accent-text); opacity: 1; }
.viewer-filters th { padding: 4px 6px; }
.viewer-filter { min-height: 26px; font-size: 11.5px; }
.viewer-row:hover { background: var(--surface-soft); cursor: pointer; }
.viewer-table td.is-number { text-align: right; font-variant-numeric: tabular-nums; }
.viewer-table td.is-null { color: var(--text-muted); font-style: italic; }
.viewer-row-detail { margin-top: var(--space-3); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); }
.viewer-row-json { margin: 6px 0 0; max-height: 320px; overflow: auto; font-family: var(--font-mono); font-size: 11.5px; }

/* ---- Markdown viewer: the app's "agent reply" surface ---------------------
   Ported from the desktop theme: a palette-tinted glow over a warm off-black,
   a peach/coral heading ramp derived from --primary, code and quotes on the same
   well, and an outline you can jump with. Prose stays on a readable measure. */
.viewer-markdown {
  max-width: none;
  width: 100%;
  padding: var(--space-6);
  border: 1px solid var(--agent-code-border);
  border-radius: var(--radius-md);
  color: var(--agent-surface-foreground);
  background:
    radial-gradient(85% 55% at 50% 0%, var(--agent-glow-a), var(--agent-glow-b) 45%, transparent 75%),
    linear-gradient(180deg, var(--agent-surface-top) 0%, var(--agent-surface) 55%, var(--agent-surface-bottom) 100%);
}
.viewer-markdown.md p,
.viewer-markdown.md li,
.viewer-markdown.md blockquote,
.viewer-markdown.md h1,
.viewer-markdown.md h2,
.viewer-markdown.md h3,
.viewer-markdown.md h4,
.viewer-markdown.md h5,
.viewer-markdown.md h6 { max-width: 74ch; }
.viewer-markdown.md p { margin: 0 0 12px; color: var(--agent-surface-foreground); }
.viewer-markdown.md h1,
.viewer-markdown.md h2,
.viewer-markdown.md h3 { color: var(--heading-1); letter-spacing: -0.015em; }
.viewer-markdown.md h1 { margin: 22px 0 10px; font-size: 22px; }
.viewer-markdown.md h2 { margin: 20px 0 9px; font-size: 18px; color: var(--heading-2); }
.viewer-markdown.md h3 { margin: 18px 0 8px; font-size: 15.5px; color: var(--heading-3); }
.viewer-markdown.md h4,
.viewer-markdown.md h5,
.viewer-markdown.md h6 { margin: 14px 0 6px; color: var(--agent-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.viewer-markdown.md > *:first-child { margin-top: 0; }
.viewer-markdown.md ul,
.viewer-markdown.md ol { margin: 0 0 12px; padding-left: 22px; color: var(--agent-surface-foreground); }
.viewer-markdown.md li { margin: 3px 0; }
.viewer-markdown.md li::marker { color: var(--agent-muted); }
.viewer-markdown.md a { color: var(--agent-link); font-weight: 500; }
.viewer-markdown.md strong { color: #fff; }
.viewer-markdown.md hr { margin: 20px 0; border: 0; border-top: 1px solid var(--heading-rule); }
.viewer-markdown.md code {
  padding: 0.1em 0.4em;
  border: 0;
  border-radius: 5px;
  background: color-mix(in srgb, var(--primary) 10%, var(--agent-code-bg));
  color: var(--agent-inline-code);
  font-size: 0.88em;
}
.viewer-markdown.md .md-code { border-color: var(--agent-code-border); background: var(--agent-code-bg); }
.viewer-markdown.md .md-code-head { background: color-mix(in srgb, var(--agent-code-bg) 70%, var(--agent-surface)); border-bottom-color: var(--agent-code-border); color: var(--agent-muted); }
.viewer-markdown.md .md-code code { color: #f4eff4; }
.viewer-markdown.md blockquote {
  margin: 0 0 12px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--agent-code-border);
  border-left-width: 1px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--agent-code-bg) 60%, transparent);
  color: var(--agent-muted);
  font-style: normal;
}
.viewer-markdown.md .md-table { border-color: var(--agent-code-border); }
.viewer-markdown.md .md-table th { background: var(--agent-code-bg); color: var(--agent-surface-foreground); }
.viewer-markdown.md .md-table th,
.viewer-markdown.md .md-table td { border-bottom-color: var(--agent-code-border); color: var(--agent-surface-foreground); }
.viewer-markdown.md h1.is-jump-target,
.viewer-markdown.md h2.is-jump-target,
.viewer-markdown.md h3.is-jump-target { animation: jump-flash 1.2s var(--ease); }
@keyframes jump-flash { 0% { background: color-mix(in srgb, var(--primary) 22%, transparent); } 100% { background: transparent; } }

/* Outline dock: fixed to the viewport's top-right so it is reachable at any
   scroll position, expands leftwards over the prose, and pins open on demand. */
.outline-dock { position: fixed; top: calc(var(--header-height) + 14px); right: 18px; z-index: 40; }
.outline-dock-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
.outline-dock-toggle:hover { color: var(--ink); border-color: var(--line); background: var(--surface); }
.outline-dock-panel {
  display: none;
  position: absolute;
  top: 0;
  right: 42px;
  width: 244px;
  max-height: min(70vh, 520px);
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}
.outline-dock.is-open .outline-dock-panel { display: block; }
.outline-dock-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 6px; }
.outline-dock-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.outline-dock-pin { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; margin-left: auto; padding: 3px; border: 0; border-radius: 6px; background: none; color: var(--text-muted); box-shadow: none; cursor: pointer; }
.outline-dock-pin:hover { background: var(--surface-soft); color: var(--ink); }
.outline-dock-pin[aria-pressed="true"] { color: var(--accent-text); background: var(--primary-soft); }
.viewer-outline-list { max-height: calc(min(70vh, 520px) - 46px); margin: 0; padding: 0 0 2px; overflow-y: auto; list-style: none; }
.viewer-outline-link {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 6px 8px;
  box-shadow: none;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-outline-link.is-nested { padding-left: 18px; font-size: 11px; }
.viewer-outline-link:hover { background: var(--surface-soft); color: var(--ink); }
.viewer-outline-link.is-active { background: var(--primary-soft); color: var(--accent-text); font-weight: 600; }
@media (max-width: 760px) {
  .document-header { padding: var(--space-3) var(--space-4); }
  .viewer-toolbar { padding: var(--space-2) var(--space-4); }
  .viewer-body { padding: var(--space-4); }
  .outline-dock { top: auto; bottom: 18px; right: 14px; }
  .outline-dock-panel { right: 0; bottom: 44px; top: auto; width: min(264px, calc(100vw - 28px)); }
}

/* In-app artifact links (link://documents/<id>, link://files/<id>) read as
   links rather than raw URIs, in messages and on the document page. */
.entity-link { color: var(--link-text); font-weight: 550; text-decoration: underline; text-underline-offset: 2px; }
.entity-link:hover { text-decoration: none; }
.viewer-markdown .entity-link { color: var(--agent-link); }

/* ---- Public invitation page (/join/<code>) ------------------------------- */
.join-page { overflow: auto; }
.join-main { max-width: 760px; margin: 0 auto; padding: var(--space-7) var(--space-5) var(--space-8); }
.join-main h1 { margin: 6px 0 8px; font-size: 30px; letter-spacing: -0.02em; }
.join-lede { max-width: 60ch; margin: 0 0 var(--space-5); color: var(--text-secondary); }
.join-card { margin-bottom: var(--space-4); padding: var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-xs); }
.join-card h2 { margin: 0 0 6px; font-size: 15px; }
.join-command {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #24221f;
  color: #f3f1ed;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
}
.join-steps { margin: 0 0 var(--space-2); padding-left: 20px; color: var(--ink-soft); font-size: 13px; }
.join-steps li { margin: 4px 0; }
