:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #6366f1;
  --accent-2: #a78bfa;
  --border: #e5e7eb;
  --good: #10b981;
  /* カテゴリ別カラー */
  --cat-root: #f59e0b;
  --cat-agents: #6366f1;
  --cat-skills: #10b981;
  --cat-commands: #ec4899;
  --cat-workflows: #8b5cf6;
  --cat-other: #9ca3af;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d23;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #818cf8;
    --accent-2: #c4b5fd;
    --border: #2d3138;
    --good: #34d399;
    --cat-root: #fbbf24;
    --cat-agents: #818cf8;
    --cat-skills: #34d399;
    --cat-commands: #f472b6;
    --cat-workflows: #a78bfa;
    --cat-other: #9ca3af;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 32px 24px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  font-size: 12px;
}

.status.ok {
  background: color-mix(in srgb, var(--good) 25%, transparent);
  color: var(--good);
}

.status.err {
  background: #fee2e2;
  color: #b91c1c;
}

main {
  padding: 16px 24px 48px;
  max-width: 1100px;
  margin: 0 auto;
}

h2 {
  margin: 32px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.stat-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.chart-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  font-size: 13px;
}

#chart {
  width: 100%;
  height: 220px;
  display: block;
}

#chart .bar {
  fill: var(--accent);
  transition: opacity 0.15s;
}

#chart .bar:hover {
  fill: var(--accent-2);
}

#chart .bar-label {
  font-size: 10px;
  fill: var(--muted);
}

#chart .grid-line {
  stroke: var(--border);
  stroke-dasharray: 2 4;
}

.commit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.commit-list li {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.commit-list li:last-child {
  border-bottom: none;
}

.commit-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

.commit-pager:empty {
  display: none;
}

.pager-btn {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.pager-btn:hover:not(:disabled) {
  border-color: var(--muted);
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pager-info {
  font-size: 13px;
  color: var(--muted);
}

.commit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  flex-wrap: wrap;
}

.commit-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 10px;
}

.commit-meta a {
  color: var(--muted);
  text-decoration: none;
}

.commit-meta a:hover {
  color: var(--accent);
}

.commit-host {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.commit-summary {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
}

.commit-summary.loading {
  color: var(--muted);
  font-style: italic;
  border-left-color: var(--border);
}

.commit-stats {
  margin-left: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

.commit-stats .add {
  color: var(--good);
}

.commit-stats .del {
  color: #ef4444;
}

.commit-files {
  margin-top: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.commit-files .file {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  margin: 2px 4px 2px 0;
}

/* ===== 設定の中身（分類）===== */
.section-hint {
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.config-contents {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 起動タイプの凡例 */
.act-legend {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.act-legend-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.act-legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}

.act-badge {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.act-legend-desc {
  color: var(--muted);
  font-size: 12px;
}

.act-legend-row.act-always .act-badge {
  color: #1e6e3a;
  background: color-mix(in srgb, #1e6e3a 12%, transparent);
}
.act-legend-row.act-auto .act-badge {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.act-legend-row.act-manual .act-badge {
  color: #b45309;
  background: color-mix(in srgb, #b45309 16%, transparent);
}

/* 手動のみノードは控えめに強調（鍵アイコンは名前先頭に付く） */
.tree-name.act-manual {
  opacity: 0.92;
}

/* ディレクトリツリー表示 */
.tree {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
}

.tree-row {
  white-space: pre;
}

.tree-prefix {
  color: var(--muted);
  user-select: none;
}

.tree-name {
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  padding: 0 3px;
}

.tree-name.type-dir {
  font-weight: 700;
}

a.tree-name:hover {
  text-decoration: underline;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.tree-name.has-tip {
  cursor: pointer;
}

/* カテゴリ別カラー（ディレクトリ/ファイル名） */
.tree-name.cat-root { color: var(--cat-root); }
.tree-name.cat-agents { color: var(--cat-agents); }
.tree-name.cat-skills { color: var(--cat-skills); }
.tree-name.cat-commands { color: var(--cat-commands); }
.tree-name.cat-workflows { color: var(--cat-workflows); }

/* tooltip を持つ要素 */
.has-tip {
  cursor: help;
}
a.has-tip {
  cursor: pointer;
}

/* commit のファイル chip もカテゴリ色分け */
.commit-files .file.cat-root { border-left: 3px solid var(--cat-root); }
.commit-files .file.cat-agents { border-left: 3px solid var(--cat-agents); }
.commit-files .file.cat-skills { border-left: 3px solid var(--cat-skills); }
.commit-files .file.cat-commands { border-left: 3px solid var(--cat-commands); }
.commit-files .file.cat-workflows { border-left: 3px solid var(--cat-workflows); }
.commit-files .file.cat-other { border-left: 3px solid var(--cat-other); }

/* ===== Floating tooltip ===== */
.floating-tip {
  position: absolute;
  z-index: 1000;
  min-width: 200px;
  max-width: 340px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", system-ui, sans-serif;
}

.floating-tip .tip-cat {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--cat-other);
}
.floating-tip .tip-cat.cat-root { color: var(--cat-root); }
.floating-tip .tip-cat.cat-agents { color: var(--cat-agents); }
.floating-tip .tip-cat.cat-skills { color: var(--cat-skills); }
.floating-tip .tip-cat.cat-commands { color: var(--cat-commands); }
.floating-tip .tip-cat.cat-workflows { color: var(--cat-workflows); }

.floating-tip .tip-path {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
  word-break: break-all;
}

/* tooltip: 起動タイプ */
.floating-tip .tip-act {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}
.floating-tip .tip-act.act-always { color: #1e6e3a; }
.floating-tip .tip-act.act-auto { color: var(--accent); }
.floating-tip .tip-act.act-manual { color: #b45309; }

/* Hermes harness engineering カテゴリのバッジ */
.floating-tip .tip-hermes {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
}
.floating-tip .tip-hermes.hermes-context {
  color: #2563eb;
  background: color-mix(in srgb, #2563eb 12%, transparent);
}
.floating-tip .tip-hermes.hermes-tool {
  color: #059669;
  background: color-mix(in srgb, #059669 12%, transparent);
}
.floating-tip .tip-hermes.hermes-evaluation {
  color: #d97706;
  background: color-mix(in srgb, #d97706 12%, transparent);
}
.floating-tip .tip-hermes.hermes-orchestration {
  color: #7c3aed;
  background: color-mix(in srgb, #7c3aed 12%, transparent);
}

.floating-tip .tip-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.floating-tip .tip-row b {
  flex: 0 0 auto;
  min-width: 3em;
  color: var(--muted);
  font-weight: 600;
}

.floating-tip .tip-na {
  color: var(--muted);
  font-style: italic;
}

footer {
  max-width: 1100px;
  margin: 24px auto 32px;
  padding: 0 24px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

footer button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}

footer button:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* ===== Harness Engineering 分類マトリクス ===== */
.hermes-matrix {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}

@media (max-width: 720px) {
  .hermes-matrix {
    grid-template-columns: 1fr;
  }
}

.herm-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--hc, var(--muted));
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.herm-agent-loop { --hc: #ef4444; }
.herm-planning { --hc: #6366f1; }
.herm-context { --hc: #0ea5e9; }
.herm-tool-design { --hc: #f59e0b; }
.herm-skills-mcp { --hc: #10b981; }
.herm-permissions { --hc: #e11d48; }
.herm-memory { --hc: #14b8a6; }
.herm-orchestration { --hc: #8b5cf6; }
.herm-verification { --hc: #ec4899; }
.herm-observability { --hc: #22c55e; }
.herm-debugging { --hc: #f97316; }
.herm-human-loop { --hc: #64748b; }

.herm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.herm-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--hc);
  line-height: 1.3;
  text-decoration: none;
}

.herm-title:hover {
  text-decoration: underline;
}

.herm-count {
  flex: none;
  min-width: 22px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--hc);
  background: color-mix(in srgb, var(--hc) 14%, transparent);
  border-radius: 999px;
  padding: 1px 7px;
}

.herm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}

.herm-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--cat, var(--muted));
  text-decoration: none;
  background: var(--bg);
  cursor: pointer;
}

.herm-item:hover {
  border-color: var(--hc);
}

.herm-item.cat-agents { --cat: var(--cat-agents); }
.herm-item.cat-skills { --cat: var(--cat-skills); }
.herm-item.cat-commands { --cat: var(--cat-commands); }
.herm-item.cat-workflows { --cat: var(--cat-workflows); }
.herm-item.cat-root { --cat: var(--cat-root); }
.herm-item.cat-other { --cat: var(--cat-other); }

.herm-item-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

.herm-item-cat {
  font-size: 10.5px;
  color: var(--muted);
}

.herm-empty {
  color: var(--muted);
  text-align: center;
  padding: 10px 0;
}

/* ===== V字開発モード分類 パネル（Harness matrix のスタイルを再利用しフェーズ色を追加）===== */
.hermes-matrix .vm-plan .herm-head { border-left: 3px solid #3b82f6; }        /* 計画・設計 */
.hermes-matrix .vm-do .herm-head { border-left: 3px solid #f59e0b; }          /* 実装・単体 */
.hermes-matrix .vm-check .herm-head { border-left: 3px solid #10b981; }       /* 検証 */
.hermes-matrix .vm-act .herm-head { border-left: 3px solid #8b5cf6; }         /* 改善 */
.hermes-matrix .vm-orchestrate .herm-head { border-left: 3px solid #6b7280; } /* 統括 */
.hermes-matrix [class^="vm-"] .herm-head, .hermes-matrix [class*=" vm-"] .herm-head { padding-left: 8px; }
