:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #101418;
  --ink-2: #47505a;
  --muted: #6b7480;
  --line: rgb(16 20 24 / 10%);
  --line-soft: rgb(16 20 24 / 6%);
  --accent: #15803d;
  --accent-soft: #e9f5ee;
  --issue: #b3261e;
  --issue-soft: #fdeceb;
  --new: #6d3fa0;
  --new-soft: #f1ebfa;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 5%), 0 6px 18px rgb(0 0 0 / 6%);
  --shadow-2: 0 4px 10px rgb(0 0 0 / 8%), 0 24px 50px rgb(0 0 0 / 14%);
  --r: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* display:inline-flex on .tag otherwise beats the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

/* ------------------------------------------------------------- chrome -- */

.top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: rgb(255 255 255 / 85%);
  backdrop-filter: saturate(180%) blur(14px);
  box-shadow: 0 0.5px 0 var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand img { width: 26px; height: 32px; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }

.tabs { display: flex; gap: 2px; padding: 3px; background: rgb(118 118 128 / 12%); border-radius: 11px; }
.tabs button {
  min-height: 32px; padding: 0 14px; border: 0; border-radius: 8px;
  background: transparent; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.tabs button.on { background: #fff; font-weight: 600; box-shadow: 0 2px 6px rgb(0 0 0 / 10%); }

.spacer { flex: 1; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.existing { background: var(--accent); }
.dot.issue { background: var(--issue); }
.dot.new { background: var(--new); }

.search {
  min-height: 34px; width: 210px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 10px;
  background: rgb(118 118 128 / 10%);
}
.search:focus { outline: none; background: #fff; border-color: var(--accent); }

/* --------------------------------------------------------------- app --- */

.view { display: none; }
.view.on { display: block; }

.apps {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--panel); box-shadow: 0 0.5px 0 var(--line);
  position: sticky; top: 53px; z-index: 30;
}
.chip {
  min-height: 32px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip b { font-weight: 600; }
.chip i { font-style: normal; color: var(--muted); font-size: 12px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on i { color: rgb(255 255 255 / 70%); }

/* ------------------------------------------------------------- board --- */

#board-wrap { position: relative; height: calc(100vh - 110px); overflow: hidden; background:
  radial-gradient(circle at 1px 1px, rgb(16 20 24 / 8%) 1px, transparent 0) 0 0 / 22px 22px; cursor: grab; }
#board-wrap.drag { cursor: grabbing; }
#board { position: absolute; transform-origin: 0 0; }
#edges { position: absolute; inset: 0; overflow: visible; pointer-events: none; }

.col-title {
  position: absolute; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}

.card {
  position: absolute; width: 230px; padding: 12px 13px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r);
  box-shadow: var(--shadow-1); cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow-2); }
.card.dim { opacity: .28; }
.card.issue { border-left: 4px solid var(--issue); }
.card.new { border-left: 4px solid var(--new); }
.card.existing { border-left: 4px solid var(--accent); }

.card h4 { margin: 0 0 3px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.card code { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.card .row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgb(118 118 128 / 12%); color: var(--ink-2);
}
.tag.new { background: var(--new-soft); color: var(--new); }
.tag.issue { background: var(--issue-soft); color: var(--issue); }
.tag.core { background: var(--accent-soft); color: var(--accent); }
.tag.cmt { background: #fff4d6; color: #8a5200; }

/* ------------------------------------------------------------ drawer --- */

#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw;
  background: var(--panel); box-shadow: -18px 0 50px rgb(0 0 0 / 14%);
  transform: translateX(102%); transition: transform .22s cubic-bezier(.16,.84,.44,1);
  display: flex; flex-direction: column; z-index: 60;
}
#drawer.on { transform: none; }
.d-head { padding: 18px 20px 12px; box-shadow: 0 0.5px 0 var(--line); }
.d-head h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.02em; }
.d-head .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.d-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
  border: 0; border-radius: 50%; background: rgb(118 118 128 / 12%); cursor: pointer;
}
.d-body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; }
.d-body h5 {
  margin: 18px 0 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.d-body h5:first-child { margin-top: 0; }
.d-body p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.d-body ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.d-body li { margin-bottom: 6px; }
.links { display: flex; flex-direction: column; gap: 4px; }
.links button {
  text-align: left; border: 0; background: rgb(118 118 128 / 8%);
  border-radius: 9px; padding: 8px 10px; font-size: 13px; cursor: pointer;
}
.links button:hover { background: var(--accent-soft); }
.links small { color: var(--muted); }

.cmt-list { display: flex; flex-direction: column; gap: 8px; }
.cmt {
  padding: 10px 12px; border-radius: 12px; background: rgb(118 118 128 / 7%);
  font-size: 13.5px; line-height: 1.5;
}
.cmt b { font-size: 12.5px; }
.cmt time { float: right; font-size: 11px; color: var(--muted); }
.cmt .del { float: right; margin-left: 8px; border: 0; background: none; color: var(--issue); cursor: pointer; font-size: 11px; }
.cmt p { margin: 4px 0 0; color: var(--ink); }

.cmt-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cmt-form input, .cmt-form textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff;
}
.cmt-form textarea { min-height: 78px; resize: vertical; }
.cmt-form input:focus, .cmt-form textarea:focus { outline: none; border-color: var(--accent); }
.btn {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 11px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: rgb(118 118 128 / 12%); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------- overview -- */

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 20px 60px; }
.lede { font-size: 16px; line-height: 1.6; color: var(--ink-2); max-width: 70ch; }
.lede strong { color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 18px 0 8px; }
.stat { background: var(--panel); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow-1); }
.stat b { display: block; font-size: 26px; letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--muted); }
.card-block { background: var(--panel); border-radius: 18px; padding: 20px; box-shadow: var(--shadow-1); margin-top: 18px; }
.card-block h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.02em; }
.card-block > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
#mind { width: 100%; height: auto; }
#mind text { font-family: var(--font); }
#mind .mnode { cursor: pointer; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); position: sticky; top: 0; background: #fff; }
tbody tr:hover { background: rgb(118 118 128 / 5%); }
td.acts button { border: 0; background: rgb(118 118 128 / 10%); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 12px; }

.zoom { position: fixed; right: 18px; bottom: 18px; display: flex; gap: 6px; z-index: 35; }
.zoom button {
  width: 38px; height: 38px; border: 0; border-radius: 10px; background: #fff;
  box-shadow: var(--shadow-1); cursor: pointer; font-size: 16px;
}

@media (max-width: 760px) {
  .legend, .brand small { display: none; }
  .search { width: 130px; }
  #drawer { width: 100%; }
}
