:root {
  --bg: #0b0b0d;
  --panel: #161619;
  --panel-2: #1e1e23;
  --line: #2a2a30;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #ff5a1f;
  --passed: #22c55e;
  --pending: #f59e0b;
  --failed: #ef4444;
  --none: #52525b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-weight: 900;
  letter-spacing: 1px;
  background: var(--accent);
  color: #fff;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 14px;
}
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.who {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.who:active { transform: scale(0.97); }

/* Summary */
.summary {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 4px 0 20px;
}
.summary-num { display: flex; flex-direction: column; line-height: 1.1; }
.summary-num strong { font-size: 28px; color: var(--passed); }
.summary-num span { font-size: 12px; color: var(--muted); }
.summary-bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.summary-bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--passed), #4ade80); transition: width 0.4s; }
.summary-total { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Tree */
.tree {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 720px) {
  .tree { grid-template-columns: 1fr; }
}

.track {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 14px 10px;
}
.track h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.track h2::before {
  content: "";
  width: 8px; height: 20px;
  border-radius: 4px;
  background: var(--accent);
}

.nodes { position: relative; margin-left: 6px; }
.node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px 9px 0;
  cursor: pointer;
  border-radius: 10px;
}
.node:hover { background: var(--panel-2); }
.node:active { transform: scale(0.99); }
/* connector line */
.nodes::before {
  content: "";
  position: absolute;
  left: 11px; top: 12px; bottom: 12px;
  width: 2px;
  background: var(--line);
}
.node .dot {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--none);
  background: var(--none);
}
.node .name { flex: 1; font-size: 14px; }
.node .badge { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* status */
.dot.passed  { background: var(--passed); box-shadow: 0 0 0 2px var(--passed), 0 0 12px var(--passed); }
.dot.pending { background: var(--pending); box-shadow: 0 0 0 2px var(--pending); }
.dot.failed  { background: var(--failed); box-shadow: 0 0 0 2px var(--failed); }
.dot.none    { background: var(--none); box-shadow: 0 0 0 2px var(--none); }
.node.passed .name { color: var(--passed); font-weight: 700; }
.node.pending .badge { color: var(--pending); }
.node.failed .badge { color: var(--failed); }

/* legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin: 26px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 12px; height: 12px; border: none; }

/* Dialogs */
dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 18px;
  padding: 22px;
  width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 6px; font-size: 18px; }
.hint { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
dialog input[type=text], dialog textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
}
dialog textarea { min-height: 70px; resize: vertical; margin-top: 10px; }
.who-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.who-list:empty { display: none; }
.who-chip {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.who-chip:hover { border-color: var(--accent); }
.who-loading { color: var(--muted); font-size: 13px; }
.filepick {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.filepick input { display: none; }
.filepick.has-file { border-color: var(--accent); color: var(--text); }

dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
}
.btn-primary, .btn-ghost {
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }

/* toast */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%);
  background: #fff; color: #111;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 50;
}
