/* Shugyo app shell — built on EmpoweredHouse tokens (colors_and_type.css).
   No raw hexes here: everything routes through semantic tokens so the
   light/dark toggle is free. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #root {
  width: 100%;
  height: 100%;
  background: var(--canvas);
  color: var(--text-primary);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, textarea { font-family: var(--sans); }

/* ---------------------------------------------------------------- shell */
.app {
  display: flex;
  height: 100vh;
  position: relative;
  background: var(--canvas);

  /* density tokens — comfortable by default */
  --pad-page: 28px;
  --pad-card: 20px;
  --gap: 16px;
  --nav-pad-y: 9px;
  --row-pad: 14px;
}
.app.density-compact {
  --pad-page: 18px;
  --pad-card: 14px;
  --gap: 10px;
  --nav-pad-y: 6px;
  --row-pad: 9px;
}

/* ambient warm glow — tweakable */
.app.has-ambient::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--ambient-warm), transparent 60%),
    radial-gradient(ellipse 60% 50% at 0% 100%, var(--ambient-lime), transparent 50%);
}

/* ------------------------------------------------------------- sidebar */
.sidebar {
  width: 228px;
  flex: 0 0 228px;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px 14px;
  border-right: 1px solid var(--border-faint);
  position: relative;
  z-index: 1;
}
.sidebar.elevated { background: var(--surface-1); }

.lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 0 10px;
}
.lockup-name {
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.012em;
  color: var(--text-primary);
}
.lockup-footnote {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 6px 10px 0 10px;
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
.nav-section {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 18px 10px 6px 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--nav-pad-y) 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.005em;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.nav-item:hover { color: var(--text-primary); background: var(--surface-1); }
.sidebar.elevated .nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  color: var(--text-primary);
  font-weight: 500;
  background: var(--surface-2);
  border-color: var(--border-faint);
}
.sidebar.elevated .nav-item.active { background: var(--surface-3); }
.nav-item svg { flex: 0 0 auto; opacity: 0.85; }
.nav-item .nav-signal {
  margin-left: auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-ink);
  opacity: 0;
  transition: opacity var(--dur-hover) var(--ease);
}
.nav-item.active .nav-signal { opacity: 1; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-menu { position: relative; }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.user-card:hover { background: var(--surface-2); border-color: var(--border-soft); }
.user-card.open { background: var(--surface-2); border-color: var(--border-soft); }
.user-card-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.user-card-name { font-size: 13px; font-weight: 500; letter-spacing: -0.008em; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-caret { flex: 0 0 auto; color: var(--text-tertiary); display: inline-flex; }

.user-pop {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 5px;
}
.user-pop-head { display: flex; align-items: center; gap: 10px; padding: 9px 9px 10px 9px; border-bottom: 1px solid var(--border-faint); margin-bottom: 4px; }
.user-pop-head .avatar { width: 30px; height: 30px; flex-basis: 30px; }
.user-pop-id { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.user-pop-name { font-size: 13px; font-weight: 500; letter-spacing: -0.008em; color: var(--text-primary); }
.user-pop-mail { font-family: var(--mono); font-size: 10.5px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 9px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  font-size: 13px; letter-spacing: -0.005em; text-align: left; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.user-pop-item svg { color: var(--text-tertiary); flex: 0 0 auto; }
.user-pop-item:hover { background: var(--surface-3); color: var(--text-primary); }
.user-pop-item:hover svg { color: var(--text-secondary); }
.user-pop-item.danger { color: var(--error-ink); }
.user-pop-item.danger svg { color: var(--error-ink); }
.user-pop-item.danger:hover { background: color-mix(in oklab, var(--error-ink) 10%, transparent); color: var(--error-ink); }
.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.user-mail {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------- chat dock (Talk to Shugyo) */
.chat-dock {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  max-width: 42vw;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border-soft);
  background: var(--surface-1);
  z-index: 6;
  animation: cd-in 0.25s var(--ease) both;
}
.app.chat-docked .main { margin-right: 380px; }
@keyframes cd-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .chat-dock { animation: none; } }
.cd-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 14px; border-bottom: 1px solid var(--border-faint);
}
.cd-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; letter-spacing: -0.008em; color: var(--text-primary); }
.cd-head-actions { display: flex; align-items: center; gap: 8px; }
.cd-new { padding: 6px 12px; font-size: 12.5px; }
.cd-head-actions .icon-btn { width: 30px; height: 30px; }

.cd-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px; }
.cd-msgs { display: flex; flex-direction: column; gap: 14px; }
.chat-dock .msg-user { font-size: 13.5px; line-height: 1.55; padding: 8px 12px; max-width: 88%; }
.chat-dock .msg-agent .msg-body { font-size: 13.5px; line-height: 1.6; max-width: none; }
.chat-dock .agent-head { margin-bottom: 5px; }
.chat-dock .composer-box { max-width: none; }

.cd-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding-top: 8px; }
.cd-empty-q { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: var(--text-primary); }
.cd-sugg { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 4px; }
.cd-sugg button {
  text-align: left; width: 100%;
  background: transparent; border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 13px; line-height: 1.45; letter-spacing: -0.005em;
  padding: 10px 13px; cursor: pointer;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.cd-sugg button:hover { color: var(--text-primary); background: var(--surface-2); border-color: var(--border-strong); }

.cd-composer { padding: 8px 14px 14px 14px; }
.chat-dock .cd-composer .composer-box { padding: 9px 9px 8px 13px; border-radius: var(--radius-lg); }
.chat-dock .cd-composer .composer-input { font-size: 13.5px; }

/* ---------------------------------------------------------------- main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px var(--pad-page) 16px var(--pad-page);
}
.page-title {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.25;
  color: var(--text-primary);
}
.page-sub { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad-page) var(--pad-page) var(--pad-page);
}

/* -------------------------------------------------------------- panels */
.panel {
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  transition: border-color var(--dur-hover) var(--ease);
}
.panel.on-canvas { background: var(--canvas); }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow 0.25s var(--ease), transform var(--dur-press) var(--ease),
    background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease),
    color var(--dur-hover) var(--ease);
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--accent-ink), 0 0 24px var(--focus-glow);
}

.btn-primary {
  background: var(--text-primary);
  color: var(--canvas);
  box-shadow: 0 0 0 1px var(--border-faint), 0 0 24px -4px var(--glow-warm-soft);
}
.btn-primary:hover { box-shadow: 0 0 0 1px var(--border-soft), 0 0 36px -2px var(--glow-warm); }
/* moderate accent mode — primary actions take the lime fill */
.app.lime-moderate .btn-primary {
  background: var(--lime);
  color: var(--on-accent);
  box-shadow: 0 0 24px -8px var(--accent-glow);
}
.app.lime-moderate .btn-primary:hover { box-shadow: 0 0 32px -2px var(--accent-glow); }

.btn-secondary { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-soft); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-soft); }
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-1); border-color: var(--border-strong); }

.btn-pill {
  background: var(--lime);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 7px 16px;
  box-shadow: 0 0 24px -8px var(--accent-glow);
}
.btn-pill:hover { box-shadow: 0 0 32px -2px var(--accent-glow), 0 0 64px -6px var(--accent-glow); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.icon-btn:hover { color: var(--text-primary); background: var(--surface-1); border-color: var(--border-strong); }
.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--accent-ink);
}

/* -------------------------------------------------------------- inputs */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap svg {
  position: absolute;
  left: 11px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13.5px;
  letter-spacing: -0.005em;
  padding: 8px 12px 8px 34px;
  transition: border-color var(--dur-hover) var(--ease), box-shadow 0.25s var(--ease);
}
.input.no-icon { padding-left: 12px; }
.input::placeholder { color: var(--text-tertiary); }
.input:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 24px var(--focus-glow);
}

/* ----------------------------------------------------------- segmented */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  background: var(--surface-1);
}
.seg button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease);
}
.seg button:hover { color: var(--text-primary); }
.seg button.on {
  background: var(--surface-3);
  border-color: var(--border-soft);
  color: var(--text-primary);
}

/* ---------------------------------------------------------------- misc */
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.record { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; color: var(--text-secondary); white-space: nowrap; }
.hairline { border: 0; border-top: 1px solid var(--border-faint); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.badge.neutral {
  color: var(--text-tertiary);
  background: var(--surface-2);
  border-color: var(--border-soft);
}

/* ------------------------------------------------------------ ontology */
.ontology-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.ontology-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-faint);
}
.ontology-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.ontology-inner { position: relative; width: 860px; height: 640px; min-width: 100%; transform-origin: 0 0; }

.ontology-stage.has-blueprint .ontology-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--border-faint) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-faint) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, black 35%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, black 35%, transparent 80%);
}

.entity-node {
  position: absolute;
  width: 196px;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease);
}
.entity-node:hover { border-color: var(--border-strong); background: var(--surface-2); }
.entity-node.selected { border-color: var(--accent-border); background: var(--surface-2); }
.entity-node .entity-name {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  margin-top: 4px;
}
.entity-node .entity-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }
.entity-node .entity-dot {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-ink);
  opacity: 0;
  transition: opacity var(--dur-hover) var(--ease);
}
.entity-node.selected .entity-dot { opacity: 1; }

.edge-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--canvas);
  border: 1px solid var(--border-faint);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  pointer-events: none;
}

.zoom-rail {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  z-index: 3;
}

.detail-rail {
  width: 296px;
  flex: 0 0 296px;
  border-left: 1px solid var(--border-faint);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--pad-card);
  gap: var(--gap);
}
.detail-rail h3 { font-size: 17px; font-weight: 500; letter-spacing: -0.014em; color: var(--text-primary); }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: var(--row-pad) 0;
  border-bottom: 1px solid var(--border-faint);
}
.kv-row:last-child { border-bottom: 0; }
.kv-key { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--text-secondary); }
.kv-val { font-family: var(--mono); font-size: 11px; color: var(--text-tertiary); text-align: right; white-space: nowrap; }
.kv-key { white-space: nowrap; }

/* ----------------------------------------------------------- processes */
.process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: var(--gap);
}
.process-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: var(--pad-card);
  text-align: left;
  cursor: pointer;
}
.process-card:hover { border-color: var(--border-soft); }
.process-card h3 { font-size: 16.5px; font-weight: 500; letter-spacing: -0.014em; color: var(--text-primary); }
.process-card p { font-size: 13.5px; line-height: 1.5; color: var(--text-secondary); }
.process-card .card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-faint);
}
.owner { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.owner .avatar { width: 22px; height: 22px; flex-basis: 22px; font-size: 8px; }

.detail-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--gap);
}
.detail-col { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--gap); }
.info-card { padding: var(--pad-card); display: flex; flex-direction: column; gap: 14px; }
.info-card h3 { font-size: 16px; font-weight: 500; letter-spacing: -0.012em; color: var(--text-primary); }
.metric-list { display: flex; flex-direction: column; }
.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: var(--row-pad) 0;
  border-bottom: 1px solid var(--border-faint);
  font-size: 13.5px;
  color: var(--text-secondary);
}
.metric-row:last-child { border-bottom: 0; }
.metric-row .record { color: var(--text-tertiary); }

/* ----- metric chart: crisp 1:1 line chart, hover tooltip, full screen ----- */
.metric-chart { position: relative; width: 100%; }
.metric-chart svg { width: 100%; }
.chart-tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}
.chart-tip-v { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; color: var(--text-primary); }
.chart-tip-l { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); }

.metric-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.metric-card-tools { display: flex; align-items: center; gap: 10px; }
.metric-card-tools .icon-btn { width: 28px; height: 28px; }

/* ----- "how it's calculated" reveal ----- */
.calc-reveal { display: flex; flex-direction: column; gap: 12px; }
.calc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  padding: 7px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.calc-toggle:hover { color: var(--text-primary); background: var(--surface-1); border-color: var(--border-strong); }
.calc-toggle.open { color: var(--text-primary); border-color: var(--border-strong); }
.calc-toggle svg { color: var(--text-tertiary); }
.calc-toggle.open svg { color: var(--accent-ink); }
.calc-chev { font-family: var(--mono); font-size: 13px; color: var(--text-tertiary); margin-left: 2px; }
.calc-meta { margin-bottom: 8px; }
.sql-block {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
}

/* ----- full-screen chart overlay ----- */
.chart-fs {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(18, 16, 12, 0.55);
  animation: chart-fs-in 0.2s var(--ease) both;
}
@keyframes chart-fs-in { from { opacity: 0; } }
.chart-fs-panel {
  width: min(1100px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chart-fs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.chart-fs-head h3 { font-size: 19px; font-weight: 500; letter-spacing: -0.014em; color: var(--text-primary); margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .chart-fs { animation: none; } }

/* --------------------------------------------------------------- chat */
.chat-layout { flex: 1; min-height: 0; display: flex; overflow: hidden; --chat-col: 680px; }
.app.chat-wide .chat-layout { --chat-col: 820px; }

/* threads rail */
.thread-rail {
  width: 264px;
  flex: 0 0 264px;
  border-right: 1px solid var(--border-faint);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
  overflow-y: auto;
}
.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 12px 12px 12px;
}
.thread-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.thread-item:hover { background: var(--surface-2); }
.thread-item.active { background: var(--surface-2); border-color: var(--border-faint); }
.thread-item .t-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.thread-item .t-name {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-item .t-when {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.thread-item .t-snippet {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* conversation — one centered reading column */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-faint);
}
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.chat-col {
  width: 100%;
  max-width: var(--chat-col);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 26px 24px 18px 24px;
}

.day-sep { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border-faint); }
.day-sep span {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* user turn — quiet bubble, right-aligned, sized to its content */
.msg-user {
  align-self: flex-end;
  width: fit-content;
  max-width: min(82%, 52ch);
  background: var(--surface-2);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* agent turn — plain text on the canvas, no bubble */
.msg-agent { width: 100%; }
.agent-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.agent-head .agent-name {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.agent-head .msg-tools { margin-left: auto; opacity: 0; transition: opacity var(--dur-hover) var(--ease); }
.msg-agent:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-tools button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease);
}
.msg-tools button:hover { color: var(--text-primary); background: var(--surface-2); }
.msg-tools button.copied { color: var(--accent-ink); }
.msg-agent .msg-body {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-primary);
  max-width: 62ch;
  text-wrap: pretty;
}
.msg-agent .msg-body p + p { margin-top: 9px; }

/* the record — structured evidence attached to a reply */
.msg-record {
  margin-top: 12px;
  max-width: 62ch;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  overflow: hidden;
}
.msg-record .rec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-faint);
}
.msg-record .rec-row { padding: 8px 14px; border-bottom: 1px solid var(--border-faint); }
.msg-record .rec-row:last-child { border-bottom: 0; }

/* typing indicator — functional, quiet, respects reduced motion */
.typing-dots { display: inline-flex; gap: 5px; padding: 6px 0 2px 0; }
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: chat-typing 1.1s var(--ease) infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

@keyframes chat-msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg-in { animation: chat-msg-in 0.25s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  .msg-in, .typing-dots span { animation: none; }
}

/* empty thread */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 0;
}
.chat-empty h2 { font-size: 19px; font-weight: 500; letter-spacing: -0.014em; color: var(--text-primary); margin-top: 14px; }
.chat-empty .empty-sub {
  font-size: 13.5px;
  color: var(--text-tertiary);
  max-width: 42ch;
  text-align: center;
  line-height: 1.55;
}
.suggest-list { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; width: 100%; max-width: 420px; }
.suggest-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  letter-spacing: -0.005em;
  padding: 10px 14px;
  cursor: pointer;
  transition: color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.suggest-list button:hover { color: var(--text-primary); background: var(--surface-1); border-color: var(--border-strong); }
.suggest-list button .s-arrow { color: var(--text-tertiary); opacity: 0; transition: opacity var(--dur-hover) var(--ease); }
.suggest-list button:hover .s-arrow { opacity: 1; }

/* composer — a single surface that grows with the draft */
.composer { padding: 8px 24px 18px 24px; }
.composer-box {
  width: 100%;
  max-width: var(--chat-col);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 12px 12px 10px 16px;
  transition: border-color var(--dur-hover) var(--ease), box-shadow 0.25s var(--ease);
}
.composer-box:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 24px var(--focus-glow);
}
.composer-input {
  width: 100%;
  background: transparent;
  border: 0;
  resize: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  max-height: 152px;
  padding: 2px 4px 0 0;
}
.composer-input::placeholder { color: var(--text-tertiary); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-hint { display: flex; align-items: center; gap: 12px; }
.key-hint {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.send-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--text-primary);
  color: var(--canvas);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 0.25s var(--ease), transform var(--dur-press) var(--ease), opacity var(--dur-hover) var(--ease);
  box-shadow: 0 0 20px -6px var(--glow-warm-soft);
}
.send-btn:hover { box-shadow: 0 0 28px -2px var(--glow-warm); }
.send-btn:active { transform: translateY(0.5px); }
.send-btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; transform: none; }
.app.lime-moderate .send-btn { background: var(--lime); color: var(--on-accent); box-shadow: 0 0 20px -6px var(--accent-glow); }
.app.lime-moderate .send-btn:disabled { box-shadow: none; }

/* ---- process-scoped agent: the Chat conversation, scaled to the rail ---- */
.agent-chat .chat-head { padding: 11px 15px; }
.agent-chat .chat-scroll { overflow-x: hidden; }
.agent-chat .chat-col { max-width: none; padding: 16px 16px 8px 16px; }
.agent-chat .msg-user {
  font-size: 13px;
  line-height: 1.55;
  padding: 7px 11px;
  max-width: 88%;
}
.agent-chat .agent-head { margin-bottom: 5px; gap: 7px; }
.agent-chat .msg-agent .msg-body { font-size: 13px; line-height: 1.6; max-width: none; }
.agent-chat .msg-agent .msg-body p + p { margin-top: 7px; }
.agent-chat .composer { padding: 6px 14px 14px 14px; }
.agent-chat .composer-box {
  max-width: none;
  gap: 7px;
  border-radius: var(--radius-lg);
  padding: 9px 9px 8px 13px;
}
.agent-chat .composer-input { font-size: 13px; line-height: 1.5; max-height: 110px; }
.agent-chat .composer-foot .badge { font-size: 9px; }
.agent-chat .send-btn { flex: 0 0 28px; width: 28px; height: 28px; }

/* ------------------------------------------------------------- empty */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* scrollbars stay quiet */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
