:root {
  --bg: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-card-hover: #252525;
  --fg: #f5f5f5;
  --fg-dim: #a3a3a3;
  --border: #333;
  --accent: #f59e0b;
  --master: #3b82f6;
  --slave: #10b981;
  --status-done: #10b981;
  --status-in-progress: #f59e0b;
  --status-blocked: #ef4444;
  --status-not-started: #6b7280;
  --status-planning: #6b7280;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: rgba(0,0,0,0.4); padding: 1px 6px; border-radius: 3px; font-family: "SF Mono", Monaco, monospace; font-size: 11px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(8px);
  z-index: 100;
}
.brand-link { color: var(--fg); text-decoration: none !important; display: flex; align-items: baseline; gap: 8px; }
.brand-link:hover .logo { filter: brightness(1.2); }
.logo { font-size: 28px; font-weight: 700; color: var(--accent); }
.tag { font-size: 14px; color: var(--fg-dim); }

.countdown { text-align: right; }
.countdown .label { display: block; font-size: 11px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 1.5px; }
.countdown .value { font-size: 22px; font-weight: 700; color: var(--accent); font-family: "SF Mono", Monaco, monospace; }

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
}

section { margin-bottom: 48px; }
section h2 { font-size: 20px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ============ Overview: Architecture diagram ============ */

.hero { margin-bottom: 48px; }
.architecture-diagram { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.arch-svg { width: 100%; height: auto; max-height: 320px; }
.box { fill: var(--bg-card-hover); stroke-width: 1.5; }
.box.master { stroke: var(--master); }
.box.slave { stroke: var(--slave); }
.box.network { stroke: var(--accent); }
.box-title { fill: var(--fg); font-size: 16px; font-weight: 700; }
.box-item { fill: var(--fg-dim); font-size: 12px; }
.arrow { stroke: var(--accent); stroke-width: 2; }
.arrow-head { fill: var(--accent); }

/* ============ Stat row ============ */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center; }
.stat-card .num { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 11px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

/* ============ Module category grid ============ */

.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.category-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.category-card h3 { font-size: 16px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--cat-color, var(--accent)); }

.module-item {
  display: block;
  background: var(--bg-card-hover);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--fg);
  text-decoration: none !important;
}
.module-item:hover { background: #2f2f2f; }
.module-item .module-name { font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.module-item .module-meta { font-size: 11px; color: var(--fg-dim); display: flex; justify-content: space-between; align-items: center; }

.mini-bar { height: 3px; background: rgba(255,255,255,0.06); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--status-done); transition: width 0.3s; }

/* ============ Status pill ============ */

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
  white-space: nowrap;
}
.status-pill.done { background: var(--status-done); }
.status-pill.in-progress { background: var(--status-in-progress); }
.status-pill.blocked { background: var(--status-blocked); }
.status-pill.not-started { background: var(--status-not-started); }
.status-pill.planning { background: transparent; color: var(--fg-dim); border: 1px solid var(--border); }

/* ============ People grid ============ */

.people-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.person-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  color: var(--fg);
  text-decoration: none !important;
}
.person-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.person-card .avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 18px; margin-bottom: 12px; }
.person-card .name { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.person-card .role { font-size: 12px; color: var(--fg-dim); margin-bottom: 12px; }
.person-card .latest { font-size: 12px; color: var(--fg-dim); padding-top: 12px; border-top: 1px solid var(--border); line-height: 1.5; white-space: pre-wrap; }

/* ============ Risks grid ============ */

.risks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.risk-card { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--status-blocked); border-radius: 8px; padding: 16px; }
.risk-card.severity-high { border-left-color: var(--status-blocked); }
.risk-card.severity-med { border-left-color: var(--status-in-progress); }
.risk-card.severity-low { border-left-color: var(--fg-dim); }
.risk-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.risk-sev { display: inline-block; padding: 2px 8px; background: var(--status-blocked); color: white; font-size: 10px; font-weight: 700; border-radius: 4px; letter-spacing: 0.5px; }
.severity-med .risk-sev { background: var(--status-in-progress); }
.severity-low .risk-sev { background: var(--fg-dim); }
.risk-kr { font-size: 11px; color: var(--accent); font-family: "SF Mono", Monaco, monospace; }
.risk-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.risk-detail { font-size: 12px; color: var(--fg-dim); margin-bottom: 10px; white-space: pre-wrap; line-height: 1.5; }
.risk-meta { font-size: 11px; color: var(--fg-dim); border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.risk-meta strong { color: var(--fg); font-weight: 600; }

/* ============ Recent activity ============ */

.activity-list { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.activity-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-item:first-child { padding-top: 0; }
.activity-item .meta { font-size: 11px; color: var(--fg-dim); margin-bottom: 4px; }
.activity-item .meta .name { font-weight: 600; color: var(--accent); }
.activity-item .summary { font-size: 13px; white-space: pre-wrap; }
.activity-item .next-line { font-size: 12px; color: var(--fg-dim); margin-top: 6px; white-space: pre-wrap; }

/* ============ Breadcrumb (module/person page top nav) ============ */

.breadcrumb {
  font-size: 13px;
  color: var(--fg-dim);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--accent); }
.breadcrumb span:last-child { color: var(--fg); font-weight: 600; }
.cat-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: white;
  font-weight: 600;
}

/* ============ Module/Person detail header ============ */

.detail-header { margin-bottom: 32px; }
.detail-header h1 { font-size: 28px; margin-bottom: 12px; }
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: var(--fg-dim);
  margin-bottom: 12px;
}
.detail-meta strong { color: var(--fg); font-weight: 600; }

.progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--status-done), var(--accent));
  transition: width 0.3s;
}

.description {
  color: var(--fg-dim);
  margin: 12px 0;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
}
.description.warn {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  padding: 12px 14px;
  border-radius: 6px;
  border-left: 3px solid #fbbf24;
}

/* ============ Phase header ============ */

.phase-header {
  font-size: 14px;
  color: var(--fg-dim);
  margin: 24px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============ Milestone table ============ */

.milestone-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.milestone-table thead { background: var(--bg-card-hover); }
.milestone-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.milestone-table td {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.milestone-table tr { cursor: pointer; transition: background 0.15s; }
.milestone-table tbody tr:hover { background: var(--bg-card-hover); }
.milestone-table tr:last-child td { border-bottom: none; }

/* ============ Siblings grid ============ */

.siblings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.sibling-link {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  color: var(--fg);
  text-decoration: none !important;
  transition: border-color 0.15s;
}
.sibling-link:hover { border-color: var(--accent); }
.sibling-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.sibling-meta { font-size: 11px; color: var(--fg-dim); display: flex; justify-content: space-between; align-items: center; }

/* ============ Person page ============ */

.person-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 32px;
}
.person-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  font-weight: 700;
  flex-shrink: 0;
}
.person-header-text { flex: 1; }
.person-header-text h1 { font-size: 28px; margin-bottom: 4px; }
.person-role-large { color: var(--fg-dim); font-size: 14px; }

.my-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.my-module-link {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--fg);
  text-decoration: none !important;
  transition: border-color 0.15s;
}
.my-module-link:hover { border-color: var(--accent); }
.my-module-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.my-module-meta { font-size: 11px; color: var(--fg-dim); display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.my-module-prog { font-size: 11px; color: var(--fg-dim); margin-top: 4px; }

.updates-list { display: flex; flex-direction: column; gap: 12px; }
.update-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.update-date { font-weight: 600; color: var(--accent); margin-bottom: 8px; font-size: 14px; }
.update-summary { font-size: 13px; white-space: pre-wrap; margin-bottom: 8px; }
.update-next {
  font-size: 12px;
  color: var(--fg-dim);
  background: rgba(245, 158, 11, 0.05);
  padding: 8px 10px;
  border-radius: 4px;
  border-left: 2px solid var(--accent);
  white-space: pre-wrap;
}
.update-related { font-size: 11px; color: var(--fg-dim); margin-top: 8px; }

/* ============ Modal (milestone quick view) ============ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  width: 100%;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}
.modal-body h2 { margin-bottom: 8px; padding-bottom: 0; border-bottom: none; }

/* ============ Footer ============ */

footer {
  padding: 24px 32px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 12px;
}

@media (max-width: 640px) {
  header { padding: 16px; flex-direction: column; gap: 12px; align-items: flex-start; }
  main { padding: 16px; }
  .countdown .value { font-size: 18px; }
  .modal { padding: 12px; }
  .modal-content { padding: 24px 20px; }
  .person-header { flex-direction: column; gap: 16px; }
  .milestone-table { font-size: 12px; }
  .milestone-table th, .milestone-table td { padding: 8px; }
}
