:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --column: #ebecf0;
  --text: #172b4d;
  --muted: #5e6c84;
  --border: #dfe1e6;
  --todo: #6b778c;
  --progress: #0c66e4;
  --done: #1f845a;
  --stale: #b65c02;
  --stale-bg: #fff7d6;
  --track: #dfe1e6;
  --radius: 6px;
  --shadow: 0 1px 1px rgba(9, 30, 66, 0.25), 0 0 1px rgba(9, 30, 66, 0.31);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2125;
    --surface: #22272b;
    --column: #161a1d;
    --text: #dee4ea;
    --muted: #9fadbc;
    --border: #38414a;
    --todo: #8c9bab;
    --progress: #579dff;
    --done: #4bce97;
    --stale: #f5cd47;
    --stale-bg: #3d3110;
    --track: #38414a;
    --shadow: 0 0 0 1px #38414a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select { font: inherit; color: inherit; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.brand { display: flex; gap: 10px; align-items: baseline; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.team { color: var(--muted); }
.meta { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.pill-on { color: var(--done); border-color: var(--done); }
.pill-off { color: var(--stale); border-color: var(--stale); }

.login {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 480px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login[hidden], .toolbar[hidden], .overall[hidden], .colhead[hidden] { display: none; }
.login input { flex: 1; min-width: 160px; padding: 6px 8px; }
.error { color: var(--stale); margin: 0; width: 100%; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar input[type='search'], .toolbar select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.toolbar input[type='search'] { flex: 1 1 220px; min-width: 0; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.spacer { flex: 1; }
.ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
}
.ghost:hover { border-color: var(--muted); }

.overall {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}
.overall .bar { flex: 1 1 200px; }

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  display: flex;
}
.bar span { display: block; height: 100%; }
.bar .seg-done { background: var(--done); }
.bar .seg-progress { background: var(--progress); }

.colhead, .lane-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.colhead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding: 8px 0;
}
.colhead-cell {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 6px 8px;
  background: var(--column);
  border-radius: var(--radius);
  display: flex;
  gap: 6px;
  align-items: center;
}
.colhead-cell::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.col-todo { --dot: var(--todo); }
.col-in_progress { --dot: var(--progress); }
.col-done { --dot: var(--done); }

.lane { margin-bottom: 8px; }
.lane-head {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.lane-head:hover { background: var(--column); }
.lane-head:focus-visible { outline: 2px solid var(--progress); outline-offset: 1px; }
.chevron { width: 16px; color: var(--muted); transition: transform 0.15s; }
.lane.is-open .chevron { transform: rotate(90deg); }
.lane-title { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.lane-name { font-weight: 600; overflow-wrap: anywhere; }
.lane-sub { color: var(--muted); font-size: 12px; }
.lane-progress { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 12px; color: var(--muted); }
.lane-progress .bar { width: 140px; }
.lozenge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--column);
  color: var(--muted);
}
.lozenge-in_progress { background: color-mix(in srgb, var(--progress) 18%, transparent); color: var(--progress); }
.lozenge-done { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }
.lozenge-ready { background: color-mix(in srgb, var(--todo) 22%, transparent); color: var(--text); }
.lozenge-stale { background: var(--stale-bg); color: var(--stale); }

.lane-body { padding: 4px 0 8px; }
.lane:not(.is-open) .lane-body { display: none; }
.col {
  background: var(--column);
  border-radius: var(--radius);
  padding: 6px;
  min-height: 48px;
  min-width: 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 10px;
  margin-bottom: 6px;
  transition: background-color 0.4s;
}
.card.is-stale { background: var(--stale-bg); }
.card.is-fresh { background: color-mix(in srgb, var(--progress) 14%, var(--surface)); }
.card.is-done .card-title { color: var(--muted); }
.card-title {
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.key { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.key-icon {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--dot);
  display: inline-block;
}
.card-foot .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--avatar, var(--todo));
  flex: none;
}
.badge { font-size: 11px; font-weight: 700; color: var(--stale); }
.badge-claimed { color: var(--progress); }
.also { color: var(--stale); margin-top: 6px; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.more {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px;
  cursor: pointer;
  border-radius: var(--radius);
}
.more:hover { background: var(--surface); }
.empty { color: var(--muted); font-size: 13px; padding: 4px; }
.foot { color: var(--muted); font-size: 12px; }

@media (max-width: 560px) {
  .colhead { display: none; }
  .lane-body { grid-template-columns: 1fr; }
  .col::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin: 2px 2px 6px;
  }
  .lane-head { grid-template-columns: auto minmax(0, 1fr); }
  .lane-progress { grid-column: 2; }
  .lane-progress .bar { width: 100px; }
}

/* ---- side panel ---- */
.lane-head { cursor: pointer; }
.lane-open {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.lane-open:hover, .lane-open:focus-visible { color: var(--progress); text-decoration: underline; }
.card { cursor: pointer; }
.card:hover { outline: 1px solid var(--progress); }
.card:focus-visible { outline: 2px solid var(--progress); }
.card.is-selected { outline: 2px solid var(--progress); }

.backdrop { position: fixed; inset: 0; background: rgba(9, 30, 66, 0.35); z-index: 9; }
.backdrop[hidden], .drawer[hidden] { display: none; }
@media (min-width: 900px) { .backdrop { display: none; } }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  background: var(--surface);
  box-shadow: -8px 0 24px rgba(9, 30, 66, 0.2);
  z-index: 10;
  display: flex;
  flex-direction: column;
}
@media (min-width: 900px) { body.has-drawer { padding-right: 496px; } }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-kicker { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.drawer-kicker button { border: 0; background: none; color: var(--progress); padding: 0; cursor: pointer; font-size: 12px; }
.icon-btn {
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--column); }
.drawer-body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.drawer-body h2 { font-size: 20px; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.drawer-body h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}
.drawer-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.desc code, .fields code { background: var(--column); border-radius: 3px; padding: 0 4px; font-size: 12.5px; }
.fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; min-width: 0; }
.fields .when { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 13px; }
.list a, .ext { color: var(--progress); text-decoration: none; overflow-wrap: anywhere; }
.list a:hover, .ext:hover { text-decoration: underline; }
.list .meta-r { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.list button.linkish { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.list button.linkish:hover { color: var(--progress); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.timeline li { position: relative; font-size: 13px; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot, var(--todo));
  border: 2px solid var(--surface);
}
.timeline .t-claimed, .timeline .t-started { --dot: var(--progress); }
.timeline .t-completed, .timeline .t-checked { --dot: var(--done); }
.timeline .t-released, .timeline .t-reopened { --dot: var(--stale); }
.timeline .when { color: var(--muted); font-size: 12px; display: block; }
.muted { color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 12px; margin: 0; }

.linkish-btn { border: 0; background: none; padding: 0; color: var(--progress); cursor: pointer; font-size: inherit; }
.linkish-btn:hover { text-decoration: underline; }

.lozenge-local { background: color-mix(in srgb, #8f7ee7 22%, transparent); color: #6e5dc6; }
.notice-local { background: color-mix(in srgb, #8f7ee7 12%, var(--surface)); border-radius: var(--radius); padding: 8px 10px; margin-top: 10px; color: var(--text); }
@media (prefers-color-scheme: dark) {
  .lozenge-local { color: #b8acf6; }
}

.project-switch {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
}
.lozenge-project { background: var(--column); color: var(--text); font-weight: 600; }

.overview[hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 28px; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.project-card { text-align: left; background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.project-card:hover, .project-card:focus-visible { outline: 2px solid var(--progress); }
.project-card.is-active { border-left: 4px solid var(--progress); }
.project-name { font-size: 16px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.project-numbers { color: var(--muted); font-size: 13px; }
.project-numbers b { color: var(--text); }

.vgroup { margin: 0 0 22px; }
.vgroup-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 8px 4px; margin-bottom: 6px; border-bottom: 2px solid var(--border); }
.vgroup-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.vgroup-head .lane-progress { margin-left: auto; }

.prompt-btn { align-self: flex-start; margin-top: 6px; padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--progress); font-size: 12px; font-weight: 600; cursor: pointer; }
.prompt-btn:hover { border-color: var(--progress); }
.prompt-btn.is-copied { color: var(--done); border-color: var(--done); }
.prompt-btn-wide { margin-top: 10px; padding: 6px 12px; font-size: 13px; }
