/* Sygnal Memory web dashboard. Same palette as the Mac app and sign-in page. */

:root {
  --ink: #1f2020;
  --muted: #525453;
  --line: #d5d7d6;
  --soft-line: #e6e7e6;
  --ground: #e3e4e3;
  --panel: #fcfcfc;
  --card: #f6f6f5;
  --brand: #a6cf4e;
  --brand-ink: #3f6512;
  --warn: #c77700;
  --danger: #9b1c12;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --topbar: 56px;
  --rail: 84px;
  --rail-bg: #262828;
  --panel-width: 248px;
}

* { box-sizing: border-box; }

/* No rubber-band scroll: pulling past the top showed the ground above the
   sticky header. */
html, body { overscroll-behavior-y: none; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.5 Montserrat, system-ui, sans-serif;
}

a { color: var(--brand-ink); }
a:hover { color: #2e4a0c; }
h1, h2, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Frame: rail | panel | content, like Discord */

.app { display: flex; min-height: 100vh; }
.content { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.rail {
  position: sticky; top: 0; height: 100vh; width: var(--rail); flex-shrink: 0;
  overflow-y: auto; scrollbar-width: none; padding: 12px 0;
  background: var(--rail-bg);
}
.rail::-webkit-scrollbar { display: none; }
.rail-list { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-item { position: relative; width: 100%; display: flex; justify-content: center; }
/* The pill on the left edge: small on hover, tall when selected. */
.rail-item::before {
  content: ''; position: absolute; left: 0; top: 23px; width: 4px; height: 0;
  border-radius: 0 4px 4px 0; background: #fff; transform: translateY(-50%);
  transition: height 0.15s ease;
}
.rail-item:hover::before { height: 18px; }
.rail-item.active::before { height: 36px; background: var(--brand); }
.rail-link { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 100%; text-decoration: none; }
.rail-button {
  position: relative; display: flex; align-items: center; justify-content: center; width: 46px; height: 46px;
  border-radius: 50%; transition: border-radius 0.15s ease, background 0.15s ease;
}
.rail-button > :first-child { width: 100%; height: 100%; border-radius: inherit; overflow: hidden; }
.rail-link:hover .rail-button, .rail-item.active .rail-button { border-radius: 14px; }
.rail-link:focus-visible { outline: none; }
.rail-link:focus-visible .rail-button { outline: 2px solid var(--brand); outline-offset: 2px; }
.rail-label {
  max-width: calc(var(--rail) - 12px); overflow: hidden; text-align: center; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  font-size: 10px; line-height: 1.2; font-weight: 600; color: #a9adab;
}
.rail-link:hover .rail-label, .rail-item.active .rail-label { color: #fff; }
.rail-home { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: #3a3c3b; color: var(--brand); }
.rail-item.active .rail-home, .rail-button:hover .rail-home { background: var(--brand); color: var(--ink); }
.rail-button .avatar { border-radius: inherit; }
.avatar-logo { display: block; object-fit: cover; }
.rail-separator { width: 32px; height: 2px; border-radius: 1px; background: #3a3c3b; margin: 2px 0; }
.rail-dot {
  position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); border: 3px solid var(--rail-bg); pointer-events: none;
}

.panel {
  position: sticky; top: 0; height: 100vh; width: var(--panel-width); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: #ecedec; border-right: 1px solid var(--line);
}
.app.panel-collapsed .panel { display: none; }
.panel-head {
  height: var(--topbar); flex-shrink: 0; padding: 9px 16px; display: flex; flex-direction: column; justify-content: center;
  border-bottom: 1px solid var(--line); background: #e6e8e7;
}
.panel-title { font-weight: 700; font-size: 15px; }
.panel-body { flex-grow: 1; overflow-y: auto; padding: 10px 8px 16px; }

.topbar {
  position: sticky; top: 0; z-index: 2; height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px 10px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.icon-button {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--ground); color: var(--ink); }
.icon-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* A sidebar glyph: a frame with a filled left column. */
.toggle-icon {
  width: 18px; height: 14px; border: 1.6px solid currentColor; border-radius: 3px;
  background: linear-gradient(90deg, currentColor 0 5px, transparent 5px);
}
.account { flex-grow: 1; min-width: 0; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.top-link { font-weight: 600; text-decoration: none; }
.me { display: inline-flex; align-items: center; gap: 8px; }
.me-name { font-weight: 500; }
.search input {
  width: 320px; height: 34px; padding: 0 12px 0 34px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; color: var(--ink);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23525453' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.search input:focus, .button:focus-visible, .link-button:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

.main { flex-grow: 1; min-width: 0; width: 100%; max-width: 1360px; padding: 28px; display: flex; flex-direction: column; gap: 20px; outline: none; }

.nav-group { padding: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.panel-body li + li { margin-top: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px;
  color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500;
}
.nav-item.mono { font-family: var(--mono); font-weight: 400; }
.nav-item:hover { background: #dfe1e0; color: var(--ink); }
.nav-item.active { background: #d3d7d4; font-weight: 600; }
.nav-item.dim { color: var(--muted); }
.nav-count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.nav-icon { flex-shrink: 0; width: 20px; height: 20px; }
/* Four tiles: the overview glyph. */
.nav-icon.overview {
  background:
    linear-gradient(currentColor, currentColor) 2px 2px / 7px 7px no-repeat,
    linear-gradient(currentColor, currentColor) 11px 2px / 7px 7px no-repeat,
    linear-gradient(currentColor, currentColor) 2px 11px / 7px 7px no-repeat,
    linear-gradient(currentColor, currentColor) 11px 11px / 7px 7px no-repeat;
  opacity: 0.7; border-radius: 2px;
}
.repo-dot { flex-shrink: 0; width: 8px; height: 8px; margin: 0 6px; border-radius: 50%; background: #9a9d9b; }
.repo-dot.recent { background: var(--brand-ink); box-shadow: 0 0 0 3px #d9ebb5; }
.repo-dot.none { background: none; border: 1.5px solid #9a9d9b; }
.pad { padding: 10px; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: #fff; font-weight: 700; letter-spacing: 0.02em;
}
.avatar-sm { width: 20px; height: 20px; border-radius: 6px; font-size: 9px; }
.avatar-md { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.avatar-xl { width: 56px; height: 56px; border-radius: 16px; font-size: 20px; }
.person { display: flex; align-items: center; gap: 10px; }
.person-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--brand);
  font-size: 11px; font-weight: 700;
}

/* Content */

.page-head { display: flex; align-items: center; gap: 16px; }
.page-head > div { flex-grow: 1; }
.page-head h1 { font-size: 26px; font-weight: 600; }
.crumb { display: inline-block; text-decoration: none; color: var(--muted); }
.crumb:hover { color: var(--brand-ink); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--soft-line); }
.kpi:has(.accent)::before { background: var(--brand); }
.kpi { padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--soft-line); }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.kpi-value.accent { color: var(--brand-ink); }
.kpi-label { font-size: 13px; font-weight: 500; }

.columns { display: flex; gap: 20px; align-items: flex-start; }
.column-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.column-side { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 20px; }
.column-side.wide { width: 440px; }

.card {
  padding: 18px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--soft-line);
  display: flex; flex-direction: column; gap: 12px;
}
.card-head h2 { font-size: 15px; font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.rows > li { border-bottom: 1px solid var(--soft-line); }
.rows > li:last-child { border-bottom: 0; }
.row-link { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--ink); text-decoration: none; }
.row-link:hover .grow { text-decoration: underline; }
.rule { padding: 8px 0; }
.health { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }

.handoff {
  padding: 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--soft-line);
  display: flex; flex-direction: column; gap: 8px;
}
.handoff-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; }
.bullets ul { list-style: disc; padding-left: 18px; }
/* Summaries and steps quote long paths and commands: break them inside the
   card instead of overflowing it. */
.handoff, .handoff-summary { min-width: 0; overflow-wrap: anywhere; }
.files { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #ecedec; color: var(--muted); }
.badge.handoff-open { background: #fbebd9; color: #8a4b00; }
.badge.handoff-accepted { background: #eef5df; color: var(--brand-ink); }
.handoff-link { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; color: var(--ink); text-decoration: none; }
.handoff-link:hover .handoff-summary { text-decoration: underline; }
.teammate-handoff .link-button { margin: -4px 0 10px; }
.badge.kind-decision { background: #eef5df; color: var(--brand-ink); }
.badge.kind-rule, .badge.kind-gotcha { background: #fbebd9; color: #8a4b00; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #9a9d9b; }
.dot.ok { background: var(--brand-ink); }
.dot.warn { background: var(--warn); }
.role-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--soft-line); vertical-align: top; }
td a { text-decoration: none; color: var(--ink); }
.repo-link { display: flex; flex-direction: column; }
.repo-link:hover .strong { text-decoration: underline; }
tbody tr:hover td { background: #f7f8f6; }
.num { text-align: right; font-family: var(--mono); }
.dim-row td { color: var(--muted); }
.dim-row a { color: var(--muted); }
.bar-cell { min-width: 160px; }
.share { display: flex; align-items: center; gap: 10px; }
.share-track { flex-grow: 1; min-width: 60px; height: 8px; border-radius: 4px; background: #e6e7e6; overflow: hidden; }
.share-fill { display: block; height: 100%; border-radius: 4px; background: var(--brand-ink); }
.share .mono { min-width: 28px; text-align: right; }

/* Overview */

.workspace-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.workspace-card {
  display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 12px;
  background: #fff; border: 1px solid var(--soft-line); color: var(--ink); text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.workspace-card:hover { color: var(--ink); border-color: var(--brand); box-shadow: 0 6px 18px rgba(31, 32, 32, 0.08); transform: translateY(-1px); }
.workspace-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.workspace-card-head { display: flex; align-items: center; gap: 12px; }
.stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats dt { font-size: 20px; font-weight: 600; line-height: 1.2; }
.stats dt.accent { color: var(--brand-ink); }
.stats dd { margin: 0; font-size: 11px; color: var(--muted); }
.strip-wrap { display: flex; align-items: center; gap: 10px; }
.strip { flex-grow: 1; display: flex; gap: 3px; }
.strip-seg { flex: 1; height: 6px; border-radius: 3px; background: #dfe1e0; }
.strip-seg.on { background: var(--brand-ink); }
.strip-seg.none { background: none; border: 1px dashed #c8cbc9; }

/* Memory browser */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.chip:hover { border-color: var(--brand-ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.kind-help { font-size: 13px; color: var(--muted); padding: 2px 2px 0; }
.chip-count { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
.chip:focus-visible, .page-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.browser { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.page-list { max-height: 520px; overflow-y: auto; border: 1px solid var(--soft-line); border-radius: 10px; background: #fff; }
.page-list li + li { border-top: 1px solid var(--soft-line); }
.page-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px;
  border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink); text-align: left; cursor: pointer;
}
.page-item:hover { background: var(--card); }
.page-item.active { background: #eef5df; }
.preview {
  min-height: 200px; max-height: 620px; overflow-y: auto; padding: 16px;
  border: 1px solid var(--soft-line); border-radius: 10px; background: var(--card);
  display: flex; flex-direction: column; gap: 12px;
}
.preview-head h3 { font-size: 17px; margin: 4px 0 2px; }
.preview-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.markdown { display: flex; flex-direction: column; gap: 8px; font-size: 14px; overflow-wrap: anywhere; }
.markdown h3, .markdown h4, .markdown h5, .markdown h6 { margin: 8px 0 0; font-size: 14px; }
.md-list { margin: 0; padding-left: 20px; }
.md-code { margin: 0; padding: 10px 12px; border-radius: 8px; background: #1f2020; color: #e6e7e6; font: 12px/1.5 var(--mono); white-space: pre-wrap; }
.md-quote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.markdown code { font-family: var(--mono); font-size: 12px; background: #e6e7e6; padding: 1px 4px; border-radius: 4px; }
.md-wikilink { color: var(--brand-ink); font-weight: 500; }

/* Sessions */

.session { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; }
.session-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.observation-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.observation-list li { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.observation-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.badge.obs-user-prompt { background: #eef5df; color: var(--brand-ink); }
.observations { padding: 10px 12px; border-radius: 8px; background: var(--card); }

/* Search */

.hit { padding: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.hit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hit-meta a { text-decoration: none; }
.snippet { font-size: 13px; color: #3e403f; overflow-wrap: anywhere; }
mark { background: #e3f0c4; color: inherit; padding: 0 2px; border-radius: 3px; }
.error-text { color: var(--danger); font-size: 13px; }

/* Controls and text */

.button {
  display: inline-flex; align-items: center; height: 36px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.button.primary { background: var(--brand); border-color: var(--brand); font-weight: 600; }
.button.primary:hover { color: var(--ink); background: #98c23f; }
.link-button {
  align-self: flex-start; padding: 0; border: 0; background: none;
  color: var(--brand-ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); }
.grow { flex-grow: 1; min-width: 0; }
.spacer { flex-grow: 1; }
.nowrap { white-space: nowrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); font-size: 13px; }
.loading { color: var(--muted); padding: 40px 0; }
.error-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px;
  background: #fbeceb; color: var(--danger); font-size: 13px;
}
.error-banner .button { margin-left: auto; }
.account .link-button { align-self: center; }

/* Narrow screens: sidebar on top, one column. */

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .rail { position: static; width: 100%; height: auto; padding: 8px 12px; overflow-x: auto; overflow-y: hidden; }
  .rail-list { flex-direction: row; gap: 6px; }
  .rail-item { width: auto; }
  .rail-item::before { display: none; }
  .rail-item.active .rail-button { box-shadow: 0 0 0 2px var(--rail-bg), 0 0 0 4px var(--brand); }
  .rail-button { width: 40px; height: 40px; }
  .rail-label { display: none; }
  .rail-separator { width: 2px; height: 28px; margin: 0 2px; align-self: center; }
  .rail-dot { right: -2px; bottom: -2px; }
  .panel { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .panel-head { height: auto; padding: 10px 16px 0; border-bottom: 0; background: none; }
  .panel-body { overflow-x: auto; padding: 8px 12px 10px; display: flex; align-items: center; gap: 4px; }
  .panel-body ul { display: flex; gap: 4px; }
  .panel-body li + li { margin-top: 0; }
  .panel-body .nav-group { display: none; }
  .nav-item { white-space: nowrap; background: #e3e5e4; }
  .topbar { position: static; height: auto; flex-wrap: wrap; padding: 10px 16px; }
  #panel-toggle { display: none; }
  .account { flex-wrap: wrap; gap: 12px; }
  .search { width: 100%; }
  .search input { width: 100%; }
  .account .spacer { display: none; }
  .me-name { display: none; }
  .main { padding: 20px 16px; }
  .browser { grid-template-columns: minmax(0, 1fr); }
  .page-list { max-height: 320px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-cell { min-width: 120px; }
  .columns { flex-direction: column; align-items: stretch; }
  .column-side, .column-side.wide { width: 100%; }
  .page-head { flex-wrap: wrap; }
  .app.panel-collapsed .panel { display: flex; }
}

/* Bots: test runs as rows that open a detail panel (failed examples, output tail). */
.runs { display: flex; flex-direction: column; border: 1px solid var(--soft-line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.run { border-bottom: 1px solid var(--soft-line); }
.run:last-child { border-bottom: 0; }
.run-row { display: grid; grid-template-columns: 72px minmax(0, 1.2fr) minmax(0, 2fr) 80px 90px; gap: 12px; align-items: center; padding: 10px 14px; font-size: 13px; }
.run-row.has-detail { cursor: pointer; }
.run-row.has-detail:hover { background: var(--card); }
.run-branch, .run-summary { min-width: 0; overflow-wrap: anywhere; }
.run-detail { display: none; padding: 12px 14px 14px; border-top: 1px dashed var(--soft-line); background: var(--card); }
.run-detail.open { display: grid; gap: 12px; }
.run-detail .rows { margin: 6px 0 0; }
.run-output { margin: 6px 0 0; max-height: 420px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: #1f2020; color: #e6e7e6; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 800px) { .run-row { grid-template-columns: 72px minmax(0, 1fr); } .run-row > :nth-child(n+4) { display: none; } }
