/* =============================================================
   HABITATS · v0.2 DESIGN SYSTEM
   Shared stylesheet — the single source of truth.
   ============================================================= */

:root {
  /* === SURFACES === */
  --bg:            #fafafa;
  --bg-subtle:     #f5f5f5;
  --surface:       #ffffff;
  --border:        #ececec;
  --border-strong: #e0e0e0;

  /* === INK === */
  --ink:    #0a0a0a;
  --ink-2:  #404040;
  --ink-3:  #737373;
  --ink-4:  #a3a3a3;

  /* === ACTION === */
  --action:        #0a0a0a;
  --action-hover:  #000000;
  --on-action:     #ffffff;

  /* === STATE === */
  --live:        #00875a;
  --live-bg:     #f0f9f4;
  --live-border: #c6e7d5;
  --warn:        #b45309;
  --warn-bg:     #fef7e6;
  --warn-border: #fde7b8;
  --info:        #0070f3;
  --info-bg:     #eff6ff;
  --info-border: #bfdbfe;
  --danger:      #c1121f;
  --danger-bg:   #fef2f2;
  --danger-border:#fecaca;

  /* === USERS === */
  --user-bens:  #0d6e6e;
  --user-wills: #6b3d8c;
  --user-benp:  #b15431;
  --user-andyh: #5a5a86;
  --user-hedda: #a64147;
  --user-milosr: #2c5e8e;

  /* === SHADOWS === */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow:    0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.08), 0 2px 4px -1px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 10px 30px -8px rgb(0 0 0 / 0.18);

  /* === TYPE === */
  --font-sans:    'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, 'SF Mono', Monaco, monospace;
  --font-display: 'Instrument Serif', 'Times New Roman', serif;

  /* === RADIUS === */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  /* === LAYOUT === */
  --rail-left: 240px;
  --thread:    320px;
  --frame-max: 1320px;
  --gutter:    12px;

  /* === MOTION === */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 0.12s;
  --dur:      0.18s;
  --dur-slow: 0.28s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === FRAME === */
.frame {
  max-width: var(--frame-max);
  margin: 0 auto;
  padding: 12px 14px 14px;
}

/* === TOPBAR === */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.crumb {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-3);
  font-family: var(--font-mono);
}
.crumb .org { color: var(--ink); font-weight: 500; }
.crumb .sep { color: var(--ink-4); }
.crumb .current { color: var(--ink); }
.crumb .org-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  border-radius: 3px;
  padding: 1px 6px;
  font-weight: 500;
  letter-spacing: 0;
  margin-right: 4px;
  border: 1px solid;
}
.crumb .org-badge.thp {
  color: #14524d;
  background: #e6efea;
  border-color: #14524d;
}
.crumb .org-badge.hh {
  color: #2d5a3f;
  background: #ebf2ed;
  border-color: #2d5a3f;
}
.crumb .org-badge.tf {
  color: #1f2937;
  background: #f1f4f9;
  border-color: #4b5563;
}
.crumb .org-badge.gl {
  color: #3b3b8a;
  background: #eef0ff;
  border-color: #6c6cc4;
}
.crumb .org-badge.bh {
  color: #1d4d3a;
  background: #e8f3ec;
  border-color: #2f7a55;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar .actions { display: flex; gap: 2px; }
.topbar .actions a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.topbar .actions a:hover { background: var(--bg-subtle); color: var(--ink); }

/* Notification bell with dot */
.bell {
  position: relative;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: background var(--dur-fast) var(--ease);
}
.bell:hover { background: var(--bg-subtle); color: var(--ink); }
.bell .dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

/* === INDEX FAB === */
.index-fab {
  position: fixed;
  bottom: 18px; right: 24px;
  z-index: 1000;
  background: var(--ink);
  color: var(--on-action);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 6px 12px 6px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.index-fab:hover { background: var(--action-hover); transform: translateY(-1px); }
.index-fab:active { transform: translateY(0); }

/* === AVATARS === */
.ava {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.ava.bens   { background: var(--user-bens); }
.ava.wills  { background: var(--user-wills); }
.ava.benp   { background: var(--user-benp); }
.ava.andyh  { background: var(--user-andyh); }
.ava.hedda  { background: var(--user-hedda); }
.ava.milosr { background: var(--user-milosr); }
.ava.agent {
  background: var(--ink);
  color: var(--on-action);
  font-family: var(--font-mono);
  font-weight: 500;
  border-radius: 5px;
}
.ava.s18 { width: 18px; height: 18px; font-size: 8px; }
.ava.s20 { width: 20px; height: 20px; font-size: 9px; }
.ava.s22 { width: 22px; height: 22px; font-size: 10px; }
.ava.s24 { width: 24px; height: 24px; font-size: 10px; }
.ava.s28 { width: 28px; height: 28px; font-size: 11px; }
.ava.s32 { width: 32px; height: 32px; font-size: 12px; }
.ava.s40 { width: 40px; height: 40px; font-size: 14px; }
.ava.s48 { width: 48px; height: 48px; font-size: 16px; }
.ava.s64 { width: 64px; height: 64px; font-size: 22px; }
.stack { display: inline-flex; }
.stack .ava { border: 2px solid var(--surface); margin-left: -7px; }
.stack .ava:first-child { margin-left: 0; }

/* === SHELL (3-col) === */
.shell {
  display: grid;
  gap: var(--gutter);
  grid-template-columns: var(--rail-left) 1fr var(--thread);
  height: calc(100vh - 86px);
  min-height: 760px;
}
.shell.shell-2col { grid-template-columns: var(--rail-left) 1fr; }
.shell.shell-1col { grid-template-columns: 1fr; height: auto; min-height: 0; }

/* === LEFT RAIL === */
.lrail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand-rail {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 14px 10px;
}
.brand-rail .bm {
  width: 24px; height: 24px;
  background: var(--ink); color: var(--on-action);
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  line-height: 1;
  text-decoration: none;
}
.brand-rail .bn {
  font-weight: 600; font-size: 14px; letter-spacing: -0.015em;
  color: var(--ink); text-decoration: none;
}
.brand-rail .bv {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px; color: var(--ink-4);
  font-weight: 500;
}
.lrail-search {
  margin: 4px 10px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 10px;
  color: var(--ink-3); font-size: 12.5px;
  display: flex; align-items: center; gap: 7px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}
.lrail-search:hover { border-color: var(--border-strong); color: var(--ink); }
.lrail-search .kbd {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 3px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 10.5px; color: var(--ink-4);
}
.lrail-label {
  font-size: 11.5px; color: var(--ink-4); font-weight: 500;
  padding: 12px 14px 4px;
}
.lrail-divider { height: 1px; background: var(--border); margin: 8px 10px; }

.lrail-item, .lrail-habitat-row, .lrail-agent-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13.5px;
  text-decoration: none;
  margin: 0 6px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.lrail-item:hover, .lrail-habitat-row:hover, .lrail-agent-row:hover {
  background: var(--bg-subtle); color: var(--ink);
}
.lrail-item.active, .lrail-habitat-row.active {
  background: var(--ink); color: var(--on-action);
}
.lrail-item.active .gly, .lrail-habitat-row.active .h-glyph {
  color: var(--on-action); opacity: 0.85;
}
.lrail-item.active .lname, .lrail-habitat-row.active .hname {
  color: var(--on-action); font-weight: 500;
}
.lrail-item.active .lcount, .lrail-habitat-row.active .hmeta {
  color: rgba(255,255,255,0.55);
}
.lrail-item.active .lcount {
  background: rgba(255,255,255,0.16);
}

.lrail-item .gly {
  color: var(--ink-3); font-size: 13px; width: 16px; text-align: center;
}
.lrail-item .lname { flex: 1; letter-spacing: -0.005em; }
.lrail-item .lcount {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
  background: var(--bg-subtle); border-radius: 999px;
  padding: 0 7px; line-height: 16px; height: 16px; min-width: 18px;
  text-align: center;
}

.lrail-habitat-row .h-glyph { color: var(--ink-3); width: 14px; font-size: 13px; }
.lrail-habitat-row .hname { flex: 1; letter-spacing: -0.005em; font-weight: 500; color: var(--ink); }
.lrail-habitat-row .hmeta {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
}
.lrail-habitat-row .hmeta.alert { color: var(--live); font-weight: 500; }
.lrail-habitat-row .hmeta.warn { color: var(--warn); font-weight: 500; }

.lrail-habitat-row.add {
  border: 1px dashed var(--border-strong);
  background: transparent;
  padding: 5px 13px;
  margin-top: 4px;
  color: var(--ink-3);
}
.lrail-habitat-row.add:hover {
  background: var(--bg-subtle);
  border-color: var(--ink-4);
  color: var(--ink);
}
.lrail-habitat-row.add .h-glyph {
  color: var(--ink-4); font-weight: 600;
}
.lrail-habitat-row.add:hover .h-glyph { color: var(--ink); }
.lrail-habitat-row.add .hname { color: var(--ink-3); font-weight: 500; }
.lrail-habitat-row.add:hover .hname { color: var(--ink); }

/* Ghost (placeholder) Habitat rows — visible in the rail but not yet built */
.lrail-habitat-row.ghost {
  cursor: default;
  opacity: 0.55;
}
.lrail-habitat-row.ghost:hover {
  background: transparent;
}
.lrail-habitat-row.ghost .hname { font-style: italic; }
.lrail-habitat-row.ghost .hmeta {
  color: var(--ink-4);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lrail-agent-row { padding: 5px 14px; font-size: 13px; }
.lrail-agent-row .aname { flex: 1; letter-spacing: -0.005em; }
.lrail-agent-row .ameta {
  font-size: 11px; color: var(--ink-4); font-family: var(--font-mono);
}

.lrail-spacer { flex: 1; min-height: 8px; }

/* ============================================================== */
/* THINKING ANIMATIONS — used by the InteractionLayer for          */
/* live agent runs (composer @-mention, re-run, new run).          */
/* ============================================================== */

@keyframes habitats-dot-pulse {
  0%, 80%, 100% { opacity: 0.28; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1); }
}
@keyframes habitats-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes habitats-run-flash {
  0%   { background: rgba(180, 83, 9, 0.07); }
  60%  { background: rgba(180, 83, 9, 0.07); }
  100% { background: transparent; }
}
@keyframes habitats-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 14px;
}
.thinking-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: habitats-dot-pulse 0.9s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

.thinking-phase {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
  margin-top: 2px;
  transition: opacity 0.25s ease;
}

.thinking-skeleton {
  display: flex; flex-direction: column;
  gap: 7px;
  margin-top: 6px;
  max-width: 520px;
}
.thinking-skeleton > .line {
  height: 10px;
  background: var(--bg-subtle);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.thinking-skeleton > .line::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 0, 0, 0.05),
    transparent
  );
  animation: habitats-shimmer 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.thinking-skeleton > .line:nth-child(1) { width: 92%; }
.thinking-skeleton > .line:nth-child(2) { width: 78%; }
.thinking-skeleton > .line:nth-child(3) { width: 64%; }

.thinking-toolcall {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 8px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  position: relative;
  overflow: hidden;
}
.thinking-toolcall::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 0, 0, 0.04),
    transparent
  );
  animation: habitats-shimmer 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  pointer-events: none;
}
.thinking-toolcall .tag {
  color: var(--ink-3); font-size: 9.5px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}

.run-flash {
  animation: habitats-run-flash 1.5s ease-out;
}

.fade-in-msg {
  animation: habitats-fade-in 0.28s ease-out;
}

.composebox.is-active {
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.04);
}
.composebox.is-active .composeinput {
  color: var(--ink);
}

/* === @-mention picker (opens above the composer @ button) === */
.mention-picker {
  position: absolute;
  bottom: 56px;
  left: 18px;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  z-index: 20;
  overflow: hidden;
  animation: habitats-fade-in 0.12s var(--ease) both;
}
.mention-picker-header {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.mention-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  color: inherit;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}
.mention-row:hover,
.mention-row.is-active {
  background: var(--bg-subtle);
}
.mention-row .mr-glyph {
  width: 28px; height: 28px;
  background: var(--ink); color: var(--on-action);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  flex-shrink: 0;
}
.mention-row .mr-meta { min-width: 0; }
.mention-row .mr-name {
  font-size: 13px; color: var(--ink); font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mention-row .mr-sub {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mention-row.add {
  border-top: 1px solid var(--border);
}
.mention-row.add .mr-glyph {
  background: var(--bg-subtle);
  color: var(--ink-2);
  border: 1px dashed var(--border-strong);
  font-size: 14px;
  font-weight: 600;
}
.mention-row.add:hover .mr-glyph {
  color: var(--ink);
  border-color: var(--ink-4);
}
.mention-row.add .mr-name {
  color: var(--ink-2);
  font-weight: 500;
}
.mention-row.add:hover .mr-name { color: var(--ink); }
.mention-empty {
  padding: 14px 14px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}

/* When the prototype's composer is hydrated as a real form, the
   composeinput becomes a textarea. Reset native chrome and inherit
   the prototype typography. */
form.compose {
  display: block;
  margin: 0;
  padding: 14px 22px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
textarea.composeinput {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  padding: 0;
  margin: 0;
  min-height: 22px;
  max-height: 240px;
  overflow-y: auto;
  display: block;
  letter-spacing: -0.005em;
}
textarea.composeinput::placeholder { color: var(--ink-4); }
.composeleft button.iconbtn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--ink-3);
  font: inherit;
  font-size: 12.5px;
  font-family: var(--font-sans);
}
.composeleft button.iconbtn:hover { color: var(--ink); }

.run-active.is-rerunning .ra-eyebrow {
  color: var(--warn);
}
.run-active.is-rerunning .ra-eyebrow .dot {
  background: var(--warn);
  box-shadow: 0 0 0 2.5px rgba(180, 83, 9, 0.18);
}

/* === USAGE BAR === */
.usage-bar {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding: 12px 14px 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink-2);
  transition: background var(--dur-fast) var(--ease);
  display: block;
}
.usage-bar:hover { background: var(--bg-subtle); }
.usage-bar.active { background: var(--ink); color: var(--on-action); }
.usage-bar .ub-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 6px;
}
.usage-bar .ub-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
}
.usage-bar.active .ub-label { color: rgba(255,255,255,0.55); }
.usage-bar .ub-amount {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.usage-bar.active .ub-amount { color: var(--on-action); }
.usage-bar .ub-amount .cents { color: var(--ink-3); font-size: 14px; }
.usage-bar.active .ub-amount .cents { color: rgba(255,255,255,0.55); }
.usage-bar .ub-track {
  height: 3px;
  background: var(--bg-subtle);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.usage-bar.active .ub-track { background: rgba(255,255,255,0.16); }
.usage-bar .ub-track .ub-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
  transition: width var(--dur-slow) var(--ease-out);
}
.usage-bar.active .ub-track .ub-fill { background: var(--on-action); }
.usage-bar .ub-foot {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.3;
}
.usage-bar.active .ub-foot { color: rgba(255,255,255,0.55); }

/* === LRAIL FOOT === */
.lrail-foot {
  border-top: 1px solid var(--border);
  padding: 10px 14px 6px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  text-decoration: none;
  color: var(--ink-2);
  transition: background var(--dur-fast) var(--ease);
  margin: 0 6px;
  border-radius: var(--r-sm);
}
.lrail-foot:hover { background: var(--bg-subtle); }
.lrail-foot .fname { font-weight: 500; color: var(--ink); }
.lrail-foot .frole { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.lrail-foot .fmeta { flex: 1; line-height: 1.25; }
.lrail-foot .fset {
  color: var(--ink-3); font-size: 14px;
  padding: 2px 6px; border-radius: var(--r-sm);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.lrail-foot .fset:hover { background: var(--bg-subtle); color: var(--ink); }

/* === MAIN === */
.main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 0;
}

/* === BUTTONS === */
.btn {
  font-family: var(--font-sans);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn.sm { font-size: 12.5px; padding: 4px 10px; height: 28px; border-radius: var(--r-sm); }
.btn.md { font-size: 13.5px; padding: 6px 12px; height: 32px; }
.btn.lg { font-size: 14px; padding: 9px 16px; height: 40px; }
.btn.primary {
  background: var(--action);
  color: var(--on-action);
  border-color: var(--action);
}
.btn.primary:hover { background: var(--action-hover); box-shadow: var(--shadow-md); }
.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { background: var(--bg-subtle); border-color: var(--ink-4); }
.btn.ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover { background: var(--bg-subtle); color: var(--ink); }
.btn.danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn.danger:hover { background: var(--danger-bg); }

/* === INPUTS === */
.input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  letter-spacing: -0.005em;
  width: 100%;
}
.input::placeholder { color: var(--ink-4); }
.input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgb(0 0 0 / 0.05);
}
.input.subtle {
  background: var(--bg-subtle);
  border-color: var(--border);
}
.input.subtle:focus {
  background: var(--surface);
  border-color: var(--ink);
}

label.field {
  display: block;
  margin-bottom: 14px;
}
label.field .field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}
label.field .field-hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 5px;
}

/* === @ TAGS === */
.at-tag {
  display: inline-flex; align-items: center;
  background: var(--bg-subtle); border: 1px solid var(--border-strong);
  color: var(--ink); font-family: var(--font-mono); font-size: 12.5px;
  border-radius: var(--r-sm); padding: 0 5px; font-weight: 500;
  letter-spacing: -0.005em;
}
.at-tag.agent { background: var(--ink); color: var(--on-action); border-color: var(--ink); }

/* === LIVE DOT === */
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 2.5px rgb(0 135 90 / 0.18);
  display: inline-block;
}
.live-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 2.5px rgb(180 83 9 / 0.18);
}
.live-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 2.5px rgb(193 18 31 / 0.18);
}
.live-dot.pulse::after {
  content: '';
  position: absolute;
  inset: -2.5px;
  border-radius: 50%;
  border: 1.5px solid var(--live);
  opacity: 0.4;
  animation: pulse-ring 2.4s ease-out infinite;
}

/* === Habitat page header (.h-head) ===========================================
   Layout overrides shared across every habitat detail page so the title strip
   reflows cleanly on narrow widths instead of mid-text wrapping inside chips
   and labels. Per-page <style> blocks still own type/spacing; these rules
   only govern flex behaviour and the new title-row + facts-row split. */
.h-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.h-title-row > .h-name {
  flex: 0 0 auto;
  margin: 0;
}
.h-title-row .at-tag.agent {
  font-size: 11px;
  padding: 1px 6px;
  letter-spacing: 0;
  white-space: nowrap;
}
.h-sub {
  flex-wrap: wrap;
  row-gap: 4px;
}
.h-sub > * { white-space: nowrap; }

/* === ANIMATIONS === */
@keyframes pulse-ring {
  0%   { transform: scale(1);   opacity: 0.4; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in-fast {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes bounce-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1; transform: translateY(-2px); }
}

/* Page enters with a soft fade. */
.frame { animation: fade-in 0.35s var(--ease-out); }

/* === SPIN === */
.spin {
  width: 12px; height: 12px;
  border: 1.5px solid var(--ink-4);
  border-top-color: var(--ink);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.9s linear infinite;
}

/* === TYPING DOTS === */
.typing-dots { display: inline-flex; gap: 3px; vertical-align: 1px; }
.typing-dots span {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ink-4);
  animation: bounce-dot 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* === FOCUS === */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* === SCROLLBARS (subtle) === */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgb(0 0 0 / 0.08);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgb(0 0 0 / 0.15); background-clip: padding-box; }

/* === SECTION HEAD (settings/admin pages) === */
.settings-head {
  padding: 32px 40px 22px;
  border-bottom: 1px solid var(--border);
}
.settings-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.settings-eyebrow .sep { color: var(--ink-4); }
/* Canonical in-app page title. Geist Sans 600 with tight letter-spacing
 * to match the marketing landing's `.section-h` cadence — keep the type
 * stack unified across the marketing and product surfaces. */
.settings-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0 0 6px;
}
.settings-deck {
  font-size: 15px;
  color: var(--ink-2);
  margin: 0;
  max-width: 640px;
  line-height: 1.55;
}

/* === TABS === */
.tabs {
  display: flex; gap: 0;
  padding: 0 40px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.tab {
  padding: 12px 0;
  margin-right: 26px;
  color: var(--ink-3);
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 600;
}
.tab .count {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-subtle); color: var(--ink-2);
  padding: 1px 7px; border-radius: 999px; font-weight: 500;
}

/* Settings content */
.settings-body { padding: 32px 40px 60px; max-width: 880px; }
html { scroll-behavior: smooth; }
.settings-section { margin-bottom: 48px; scroll-margin-top: 16px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section-head { margin-bottom: 18px; }
.settings-section-title {
  font-size: 17px; font-weight: 600; color: var(--ink);
  margin: 0 0 4px; letter-spacing: -0.01em;
}
.settings-section-sub {
  font-size: 13px; color: var(--ink-3); line-height: 1.5;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}
.info-card.flush { padding: 0; overflow: hidden; }

/* === MEDIA === */
@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--rail-left) 1fr; }
  .shell.shell-3col-collapse-rrail .rrail { display: none; }
}
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .lrail { max-height: 220px; }
  .settings-head, .tabs, .settings-body { padding-left: 24px; padding-right: 24px; }
  .settings-title { font-size: 32px; }
}

/* =============================================================
   ARTIFACT DRAWER
   Right-side slide-in panel that opens when you click "Open ›"
   on any artifact card. Single global instance mounted in the
   layout, populated client-side by InteractionLayer.
   ============================================================= */

.artifact-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  visibility: hidden;
}
.artifact-drawer.open {
  visibility: visible;
  pointer-events: auto;
}

.artifact-drawer .ad-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0);
  transition: background var(--dur-base) var(--ease);
}
.artifact-drawer.open .ad-backdrop {
  background: rgba(10, 10, 10, 0.32);
}

.artifact-drawer .ad-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(880px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 40px -12px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease);
}
.artifact-drawer.open .ad-panel {
  transform: translateX(0);
}

/* Header */
.ad-header {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ad-header .ad-icon {
  width: 44px; height: 44px;
  background: var(--ink); color: var(--on-action);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  flex-shrink: 0;
}
.ad-header .ad-meta {
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.ad-header .ad-eyebrow {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.ad-header .ad-eyebrow .sep { color: var(--ink-4); }
.ad-header h2.ad-title {
  font-size: 18px; line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
  word-break: break-word;
}
.ad-header .ad-submeta {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.ad-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-weight: 600;
}
.ad-status.approved { background: var(--live-bg); color: var(--live); border-color: var(--live-border); }
.ad-status.review   { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.ad-status.draft,
.ad-status.in-progress { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.ad-status.superseded { background: var(--bg-subtle); color: var(--ink-3); }

.ad-header .ad-close {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ad-header .ad-close:hover { border-color: var(--ink); color: var(--ink); }

/* Version switcher (sub-row under header) */
.ad-versions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.ad-versions .ad-versions-label {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em; text-transform: uppercase;
  margin-right: 6px;
}
.ad-versions .ad-version-pill {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.ad-versions .ad-version-pill:hover {
  border-color: var(--ink-3);
}
.ad-versions .ad-version-pill.current {
  background: var(--ink); color: var(--on-action);
  border-color: var(--ink);
}

/* Body — scrollable */
.ad-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 20px 22px 28px;
}

/* Footer — sticky actions */
.ad-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ad-footer .ad-foot-meta {
  margin-right: auto;
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-3);
}

/* === CSV table content === */
.ad-csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ad-csv-table thead th {
  position: sticky; top: -20px;
  background: var(--surface);
  text-align: left;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ad-csv-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  vertical-align: top;
}
.ad-csv-table tbody td:first-child {
  width: 36px;
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 11px;
}
.ad-csv-table tbody td.subj { color: var(--ink); }
.ad-csv-table tbody td.send,
.ad-csv-table tbody td.aud,
.ad-csv-table tbody td.status {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.ad-csv-table tbody tr.row-locked td { background: var(--bg-subtle); }
.ad-csv-table tbody tr.row-locked td.subj::after {
  content: " 🔒";
  color: var(--ink-3);
  font-size: 11px;
}
.ad-csv-table tbody tr.row-new td:first-child {
  border-left: 2px solid var(--live);
  padding-left: 10px;
}
.ad-csv-table tbody tr.row-edited td:first-child {
  border-left: 2px solid var(--info);
  padding-left: 10px;
}
.ad-csv-table tbody tr.row-removed td {
  text-decoration: line-through;
  color: var(--ink-4);
}
.ad-csv-table tbody tr.row-removed td:first-child {
  border-left: 2px solid var(--ink-4);
  padding-left: 10px;
  text-decoration: none;
}

.ad-row-flag {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 600;
}
.ad-row-flag.flag-new { color: var(--live); border-color: var(--live-border); background: var(--live-bg); }
.ad-row-flag.flag-edited { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }
.ad-row-flag.flag-removed { color: var(--ink-3); }

.ad-footnote {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* === Deck content === */
.ad-deck-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.ad-slide {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 16px 18px 14px;
  position: relative;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  cursor: default;
  min-height: 130px;
  display: flex; flex-direction: column; gap: 8px;
}
.ad-slide:hover { border-color: var(--ink-3); }
.ad-slide.slide-caveat { border-color: var(--warn-border); background: var(--warn-bg); }
.ad-slide.slide-edit { border-left: 3px solid var(--info); }
.ad-slide.slide-new { border-left: 3px solid var(--live); }

.ad-slide .slide-num {
  position: absolute;
  top: 10px; right: 12px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-4);
}
.ad-slide .slide-eyebrow {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 600;
}
.ad-slide .slide-title {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.35;
  padding-right: 30px;
}
.ad-slide.slide-caveat .slide-title { color: var(--warn); }
.ad-slide .slide-bullets {
  list-style: none; padding: 0; margin: 4px 0 0;
  display: flex; flex-direction: column; gap: 3px;
}
.ad-slide .slide-bullets li {
  font-size: 12px; color: var(--ink-3);
  line-height: 1.45;
  padding-left: 10px;
  position: relative;
}
.ad-slide .slide-bullets li::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: var(--ink-4);
}
.ad-slide .slide-flag {
  position: absolute;
  bottom: 8px; right: 12px;
  font-family: var(--font-mono); font-size: 9.5px;
  color: var(--ink-3);
  letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 600;
}

.ad-deck-progress {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--info);
  font-family: var(--font-mono);
}

/* === Doc content === */
.ad-doc {
  max-width: 720px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
}
.ad-doc h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 28px; line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 8px;
}
.ad-doc h3 {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  margin: 22px 0 6px;
  letter-spacing: -0.005em;
}
.ad-doc p { margin: 0 0 10px; }
.ad-doc p strong { color: var(--ink); }
.ad-doc ul {
  margin: 0 0 14px;
  padding-left: 18px;
}
.ad-doc ul li { margin-bottom: 6px; }
.ad-doc .doc-eyebrow {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 16px;
}
.ad-doc .doc-meta {
  margin-top: 22px;
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-3);
}

/* === Row + slide expansion (artifact drawer detail view) === */
/* The expand UX is universal: every list-style artifact row/slide can be
   clicked to reveal the full markdown body. Same pattern across HH, GTO,
   demo — so reviewers learn it once and use it everywhere. */

/* Chevron column on CSV tables — narrow, right-aligned, only visible on
   rows that are actually expandable. */
.ad-csv-table thead th.ad-csv-chev-col { width: 28px; padding: 0; }
.ad-csv-table tbody td.ad-csv-chev-cell {
  width: 28px;
  text-align: right;
  color: var(--ink-4);
  padding-right: 10px;
}

.ad-chev {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-3);
  transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  user-select: none;
}

/* Expandable rows: cursor + hover lift + active-row treatment when open. */
.ad-csv-table tbody tr.ad-row-expandable {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.ad-csv-table tbody tr.ad-row-expandable:hover td { background: var(--bg-subtle); }
.ad-csv-table tbody tr.ad-row-expandable:hover .ad-chev { color: var(--ink); }
.ad-csv-table tbody tr.ad-row-expandable.is-expanded td {
  background: var(--bg-subtle);
  border-bottom-color: transparent;
}
.ad-csv-table tbody tr.ad-row-expandable.is-expanded .ad-chev {
  transform: rotate(90deg);
  color: var(--ink);
}

/* The detail row sits beneath the head row and spans every column. The
   inner div takes the actual padding so the table cell can be borderless. */
.ad-csv-table tbody tr.ad-row-detail td {
  padding: 0;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.ad-row-detail-inner {
  padding: 4px 18px 22px;
  max-width: 720px;
}

/* Detail metadata strip — small key/value pairs above the body. */
.ad-detail-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin: 8px 0 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.ad-detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ad-detail-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 600;
}
.ad-detail-value {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.4;
}

/* The actual rendered email / slide body. Reads like a markdown doc. */
.ad-detail-body {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px 20px;
}
.ad-detail-body p { margin: 0 0 10px; }
.ad-detail-body p:last-child { margin-bottom: 0; }
.ad-detail-body p strong { color: var(--ink); font-weight: 600; }
.ad-detail-body ul, .ad-detail-body ol {
  margin: 6px 0 12px;
  padding-left: 18px;
}
.ad-detail-body ul li, .ad-detail-body ol li { margin-bottom: 4px; }
.ad-detail-body h4 {
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin: 18px 0 6px;
}
.ad-detail-body h4:first-child { margin-top: 0; }

/* Internal note — a soft amber callout at the bottom of the detail body. */
.ad-detail-note {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--warn);
  line-height: 1.5;
}

/* Removed-row detail keeps the muted treatment so reviewers know they're
   reading content that was cut. */
.ad-csv-table tbody tr.row-removed.ad-row-expandable td { color: var(--ink-4); }
.ad-csv-table tbody tr.row-removed.ad-row-expandable.is-expanded ~ tr.ad-row-detail .ad-detail-body { opacity: 0.92; }

/* === Slide expansion === */
/* Expandable slides get a subtle pointer + chevron, then span both grid
   columns when expanded so the body has room to breathe. */
.ad-slide.ad-slide-expandable { cursor: pointer; }
.ad-slide.ad-slide-expandable:hover { border-color: var(--ink); }
.ad-slide .slide-chev {
  position: absolute;
  bottom: 10px; right: 12px;
  font-size: 16px;
  color: var(--ink-4);
}
.ad-slide.ad-slide-expandable:hover .slide-chev { color: var(--ink); }
/* When the slide also carries a flag-label, push the chevron up to make
   room. (Caveat / Edited / New labels also live in the bottom-right.) */
.ad-slide:has(.slide-flag) .slide-chev { display: none; }

.ad-slide.is-expanded {
  grid-column: 1 / -1;
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 1px 0 var(--border), 0 8px 24px rgba(15, 18, 23, 0.05);
}
.ad-slide.is-expanded .slide-chev {
  transform: rotate(90deg);
  color: var(--ink);
}

.ad-slide-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
/* Inside an expanded slide, reuse the same detail-body styling but adjust
   the surface so it doesn't double-stack borders against the slide tile. */
.ad-slide .ad-detail-fields {
  background: var(--bg-subtle);
}
.ad-slide .ad-detail-body {
  background: transparent;
  border: none;
  padding: 4px 0 0;
}

@media (max-width: 720px) {
  .artifact-drawer .ad-panel { width: 100vw; }
  .ad-deck-grid { grid-template-columns: 1fr; }
  .ad-csv-table thead { display: none; }
  .ad-csv-table tbody td { display: block; padding: 4px 0; border-bottom: none; }
  .ad-csv-table tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .ad-csv-table tbody td.ad-csv-chev-cell { display: none; }
  .ad-row-detail-inner { padding: 0 0 16px; }
  .ad-slide.is-expanded { grid-column: 1; }
}

/* =============================================================
   HABITAT ROOM — the host page (/h/[slug]) product shell.
   A real "room": editorial header (Instrument Serif title), a
   live conversation surface, and a context rail of agents + people.
   ============================================================= */

.hroom {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 22px 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.hroom-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 28px;
  flex-wrap: wrap;
}
.hroom-head-main { min-width: 0; }
.hroom-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500;
  margin-bottom: 7px;
}
.hroom-eyebrow .sep { color: var(--ink-4); }
.hroom-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 44px; line-height: 1.02;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 0;
}
.hroom-sub {
  font-size: 13px; color: var(--ink-3);
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.hroom-sub .dot { color: var(--ink-4); }

.hroom-head-side {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.hroom-people { display: flex; align-items: center; gap: 10px; }
.hroom-people-label {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3);
}

.hroom-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--live);
  background: var(--live-bg);
  border: 1px solid var(--live-border);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
}

.hroom-grid {
  display: grid;
  grid-template-columns: 1fr 284px;
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.hroom-grid.no-rail { grid-template-columns: 1fr; }
.hroom-main { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.hroom-main > * { flex: 1; min-height: 0; }

.hroom-rail {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0; overflow-y: auto;
}
.hroom-rail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 13px 14px 9px;
}
.hroom-rail-label {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 600;
  margin-bottom: 8px;
}
.hroom-rail-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px;
  border-radius: var(--r-sm);
}
.hroom-rail-row + .hroom-rail-row { border-top: 1px solid var(--border); }
.hroom-rail-row .rr-meta { min-width: 0; flex: 1; }
.hroom-rail-row .rr-name {
  font-size: 13px; color: var(--ink); font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hroom-rail-row .rr-sub {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3);
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hroom-rail-row .rr-ready {
  font-family: var(--font-mono); font-size: 9.5px;
  color: var(--live); letter-spacing: 0.04em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
}

.hroom-foot {
  text-align: center;
  color: var(--ink-4);
  font-size: 11.5px;
  font-family: var(--font-mono);
  padding: 2px 0 4px;
}

@media (max-width: 1080px) {
  .hroom-grid { grid-template-columns: 1fr; }
  .hroom-rail {
    flex-direction: row; flex-wrap: wrap; overflow: visible;
    order: 2;
  }
  .hroom-rail-card { flex: 1; min-width: 240px; }
}
@media (max-width: 640px) {
  .hroom-title { font-size: 34px; }
  .hroom-head-side { align-items: flex-start; }
}
