:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --paper: #ffffff;
  --ink: #202522;
  --muted: #66706a;
  --line: #dfe6dd;
  --line-strong: #b9c7bf;
  --green: #176b5b;
  --green-soft: #e3f2ed;
  --blue: #275d9f;
  --blue-soft: #e5eef8;
  --amber: #9b5f10;
  --amber-soft: #f8efd9;
  --rose: #9d3b4a;
  --rose-soft: #f7e3e7;
  --side: #1d2f29;
  --side-soft: #29423a;
  --shadow: 0 18px 50px rgba(30, 44, 38, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 107, 91, 0.05), transparent 28%),
    var(--bg);
  font-family: var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px;
  color: #edf6f1;
  background: var(--side);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  color: #102019;
  background: #b7e4d4;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: var(--radius);
  font-weight: 900;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 1.08rem;
  line-height: 1.2;
}

#profileLine {
  margin-top: 3px;
  color: #b8c9c1;
  font-size: 0.88rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.summary-cell {
  padding: 12px;
  background: var(--side-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
}

.summary-label {
  display: block;
  color: #b8c9c1;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.summary-cell strong {
  display: block;
  margin-top: 6px;
  color: #ffffff;
  font-size: 1.45rem;
}

.control-group {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

label,
.control-group label,
.wide-label span,
.field-grid span {
  color: inherit;
  font-size: 0.78rem;
  font-weight: 750;
}

.control-group label {
  color: #c8d9d1;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 110px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.16);
}

.owner-row,
.search-row {
  display: grid;
  align-items: center;
  gap: 8px;
}

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

.search-row {
  position: relative;
}

.search-row svg {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.search-row input {
  padding-left: 38px;
}

.icon-button,
.secondary-button,
.ghost-button,
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.icon-button.small {
  width: 36px;
  min-height: 36px;
}

.secondary-button {
  width: 100%;
  padding: 0 12px;
  color: #effaf5;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
}

.secondary-button.compact {
  width: auto;
  min-height: 38px;
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.07);
}

.secondary-button.compact:hover,
.secondary-button.compact:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--line-strong);
  background: #f5f8f5;
}

.side-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.main-area {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 38px);
}

.top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow,
.section-label {
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-strip h2 {
  margin-top: 4px;
  font-size: clamp(1.55rem, 2.5vw, 2.35rem);
  letter-spacing: 0;
}

.sync-pill,
.confidence-pill,
.count-pill,
.repo-status,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 780;
  white-space: nowrap;
}

.sync-pill {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #c5dfd5;
}

.sync-pill.error {
  color: var(--rose);
  background: var(--rose-soft);
  border-color: #e7b7c0;
}

.sync-pill.loading svg {
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.insight-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 24px;
  align-items: start;
  padding: 18px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.insight-copy p {
  max-width: 820px;
  margin-top: 8px;
  color: #3f4944;
  font-size: 1rem;
  line-height: 1.55;
}

.language-bars {
  display: grid;
  gap: 8px;
}

.language-row {
  display: grid;
  grid-template-columns: minmax(78px, 110px) minmax(80px, 1fr) 34px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  background: #e7ede8;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(360px, 0.78fr);
  gap: 22px;
  align-items: start;
  margin-top: 22px;
}

.project-column,
.detail-panel {
  min-width: 0;
}

.column-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.column-header h3 {
  margin-top: 3px;
  font-size: 1.05rem;
}

.ghost-button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  color: var(--ink);
  background: #ffffff;
}

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

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  width: 100%;
  min-height: 112px;
  padding: 15px;
  color: var(--ink);
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 0 rgba(31, 46, 40, 0.03);
}

.project-row:hover,
.project-row:focus-visible,
.project-row.selected {
  border-color: #9ccabd;
  box-shadow: 0 10px 24px rgba(23, 107, 91, 0.1);
}

.project-name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.repo-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.repo-status {
  color: var(--green);
  background: var(--green-soft);
}

.repo-status.Backlog,
.repo-status.Paused {
  color: var(--amber);
  background: var(--amber-soft);
}

.repo-status.Archived {
  color: var(--muted);
  background: #edf0ec;
}

.repo-status.Shipped {
  color: var(--blue);
  background: var(--blue-soft);
}

.repo-built {
  color: var(--muted);
  display: -webkit-box;
  min-height: 42px;
  overflow: hidden;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.repo-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  min-height: 24px;
  color: #48544e;
  background: #eef2ed;
  border: 1px solid #e0e7df;
}

.project-row-meta {
  display: grid;
  align-content: space-between;
  justify-items: end;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.repo-lang {
  color: var(--blue);
  font-weight: 760;
}

.detail-panel {
  position: sticky;
  top: 22px;
}

.empty-detail,
.detail-content {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-detail {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-detail svg {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  color: var(--green);
}

.detail-content {
  padding: 18px;
}

.hidden {
  display: none !important;
}

.detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.detail-heading h3 {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 1.28rem;
}

.detail-heading p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.icon-link {
  flex: 0 0 40px;
  width: 40px;
  color: var(--ink);
  background: #f4f7f4;
  border-color: var(--line);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-grid label,
.wide-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.detail-section {
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h4 {
  font-size: 0.98rem;
}

.confidence-pill {
  color: var(--blue);
  background: var(--blue-soft);
}

.count-pill {
  color: var(--green);
  background: var(--green-soft);
}

#builtSummary {
  color: #3f4944;
  line-height: 1.55;
}

.evidence-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.evidence-item {
  padding: 9px 10px;
  color: #48544e;
  background: #f4f7f4;
  border: 1px solid #e5ebe5;
  border-radius: var(--radius);
  line-height: 1.4;
}

.next-step-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.step-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px;
  color: #3f4944;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.42;
}

.step-item svg {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  color: var(--amber);
}

.kb-section pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  color: #dceee7;
  background: #1d2f29;
  border-radius: var(--radius);
  font: 0.78rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}

@media (max-width: 1100px) {
  .workspace,
  .insight-band {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 20px 16px;
  }

  .main-area {
    padding: 20px 16px;
  }

  .top-strip,
  .column-header {
    align-items: start;
    flex-direction: column;
  }

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

  .project-row {
    grid-template-columns: 1fr;
  }

  .project-row-meta {
    grid-template-columns: repeat(2, auto);
    justify-content: space-between;
    justify-items: start;
  }
}

@media (max-width: 520px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .language-row {
    grid-template-columns: 1fr;
  }

  .bar-track {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
