/* Source-code browser (/code). Layout + a dependency-free highlighter.
   All colours come from the design-system tokens in shellproof.css so light and
   dark both work. No inline styles on the page keep the strict CSP happy. */

.cb {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - var(--nav-h));
}

/* ---- file tree (left) ---- */
.cb-tree {
  border-right: 1px solid var(--border);
  padding: 18px 10px 40px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  background: var(--bg);
}
.cb-tree .label { padding: 14px 10px 6px; display: block; }
.cb-tree .label:first-child { padding-top: 0; }
.cb-group + .cb-group { margin-top: 2px; }
.cb-file {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: var(--fg-muted);
  font: inherit;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.3;
}
.cb-file:hover { color: var(--fg); background: var(--bg-subtle); }
.cb-file[aria-current="true"] { color: var(--fg); background: var(--bg-muted); font-weight: 500; }
.cb-file .cb-name { font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere; }
.cb-file .cb-lc { margin-left: auto; font-size: 11px; color: var(--fg-faint); flex: none; }
.cb-omit {
  padding: 8px 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 1.45;
}
.cb-omit .cb-name { font-family: var(--font-mono); color: var(--fg-muted); }

/* ---- viewer (right) ---- */
.cb-view { min-width: 0; padding: 28px clamp(16px, 3.5vw, 44px) 80px; }
.cb-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.cb-note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--ok); }
.cb-note p { margin: 0; font-size: 14px; color: var(--fg-2); }

.cb-meta { margin-bottom: 14px; }
.cb-meta h1 {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  margin: 0;
}
.cb-desc { color: var(--fg-muted); margin: 6px 0 0; font-size: 14px; max-width: 70ch; }
.cb-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--fg-faint);
  font-family: var(--font-mono);
}
.cb-stats .cb-actions { margin-left: auto; display: flex; gap: 8px; }
.cb-actions .btn { font-family: var(--font-sans); }

/* code surface */
.cb-pre {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 4;
}
.cb-line { display: flex; }
.cb-line:hover { background: var(--bg-muted); }
.cb-ln {
  position: sticky;
  left: 0;
  flex: 0 0 auto;
  width: 3.5em;
  padding: 0 12px 0 14px;
  text-align: right;
  color: var(--fg-faint);
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}
.cb-line:hover .cb-ln { background: var(--bg-muted); }
.cb-src { padding: 0 16px 0 14px; white-space: pre; color: var(--fg-2); }

/* highlighter token colours */
.t-com { color: var(--fg-faint); font-style: italic; }
.t-str { color: var(--ok); }
.t-num { color: var(--sev-low); }
.t-kw  { color: var(--sev-critical); }
.t-lit { color: var(--sev-medium); }

.cb-empty { text-align: center; padding: 64px 20px; color: var(--fg-muted); }
.cb-empty svg { width: 34px; height: 34px; color: var(--fg-faint); margin-bottom: 10px; }

@media (max-width: 860px) {
  .cb { grid-template-columns: minmax(0, 1fr); }
  .cb-tree {
    position: static;
    height: auto;
    max-height: 46vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .cb-view { padding-top: 22px; }
  .cb-stats .cb-actions { margin-left: 0; width: 100%; }
}
