/* ghr · research reports — central hub shell */
:root {
  --bg: #0f1115;
  --bg-2: #161922;
  --bg-3: #1d212c;
  --fg: #e8eaed;
  --fg-muted: #9aa3b2;
  --fg-dim: #6c7385;
  --line: #2a2f3a;
  --line-hover: #3a4150;
  --accent: #6ea8ff;
  --ok: #5cd6a8;
  --warn: #f4c14a;
  --bad: #ff7a7a;
  --code-bg: #0a0c12;
  --outer-w: 300px;
  --inner-w: 248px;
  --topbar-h: 50px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SF Mono, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.5;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───── Layout: topbar (full width) + outer sidebar + inner sidebar + content ─────
   Column tracks are `auto` so a display:none sidebar collapses its track to 0. */
.app {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  height: 100vh;
}
.topbar {
  grid-column: 1 / -1;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  display: flex; align-items: center; gap: 12px;
}
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
/* Explicit column placement so a display:none sidebar never shifts the content
   out of the 1fr track (which would leave a dead gap on the right). */
.sidebar.outer { grid-column: 1; grid-row: 2; width: var(--outer-w); }
.sidebar.inner { grid-column: 2; grid-row: 2; width: var(--inner-w); display: none; }

/* state toggles */
.app.has-inner .sidebar.inner { display: flex; }
.app.outer-hidden .sidebar.outer { display: none; }

.content {
  grid-column: 3; grid-row: 2;
  background: var(--bg);
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* ───── Topbar ───── */
.icon-btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  width: 30px; height: 30px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.icon-btn:hover { color: var(--fg); border-color: var(--line-hover); }
.crumbs { color: var(--fg-muted); font-size: 12.5px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--fg-muted); }
.crumbs b { color: var(--fg); font-weight: 600; }
.crumbs .sep { color: var(--fg-dim); margin: 0 7px; }
.swatch-inline { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.actions { display: flex; gap: 6px; flex: 0 0 auto; }
.btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  padding: 5px 11px;
  font-size: 12px;
  font-family: inherit;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { color: var(--fg); border-color: var(--line-hover); text-decoration: none; }

/* ───── Outer sidebar (projects) ───── */
.sidebar-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sidebar-header h1 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; letter-spacing: .02em; }
.sidebar-header h1 a { color: var(--fg); }
.sidebar-header h1 a:hover { text-decoration: none; color: var(--accent); }
.sidebar-header .meta { font-size: 11px; color: var(--fg-dim); }
.search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.search-wrap input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line);
  color: var(--fg); padding: 7px 10px; border-radius: 4px;
  font-size: 12.5px; font-family: inherit; outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }

.project-list { flex: 1; overflow-y: auto; padding: 8px 0 30px; }
.project-list::-webkit-scrollbar,
.inner-nav::-webkit-scrollbar { width: 8px; }
.project-list::-webkit-scrollbar-thumb,
.inner-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.project-list::-webkit-scrollbar-thumb:hover,
.inner-nav::-webkit-scrollbar-thumb:hover { background: var(--line-hover); }

.project-group { padding: 4px 0; }
.project-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 4px; cursor: pointer; user-select: none;
}
.project-header .swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.project-header .name {
  font-size: 12px; font-weight: 600; color: var(--fg);
  text-transform: uppercase; letter-spacing: .06em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-header .count { margin-left: auto; font-size: 10.5px; color: var(--fg-dim); }
.project-header .chev { font-size: 10px; color: var(--fg-dim); transition: transform .12s ease; flex: 0 0 auto; }
.project-group.collapsed .chev { transform: rotate(-90deg); }
.project-group.collapsed .project-reports,
.project-group.collapsed .project-desc { display: none; }
.project-desc { padding: 0 16px 4px 32px; font-size: 10.5px; color: var(--fg-dim); line-height: 1.4; }

.project-reports { padding: 2px 0; }
.report-item {
  display: block; padding: 6px 16px 6px 32px;
  font-size: 12.5px; color: var(--fg-muted);
  border-left: 2px solid transparent; cursor: pointer; position: relative;
}
.report-item:hover { color: var(--fg); background: var(--bg-3); text-decoration: none; }
.report-item.active { color: var(--fg); background: var(--bg-3); border-left-color: var(--accent); }
.report-item .date { font-size: 10px; color: var(--fg-dim); margin-left: 6px; }

/* ───── Inner sidebar (pages of current project) ───── */
.inner-nav { flex: 1; overflow-y: auto; padding: 14px 14px 30px; }
.inner-home { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.inner-home .swatch { width: 9px; height: 9px; border-radius: 2px; }
.inner-home .inner-title { font-size: 14px; font-weight: 700; color: var(--fg); }
.inner-home:hover { text-decoration: none; }
.inner-home:hover .inner-title { color: var(--accent); }
.inner-blurb { font-size: 10.5px; color: var(--fg-dim); line-height: 1.5; margin: 0 0 14px; padding: 0 2px; }
.inner-group { margin-bottom: 16px; }
.inner-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--fg-dim); margin: 0 0 6px; padding: 0 4px; font-weight: 600;
}
.inner-nav ul { list-style: none; margin: 0; padding: 0; }
.inner-nav li { margin: 1px 0; }
.inner-nav a.inav {
  display: block; padding: 5px 10px; border-radius: 5px;
  font-size: 12.5px; color: var(--fg-muted); line-height: 1.35;
  border-left: 2px solid transparent;
}
.inner-nav a.inav:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.inner-nav a.inav.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--fg); font-weight: 600; border-left-color: var(--accent);
}
.ibadge {
  font-size: 9px; padding: 0 5px; margin-left: 5px; border-radius: 7px;
  background: var(--bg); color: var(--accent); border: 1px solid var(--line);
  vertical-align: 1px;
}

/* ───── content: iframe ───── */
.content-iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }

/* ───── content: markdown ───── */
.content.markdown { overflow-y: auto; }
.md-body { max-width: 880px; margin: 0 auto; padding: 36px 44px 90px; }
.md-body h1 { font-size: 25px; margin: 0 0 10px; line-height: 1.25; }
.md-body h2 { font-size: 19px; margin: 34px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 16px; }
.md-body h3 { font-size: 16px; margin: 26px 0 10px; color: var(--fg); scroll-margin-top: 16px; }
.md-body h4 { font-size: 14px; margin: 20px 0 8px; color: var(--fg-muted); }
.md-body p, .md-body li { font-size: 14px; line-height: 1.7; color: var(--fg); }
.md-body p { margin: 12px 0; }
.md-body ul, .md-body ol { margin: 12px 0; padding-left: 24px; }
.md-body li { margin: 5px 0; }
.md-body a { color: var(--accent); }
.md-body strong { color: #fff; }
.md-body hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }
.md-body blockquote {
  margin: 16px 0; padding: 8px 16px; border-left: 3px solid var(--accent);
  background: var(--bg-2); color: var(--fg-muted); border-radius: 0 4px 4px 0;
}
.md-body code {
  background: var(--code-bg); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 4px; font-size: .86em;
  font-family: ui-monospace, SF Mono, Menlo, Consolas, monospace;
}
.md-body pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 14px 16px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; margin: 16px 0;
}
.md-body pre code { background: none; border: 0; padding: 0; font-size: 12.5px; }
.md-body img, .md-body video {
  max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line);
  display: block; margin: 12px 0; background: #000;
}
.md-body table { border-collapse: collapse; margin: 16px 0; font-size: 13px; display: block; overflow-x: auto; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top; }
.md-body th { background: var(--bg-3); font-weight: 600; color: var(--fg); }
.md-body td { color: var(--fg-muted); }
.md-body details {
  margin: 12px 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 0 14px;
}
.md-body summary { cursor: pointer; color: var(--accent); padding: 9px 0; font-weight: 500; }
.md-body details[open] { padding-bottom: 8px; }

/* ───── landing grid ───── */
.grid-view { height: 100%; overflow-y: auto; padding: 28px 32px 60px; }
.grid-view h2 { margin: 0 0 18px; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.count-dim { font-weight: 400; color: var(--fg-dim); font-size: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.report-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 14px 16px; display: flex; flex-direction: column;
  color: var(--fg); transition: border-color .1s;
}
.report-card:hover { border-color: var(--accent); text-decoration: none; }
.report-card .card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.report-card .swatch { width: 9px; height: 9px; border-radius: 2px; }
.report-card .project-name { font-size: 10.5px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .06em; }
.report-card .card-date { margin-left: auto; font-size: 10.5px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.report-card .title { font-size: 13.5px; font-weight: 600; margin-bottom: 7px; color: var(--fg); line-height: 1.35; }
.report-card .summary { font-size: 11.5px; color: var(--fg-muted); line-height: 1.5; margin-bottom: 10px; }
.report-card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.tag { font-size: 10px; padding: 1px 6px; background: var(--bg-3); color: var(--fg-dim); border: 1px solid var(--line); border-radius: 3px; }

.empty { color: var(--fg-dim); padding: 40px; text-align: center; font-size: 13px; }
.welcome { color: var(--fg-muted); padding: 60px 0 20px; text-align: center; }
.welcome h2 { color: var(--fg); }

/* ───── review queue panel ───── */
.review-panel {
  background: linear-gradient(180deg, rgba(110,168,255,.10), rgba(110,168,255,.04));
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 14px 18px; margin: 0 0 24px;
}
.review-panel-head { font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-panel-head .rq-count { background: var(--accent); color: #0a0c12; font-size: 11px; padding: 1px 7px; border-radius: 8px; font-weight: 700; }
.review-panel-head .rq-hint { font-size: 11px; font-weight: 400; color: var(--fg-dim); margin-left: auto; }
.review-panel-head .rq-hint code { background: var(--bg-3); padding: 0 5px; border-radius: 3px; font-size: 10.5px; }
.rq-list { list-style: none; margin: 0; padding: 0; }
.rq-item { padding: 7px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 10px auto 1fr auto; gap: 8px; align-items: baseline; }
.rq-item:first-child { border-top: none; padding-top: 2px; }
.rq-item .swatch { width: 8px; height: 8px; border-radius: 2px; align-self: center; }
.rq-item .rq-proj { font-size: 10.5px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; min-width: 90px; }
.rq-item .rq-title { font-weight: 600; font-size: 13px; color: var(--accent); }
.rq-item .rq-added { font-size: 10.5px; color: var(--fg-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rq-item .rq-desc { grid-column: 2 / -1; font-size: 12px; color: var(--fg-muted); margin-top: 3px; }

/* ───── responsive: collapse sidebars into overlay on narrow screens ───── */
@media (max-width: 820px) {
  :root { --outer-w: 260px; --inner-w: 220px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .content { grid-column: 1; }
  .sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 20; box-shadow: 4px 0 16px rgba(0,0,0,.4); }
  .sidebar.inner { left: var(--outer-w); }
  .app.outer-hidden .sidebar.inner { left: 0; }
}

.hidden { display: none !important; }
