/* ============================================================================
   claude-foundation dashboard — presence view.
   Shares the landing page's "workshop blueprint" palette: warm paper, charcoal
   ink, electric-cobalt signal, warm-orange marker. Vanilla CSS, no build.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400..700&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap");

:root {
  --paper: #f4f1ea;
  --paper-2: #efeae0;
  --card: #fbf9f4;
  --ink: #18191d;
  --ink-soft: #3a3d44;
  --muted: #6b6e78;
  --faint: #9a9caa;
  --line: #ddd6c7;
  --line-soft: #e7e1d4;

  --signal: #2c46f0;
  --signal-soft: rgba(44, 70, 240, 0.1);
  --marker: #e8501e;
  --ok: #1d8f7a;
  --ok-soft: rgba(29, 143, 122, 0.12);

  --display: "Fraunces", "Times New Roman", serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(24, 25, 29, 0.04), 0 18px 40px -22px rgba(24, 25, 29, 0.28);
  --maxw: 1080px;
}

*, *::before, *::after { box-sizing: border-box; }

/* The [hidden] attribute must win even where an author rule sets `display`
   (e.g. .gate sets display:grid). Without this, JS toggling .hidden = true
   leaves the element visible. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

/* Blueprint grid backdrop */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(44, 70, 240, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(44, 70, 240, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 120% 70% at 50% 0%, #000 35%, transparent 85%);
}

/* --- Top bar -------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 249, 244, 0.7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { color: var(--signal); font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-tag {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--marker);
  border: 1px solid var(--marker);
  border-radius: 999px;
  padding: 1px 8px;
}
.status { display: flex; align-items: center; gap: 10px; }
.status-text { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.signout {
  font-size: 12px;
  color: var(--faint);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}
.signout:hover { color: var(--ink); border-color: var(--muted); }
.header-demo {
  font-size: 12px;
  font-weight: 600;
  color: var(--signal);
  background: var(--signal-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 12px;
}
.header-demo:hover { background: rgba(44, 70, 240, 0.18); }

/* Pulse dot */
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.pulse[data-state="ok"] { background: var(--ok); box-shadow: 0 0 0 0 var(--ok-soft); animation: pulse 2s infinite; }
.pulse[data-state="error"] { background: var(--marker); }
.pulse[data-state="loading"] { background: var(--signal); animation: blink 1s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(29, 143, 122, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(29, 143, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 143, 122, 0); }
}
@keyframes blink { 50% { opacity: 0.3; } }

/* --- Layout --------------------------------------------------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 32px 24px 64px; }

.counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.count {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.count--online { border-color: rgba(29, 143, 122, 0.4); }
.count-num { display: block; font-family: var(--display); font-size: 40px; font-weight: 600; line-height: 1; }
.count-num--sm { font-size: 22px; font-family: var(--mono); font-weight: 500; }
.count--online .count-num { color: var(--ok); }
.count-label {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.section-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 16px;
}
.section-title--muted { color: var(--muted); }
.section-title--warn { color: var(--marker); }
.section-sub { margin: -8px 0 16px; font-size: 13px; color: var(--muted); }

/* --- Conflicts panel ------------------------------------------------------ */
.conflicts { display: flex; flex-direction: column; gap: 12px; margin-bottom: 40px; }
.conflict {
  background: var(--marker-soft, rgba(232, 80, 30, 0.08));
  border: 1px solid rgba(232, 80, 30, 0.35);
  border-left: 3px solid var(--marker);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.cf-file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.cf-repo { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.cf-path { font-weight: 600; font-size: 14px; color: var(--ink); }
.cf-parties { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cf-party { display: inline-flex; align-items: baseline; gap: 7px; }
.cf-party b { font-size: 13px; }
.cf-branch {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px;
}
.cf-lines { font-family: var(--mono); font-size: 11px; color: var(--marker); }
.cf-vs { color: var(--faint); font-family: var(--mono); }

/* --- Agent grid ----------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.grid--muted { opacity: 0.72; }

.agent {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.agent:hover { transform: translateY(-2px); border-color: var(--muted); }
.agent--online { border-left: 3px solid var(--ok); }
.agent--stale { border-left: 3px solid var(--faint); }

.agent-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.agent-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.agent--online .agent-dot { background: var(--ok); animation: pulse 2s infinite; }
.agent--stale .agent-dot { background: var(--faint); }
.agent-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-meta { font-family: var(--mono); font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Which repos the agent is working in — one compact line each, recency-sorted */
.agent-working {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
}
.wk-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-bottom: 7px;
}
.wk { display: flex; align-items: center; gap: 7px; padding: 3px 0; line-height: 1.3; }
.wk-repo { font-weight: 600; font-size: 13px; color: var(--signal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 150px; }
.wk-branch {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-soft);
  background: var(--signal-soft);
  border-radius: 4px;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.wk-files { font-family: var(--mono); font-size: 11px; color: var(--muted); flex: none; }
.wk-tag { font-size: 9.5px; font-weight: 700; color: #fff; background: var(--marker); border-radius: 4px; padding: 1px 5px; flex: none; }
.wk-more { margin-top: 7px; font-family: var(--mono); font-size: 11px; color: var(--signal); background: none; border: none; padding: 2px 0; }
.wk-more:hover { text-decoration: underline; }

/* What the agent is working on (active /dev runs: repo + branch) */
.agent-activity {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-activity--idle { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.act { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; line-height: 1.4; }
.act-repo {
  font-weight: 600;
  font-size: 13px;
  color: var(--signal);
}
.act-branch {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--signal-soft);
  border-radius: 5px;
  padding: 0 6px;
}
.act-run { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.agent-seen { margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.agent--online .agent-seen { color: var(--ok); }

.empty {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 40px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

/* --- Key gate ------------------------------------------------------------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--paper);
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-title { font-family: var(--display); font-size: 26px; font-weight: 600; margin: 0 0 6px; }
.gate-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.gate-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  margin-bottom: 12px;
}
.gate-input:focus { outline: 2px solid var(--signal); border-color: var(--signal); }
.gate-btn {
  width: 100%;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  background: var(--signal);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
}
.gate-btn:hover { background: #1d31c4; }
.gate-error { color: var(--marker); font-size: 13px; margin: 12px 0 0; }

/* --- Demo mode ------------------------------------------------------------ */
.gate-demo {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--signal);
  font-size: 13px;
  text-decoration: underline;
}
.gate-demo:hover { color: #1d31c4; }

.demo-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 12px 16px;
  background: var(--marker-soft, rgba(232, 80, 30, 0.1));
  border: 1px dashed var(--marker);
  border-radius: var(--radius);
}
.demo-tag {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  background: var(--marker);
  border-radius: 5px;
  padding: 2px 8px;
}
.demo-text { flex: 1; font-size: 13px; color: var(--ink-soft); }
.demo-exit {
  flex: none;
  font-size: 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}
.demo-exit:hover { border-color: var(--muted); }

/* ============================================================================
   v1.5 layout: sidebar + tabs + insights. Reuses .agent / .conflict / .wk /
   .gate / .demo-banner component styles above.
   ========================================================================== */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

/* --- Sidebar -------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(251, 249, 244, 0.6);
  backdrop-filter: blur(6px);
}
.side-brand { display: flex; align-items: baseline; gap: 9px; }
.side-brand .brand-mark { color: var(--signal); font-size: 17px; }
.side-brand .brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; }
.sidebar .brand-tag {
  display: inline-block;
  margin: 2px 0 18px 26px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--marker);
  border: none;
  padding: 0;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--paper-2); }
.nav-item.is-active { background: var(--signal-soft); color: var(--signal); }
.ni-ic { width: 18px; text-align: center; font-size: 13px; opacity: 0.85; }
.ni-label { flex: 1; }
.ni-badge {
  font-family: var(--mono);
  font-size: 11px;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
}
.ni-badge--warn { background: var(--marker-soft); color: var(--marker); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-status { display: flex; align-items: center; gap: 8px; }
.side-actions { display: flex; gap: 8px; }
.side-btn {
  font-size: 12px;
  color: var(--faint);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
}
.side-btn:hover { color: var(--ink); border-color: var(--muted); }
.side-btn--accent { color: var(--signal); background: var(--signal-soft); border-color: transparent; font-weight: 600; }
.side-btn--accent:hover { background: rgba(44, 70, 240, 0.18); color: var(--signal); }

/* --- Main + tabs ---------------------------------------------------------- */
.main { padding: 32px 40px 64px; max-width: 1180px; }
.tab { display: none; }
.tab.is-active { display: block; animation: tab-in 0.25s ease; }
@keyframes tab-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tab-head { margin-bottom: 26px; }
.tab-head h1 { font-family: var(--display); font-size: 30px; font-weight: 600; margin: 0 0 4px; }
.tab-head h1.head--warn { color: var(--marker); }
.tab-head p { margin: 0; color: var(--muted); font-size: 15px; }

.sec-title { font-family: var(--display); font-size: 21px; font-weight: 600; margin: 0 0 16px; }
.sec-title--muted { color: var(--muted); margin-top: 32px; }
.count--ok { border-color: rgba(29, 143, 122, 0.4); }
.count--ok .count-num { color: var(--ok); }
.empty--sm { padding: 14px; font-size: 13px; }

/* --- Insights: stat cards -------------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-num { display: block; font-family: var(--display); font-size: 38px; font-weight: 600; line-height: 1; color: var(--signal); }
.stat-label { display: block; margin-top: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.panel--wide { grid-column: 1 / -1; }
.panel h3 { font-size: 14px; font-weight: 600; margin: 0 0 14px; color: var(--ink-soft); }

/* --- Bar chart ------------------------------------------------------------ */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 84px 1fr 52px; align-items: center; gap: 10px; }
.bar-label { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; min-width: 3px; transition: width 0.4s ease; }
.bar-val { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }

/* --- Column chart (throughput) -------------------------------------------- */
.cols-plot { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.col-n { font-family: var(--mono); font-size: 11px; color: var(--muted); height: 14px; }
.col-bar { width: 100%; max-width: 30px; background: var(--signal); border-radius: 4px 4px 0 0; min-height: 0; transition: height 0.4s ease; }
.col-lab { font-family: var(--mono); font-size: 9.5px; color: var(--faint); white-space: nowrap; }

/* --- Activity feed -------------------------------------------------------- */
.feed { display: flex; flex-direction: column; gap: 8px; }
.feed-row { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 16px; box-shadow: var(--shadow); }
.fe-type { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: #fff; border-radius: 5px; padding: 2px 8px; flex: none; min-width: 58px; text-align: center; }
.fe-main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fe-id { font-weight: 600; font-size: 14px; }
.fe-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.fe-state { display: flex; align-items: center; gap: 12px; flex: none; }
.fe-done { font-size: 12px; color: var(--ok); font-weight: 600; }
.fe-active { font-size: 12px; color: var(--signal); font-weight: 600; }
.fe-dur { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.fe-when { font-family: var(--mono); font-size: 11px; color: var(--faint); min-width: 64px; text-align: right; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar .brand-tag { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav-item { width: auto; }
  .side-foot { margin: 0; border: none; padding: 0; flex-direction: row; align-items: center; }
  .main { padding: 24px 18px 48px; }
  .ins-grid { grid-template-columns: 1fr; }
}

/* --- Member filter (Insights / Activity) ---------------------------------- */
.mfilter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.mchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.mchip:hover { border-color: var(--muted); }
.mchip.is-active { background: var(--signal); border-color: var(--signal); color: #fff; }
.mchip-n { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
