:root {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-card: #161a23;
  --border: #262b38;
  --text: #e6e8ee;
  --text-soft: #9aa1b2;
  --text-faint: #666e82;
  --accent: #6ea8fe;
  --accent-soft: #2a3752;
  --green: #57c785;
  --green-soft: #17301f;
  --amber: #e0b24c;
  --amber-soft: #332a12;
  --red: #e0605a;
  --red-soft: #331616;
  --purple: #a48cf0;
  --purple-soft: #241f3a;

  /* 6(+1)-stage project model colors, tuned for AA-ish contrast on the
     dark card/section backgrounds above (soft = translucent chip/section
     background, solid = dot/swatch color matching the spec hues). */
  --stage-idea: #9ca3af;       --stage-idea-solid: #6b7280;     --stage-idea-soft: rgba(107, 114, 128, 0.18);
  --stage-planned: #60a5fa;    --stage-planned-solid: #3b82f6;  --stage-planned-soft: rgba(59, 130, 246, 0.16);
  --stage-building: #4ade80;   --stage-building-solid: #22c55e; --stage-building-soft: rgba(34, 197, 94, 0.16);
  --stage-blocked: #fbbf24;    --stage-blocked-solid: #f59e0b;  --stage-blocked-soft: rgba(245, 158, 11, 0.16);
  --stage-shipped: #2dd4bf;    --stage-shipped-solid: #14b8a6;  --stage-shipped-soft: rgba(20, 184, 166, 0.16);
  --stage-paused: #9aa1ae;     --stage-paused-solid: #4b5563;   --stage-paused-soft: rgba(75, 85, 99, 0.22);
  --stage-archived: #7b8296;   --stage-archived-solid: #374151; --stage-archived-soft: rgba(55, 65, 81, 0.22);

  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-dot { color: var(--accent); }
.brand-sub {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar-nav { margin-left: auto; display: flex; gap: 14px; }
.topbar-link { font-size: 13px; color: var(--text-soft); }
.topbar-link:hover { color: var(--accent); text-decoration: none; }
.topbar-link-active { color: var(--accent); }

main {
  flex: 1;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
}

.footer {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12.5px;
}

/* Index */

.hero { margin-bottom: 28px; }
.hero h1 { font-size: 30px; margin: 0 0 6px; }
.hero-sub { color: var(--text-soft); margin: 0; font-size: 14.5px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-name { font-size: 17px; margin: 0; }
.card-summary { margin: 0; color: var(--text-soft); font-size: 13.5px; line-height: 1.5; flex: 1; }
.card-meta { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.card-phase { color: var(--text-faint); }
.card-next-label { color: var(--text-faint); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; margin-right: 4px; }
.card-next { color: var(--text-soft); }

.card-live {
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.card-live[hidden] { display: none; }
.card-live-start { color: var(--accent); border-color: var(--accent-soft); }
.card-live-done { color: var(--green); border-color: var(--green-soft); }
.card-live-blocked { color: var(--red); border-color: var(--red-soft); }
.card-live-note, .card-live-heartbeat { color: var(--text-faint); font-style: italic; }

.card-bottom { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.card-progress { height: 5px; border-radius: 4px; background: var(--bg-elevated); overflow: hidden; }
.card-progress-bar { height: 100%; background: var(--green); }
.card-progress-label { font-size: 11px; color: var(--text-faint); }

/* Session summary (quiet header line) + per-card "working now" pulse */

.session-summary {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}
.session-summary[hidden] { display: none; }

.card-top-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.card-pulse {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stage-building);
}
.card-pulse[hidden] { display: none; }
.card-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stage-building-solid);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: session-pulse 1.6s infinite;
}

@keyframes session-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Stage sections (index grouping) */

.stage-section { margin-bottom: 30px; }
.stage-section:last-child { margin-bottom: 0; }
.stage-section-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.stage-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.stage-dot-idea { background: var(--stage-idea-solid); }
.stage-dot-planned { background: var(--stage-planned-solid); }
.stage-dot-building { background: var(--stage-building-solid); }
.stage-dot-blocked { background: var(--stage-blocked-solid); }
.stage-dot-shipped { background: var(--stage-shipped-solid); }
.stage-dot-paused { background: var(--stage-paused-solid); }
.stage-dot-archived { background: var(--stage-archived-solid); }
.stage-name { text-transform: uppercase; letter-spacing: 0.05em; font-size: 12.5px; }
.stage-count { color: var(--text-faint); font-weight: 400; font-size: 12.5px; }

/* Git status chip (Phase 3.5) */

.card-git {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.card-git[hidden] { display: none; }
.project-git {
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}
.project-git[hidden] { display: none; }
.git-branch { color: var(--text-soft); font-family: 'JetBrains Mono', Consolas, monospace; }
.git-clean { color: var(--green); }
.git-dirty { color: var(--amber); }
.git-aheadbehind { color: var(--accent); }
.git-commit { color: var(--text-faint); }
.git-github-link { color: var(--accent); cursor: pointer; }
.git-github-link:hover { text-decoration: underline; }
.git-no-remote { color: var(--text-faint); font-style: italic; }
.git-sep { color: var(--border); }

/* Chips */

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.chip-project-idea { background: var(--stage-idea-soft); color: var(--stage-idea); }
.chip-project-planned { background: var(--stage-planned-soft); color: var(--stage-planned); }
.chip-project-building { background: var(--stage-building-soft); color: var(--stage-building); }
.chip-project-blocked { background: var(--stage-blocked-soft); color: var(--stage-blocked); }
.chip-project-shipped { background: var(--stage-shipped-soft); color: var(--stage-shipped); }
.chip-project-paused { background: var(--stage-paused-soft); color: var(--stage-paused); }
.chip-project-archived { background: var(--stage-archived-soft); color: var(--stage-archived); }

.chip-feature-done { background: var(--green-soft); color: var(--green); }
.chip-feature-doing { background: var(--amber-soft); color: var(--amber); }
.chip-feature-ahead { background: var(--purple-soft); color: var(--purple); }

/* Project page */

.project-header { margin-bottom: 26px; }
.project-header-top { display: flex; align-items: center; gap: 12px; }
.project-header-top h1 { margin: 0; font-size: 28px; }
.project-summary { color: var(--text-soft); font-size: 15px; margin: 10px 0 4px; }
.project-phase { color: var(--text-faint); font-size: 13px; margin: 0 0 8px; }
.project-links { font-size: 13px; margin-bottom: 6px; }
.link-static { color: var(--text-faint); }
.project-updated { color: var(--text-faint); font-size: 12px; }

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}
.board-col {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}
.board-col-title {
  margin: 0 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
}
.board-col-count { color: var(--text-faint); }
.empty { color: var(--text-faint); font-size: 13px; font-style: italic; margin: 0; }

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.feature-card:hover { border-color: var(--accent); }
.feature-card-top h4 { margin: 0; font-size: 14px; }
.feature-desc { color: var(--text-soft); font-size: 12.5px; margin: 6px 0; line-height: 1.4; }
.feature-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.feature-tag {
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 100px;
}
.feature-tag-models { color: var(--accent); }

.gantt-section { margin-top: 30px; }
.gantt-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }

.gantt-chart {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow-x: auto;
}
.gantt-chart:empty { display: none; }
.gantt-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  background: var(--bg-elevated);
  margin: 0;
}

/* Gantt bar colors by feature status (attribute-contains selectors, since
   frappe-gantt assigns a single custom_class token per bar). */
.gantt .bar-wrapper[class*="bar-status-done"] .bar { fill: var(--green); }
.gantt .bar-wrapper[class*="bar-status-done"] .bar-progress { fill: var(--green); opacity: 0.6; }
.gantt .bar-wrapper[class*="bar-status-doing"] .bar { fill: var(--amber); }
.gantt .bar-wrapper[class*="bar-status-doing"] .bar-progress { fill: var(--amber); opacity: 0.6; }
.gantt .bar-wrapper[class*="bar-status-ahead"] .bar { fill: var(--purple); }
.gantt .bar-wrapper[class*="bar-status-ahead"] .bar-progress { fill: var(--purple); opacity: 0.6; }
.gantt .bar-wrapper[class*="-estimated"] .bar { stroke: var(--text-faint); stroke-width: 1.5; stroke-dasharray: 4 3; }
.gantt .bar-wrapper[class*="-drift"] .bar { stroke: var(--red); stroke-width: 2; }
.gantt .bar-label { fill: #0b0d12; font-weight: 600; }

/* Timeline page */
.timeline-sections { display: flex; flex-direction: column; gap: 26px; margin-top: 10px; }
.timeline-project-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin: 0 0 8px;
}
.timeline-project-title a { color: var(--text); }
.timeline-project-title a:hover { color: var(--accent); }

/* Plan-drift / estimated-date badges */
.drift-badge, .estimate-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 100px;
  vertical-align: middle;
}
.drift-badge { background: var(--red-soft); color: var(--red); }
.estimate-badge { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-faint); }
.drawer-drift-note { color: var(--text-soft); font-size: 12.5px; }

/* Activity feed */

.activity-section { margin-top: 30px; }
.activity-section[hidden] { display: none; }
.activity-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
.activity-feed { display: flex; flex-direction: column; gap: 8px; }
.activity-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
}
.activity-when { color: var(--text-faint); font-size: 11.5px; min-width: 52px; }
.activity-glyph { width: 16px; text-align: center; }
.activity-glyph-start { color: var(--accent); }
.activity-glyph-done { color: var(--green); }
.activity-glyph-blocked { color: var(--red); }
.activity-glyph-note, .activity-glyph-heartbeat { color: var(--text-faint); }
.activity-body { color: var(--text-soft); flex: 1; }
.activity-body b { color: var(--text); font-weight: 600; }
.activity-tag { color: var(--text-faint); font-size: 11px; }

/* Drawer */

.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 92vw);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 26px;
  overflow-y: auto;
}
.drawer-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  color: var(--text-soft);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.drawer-close:hover { color: var(--text); }
.drawer-panel h2 { margin: 0 20px 6px 0; font-size: 19px; }
.drawer-section { margin-top: 18px; }
.drawer-section h5 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.drawer-detail { color: var(--text-soft); font-size: 13.5px; line-height: 1.6; white-space: pre-line; }
.drawer-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-soft);
}
.stat-pill b { color: var(--text); display: block; font-size: 13px; }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task { font-size: 13px; color: var(--text-soft); display: flex; gap: 8px; align-items: flex-start; }
.task-check { color: var(--text-faint); }
.task-done { color: var(--text-faint); text-decoration: line-through; }
.task-done .task-check { color: var(--green); }

@media (max-width: 760px) {
  .board { grid-template-columns: 1fr; }
  main { padding: 20px; }
}
