:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #17201c;
  --muted: #65716d;
  --line: #dce3df;
  --accent: #2364aa;
  --accent-2: #2f7d57;
  --warn: #a06418;
  --danger: #a43d3d;
  --graph-artifact: #7657a8;
  --graph-mail: #b06c2f;
  --shadow: 0 10px 30px rgba(20, 32, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(78px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto 14px;
  max-width: 920px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.25;
}

p {
  margin: 0;
}

.content {
  display: grid;
  gap: 12px;
  max-width: 920px;
  margin: 0 auto;
}

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

.metric {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.state-panel,
.section,
.search-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.state-panel p,
.empty {
  color: var(--muted);
  line-height: 1.45;
}

.assistant-panel {
  display: grid;
  gap: 13px;
  padding: 15px;
  border-radius: 8px;
  background: #17201c;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.assistant-panel .eyebrow {
  color: rgba(255, 255, 255, 0.68);
}

.assistant-panel h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.assistant-status {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.assistant-comment {
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.45;
}

.next-actions {
  display: grid;
  gap: 9px;
}

.assistant-action {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.assistant-action-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.assistant-action-body {
  min-width: 0;
}

.assistant-action h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.assistant-action p {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  line-height: 1.38;
}

.assistant-action-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.assistant-action-details span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  line-height: 1.2;
}

.assistant-action-buttons {
  margin-top: 9px;
}

.digest {
  white-space: pre-wrap;
  color: var(--text);
  font-size: 14px;
  line-height: 1.42;
}

.compact-digest {
  color: var(--muted);
}

.list {
  display: grid;
  gap: 10px;
}

.event-card,
.project-row {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.event-card.is-done,
.event-card.is-archived {
  opacity: 0.62;
}

.event-card.compact {
  gap: 7px;
  padding: 10px;
  box-shadow: none;
}

.event-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.event-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
}

.entity-list {
  display: grid;
  gap: 8px;
}

.entity-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.entity-row strong {
  font-size: 14px;
  line-height: 1.25;
}

.entity-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.pill.due {
  background: #fff1dc;
  color: var(--warn);
}

.pill.important {
  background: #e4f3eb;
  color: var(--accent-2);
}

.pill.status {
  background: #e8eef7;
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.button,
.action-button,
.icon-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.button,
.action-button {
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 650;
}

.icon-button {
  width: 42px;
  height: 42px;
  font-size: 20px;
}

.button.primary,
.action-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.danger,
.action-button.danger {
  border-color: #ead0d0;
  color: var(--danger);
}

.button:disabled,
.action-button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.project-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.project-name {
  display: block;
  margin: 0 0 5px;
  font-size: 15px;
}

.project-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.project-counts {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.project-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
}

.project-hero .eyebrow,
.project-hero .pill {
  color: rgba(255, 255, 255, 0.78);
}

.project-hero .pill {
  background: rgba(255, 255, 255, 0.12);
}

.project-section {
  box-shadow: none;
}

.compact-list {
  gap: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-row input,
.chat-row input {
  min-height: 40px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.chat-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-messages {
  display: grid;
  gap: 8px;
}

.chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.42;
}

.chat-message.assistant {
  justify-self: start;
  background: var(--surface-2);
  color: var(--text);
}

.chat-message.user {
  justify-self: end;
  background: var(--accent);
  color: #ffffff;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.project-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
}

.graph-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.graph-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
}

.graph-project-control {
  display: grid;
  gap: 4px;
  min-width: 190px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.graph-project-control select {
  min-height: 36px;
  padding: 6px 30px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.graph-stats {
  flex: 1 1 auto;
  padding-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.graph-stage {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  border-radius: 8px;
  background-color: var(--surface-2);
  background-image: radial-gradient(circle, rgba(101, 113, 109, 0.18) 1px, transparent 1px);
  background-size: 18px 18px;
  touch-action: none;
}

.knowledge-graph {
  display: block;
  width: 100%;
  height: 540px;
  cursor: grab;
  user-select: none;
}

.knowledge-graph:active {
  cursor: grabbing;
}

.graph-background {
  fill: transparent;
}

.graph-link {
  stroke: var(--line);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  transition: opacity 160ms ease, stroke 160ms ease, stroke-width 160ms ease;
}

.graph-link--event {
  stroke: var(--muted);
  stroke-dasharray: 4 4;
  opacity: 0.62;
}

.graph-link.is-connected {
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.9;
}

.graph-link.is-muted {
  opacity: 0.1;
}

.graph-node {
  cursor: pointer;
  transition: opacity 160ms ease;
}

.graph-node__halo {
  fill: none;
  stroke: transparent;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.graph-node__circle {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.graph-node--project .graph-node__circle {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2.4;
}

.graph-node--person .graph-node__circle {
  fill: var(--accent-2);
  stroke: var(--surface);
  stroke-width: 2;
}

.graph-node--repository .graph-node__circle,
.graph-node--file .graph-node__circle {
  fill: var(--graph-artifact);
  stroke: var(--surface);
  stroke-width: 2;
}

.graph-node--mail .graph-node__circle {
  fill: var(--graph-mail);
  stroke: var(--surface);
  stroke-width: 2;
}

.graph-node--entity .graph-node__circle {
  fill: var(--muted);
  stroke: var(--surface);
  stroke-width: 2;
}

.graph-node.is-selected .graph-node__halo {
  stroke: var(--accent);
}

.graph-node.is-neighbor .graph-node__halo {
  stroke: rgba(35, 100, 170, 0.35);
}

.graph-node.is-muted {
  opacity: 0.16;
}

.graph-node__label {
  display: none;
  fill: var(--text);
  stroke: var(--surface-2);
  stroke-width: 4px;
  paint-order: stroke;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.graph-node__label.is-visible,
.graph-node__label.is-context {
  display: block;
}

.graph-node.is-muted .graph-node__label {
  display: none;
}

.graph-tooltip {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 3px;
  width: min(210px, calc(100% - 16px));
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.graph-tooltip[hidden] {
  display: none;
}

.graph-tooltip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.graph-tooltip span {
  color: var(--muted);
  font-size: 11px;
}

.graph-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 28px;
  text-align: center;
}

.graph-message strong {
  font-size: 16px;
}

.graph-message span {
  color: var(--muted);
  font-size: 13px;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 11px;
}

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

.graph-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.graph-legend__dot--project {
  background: var(--accent);
}

.graph-legend__dot--event {
  border: 1.5px solid var(--text);
  background: var(--surface);
}

.graph-legend__dot--person {
  background: var(--accent-2);
}

.graph-legend__dot--artifact {
  background: var(--graph-artifact);
}

.graph-selection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.graph-selection__hint {
  color: var(--muted);
  font-size: 13px;
}

.graph-selection__copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.graph-selection__copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.graph-selection__copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.graph-selection__type {
  color: var(--accent) !important;
  font-size: 10px !important;
  font-weight: 800;
  text-transform: uppercase;
}

.graph-selection__actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.94);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 2px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.1;
}

.tab.active {
  background: var(--text);
  color: #ffffff;
}

@media (max-width: 520px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric {
    min-height: 70px;
    padding: 10px;
  }

  .metric strong {
    font-size: 19px;
  }

  .project-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-counts {
    justify-content: flex-start;
  }

  .graph-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .graph-project-control {
    flex: 1 1 170px;
    min-width: 0;
  }

  .graph-stats {
    order: 3;
    flex-basis: 100%;
    padding: 0;
  }

  .graph-stage,
  .knowledge-graph {
    min-height: 460px;
    height: 460px;
  }

  .graph-selection {
    align-items: stretch;
    flex-direction: column;
  }

  .graph-selection__actions {
    flex-wrap: wrap;
  }
}
