/* ==========================================================================
   Grok Bot Agent Overview — calm ops mirror
   Mobile-first. Two themes, one restrained palette per theme.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0f1218;
  --surface: #181e29;
  --surface-hover: #1e2633;
  --line: #2a3344;
  --line-soft: #222a38;

  --text: #e6eaf0;
  --muted: #9aa3b2;
  --dim: #6b7385;

  --accent: #6ea8fe;
  --focus: #6ea8fe;

  --urgent: #f07178;
  --warn: #e6b450;
  --info: #6ea8fe;

  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --tap: 2.75rem; /* 44px */
  --radius: 10px;
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-hover: #eef2f8;
  --line: #d5dce8;
  --line-soft: #e4e9f1;

  --text: #12151c;
  --muted: #5c6575;
  --dim: #8a93a3;

  --accent: #3d7eea;
  --focus: #3d7eea;

  --urgent: #d94850;
  --warn: #c4922a;
  --info: #3d7eea;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.shell {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-left)) calc(4rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-right));
}

/* ---------- masthead ---------- */

.masthead { margin-bottom: 1.5rem; }

.masthead-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.masthead h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.masthead-note {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.2rem 0 0;
  color: var(--dim);
  font-size: 0.78rem;
  line-height: 1.4;
}

.masthead-note .sep { display: none; }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  margin: -0.4rem -0.5rem 0 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover { color: var(--text); background: var(--surface); }
.icon-btn .ico { grid-area: 1 / 1; }

html[data-theme="dark"] .ico-moon { display: none; }
html[data-theme="light"] .ico-sun { display: none; }

/* ---------- tabs ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  margin-top: 1.1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.85rem;
}

.tabs a {
  flex: 1 1 0;
  min-height: var(--tap);
  display: grid;
  place-items: center;
  padding: 0.5rem 0.4rem;
  color: var(--dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease;
}

.tabs a:hover { color: var(--muted); }

.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-full { display: none; }

/* ---------- shared ---------- */

.quiet {
  color: var(--dim);
  font-size: 0.85rem;
}

.group { margin-top: 2.25rem; }
.group:first-child { margin-top: 0; }

.section-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.85rem;
  color: var(--dim);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.section-count {
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  flex: none;
  background: var(--info);
}

.dot.urgent { background: var(--urgent); }
.dot.warn { background: var(--warn); }
.dot.info { background: var(--info); }

.avatar,
.avatar-fallback {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.avatar-lg,
.avatar-fallback.avatar-lg {
  width: 3rem;
  height: 3rem;
  font-size: 0.88rem;
}

/* buttons */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { color: var(--text); border-color: var(--muted); }
.btn-text {
  border: 0;
  padding: 0.3rem 0;
  color: var(--dim);
  background: transparent;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.btn-text:hover { color: var(--text); border: 0; }

/* ---------- filter bar ---------- */

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search svg {
  position: absolute;
  left: 0.7rem;
  color: var(--dim);
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.85rem 0.5rem 2.1rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.87rem;
}

.search input::placeholder { color: var(--dim); }
.search input:focus { border-color: var(--line); outline-offset: 1px; }
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.6); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  appearance: none;
  flex: none;
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover { color: var(--muted); }

.chip[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.chip-count {
  margin-left: 0.2rem;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] .chip-count { color: inherit; }

.picker {
  min-height: var(--tap);
  max-width: 100%;
  padding: 0.4rem 2rem 0.4rem 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1.05rem center, right 0.75rem center;
  background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
  background-repeat: no-repeat;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  appearance: none;
  cursor: pointer;
}

.result-count {
  color: var(--dim);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- roster ---------- */

.roster {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.card:hover { border-color: var(--line); background: var(--surface-hover); }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-id { min-width: 0; flex: 1 1 auto; }

.card-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 550;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-role {
  margin: 0;
  color: var(--dim);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-flag {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--dim);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.card-desc {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- agent detail ---------- */

.back {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  margin-bottom: 1rem;
  color: var(--dim);
  font-size: 0.8rem;
}

.back:hover { color: var(--text); }

.detail-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.4rem;
}

.detail-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.detail-head p {
  margin: 0.1rem 0 0;
  color: var(--dim);
  font-size: 0.78rem;
}

.detail-desc {
  margin: 0 0 1.75rem;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.open-hint {
  margin: -0.85rem 0 1.75rem;
  color: var(--dim);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.lines { margin: 0; padding: 0; list-style: none; }

.lines li {
  padding: 0.7rem 0;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.lines li:first-child { border-top: none; padding-top: 0; }

.lines .when { color: var(--dim); }
.lines .paused { color: var(--dim); }

.more-link {
  display: inline-block;
  margin-top: 0.9rem;
  color: var(--dim);
  font-size: 0.78rem;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.more-link:hover { color: var(--text); }

/* ---------- needs ---------- */

.item {
  padding: 1rem 0;
  border-top: 1px solid var(--line-soft);
}

.item:first-of-type { border-top: none; padding-top: 0; }

.item-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.item-agent {
  margin: 0.2rem 0 0;
  color: var(--dim);
  font-size: 0.76rem;
}

.item-agent .sep { margin: 0 0.35rem; }

.item-detail {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  overflow-wrap: anywhere;
}

.item-detail.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-top: 0.75rem;
}

/* ---------- activity ---------- */

.entry {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line-soft);
}

.entry:first-of-type { border-top: none; padding-top: 0; }

.entry time {
  flex: none;
  color: var(--dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.entry time.is-dup { display: none; }

.entry-body { min-width: 0; }

.entry-agent {
  margin: 0;
  color: var(--muted);
  font-size: 0.79rem;
}

.entry-summary {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* ---------- desktop ---------- */

@media (min-width: 40rem) {
  .shell { padding: 2.75rem 1.75rem 6rem; }

  .masthead { margin-bottom: 2.25rem; }

  .masthead-note {
    flex-direction: row;
    gap: 0;
  }

  .masthead-note .sep {
    display: inline;
    margin: 0 0.4rem;
  }

  .tabs {
    gap: 1.6rem;
    margin-top: 1.6rem;
  }

  .tabs a {
    flex: 0 0 auto;
    min-height: 0;
    padding: 0.55rem 0;
  }

  .tab-full { display: inline; }
  .tab-short { display: none; }

  .filters {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .search { flex: 1 1 16rem; }
  .search input { min-height: 2.4rem; }
  .picker { min-height: 2.4rem; }
  .result-count { margin-left: auto; }

  .roster { grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 0.65rem; }

  .entry { flex-direction: row; gap: 1rem; }
  .entry time { width: 4.75rem; padding-top: 0.1rem; }
  .entry time.is-dup { display: block; visibility: hidden; }

  .group { margin-top: 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* ---------- brand logo (Grok Bot product mark) ---------- */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.brand-logo {
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 auto;
  display: block;
}
/* Dark UI → light/white mark; light UI → dark mark */
html[data-theme="light"] .brand-logo-on-dark { display: none; }
html:not([data-theme="light"]) .brand-logo-on-light { display: none; }
html[data-theme="light"] .brand-logo-on-light { display: block; }
