:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #14181f;
  --muted: #667085;
  --line: #e3e6ea;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --panel: #161b22; --ink: #e6edf3; --muted: #8b949e;
    --line: #262c36; --accent: #818cf8; --accent-soft: #1e2333;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }

/* The hidden attribute must win. Any element with an explicit `display` in
   author CSS — .gate and .shell both use grid — otherwise ignores it entirely
   and stays on screen while JS believes it is hidden. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
nav {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { font-weight: 650; letter-spacing: -.01em; padding: 0 10px 18px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
nav button {
  text-align: left; background: none; border: 0; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500;
}
nav button:hover { background: var(--bg); color: var(--ink); }
nav button.on { background: var(--accent-soft); color: var(--accent); }
nav .spacer { flex: 1; }
nav .foot { padding: 0 10px; font-size: 12px; color: var(--muted); }
main { padding: 24px 28px 64px; max-width: 1200px; }
h1 { font-size: 20px; margin: 0 0 2px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- generic bits ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); color: inherit; }
a.btn { text-decoration: none; display: inline-block; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.empty { color: var(--muted); padding: 28px; text-align: center; }

/* ---------- backlog ---------- */
.filters { gap: 8px; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 130px; }
.item {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--accent-soft); }
.score { text-align: center; font-weight: 650; font-size: 16px; }
.score small { display: block; font-size: 10px; font-weight: 400; color: var(--muted); text-transform: uppercase; }
.item h3 { margin: 0 0 4px; font-size: 14px; font-weight: 550; }
.meta { gap: 6px; }
.votes { display: flex; flex-direction: column; align-items: center; }
.votes button { background: none; border: 0; cursor: pointer; color: var(--muted); line-height: 1; padding: 2px; }
.votes button:hover { color: var(--accent); }
.votes b { font-size: 14px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col.drag { border-color: var(--accent); background: var(--accent-soft); }
.col h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 2px 4px 10px; }
.col h2 span { float: right; }
.mini {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; margin-bottom: 8px; cursor: grab;
}
.mini:active { cursor: grabbing; }
.mini strong { font-weight: 550; display: block; margin-bottom: 5px; }

/* ---------- strategy ---------- */
.alloc { height: 10px; border-radius: 999px; overflow: hidden; display: flex; background: var(--line); margin: 14px 0 18px; }
.alloc div { height: 100%; }
.obj { padding: 16px; margin-bottom: 12px; }
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar div { height: 100%; }

/* ---------- people ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person { padding: 16px; }
.light { display: flex; gap: 6px; margin: 12px 0 8px; }
.light button {
  flex: 1; border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; padding: 6px; cursor: pointer; color: var(--muted); font-size: 12px;
}
.light button.on { color: #fff; border-color: transparent; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(16,24,40,.4); display: none; }
.scrim.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%);
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 22px; overflow-y: auto; transform: translateX(100%); transition: transform .18s ease;
}
.drawer.open { transform: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.quote { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 10px 0; }
.quote b { font-size: 12px; }
.quote p { margin: 2px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  /* Rows are laid out for a desktop toolbar; on a phone let them stack rather
     than force the whole page wider than the screen. */
  .row { flex-wrap: wrap; }
  .row > input, .row > select, .row > textarea { min-width: 0; }
  .filters select, .filters input { flex: 1 1 140px; min-width: 0; }
  .shell { grid-template-columns: 1fr; }
  nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .brand, nav .spacer, nav .foot { display: none; }
  main { padding: 18px 16px 48px; }
  .board { grid-template-columns: 1fr; }
}

/* ---------- pulse / signals ---------- */
.signal { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; margin-bottom: 10px; }
.signal .stripe { width: 4px; height: 100%; border-radius: 2px; min-height: 34px; }
.signal strong { display: block; margin-bottom: 2px; }
.signal p { margin: 0; color: var(--muted); font-size: 13px; }
.digest { padding: 16px; margin-top: 8px; }
.digest pre {
  white-space: pre-wrap; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; margin: 12px 0 0; max-height: 340px; overflow: auto;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { padding: 14px 16px; }
.tile b { display: block; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.tile span { color: var(--muted); font-size: 12px; }

/* ---------- insights ---------- */
.insight { padding: 14px 16px; margin-bottom: 10px; }
.insight blockquote { margin: 6px 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink); }
.insight .row select { width: auto; min-width: 150px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 10px; }
.section-head h2 { font-size: 14px; margin: 0; }
.section-head span { color: var(--muted); font-size: 12px; }
.linked { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.linked:last-child { border-bottom: 0; }


/* ---------- sign-in gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-inner { width: 100%; max-width: 420px; text-align: center; }
.gate-inner h1 { font-size: 22px; margin: 0 0 4px; }
.gate-inner .sub { margin-bottom: 24px; }
#signin { display: flex; justify-content: center; }
.signout {
  width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px;
}
.signout:hover { background: var(--bg); color: var(--ink); }
