:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --panel: #ffffff;
  --panel-2: #f0f6f4;
  --ink: #181916;
  --muted: #676b61;
  --line: #d9ddd3;
  --green: #0f766e;
  --green-dark: #0b4f49;
  --blue: #2457a6;
  --amber: #a76011;
  --red: #b42318;
  --shadow: 0 14px 40px rgba(24, 25, 22, 0.08);
  font-family:
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 260px),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px 16px;
}

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

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 6px;
  color: white;
  display: inline-flex;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.15;
}

.brand strong {
  font-size: 17px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.icon-button {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 20px;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.layout {
  display: grid;
  gap: 14px;
  grid-template-columns: 340px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1180px;
}

.project-pane,
.work-pane {
  min-width: 0;
}

.new-project,
.work-pane,
.project-card,
.message,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.new-project {
  display: grid;
  gap: 10px;
  padding: 14px;
}

label span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

input,
textarea {
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary-button {
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 6px;
  color: white;
  min-height: 42px;
  padding: 0 14px;
}

.primary-button:hover {
  background: var(--green-dark);
}

.primary-button:disabled {
  background: #9da9a4;
  border-color: #9da9a4;
  cursor: wait;
}

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

.project-card {
  padding: 12px;
  text-align: left;
  width: 100%;
}

.project-card.is-active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.project-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 5px;
}

.project-card p {
  color: var(--muted);
  display: -webkit-box;
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.work-pane {
  box-shadow: var(--shadow);
  min-height: calc(100vh - 88px);
  overflow: hidden;
}

.status-strip {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--green-dark);
  display: none;
  font-size: 13px;
  padding: 10px 16px;
}

.status-strip.is-visible {
  display: block;
}

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

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

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

.state-pill {
  background: #fff6e7;
  border: 1px solid rgba(167, 96, 17, 0.28);
  border-radius: 999px;
  color: var(--amber);
  flex: 0 0 auto;
  font-size: 12px;
  padding: 6px 10px;
  white-space: nowrap;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  padding: 0 14px;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  min-height: 42px;
  padding: 0 12px;
}

.tab.is-active {
  border-color: var(--green);
  color: var(--ink);
  font-weight: 700;
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.is-active {
  display: block;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
}

.message {
  max-width: min(720px, 100%);
  padding: 12px;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #eef3ff;
  border-color: rgba(36, 87, 166, 0.24);
}

.message.assistant {
  align-self: flex-start;
}

.message small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-bottom: 6px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 22px;
  text-align: center;
}

.composer {
  align-items: end;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 92px;
  margin-top: 14px;
  padding-top: 14px;
}

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

.metric {
  padding: 12px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 7px;
}

.metric strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.event-item {
  border-left: 3px solid var(--green);
  padding: 4px 0 4px 10px;
}

.event-item strong {
  display: block;
  font-size: 14px;
}

.event-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.file-browser {
  display: grid;
  gap: 12px;
  grid-template-columns: 300px minmax(0, 1fr);
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 520px;
  overflow: auto;
}

.file-row {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: block;
  min-height: 38px;
  overflow-wrap: anywhere;
  padding: 9px 10px;
  text-align: left;
  width: 100%;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row[data-type="dir"] {
  color: var(--green-dark);
  font-weight: 700;
}

.file-preview {
  background: #1f211d;
  border-radius: 8px;
  color: #f4f5ef;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  max-height: 520px;
  min-height: 260px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 840px) {
  .app-shell {
    padding: env(safe-area-inset-top) 10px 10px;
  }

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

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

  .project-list {
    grid-auto-columns: minmax(220px, 78vw);
    grid-auto-flow: column;
    margin-top: 0;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .work-pane {
    min-height: 620px;
  }

  .project-head {
    padding: 16px 14px 10px;
  }

  h1 {
    font-size: 21px;
  }

  .tab-panel {
    padding: 14px;
  }

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

  .overview-grid,
  .file-browser {
    grid-template-columns: 1fr;
  }
}
