:root {
  --text: #1f1e24;
  --muted: #626168;
  --line: #dcdcde;
  --bg: #fbfafd;
  --card: #fff;
  --p1: #c91c00;
  --p2: #a35200;
  --p3: #1068bf;
  --p4: #626168;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.4; }
a { color: inherit; }

/* Per-epic accent colour */
[data-id="e54"] { --c: #5b45b5; }
[data-id="e55"] { --c: #7d3fae; }
[data-id="e56"] { --c: #a8358f; }
[data-id="e57"] { --c: #c4391d; }
[data-id="e58"] { --c: #9a5a00; }
[data-id="e35"], [data-id="e36"] { --c: #1f7a4d; }
[data-id="e59"], [data-id="e60"] { --c: #5c6370; }

/* Page header */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding: 16px 56px 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.page-head h1 { margin: 0; font-size: 20px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Repo ribbon, visible in every state. The header reserves room for it.
   Only the ribbon catches clicks; its transparent wrapper does not. */
.repo-corner-wrapper {
  position: absolute; top: 0; right: 0; z-index: 50;
  width: 48px; height: 48px; overflow: hidden; pointer-events: none;
}
.repo-corner {
  position: absolute; top: -8px; right: -24px; transform: rotate(45deg); pointer-events: auto;
  background: #fc6d26; border: 21px solid #fc6d26; border-bottom: none; border-top-width: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.repo-corner:focus-visible { outline: 2px solid var(--text); outline-offset: -3px; }
.repo-corner svg { display: block; width: 28px; height: 28px; margin-bottom: -2px; transition: transform 150ms ease; }
.repo-corner:hover svg { transform: scale(1.08); }
@media (prefers-reduced-motion: reduce) {
  .repo-corner svg { transition: none; }
  .repo-corner:hover svg { transform: none; }
}
@media (max-width: 720px) {
  .page-head { padding-right: 48px; }
  .repo-corner-wrapper { width: 40px; height: 40px; }
  .repo-corner { top: -7px; right: -20px; border-left-width: 18px; border-right-width: 18px; border-top-width: 7px; }
  .repo-corner svg { width: 23px; height: 23px; }
}

/* Sign-in, loading and error states. The board only shows once data is ready. */
.gate {
  display: none; max-width: 420px; margin: 80px auto; padding: 24px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.gate p { margin: 0 0 14px; color: var(--muted); }
.gate p:empty { display: none; }
.btn.primary { padding: 6px 14px; background: #5b45b5; border-color: #5b45b5; color: #fff; }
.btn.primary:hover { background: #4a379b; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
#sign-in, #retry { display: none; }
body:not([data-state="ready"]) .board,
body:not([data-state="ready"]) .session { display: none; }
body:not([data-state="ready"]) .gate { display: block; }
body[data-state="signed-out"] #sign-in,
body[data-state="error"] #retry { display: inline-block; }

/* Three columns: advocacy | funnel + outcomes | outside the flywheel */
.board {
  position: relative; display: grid; align-items: start; gap: 48px;
  grid-template-columns: 230px minmax(560px, 1fr) 380px;
  padding: 20px 24px 48px;
}
.col-label {
  margin: 0 0 8px; color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.advocacy { margin-top: 130px; }
.col-right { padding-left: 24px; border-left: 1px dashed #bfbfc3; }
.stack { display: grid; gap: 12px; }
.outcomes-label { margin-top: 40px; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Funnel: each tier is 10% narrower than the one above, with slanted sides */
.funnel { display: grid; gap: 6px; padding-top: 24px; }
.funnel .epic-head {
  --d: calc(500% / (100 - var(--i) * 10));
  width: calc(100% - var(--i) * 10%);
  margin-inline: auto;
  padding: 12px calc(5% + 16px) 14px;
  background: var(--c); color: #fff;
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--d)) 100%, var(--d) 100%);
}

/* Cards outside the funnel */
.advocacy .epic, .outcomes .epic, .stack .epic {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px;
}
.epic-head { padding: 12px 14px; }
.epic-top { display: flex; align-items: baseline; gap: 8px; }
.epic-top h3 { margin: 0; font-size: 15px; }
.ref { margin-left: auto; font-size: 12px; opacity: .85; text-decoration: none; white-space: nowrap; }
.ref:hover { text-decoration: underline; }
.epic-meta { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.epic-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; }
.assigned-count { flex: none; margin-left: auto; font-size: 16px; font-weight: 600; }

/* Issue count badge: P1/P2/P3/P4 ?unknown (total) */
.badge {
  display: inline-flex; align-items: center; padding: 0 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; color: #89888d;
  font: 600 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap;
}
.badge .p1 { color: var(--p1); }
.badge .p2 { color: var(--p2); }
.badge .p3 { color: var(--p3); }
.badge .p4 { color: var(--p4); }
.badge .pu { margin-left: 7px; color: var(--muted); border-bottom: 1px dashed currentColor; line-height: 1.2; }
.badge .total { margin-left: 7px; color: var(--text); }

/* Metric placeholders */
.metrics-row { display: flex; align-items: flex-start; gap: 6px; margin-top: 8px; }
.tag { padding: 2px 5px; border-radius: 4px; background: rgba(0, 0, 0, .08); font-size: 10px; font-weight: 700; }
.metrics { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0; padding: 0; list-style: none; }
.metrics li {
  display: inline-flex; gap: 6px; padding: 1px 8px; font-size: 12px;
  background: #f6f6f8; border: 1px dashed #bfbfc3; border-radius: 4px;
}
.note { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.funnel .tag { background: rgba(255, 255, 255, .22); }
.funnel .metrics li { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .6); }
.funnel .note { color: rgba(255, 255, 255, .85); }

/* Orphans tile and the "should have no children" warning */
[data-id="orphans"] { --c: #b42318; }
.col-right .stack + .col-label { margin-top: 20px; }
.warn {
  margin: 6px 0 0; padding: 3px 8px; background: #fdf1dd; border: 1px solid #e9be74; border-radius: 4px;
  color: #703800; font-size: 12px; font-weight: 600;
}
.where { flex: none; padding: 0 6px; background: #fdf1dd; border-radius: 999px; color: #703800; font-size: 11px; font-weight: 400; }

/* Expand and collapse */
.btn { padding: 3px 10px; background: #fff; border: 1px solid #bfbfc3; border-radius: 4px; font: inherit; cursor: pointer; }
.btn:hover { background: #f1f0f5; }
[data-toggle] { cursor: pointer; }
.toggle { flex: none; align-self: center; width: 16px; height: 16px; padding: 0; background: none; border: 0; color: inherit; cursor: pointer; }
.toggle::before { content: "\25B8"; display: block; font-size: 12px; line-height: 16px; transition: transform .1s; }
.toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.toggle-gap { flex: none; width: 16px; }

.epic-panel { padding: 6px 10px 8px; border-top: 1px solid var(--line); }
.funnel .epic-panel {
  width: calc(100% - var(--i) * 10%); margin: 4px auto 0;
  background: var(--card); border: 1px solid var(--c); border-radius: 0 0 8px 8px;
}

/* Tree rows: [toggle] [priority] [reference] title [assignment or counts] */
.tree { margin: 0; padding: 0; list-style: none; }
.tree .tree { margin-left: 11px; padding-left: 8px; border-left: 2px solid var(--line); }
.row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 3px 4px; border-radius: 4px; font-size: 13px; }
.row:hover { background: #f1f0f5; }
.row-epic { font-weight: 600; }
.row .title { flex: 1 1 150px; min-width: 0; overflow-wrap: anywhere; }
.lock { flex: none; font-size: 11px; }
.row .iid { flex: none; min-width: 42px; color: var(--muted); font-size: 12px; font-weight: 400; text-decoration: none; }
.row a.iid:hover { text-decoration: underline; }
.row .badge { flex: none; margin-left: auto; font-size: 11px; }
.assigned { flex: none; display: inline-flex; align-self: center; color: #4a379b; }
.chip { flex: none; width: 26px; border-radius: 4px; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.chip.p1 { background: var(--p1); }
.chip.p2 { background: var(--p2); }
.chip.p3 { background: var(--p3); }
.chip.p4 { background: var(--p4); }
.chip.pu { background: none; border: 1px dashed #89888d; color: var(--muted); line-height: 16px; }

/* Flywheel loop and outcome fork (drawn by arrows.js) */
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.arrows .line { fill: none; stroke-width: 2; }
.arrows .loop { stroke: #9a5a00; }
.arrows .optional { stroke-dasharray: 5 5; }
.arrows .fork { stroke: #89888d; stroke-width: 1.5; }
.arrows text {
  fill: #7a4700; font-size: 11px; text-anchor: middle;
  paint-order: stroke; stroke: var(--bg); stroke-width: 4px;
}

@media (max-width: 1150px) {
  .arrows { display: none; }
  .board { grid-template-columns: 1fr; gap: 24px; }
  .advocacy { margin-top: 0; }
  .col-right { padding-left: 0; border-left: 0; }
}
