/* intel: GitHub-notifications-style dark inbox */
:root {
  --bg: #0d1117;
  --bg2: #010409;
  --panel: #161b22;
  --panel2: #21262d;
  --border: #30363d;
  --fg: #e6edf3;
  --fg-dim: #8d96a0;
  --accent: #2f81f7;
  --green: #3fb950;
  --purple: #a371f7;
  --red: #f85149;
  --orange: #d29922;
}
* { box-sizing: border-box; }
/* min-height, NOT height: a fixed body height caps every position:sticky
   containing block at one viewport, so the topbar unsticks after ~100vh. */
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input {
  font: inherit; color: var(--fg); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px;
}
button { cursor: pointer; }
button:hover { border-color: var(--fg-dim); }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 16px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
#logo { font-weight: 700; font-size: 16px; color: var(--fg); margin-right: 4px; }
#tabs { display: flex; gap: 4px; }
.tab { background: transparent; border: none; color: var(--fg-dim); font-weight: 600; }
.tab.active { color: var(--fg); background: var(--panel2); }
.pill {
  background: var(--accent); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 7px; margin-left: 3px;
}
#searchwrap { flex: 1; position: relative; }
#search { width: 100%; background: var(--bg); padding-right: 28px; }
#search:focus { outline: none; border-color: var(--accent); }
#clearsearch {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--fg-dim); padding: 2px 6px;
}

/* ---------- layout ---------- */
#layout { display: flex; min-height: calc(100vh - 54px); }
#sidebar {
  width: 240px; flex-shrink: 0; padding: 12px;
  border-right: 1px solid var(--border);
  position: sticky; top: 54px; align-self: flex-start;
  max-height: calc(100vh - 54px); overflow-y: auto;
}
.side-section h3 {
  margin: 14px 0 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--fg-dim);
}
.side-section ul { list-style: none; margin: 0; padding: 0; }
.side-section li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 8px; border-radius: 6px; cursor: pointer; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden;
}
.side-section li:hover { background: var(--panel); color: var(--fg); }
.side-section li.on { background: var(--panel2); color: var(--fg); }
.side-section li .n { font-size: 11px; color: var(--fg-dim); }
.side-section li .n.hot { color: var(--accent); font-weight: 700; }
#pollerinfo { font-size: 11px; color: var(--fg-dim); white-space: pre-line; }

/* ---------- list ---------- */
#list { flex: 1; min-width: 0; padding: 12px 16px 80px; }
/* NOTE: no overflow:hidden here. It would make .group the sticky header's
   scroll container, which parks the header 54px INSIDE the box over the rows. */
.group {
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 14px; background: var(--panel);
}
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--panel2);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  position: sticky; top: 54px; z-index: 10;
}
.row:last-child { border-radius: 0 0 8px 8px; }
.group-head .gtitle { font-weight: 700; }
.group-head .gsrc {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--fg-dim);
}
.group-head .spacer { flex: 1; }
.group-head button { font-size: 12px; padding: 2px 10px; }

/* thread subgroup: indented block inside its repo box (repo > thread mode) */
.subgroup {
  margin: 6px 10px 8px 28px;
  border-left: 2px solid var(--border);
  background: var(--bg);
  border-radius: 0 6px 6px 0;
}
.sub-head {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.sub-head .stitle {
  font-weight: 600; cursor: pointer; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sub-head .stitle:hover { color: var(--accent); text-decoration: underline; }
.sub-head .gdone { font-size: 11px; padding: 1px 8px; visibility: hidden; }
.subgroup:hover .sub-head .gdone { visibility: visible; }
.subgroup .row { padding: 6px 12px; }
/* repo, #N and thread title already live in the group/sub headers: rows keep
   only actor + action + snippet, one dense line each */
.subgroup .row .rtop { display: none; }
.subgroup .row .rsub { color: var(--fg); }
.subgroup .row.read .rsub { color: var(--fg-dim); }
.subgroup .row:last-child { border-radius: 0 0 6px 0; }

.row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row:hover { background: #1c2129; }
.row.sel { background: #1c2534; box-shadow: inset 3px 0 0 var(--accent); }
.row.read { opacity: .55; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.row:not(.read) .dot { background: var(--accent); }
.kicon { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; }
.rmain { flex: 1; min-width: 0; }
.rtop { display: flex; gap: 6px; align-items: baseline; }
.rrepo { color: var(--fg-dim); font-size: 12px; white-space: nowrap; }
.rnum { color: var(--fg-dim); font-size: 12px; }
.rtitle {
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rtitle a { color: inherit; }
.rtitle a:hover { color: var(--accent); text-decoration: underline; }
.blank {
  border: none; background: none; color: var(--fg-dim); padding: 2px 4px;
  font-size: 14px; line-height: 1;
}
.blank:hover { color: var(--accent); border: none; }
.rsub { color: var(--fg-dim); font-size: 12px; overflow: hidden;
        text-overflow: ellipsis; white-space: nowrap; }
.rmeta {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto;
}
.avatar { width: 20px; height: 20px; border-radius: 50%; background: var(--panel2); }
.rtime { color: var(--fg-dim); font-size: 12px; white-space: nowrap; width: 60px; text-align: right; }
.rbtns { display: none; gap: 4px; }
.row:hover .rbtns, .row.sel .rbtns { display: flex; }
.rbtns button { padding: 1px 8px; font-size: 12px; }

.empty { text-align: center; color: var(--fg-dim); padding: 60px 0; }

/* kind colors */
.k-opened_pr, .k-reopened_pr { color: var(--green); }
.k-merged_pr { color: var(--purple); }
.k-closed_pr, .k-closed_issue { color: var(--red); }
.k-opened_issue, .k-reopened_issue { color: var(--green); }
.k-approved { color: var(--green); }
.k-changes_requested { color: var(--orange); }
.k-comment, .k-review_comment, .k-review { color: var(--fg-dim); }
.k-push, .k-tag, .k-release, .k-other { color: var(--fg-dim); }

/* ---------- thread pane ---------- */
#threadpane {
  width: 40%; max-width: 640px; min-width: 380px; flex-shrink: 0;
  border-left: 1px solid var(--border); background: var(--bg2);
  position: sticky; top: 54px; align-self: flex-start;
  height: calc(100vh - 54px); display: flex; flex-direction: column;
}
#threadpane.hidden { display: none; }
#threadhead {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
#threadlink { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis;
              white-space: nowrap; }
#threadbody { overflow-y: auto; padding: 12px 14px; }
.titem { margin-bottom: 14px; }
.titem .thead {
  display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--fg-dim);
}
.titem .tbody {
  margin-top: 4px; padding: 8px 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px;
  white-space: pre-wrap; word-break: break-word; font-size: 13px;
}
.tdesc .tbody { border-left: 3px solid var(--accent); }

/* ---------- misc ---------- */
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 18px; z-index: 99;
}
#toast.hidden, .hidden { display: none; }

/* ---------- search help ---------- */
#helpbtn { font-weight: 700; padding: 5px 11px; }
#helppanel {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: grid; place-items: start center; padding-top: 70px;
}
#helppanel.hidden { display: none; }
#helpcard {
  width: min(760px, 92vw); max-height: 75vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
#helphead {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel);
}
#helphead span { color: var(--fg-dim); font-size: 12px; flex: 1; }
#helptable { border-collapse: collapse; width: 100%; }
#helptable td { padding: 8px 16px; border-bottom: 1px solid var(--border);
                vertical-align: top; }
#helptable td:first-child {
  white-space: nowrap; font-family: ui-monospace, monospace; font-size: 13px;
  color: var(--accent); cursor: pointer;
}
#helptable td:first-child:hover { text-decoration: underline; }
#helptable td:last-child { color: var(--fg-dim); font-size: 13px; }

/* ---------- poller panel ---------- */
#pollerhead { cursor: pointer; }
#pollerhead:hover { color: var(--accent); }
#pollerpanel {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: grid; place-items: start center; padding-top: 70px;
}
#pollerpanel.hidden { display: none; }
#pollercard {
  width: min(900px, 94vw); max-height: 80vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
#pollerhd {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel);
}
#pollerhd span { color: var(--fg-dim); font-size: 12px; flex: 1; }
#pollerbody { padding: 8px 16px 16px; font-size: 13px; }
#pollerbody h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase;
                 color: var(--fg-dim); letter-spacing: .04em; }
#pollerbody table { border-collapse: collapse; width: 100%; }
#pollerbody td, #pollerbody th { padding: 4px 8px; border-bottom: 1px solid var(--border);
                                 text-align: left; vertical-align: top;
                                 font-family: ui-monospace, monospace; font-size: 12px; }
#pollerbody th { color: var(--fg-dim); font-weight: 500; }
#pollerbody .err { color: var(--red); }
#pollerbody .ok { color: var(--green); }
#pollerbody .kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; }
#pollerbody .kv b { color: var(--fg-dim); font-weight: 500; }
#whoami { color: var(--fg-dim); font-size: 12px; margin-left: 4px; }
#autodone.on { border-color: var(--accent); color: var(--accent); }

/* ---------- login ---------- */
.loginpage { display: grid; place-items: center; height: 100vh; }
#loginform {
  display: flex; flex-direction: column; gap: 10px; width: 280px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px;
}
#loginform h1 { margin: 0 0 8px; text-align: center; }
#loginerr { color: var(--red); text-align: center; margin: 0; min-height: 1em; }

@media (max-width: 1000px) {
  #sidebar { display: none; }
  #threadpane { position: fixed; right: 0; width: 90%; max-width: none; z-index: 40; }
}
