:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: #ffffff;
  --ink: #222019;
  --muted: #6e6a60;
  --line: #ddd5c7;
  --teal: #0f766e;
  --berry: #a3325f;
  --amber: #b7791f;
  --blue: #2f6690;
  --leaf: #3d7d55;
  --soft: #edf5f1;
  --warm: #fff8ea;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.topbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.88);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.topbar-inner,
main {
  width: min(100%, 810px);
  margin: 0 auto;
}

.topbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title controls"
    "summary summary"
    "status status";
  gap: 12px;
  align-items: center;
}

.brand-lockup {
  grid-area: title;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  box-shadow: 0 5px 14px rgba(54, 45, 27, 0.13);
  overflow: hidden;
}

.app-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.15;
  min-width: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
}

h3 {
  margin-bottom: 4px;
  font-size: 18px;
}

h4 {
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--blue);
}

button,
select {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  font: inherit;
}

button {
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--teal);
}

button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

button:disabled:hover,
button:disabled:focus-visible {
  border-color: var(--line);
  outline: none;
}

button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--teal), var(--line) 35%);
  background: var(--soft);
  color: var(--teal);
}

#refreshButton:disabled {
  cursor: wait;
}

.refresh-icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
}

.refresh-icon-button:hover,
.refresh-icon-button:focus-visible {
  background: var(--soft);
  color: var(--teal);
  outline: none;
}

.refresh-icon-button:disabled {
  cursor: wait;
  opacity: 1;
}

.refresh-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-icon-button.is-refreshing svg {
  animation: refresh-spin 900ms linear infinite;
}

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

main {
  padding: 12px 12px 40px;
}

.summary-band {
  grid-area: summary;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.summary-band > div {
  min-height: 0;
  display: flex;
  align-items: center;
}

.latest-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
}

.summary-band span {
  font-size: 14px;
}

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

.view-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-status {
  grid-area: status;
  color: var(--berry);
  font-size: 13px;
  margin: 8px 0 0;
}

.header-status:empty {
  display: none;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.project-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  border-left: 5px solid var(--leaf);
  min-width: 0;
}

.project-card.is-dirty {
  border-left-color: var(--amber);
}

.project-card.is-codex-workspace {
  border-left-color: var(--blue);
}

.project-card.has-error {
  border-color: color-mix(in srgb, var(--berry), var(--line) 50%);
  border-left-color: var(--berry);
}

.project-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}

.project-heading {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.disclosure-button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  flex: 0 0 auto;
}

.disclosure-button:hover,
.disclosure-button:focus-visible {
  color: var(--teal);
  background: var(--soft);
  border-color: var(--line);
  outline: none;
}

.disclosure-caret {
  width: 16px;
  height: 16px;
  display: block;
  transition: transform 120ms ease;
}

.disclosure-caret svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.disclosure-button[aria-expanded="true"] .disclosure-caret {
  transform: rotate(90deg);
}

.title-line h3 {
  margin-bottom: 0;
}

.title-line span {
  color: var(--muted);
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.project-summary {
  margin: 8px 0 0;
  color: #4f4b43;
  line-height: 1.45;
  min-width: 0;
  width: 100%;
  max-width: min(72ch, 100%);
  overflow-wrap: anywhere;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 260px;
  font-size: 13px;
  color: var(--teal);
  overflow-wrap: anywhere;
}

.project-card.is-dirty .status-pill {
  color: #8a520d;
}

.summary {
  margin-bottom: 12px;
  color: var(--ink);
}

.error {
  color: var(--berry);
  margin-bottom: 12px;
}

.mini-list {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee7db;
}

.mini-list ul {
  margin: 0;
  padding-left: 0;
  max-width: 76ch;
  min-width: 0;
}

.mini-list li {
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.source-list {
  display: grid;
  gap: 6px;
  list-style: none;
}

.source-item {
  --source-color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
}

.source-marker {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border: 2px solid var(--source-color);
  border-radius: 50%;
  transform: translateY(-1px);
}

.source-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-git {
  --source-color: var(--teal);
}

.source-git .source-marker {
  border-radius: 2px;
  background: color-mix(in srgb, var(--source-color), transparent 72%);
}

.source-codex {
  --source-color: var(--blue);
}

.source-codex .source-marker {
  border-radius: 2px;
  transform: translateY(-1px) rotate(45deg);
  background: color-mix(in srgb, var(--source-color), transparent 72%);
}

.source-plan {
  --source-color: var(--amber);
}

.source-plan .source-marker {
  border-radius: 50%;
  background: color-mix(in srgb, var(--source-color), transparent 78%);
}

.source-mixed {
  --source-color: var(--blue);
}

.source-mixed .source-marker {
  border-color: var(--teal);
  border-radius: 3px;
  background: linear-gradient(135deg, var(--teal) 0 48%, var(--blue) 52% 100%);
}

.details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.details p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .topbar {
    padding: 12px;
  }

  .topbar-inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "summary"
      "controls"
      "status";
    row-gap: 10px;
  }

  main {
    padding: 12px;
  }

  .summary-band {
    gap: 6px 12px;
  }

  .view-controls {
    justify-content: flex-start;
  }

  .project-main {
    flex-direction: column;
  }

  .project-actions {
    width: 100%;
    justify-content: space-between;
  }

  .title-line {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 4px;
    min-width: 0;
  }

  .disclosure-button {
    grid-column: 1;
    grid-row: 1;
  }

  .title-line h3 {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .title-line span {
    grid-column: 2;
    grid-row: 2;
    padding-left: 0;
  }

  .status-pill {
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  main {
    padding: 10px 8px 32px;
  }

  .topbar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .view-controls {
    gap: 6px;
  }

  .small-button {
    padding-left: 10px;
    padding-right: 10px;
  }
}
