/* MOI Compass · Agent prototype — shared styles */

:root {
  --cream: #FBF9F4;
  --cream-deep: #F5F1E8;
  --ink: #1C1917;
  --ink-dim: #57534E;
  --ink-faint: #8C8579;
  --line: #E7E5E0;
  --line-strong: #D5D2CB;
  --forest: #175C39;
  --forest-dim: #3E7B5F;
  --forest-pale: #DDE9E2;
  --rust: #B7412E;
  --rust-pale: #F4DED8;
  --gold: #A87E27;
  --gold-pale: #F5EBD0;
  --purple: #4A2A80;
  --purple-pale: #F0EAFC;
  --blue: #1F345A;
  --blue-pale: #E8F0F8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}

/* Typography */
.font-serif { font-family: 'Instrument Serif', ui-serif, Georgia, serif; font-weight: 400; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.tabular { font-variant-numeric: tabular-nums; }

.eyebrow {
  text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 10.5px; font-weight: 600; color: var(--ink-faint);
}

h1 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400; font-size: 48px; line-height: 1.05;
  margin: 8px 0 0; letter-spacing: -0.01em;
}
h1::after {
  content: ''; display: block; width: 32px; height: 2px;
  background: var(--ink); margin-top: 14px;
}
h2 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400; font-size: 26px; line-height: 1.15;
  margin: 0 0 10px;
}
h3 {
  font-family: 'Inter', sans-serif;
  font-weight: 600; font-size: 14px; margin: 0;
}
p { margin: 0 0 8px; }
a { color: var(--forest); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* -------- App shell -------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #FFFFFF;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand-wrap {
  padding: 20px 22px 18px 22px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: 'Instrument Serif', serif;
  font-size: 22px; letter-spacing: -0.01em;
  color: var(--ink);
  display: inline-flex; align-items: baseline; gap: 6px;
  text-decoration: none;
}
.brand em { color: var(--forest); font-style: italic; font-weight: 400; }
.brand-mark {
  display: inline-block; width: 14px; height: 14px; border-radius: 999px;
  border: 2px solid var(--forest); position: relative;
  transform: translateY(1px);
}
.brand-mark::after {
  content: ''; position: absolute; top: 1px; left: 50%; width: 1.5px; height: 5px;
  background: var(--forest); transform: translateX(-50%);
}
.brand-sub {
  margin-top: 4px;
  font-family: 'Inter', sans-serif; font-size: 10px;
  letter-spacing: 0.14em; color: var(--ink-faint);
  text-transform: uppercase; font-weight: 600;
}

.nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 22px;
  color: var(--ink); font-size: 13.5px;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav a:hover { background: var(--cream); text-decoration: none; }
.nav a.active {
  background: var(--forest-pale);
  color: var(--forest);
  border-left-color: var(--forest);
  font-weight: 600;
}
.nav .icon {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  color: currentColor;
}
.nav .count-pill {
  margin-left: auto;
  font-size: 10.5px; font-weight: 600;
  background: var(--cream);
  color: var(--ink-dim);
  padding: 1px 6px; border-radius: 999px;
  min-width: 20px; text-align: center;
}
.nav a.active .count-pill { background: #FFFFFF; color: var(--forest); }

.nav-section-label {
  padding: 16px 22px 6px 22px;
  font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; font-weight: 600;
  color: var(--ink-faint);
  display: flex; align-items: center; gap: 6px;
}
.nav-section-label:first-child { padding-top: 8px; }
.nav-section-label .pill-new {
  font-size: 9px; letter-spacing: 0.1em;
  background: var(--forest); color: var(--cream);
  padding: 1px 5px; border-radius: 999px;
  font-weight: 600;
}
.nav .ext {
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 11px;
}
.nav a[target="_blank"] { color: var(--ink-dim); }
.nav a[target="_blank"]:hover .ext { color: var(--forest); }

.agent-status {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-dim);
}
.dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 999px; background: #10b981;
  margin-right: 4px; vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(16,185,129,0.28); }
}

/* -------- Main -------- */
main {
  padding: 36px 48px 64px 48px;
  max-width: 1400px;
}
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  margin-bottom: 32px;
}
.subtitle {
  margin-top: 18px; max-width: 640px;
  color: var(--ink-dim); font-size: 15px; line-height: 1.55;
}

/* Stat strip */
.stat-strip {
  display: flex; flex-wrap: wrap; gap: 56px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.stat .stat-num {
  font-family: 'Instrument Serif', serif; font-size: 28px;
  margin-top: 4px; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat .stat-num.pos { color: var(--forest); }
.stat .stat-num.warn { color: var(--gold); }
.stat .stat-num.neg { color: var(--rust); }

/* Surface / cards */
.surface {
  background: #FFFFFF;
  border: 1px solid var(--line);
}
.surface-hover:hover { border-color: var(--line-strong); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: 11px; font-weight: 500;
  border-radius: 3px; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.chip-quick { background: var(--forest-pale); color: #0F3B25; border-color: #B5D0BE; }
.chip-medium { background: var(--cream-deep); color: var(--ink-dim); border-color: var(--line); }
.chip-heavy { background: var(--gold-pale); color: #6B4C0B; border-color: #DBBE7D; }
.chip-info { background: var(--blue-pale); color: var(--blue); border-color: #B0C5DB; }
.chip-warn { background: var(--gold-pale); color: #6B4C0B; border-color: #DBBE7D; }
.chip-crit { background: var(--rust-pale); color: #8B2F1F; border-color: #E4A79C; }
.chip-purple { background: var(--purple-pale); color: var(--purple); border-color: #D5C4F0; }
.chip-owner { background: #FFFFFF; color: var(--ink); border-color: var(--line-strong); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--ink); color: var(--cream);
  font-size: 13px; font-weight: 500;
  border-radius: 3px; border: 1px solid var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #0F0E0C; text-decoration: none; }
.btn-primary { background: var(--forest); border-color: var(--forest); }
.btn-primary:hover { background: #0F3B25; }
.btn-ghost {
  background: transparent; color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--cream-deep); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* -------- Insights feed cards -------- */
.insight {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  margin-bottom: 10px;
}
.insight-marker {
  width: 8px; height: 8px; border-radius: 999px;
  margin-top: 6px;
}
.insight-marker.crit { background: var(--rust); }
.insight-marker.warn { background: var(--gold); }
.insight-marker.pos  { background: var(--forest); }
.insight-marker.info { background: var(--blue); }

.insight-body .insight-title {
  font-weight: 600; font-size: 15px; color: var(--ink);
  margin-bottom: 4px;
}
.insight-body .insight-detail {
  font-size: 13px; color: var(--ink-dim); line-height: 1.55;
}
.insight-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--ink-faint);
  margin-top: 8px;
}
.source-badge {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--cream);
  padding: 2px 8px; border-radius: 3px;
  font-size: 11px; color: var(--ink-dim); font-weight: 500;
}
.source-badge .mark { width: 8px; height: 8px; border-radius: 2px; }
.insight-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.insight-actions .row { display: flex; gap: 6px; }
.insight-actions .stamp { font-size: 11px; color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; }

/* -------- Insights: grouped + collapsible rows -------- */
.insight-group {
  margin-bottom: 20px;
  border: 1px solid var(--line);
  background: #FFFFFF;
}
.insight-group-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 20px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
}
.insight-group-header h3 {
  margin: 0;
  font-family: 'Instrument Serif', serif;
  font-size: 20px;
  color: var(--ink);
  font-weight: 400;
}
.insight-group-count {
  font-size: 11px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.insight-row {
  border-top: 1px solid var(--line);
}
.insight-row:first-of-type {
  border-top: none;
}
.insight-row summary {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.insight-row summary::-webkit-details-marker { display: none; }
.insight-row summary::marker { content: ""; }
.insight-row summary:hover { background: var(--cream); }
.insight-row[open] summary { background: var(--cream); border-bottom: 1px solid var(--line); }

.insight-row-title {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.4;
}
.insight-row-chips {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  white-space: nowrap;
}
.row-stamp {
  font-size: 11px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  min-width: 100px;
  text-align: right;
}
.insight-row-body {
  padding: 16px 20px 16px 48px;
  border-top: 1px solid transparent;
}
.insight-row-body .insight-detail {
  font-size: 13px; color: var(--ink-dim); line-height: 1.6;
  margin-bottom: 10px;
}
.insight-rec {
  margin: 10px 0;
  padding: 8px 12px;
  background: var(--forest-pale);
  border-left: 2px solid var(--forest);
  border-radius: 0 3px 3px 0;
  font-size: 13px;
  color: var(--ink);
}
.insight-row-body .insight-meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.insight-row-actions {
  display: flex; gap: 6px;
  margin-top: 12px;
}

/* -------- Context: form + notes -------- */
.context-add {
  background: #FFFFFF;
  border: 1px solid var(--line);
  padding: 16px 20px 20px 20px;
  margin-bottom: 8px;
}
.context-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.context-form-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
}
.context-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}
.context-form label .aside {
  color: var(--ink-faint);
  font-weight: 400;
}
.context-form input[type="date"],
.context-form select,
.context-form textarea {
  border: 1px solid var(--line-strong);
  background: var(--cream);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}
.context-form textarea {
  resize: vertical;
}
.context-form input[type="date"]:focus,
.context-form select:focus,
.context-form textarea:focus {
  outline: none;
  border-color: var(--ink-dim);
  background: #FFFFFF;
}
.context-form-body { }
.context-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.context-form-inline {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.context-note {
  border-top: 1px solid var(--line);
}
.context-note:first-of-type { border-top: none; }
.context-note summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.context-note summary::-webkit-details-marker { display: none; }
.context-note summary::marker { content: ""; }
.context-note summary:hover { background: var(--cream); }
.context-note[open] summary { background: var(--cream); border-bottom: 1px solid var(--line); }
.context-note-body {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
}
.context-note-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  white-space: nowrap;
}
.context-note-detail {
  padding: 16px 20px 20px 20px;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.6;
}

/* -------- Dismiss dialog -------- */
.dismiss-dialog {
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  padding: 24px 28px;
  width: min(520px, 92vw);
  color: var(--ink);
}
.dismiss-dialog::backdrop {
  background: rgba(28, 25, 23, 0.35);
}
.dismiss-dialog h3 {
  font-family: 'Instrument Serif', serif;
  font-size: 24px;
  font-weight: 400;
  margin: 0 0 6px 0;
}
.dismiss-dialog-title {
  font-size: 13px;
  color: var(--ink-dim);
  margin: 0 0 16px 0;
  padding: 8px 12px;
  background: var(--cream);
  border-left: 2px solid var(--line-strong);
  font-style: italic;
}
.dismiss-dialog label {
  display: block;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  margin-bottom: 8px;
}
.dismiss-dialog label .aside {
  display: block;
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 12px;
  margin-top: 2px;
}
.dismiss-dialog textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--cream);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  resize: vertical;
  box-sizing: border-box;
}
.dismiss-dialog textarea:focus {
  outline: none;
  border-color: var(--ink-dim);
  background: #FFFFFF;
}
.dismiss-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* -------- Insight detail as scannable bullets -------- */
.insight-detail .insight-detail-intro {
  margin: 0 0 8px 0;
  color: var(--ink-dim);
  line-height: 1.6;
}
.insight-detail .insight-detail-bullets {
  list-style: none;
  padding: 0;
  margin: 0;
}
.insight-detail .insight-detail-bullets li {
  position: relative;
  padding: 0 0 6px 16px;
  color: var(--ink);
  line-height: 1.55;
}
.insight-detail .insight-detail-bullets li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--ink-faint);
}
.insight-detail .insight-detail-bullets li strong {
  color: var(--ink);
  font-weight: 600;
}

/* -------- Insight comments thread + composer -------- */
.insight-comments {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.insight-comments-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.insight-comments-count {
  font-size: 11px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
}
.insight-comments-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.insight-comment {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
}
.insight-comment-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--cream-deep);
  color: var(--ink);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.insight-comment-body {
  min-width: 0;
}
.insight-comment-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  margin-bottom: 2px;
}
.insight-comment-author {
  color: var(--ink);
  font-weight: 500;
}
.insight-comment-time {
  font-family: 'JetBrains Mono', monospace;
}
.insight-comment-delete-btn {
  border: none;
  background: none;
  color: var(--ink-faint);
  font-size: 11px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
  text-decoration: underline;
}
.insight-comment-delete-btn:hover {
  color: var(--rust);
}
.insight-comment-text {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}
.insight-comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.insight-comment-form textarea {
  flex: 1;
  min-height: 32px;
  max-height: 120px;
  border: 1px solid var(--line-strong);
  background: var(--cream);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  resize: vertical;
  line-height: 1.4;
}
.insight-comment-form textarea:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--ink-dim);
}
.insight-comment-form .btn {
  align-self: stretch;
}

/* -------- Ask agent button — visually elevated (black + icon) -------- */
.btn-ask-agent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: var(--cream);
  border: 1px solid var(--ink);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s ease, transform 0.06s ease;
  line-height: 1.2;
}
.btn-ask-agent:hover {
  background: #2E2925;   /* slightly lighter than --ink for hover */
  color: var(--cream);
  text-decoration: none;
}
.btn-ask-agent:active { transform: translateY(1px); }
.btn-ask-agent svg {
  width: 12px; height: 12px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 2;
}
/* Small variant used on location-detail insight cards */
.btn-ask-agent-sm {
  padding: 3px 9px;
  font-size: 11px;
  gap: 5px;
}

/* -------- Insight ID badges (visible on cards, tooltip explains #ref) -------- */
.insight-id, .insight-id-inline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-faint);
  background: var(--cream-deep);
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  font-weight: 500;
  vertical-align: middle;
}
.insight-id-inline {
  /* inline variant used inside tighter paragraph text on location detail */
  font-size: 11px;
}
/* Deep-link target flash — brief highlight when jumped to via #insight-N */
:target.macro-card,
:target.insight-row,
:target.surface.border-l-2 {
  animation: insight-flash 1.6s ease-out;
}
@keyframes insight-flash {
  0%   { background-color: var(--gold-pale); }
  100% { background-color: transparent; }
}

/* -------- Portfolio-patterns macro section -------- */
.macro-section {
  margin-bottom: 32px;
  padding: 20px 24px;
  background: var(--forest-pale);
  border: 1px solid var(--forest);
}
.macro-section .section-header {
  border-bottom: 1px solid var(--forest);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.macro-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.macro-card {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-left: 3px solid var(--forest);
}
.macro-card.sev-crit { border-left-color: var(--rust); }
.macro-card.sev-warn { border-left-color: var(--gold); }
.macro-card.sev-pos  { border-left-color: var(--forest); }
.macro-card.sev-info { border-left-color: var(--blue); }
.macro-card > summary {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.macro-card > summary::-webkit-details-marker { display: none; }
.macro-card > summary::marker { content: ""; }
.macro-card > summary:hover { background: var(--cream); }
.macro-card[open] > summary { background: var(--cream); border-bottom: 1px solid var(--line); }
.macro-card-title-block {
  min-width: 0;
}
.macro-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.005em;
}
.macro-card-scope {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
}
.macro-card-chips {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  white-space: nowrap;
}
.macro-card-body {
  padding: 16px 18px 18px 46px;
}
.macro-card-body .insight-detail {
  font-size: 14px; color: var(--ink-dim); line-height: 1.65;
  margin-bottom: 12px;
}

/* -------- Location detail: collapsible insight cards -------- */
.location-insight-card {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-left: 2px solid var(--blue);
}
.location-insight-card.sev-crit { border-left-color: var(--rust); }
.location-insight-card.sev-warn { border-left-color: var(--gold); }
.location-insight-card.sev-pos  { border-left-color: var(--forest); }
.location-insight-card.sev-info { border-left-color: var(--blue); }
.location-insight-card > summary {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.location-insight-card > summary::-webkit-details-marker { display: none; }
.location-insight-card > summary::marker { content: ""; }
.location-insight-card > summary:hover { background: var(--cream); }
.location-insight-card[open] > summary { background: var(--cream); border-bottom: 1px solid var(--line); }
.location-insight-caret {
  color: var(--ink-faint);
  font-size: 12px;
  transition: transform 0.15s ease;
  transform-origin: center;
  display: inline-block;
}
.location-insight-card[open] > summary .location-insight-caret {
  transform: rotate(90deg);
}
.location-insight-headline {
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.location-insight-title {
  color: var(--ink);
}
.location-insight-chips {
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.location-insight-body {
  padding: 14px 16px 16px 44px;
}

/* -------- Playbook plays: collapsible card summary -------- */
.play-card > summary {
  list-style: none;
}
.play-card > summary::-webkit-details-marker { display: none; }
.play-card > summary::marker { content: ""; }
.play-card > summary .play-caret {
  display: inline-block;
  transition: transform 0.15s ease;
  transform-origin: center;
}
.play-card[open] > summary .play-caret {
  transform: rotate(90deg);
}

/* -------- Chat trigger button (floating, always visible) -------- */
.chat-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  box-shadow: 0 4px 16px rgba(28, 25, 23, 0.16), 0 2px 4px rgba(28, 25, 23, 0.08);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.chat-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(28, 25, 23, 0.22), 0 3px 6px rgba(28, 25, 23, 0.10);
}
.chat-trigger .agent-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  animation: pulse 2.4s infinite;
}
.chat-trigger .agent-glyph {
  font-family: 'Instrument Serif', serif;
  font-size: 15px; font-style: italic;
  color: var(--cream);
}

/* -------- Backdrop + panel -------- */
.chat-backdrop {
  position: fixed; inset: 0;
  background: rgba(28, 25, 23, 0.12);
  backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.chat-backdrop.open { opacity: 1; pointer-events: auto; }

.chat-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: #FFFFFF;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(28, 25, 23, 0.08);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0.32, 1);
}
.chat-panel.open { transform: translateX(0); }

.chat-panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
}
.chat-panel-header .agent-brand {
  font-family: 'Instrument Serif', serif;
  font-size: 18px; letter-spacing: -0.01em;
  color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
}
.chat-panel-header .agent-brand em { color: var(--forest); font-style: italic; }
.chat-panel-header .status-mini {
  font-size: 10.5px; color: var(--ink-faint);
  letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.chat-panel-header .status-mini .agent-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  animation: pulse 2.4s infinite;
}
.chat-panel-header .spacer { flex: 1; }
.chat-panel-header button.icon-btn {
  background: transparent; border: none; color: var(--ink-dim);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  border-radius: 3px; line-height: 1;
}
.chat-panel-header button.icon-btn:hover { background: var(--cream-deep); color: var(--ink); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px;
}
.chat-msg { display: grid; grid-template-columns: 28px 1fr; gap: 10px; margin-bottom: 18px; }
.chat-msg .avatar {
  width: 28px; height: 28px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.chat-msg.user .avatar { background: var(--cream-deep); color: var(--ink); }
.chat-msg.agent .avatar {
  background: var(--forest); color: var(--cream);
  font-family: 'Instrument Serif', serif; font-size: 15px;
}
.chat-msg .content { padding-top: 4px; font-size: 14.5px; line-height: 1.6; }
.chat-msg .who { font-weight: 600; font-size: 12px; margin-bottom: 4px; color: var(--ink); }
.chat-msg.user .who { color: var(--ink-dim); }
.chat-msg .body { color: var(--ink); }
.chat-msg .body p { margin: 0 0 10px; }
.chat-msg .body ul { margin: 0 0 10px; padding-left: 20px; }
.chat-msg .body ul li { margin-bottom: 4px; }

/* Chat #N insight references — linked with hover tooltip */
.chat-msg .body a.insight-ref {
  color: var(--forest);
  text-decoration: none;
  border-bottom: 1px dotted var(--forest);
  font-weight: 500;
  cursor: help;
  white-space: nowrap;
}
.chat-msg .body a.insight-ref:hover {
  background: var(--forest-pale);
  border-bottom-style: solid;
}

/* Chat markdown tables */
.chat-msg .body .chat-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: #FFFFFF;
}
.chat-msg .body .chat-table thead th {
  background: var(--cream);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-msg .body .chat-table tbody td {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  vertical-align: top;
  line-height: 1.45;
}
.chat-msg .body .chat-table tbody tr:hover td {
  background: var(--cream);
}
.chat-msg .body .chat-table {
  font-variant-numeric: tabular-nums;
}
.tool-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 2px 8px;
  border: 1px solid var(--line-strong); border-radius: 3px;
  color: var(--ink-dim); background: var(--cream);
  margin-right: 6px; margin-bottom: 6px;
  font-family: 'JetBrains Mono', monospace;
}
.tool-badges { margin-bottom: 6px; }
.chat-msg .agent-callout {
  border-left: 2px solid var(--forest);
  padding-left: 12px;
  background: var(--forest-pale);
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 0 3px 3px 0;
}
.chat-typing {
  display: inline-flex; gap: 4px; padding: 4px 0;
}
.chat-typing span {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--ink-faint);
  animation: bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Chat status message — cycles through phases while the agent thinks */
.chat-msg .chat-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.chat-msg .chat-status-label {
  font-size: 13px;
  color: var(--ink-faint);
  font-style: italic;
  animation: status-fade-in 0.4s ease-out;
}
@keyframes status-fade-in {
  from { opacity: 0.2; }
  to   { opacity: 1; }
}
.chat-composer {
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px 16px;
  background: #FFFFFF;
}
.suggested-prompts {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
}
.suggested-prompts button {
  background: var(--cream); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px;
  font-size: 12px; color: var(--ink); cursor: pointer;
  font-family: inherit;
}
.suggested-prompts button:hover { background: var(--cream-deep); border-color: var(--line-strong); }
.chat-composer form {
  display: flex; gap: 8px; align-items: flex-end;
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 10px; background: var(--cream);
}
.chat-composer textarea {
  flex: 1; border: none; background: transparent;
  font-family: inherit; font-size: 14px;
  resize: none; height: 24px; max-height: 120px;
  padding: 4px 0; color: var(--ink);
  line-height: 1.5;
}
.chat-composer textarea:focus { outline: none; }
.chat-composer button {
  background: var(--ink); color: var(--cream); border: none;
  border-radius: 4px; padding: 6px 12px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.chat-composer button:hover { background: #0F0E0C; }

/* -------- Integrations -------- */
.integration-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.integration {
  padding: 20px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  display: flex; flex-direction: column; gap: 12px;
}
.integration .row {
  display: flex; align-items: flex-start; gap: 14px;
}
.integration .logo {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--cream);
  border-radius: 8px;
  flex: none;
  font-size: 22px;
  color: var(--ink);
}
.integration .name {
  font-size: 15px; font-weight: 600; color: var(--ink);
  margin-bottom: 2px;
}
.integration .provider {
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 600;
}
.integration .description {
  font-size: 12.5px; color: var(--ink-dim); line-height: 1.5;
}
.integration .status-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--ink-dim);
  padding-top: 10px; border-top: 1px solid var(--line);
  margin-top: auto;
}
.integration .status-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 999px;
}
.integration .status-dot.on { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.14); }
.integration .status-dot.off { background: var(--line-strong); }
.integration .status-dot.syncing { background: var(--gold); }
.integration .status-text { flex: 1; }
.integration .integ-actions {
  display: flex; gap: 6px;
}
.integration.disconnected {
  background: var(--cream);
  border-style: dashed;
}
.integration.disconnected .name { color: var(--ink-dim); }

/* Section header pattern */
.section-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 32px 0 14px 0;
}
.section-header h2 { margin: 0; }
.section-header .aside { font-size: 12px; color: var(--ink-faint); }

/* Utilities */
.stack > * + * { margin-top: 16px; }
.text-ink-dim { color: var(--ink-dim); }
.text-ink-faint { color: var(--ink-faint); }
.text-forest { color: var(--forest); }
.text-rust { color: var(--rust); }
.text-gold { color: var(--gold); }

/* -------- Chat landing page (classic LLM UI) -------- */

/* Suppress the floating trigger on the chat page — it lives here */
body.chat-page .chat-trigger,
body.chat-page .chat-backdrop,
body.chat-page .chat-panel { display: none !important; }

.chat-main {
  padding: 0;
  max-width: none;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Empty-state: centered composer + prompt chips */
.chat-empty[hidden],
.chat-conversation[hidden] { display: none !important; }

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 48px;
  overflow-y: auto;
}
.chat-empty-inner {
  width: 100%;
  max-width: 720px;
  text-align: center;
}
.chat-empty-inner .eyebrow {
  display: inline-block;
  margin-bottom: 14px;
}
.chat-greeting {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: 52px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}
.chat-greeting::after { display: none; }
.chat-subgreeting {
  color: var(--ink-dim);
  font-size: 15.5px;
  line-height: 1.55;
  max-width: 560px;
  margin: 0 auto 32px;
}

.chat-insight-banner {
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  background: var(--forest-pale);
  border-left: 3px solid var(--forest);
  text-align: left;
}
.chat-insight-banner .eyebrow {
  color: var(--forest);
  font-weight: 600;
}
.chat-insight-banner-title {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}
.chat-insight-banner-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  font-style: italic;
}

.chat-hero-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px 14px 14px 18px;
  background: #FFFFFF;
  box-shadow: 0 2px 12px rgba(28, 25, 23, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  text-align: left;
}
.chat-hero-composer:focus-within {
  border-color: var(--ink-dim);
  box-shadow: 0 4px 20px rgba(28, 25, 23, 0.08);
}
.chat-hero-composer textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.55;
  resize: none;
  min-height: 28px;
  max-height: 200px;
  color: var(--ink);
  padding: 4px 0;
}
.chat-hero-composer textarea::placeholder {
  color: var(--ink-faint);
}
.chat-hero-composer button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 160ms ease, transform 100ms ease;
  flex: none;
}
.chat-hero-composer button:hover { background: #0F0E0C; }
.chat-hero-composer button:active { transform: scale(0.95); }
.chat-hero-composer button:disabled {
  background: var(--line-strong);
  cursor: not-allowed;
}
.send-glyph {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.chat-hero-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}
.chat-hero-prompts button {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.chat-hero-prompts button:hover {
  background: var(--cream-deep);
  border-color: var(--line-strong);
  color: var(--ink);
}

.chat-hero-footer {
  margin-top: 32px;
  font-size: 12px;
  color: var(--ink-faint);
}
.chat-hero-footer a {
  color: var(--ink-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  margin: 0 2px;
}
.chat-hero-footer a:hover { color: var(--forest); text-decoration-color: var(--forest); }

/* Conversation view (post first send) */
.chat-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-conversation-log {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px 24px;
}
.chat-conversation-log .chat-msg {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.chat-conversation-log .chat-msg .avatar {
  width: 32px;
  height: 32px;
}
.chat-conversation-log .chat-msg .content {
  font-size: 15px;
}
.chat-conversation-log .chat-msg .body ul { padding-left: 22px; }
.chat-conversation-log .chat-msg .body li { margin-bottom: 6px; }

.chat-conversation-composer {
  border-top: 1px solid var(--line);
  padding: 16px 48px 20px;
  background: var(--cream);
}
.chat-conversation-composer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px 12px 12px 18px;
  background: #FFFFFF;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.chat-conversation-composer-inner:focus-within {
  border-color: var(--ink-dim);
  box-shadow: 0 4px 16px rgba(28, 25, 23, 0.06);
}
.chat-conversation-composer textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  min-height: 24px;
  max-height: 160px;
  color: var(--ink);
  padding: 4px 0;
}
.chat-conversation-composer textarea::placeholder { color: var(--ink-faint); }
.chat-conversation-composer button[type="submit"] {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease;
  flex: none;
}
.chat-conversation-composer button[type="submit"]:hover { background: #0F0E0C; }
.chat-conversation-composer button[type="submit"]:disabled {
  background: var(--line-strong);
  cursor: not-allowed;
}

.chat-conversation-footer {
  max-width: 780px;
  margin: 8px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-faint);
}
.chat-conversation-footer .hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.02em;
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.link-btn:hover { background: var(--cream-deep); color: var(--ink); }

/* Narrow screens */
@media (max-width: 820px) {
  .chat-empty { padding: 24px 20px; }
  .chat-greeting { font-size: 40px; }
  .chat-conversation-log { padding: 24px 20px; }
  .chat-conversation-composer { padding: 12px 20px 16px; }
}
