/* expand.css — Cortex expansion modules: Segmented · Palette · Feed · Agents · Views.
   Styles ONLY the new module classes. Reuses app.css components (.card/.btn-*/.modal/
   .chip/.input) — never redefines them. Dark, calm, bioluminescent; tokens only. */

/* ============================== Segmented (topbar view-switch) ============== */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-3);
  border: 1px solid var(--stroke);
  border-radius: var(--r-pill);
  padding: 2px;
}
.seg-btn {
  font-size: var(--fs-fine);
  color: var(--t-3);
  background: transparent;
  border: 0;
  border-radius: var(--r-pill);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.seg-btn:hover { color: var(--t-2); }
.seg-btn.is-active {
  background: var(--bg-1);
  color: var(--t-1);
  box-shadow: var(--sh-1);
}

/* ============================== Palette (Cmd+K) ============================= */
/* mounts inside a .backdrop; override its centering to align toward the top */
#palette-host .backdrop,
.palette-backdrop {
  place-content: start center;
  padding-top: 12vh;
}
.palette {
  width: min(640px, 94vw);
  background: var(--bg-2);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.pal-input {
  width: 100%;
  background: transparent;
  border: 0;
  font-size: var(--fs-lg);
  padding: var(--s-4);
  color: var(--t-1);
}
.pal-input::placeholder { color: var(--t-3); }
/* keep the borderless look but give keyboard users a visible focus ring */
.pal-input:focus { outline: none; box-shadow: inset 0 -2px 0 var(--acc); }
.seg-btn:focus-visible, .feed-tab:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.pal-item:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
.pal-list {
  max-height: 50vh;
  overflow: auto;
  border-top: 1px solid var(--stroke);
}
.pal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 10px var(--s-4);
  cursor: pointer;
  border-bottom: 1px solid var(--stroke);
  transition: background .14s var(--ease);
}
.pal-item:last-child { border-bottom: 0; }
.pal-item:hover { background: var(--bg-3); }
.pal-item.is-active { background: var(--bg-3); box-shadow: inset 2px 0 0 var(--acc); }
.pal-item > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--t-1);
}
.pal-kind {
  flex: none;
  font-size: var(--fs-fine);
  color: var(--t-3);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.pal-empty,
.pal-hint {
  font-size: var(--fs-fine);
  color: var(--t-3);
  padding: var(--s-4);
}
.pal-hint { border-top: 1px solid var(--stroke); }

/* ============================== Path tracer breadcrumb ===================== */
.path-breadcrumb {
  position: absolute; bottom: var(--s-3); left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: 80%;
  padding: 6px 10px; border-radius: var(--r-pill);
  background: var(--bg-glass); backdrop-filter: blur(14px);
  border: 1px solid var(--stroke-strong); box-shadow: var(--sh-2);
}
.pb-node { font: inherit; font-size: var(--fs-fine); color: var(--t-1); background: transparent; border: 0; cursor: pointer; padding: 2px 5px; border-radius: var(--r-sm); }
.pb-node:hover { color: var(--acc-2); }
.pb-node:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.pb-arrow { color: var(--t-3); }
.pb-close { margin-left: 4px; background: transparent; border: 0; color: var(--t-3); cursor: pointer; font-size: var(--fs-cap); }
.pb-close:hover { color: var(--t-1); }

/* ============================== Shortcuts help panel ======================= */
.sc-modal { width: min(560px, 94vw); }
.sc-list { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s-2); }
.sc-row { display: flex; align-items: center; gap: var(--s-3); padding: 7px var(--s-2); border-bottom: 1px solid var(--stroke); }
.sc-row:last-child { border-bottom: 0; }
.sc-key { flex: none; min-width: 176px; font: inherit; font-size: var(--fs-fine); color: var(--t-1); background: var(--bg-3); border: 1px solid var(--stroke); border-radius: var(--r-sm); padding: 3px 8px; }
.sc-desc { color: var(--t-2); font-size: var(--fs-cap); }
@media (max-width: 860px) { .sc-key { min-width: 116px; } .path-breadcrumb { max-width: 94%; } }

/* ============================== Feed (ingest modal) ======================== */
.feed-tabs { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.feed-tab {
  font-size: var(--fs-fine);
  color: var(--t-3);
  background: transparent;
  border: 1px solid var(--stroke);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  cursor: pointer;
  transition: color .16s var(--ease), background .16s var(--ease);
}
.feed-tab:hover { color: var(--t-2); }
.feed-tab.is-active { background: var(--bg-3); color: var(--t-1); border-color: var(--stroke-strong); }
.feed-body { padding-top: var(--s-3); }
.feed-drop {
  border: 1.5px dashed var(--stroke-strong);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  text-align: center;
  color: var(--t-3);
  font-size: var(--fs-cap);
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease), color .18s var(--ease);
}
.feed-drop:hover,
.feed-drop.is-active {
  border-color: var(--acc);
  background: var(--bg-3);
  color: var(--t-2);
}
.feed-progress {
  font-size: var(--fs-cap);
  color: var(--acc-2);
  margin-top: var(--s-3);
}

/* ============================== Agents (runner modal) ====================== */
.agent-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}
.agent-card {
  background: var(--bg-3);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}
.agent-card h3 {
  font-size: var(--fs-lg);
  color: var(--t-1);
  margin-bottom: var(--s-1);
}
.agent-card p {
  font-size: var(--fs-cap);
  color: var(--t-3);
  margin-bottom: var(--s-3);
}
.agent-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.agent-out {
  margin-top: var(--s-2);
  font-size: var(--fs-cap);
  color: var(--t-2);
  background: var(--bg-1);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: var(--s-3);
  max-height: 220px;
  overflow: auto;
  line-height: var(--lh);
  white-space: pre-wrap;
}
.agent-out:empty { display: none; }
.dup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 6px 0;
  border-bottom: 1px solid var(--stroke);
}
.dup-row:last-child { border-bottom: 0; }
.dup-score {
  flex: none;
  font-size: var(--fs-fine);
  color: var(--acc-warn);
  font-variant-numeric: tabular-nums;
}

/* ============================== Views (outline / table) ==================== */
.view-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-1);
  overflow: auto;
  padding: var(--s-5);
  z-index: 4;
}
.outline { max-width: 820px; margin: 0 auto; }
.outline-group { margin-bottom: var(--s-4); }
.otype {
  font-size: var(--fs-fine);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--t-3);
  margin-bottom: var(--s-2);
}
.onode {
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--t-1);
  transition: background .14s var(--ease);
}
.onode:hover { background: var(--bg-3); }
.onode-meta {
  font-size: var(--fs-fine);
  color: var(--t-3);
  margin-top: 2px;
}
.vtable {
  width: 100%;
  border-collapse: collapse;
}
.vtable th {
  text-align: left;
  font-size: var(--fs-fine);
  color: var(--t-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  padding: 8px;
  position: sticky;
  top: 0;
  background: var(--bg-1);
}
.vtable th:hover { color: var(--t-2); }
.vtable td {
  padding: 8px;
  border-top: 1px solid var(--stroke);
  font-size: var(--fs-cap);
  color: var(--t-2);
}
.vtable tr { cursor: pointer; }
.vtable tr:hover td { background: var(--bg-2); }

/* ============================== Mobile ===================================== */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; row-gap: var(--s-2); }
  .seg { width: 100%; justify-content: center; }
  .seg-btn { flex: 1; padding: 6px 10px; text-align: center; }
  .feed-tabs { width: 100%; }
  .feed-tab { flex: 1; text-align: center; padding: 6px 10px; }
  #palette-host .backdrop,
  .palette-backdrop { padding-top: 6vh; padding-left: var(--s-3); padding-right: var(--s-3); }
  .palette { width: 100%; }
  .pal-list { max-height: 60vh; }
  .view-overlay { padding: var(--s-4); }
  .agent-run { flex-direction: column; align-items: stretch; }
  .agent-out { max-height: 180px; }
}
