:root {
  color-scheme: light;
  --bg: #f8f7f2;
  --paper: #fffdf7;
  --ink: #222;
  --muted: #76716a;
  --line: #2f2f2b;
  --line-soft: #d8d0c2;
  --done: #3f8f6b;
  --doing: #2c73d2;
  --todo: #a49c90;
  --blocked: #c94c3b;
  --sprint: #f2b84b;
  --shadow: 0 14px 30px rgba(40, 35, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,0.58), rgba(255,255,255,0.58)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(70,60,45,0.035) 24px),
    var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

button,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 24px 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

select,
button {
  min-height: 36px;
  border: 1px solid #d5cdbf;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
}

button {
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 0 24px 16px;
}

.map-panel,
.side-panel,
.people-panel {
  min-width: 0;
}

.map-panel,
.summary-card,
.people-panel {
  border: 1px solid #ddd5c8;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
}

.map-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
  border-bottom: 1px dashed #d9d0c2;
}

#projectSubtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--todo);
}

.dot.done { background: var(--done); }
.dot.doing { background: var(--doing); }
.dot.todo { background: var(--todo); }

.line {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 3px;
  background: var(--line-soft);
}

.line.sprint {
  background: var(--sprint);
}

.graph-viewport {
  width: 100%;
  height: calc(100vh - 420px);
  min-height: 380px;
  overflow: auto;
  overscroll-behavior: contain;
}

.graph-canvas {
  position: relative;
  min-width: 980px;
  min-height: 600px;
  transform-origin: top left;
}

.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

.edge-layer {
  overflow: visible;
}

.edge {
  fill: none;
  stroke: var(--line-soft);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edge.sprint {
  stroke: var(--sprint);
  stroke-width: 4;
}

.edge.blocked {
  stroke: var(--blocked);
}

.node-card {
  position: absolute;
  width: 140px;
  height: 58px;
  border: 1.5px solid #cfc5b6;
  border-radius: 8px;
  background: #fffefb;
  padding: 7px 8px;
  box-shadow: 0 8px 16px rgba(35, 30, 20, 0.06);
  overflow: hidden;
}

.node-card::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--todo);
}

.node-card.done {
  opacity: 0.58;
}

.node-card.done::before {
  background: var(--done);
}

.node-card.doing {
  border-color: #8ab4ef;
  box-shadow: 0 0 0 3px rgba(44, 115, 210, 0.11), 0 8px 16px rgba(35, 30, 20, 0.06);
}

.node-card.doing::before {
  background: var(--doing);
}

.node-card.sprint {
  border-color: #e7b84f;
  background: #fff9e8;
  box-shadow: 0 0 0 3px rgba(242, 184, 75, 0.16), 0 8px 16px rgba(35, 30, 20, 0.06);
}

.node-card.milestone {
  background: #fbfbf2;
  border-style: dashed;
}

.node-id {
  display: block;
  margin-left: 14px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.node-owner {
  position: absolute;
  top: 7px;
  right: 8px;
  max-width: 48px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-title {
  display: -webkit-box;
  margin: 4px 0 0;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.28;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node-note {
  display: none;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: absolute;
  right: 8px;
  bottom: 5px;
  left: 8px;
  color: var(--muted);
  font-size: 9px;
}

.status-text {
  opacity: 0.9;
}

.sprint-mark {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--sprint);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  border: 1px solid #ddd5c8;
  border-radius: 999px;
  padding: 0 6px;
  background: #fff;
  white-space: nowrap;
}

.badge.sprint-badge {
  border-color: #eac46f;
  background: #fff8df;
  color: #7c5b10;
}

.side-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.summary-card {
  max-height: 154px;
  overflow: auto;
  padding: 11px;
}

.summary-card h2 {
  position: sticky;
  top: -11px;
  z-index: 1;
  margin: -11px -11px 8px;
  border-bottom: 1px dashed #ded6c8;
  background: rgba(255, 253, 247, 0.96);
  padding: 10px 11px 8px;
}

.focus-list,
.compact-list {
  display: grid;
  gap: 8px;
}

.summary-row {
  display: grid;
  gap: 3px;
  border-top: 1px dashed #ded6c8;
  padding-top: 7px;
}

.summary-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.summary-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.summary-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.progress-stats {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: grid;
  gap: 4px;
}

.stat-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.stat-label span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.stat-bar {
  height: 7px;
  overflow: hidden;
  border: 1px solid #ddd5c8;
  border-radius: 999px;
  background: #f1ece2;
}

.stat-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stat-fill.done { background: var(--done); }
.stat-fill.doing { background: var(--doing); }
.stat-fill.todo { background: var(--todo); }

.people-panel {
  margin: 0;
  border-width: 1px 0 0;
  border-radius: 0 0 8px 8px;
  box-shadow: none;
  padding: 10px 16px 12px;
}

.people-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.people-header p {
  color: var(--muted);
  font-size: 12px;
}

.people-lanes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.lane {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lane-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.lane-track {
  position: relative;
  min-height: 28px;
  border-top: 2px solid #ddd5c8;
  min-width: 0;
  overflow: hidden;
}

.lane-task {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  margin-top: -13px;
  border: 1px solid #d6cdbf;
  border-radius: 999px;
  background: #fffefb;
  padding: 0 8px;
  font-size: 11px;
  white-space: nowrap;
}

.lane-task.current {
  border-color: #8ab4ef;
  background: #eef6ff;
}

.empty-lane {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 920px) {
  .app-header,
  .map-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .graph-viewport {
    height: 620px;
  }

  .people-panel {
    margin-inline: 16px;
  }

  .people-lanes {
    grid-template-columns: 1fr;
  }
}
