:root {
  color-scheme: light;
  --ink: #20242e;
  --muted: #7c8290;
  --border: #e7e9ee;
  --paper: #ffffff;
  --canvas: #f5f6f8;
  --accent: #6558e8;
  --accent-dark: #5144d1;
  --green: #2aa779;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button, textarea { font: inherit; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  width: 238px;
  flex-direction: column;
  padding: 25px 17px;
  border-right: 1px solid var(--border);
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 4px 49px;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: #eeeaff;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: -.5px;
}

.sidebar-label {
  margin: 0 11px 12px;
  color: #a0a5b0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #615f74;
  font-weight: 600;
  text-decoration: none;
}

.nav-button { width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; }
.nav-button:hover { color: var(--accent); }

.nav-item.active { background: #f1efff; color: var(--accent); }
.nav-icon { font-size: 18px; }

.sidebar-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 14px 9px 3px;
  color: var(--muted);
  font-size: 12px;
}

.online-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--green);
}

.sidebar-version { margin-left: auto; color: #a6aab4; font-size: 11px; }

.main-content { max-width: 1600px; margin-left: 238px; padding: 0 46px 30px; }

.topbar {
  display: flex;
  height: 68px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.breadcrumb { color: var(--muted); font-size: 12px; }
.breadcrumb span { margin: 0 7px; color: #b9bdc6; }
.topbar-status { display: flex; align-items: center; gap: 8px; color: #626979; font-size: 12px; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 35px 0 27px;
}

.eyebrow { margin-bottom: 9px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 1.15px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: "Space Grotesk", sans-serif; font-size: clamp(24px, 3vw, 31px); letter-spacing: -1.2px; }
.page-heading p, .section-title p { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.team-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: #626979;
  font-size: 11px;
  font-weight: 600;
}

.team-badge span { color: var(--accent); }
.panel { border: 1px solid var(--border); border-radius: 10px; background: var(--paper); box-shadow: 0 2px 7px rgb(36 42 59 / 3%); }
.project-manager { margin-bottom: 16px; padding: 21px 23px 17px; }
.project-manager-layout { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(0, 1.8fr); gap: 24px; margin-top: 18px; }
.user-manager { margin-top: 28px; }
.user-list-column { min-width: 0; }
.user-list-column > button { margin-top: 12px; }
.user-manager .project-form-footer { flex-wrap: wrap; }
.user-manager .query-message { overflow-wrap: anywhere; }
.login-form { max-width: 480px; }
.user-manager .project-form-heading h3 { overflow-wrap: anywhere; }
.project-list-heading, .project-form-heading h3 { color: #727887; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.project-list { display: grid; gap: 7px; margin-top: 9px; }
.project-list-empty { padding: 14px 12px; border: 1px dashed var(--border); border-radius: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.project-list-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 11px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--ink); cursor: pointer; text-align: left; }
.project-list-item:hover, .project-list-item.selected { border-color: #c9c4f3; background: #f8f7ff; }
.project-list-item strong { overflow: hidden; flex: 1; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.project-list-item span { color: var(--muted); font-size: 10px; }
.project-form { min-width: 0; }
.project-form-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.project-form-heading h3 { margin: 0 0 4px; color: var(--ink); font-size: 14px; letter-spacing: 0; text-transform: none; }
.project-form-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.project-form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 15px; }
.project-form-fields .repository-field:nth-child(3) { grid-column: 1 / -1; }
.project-context-field { grid-column: 1 / -1; }
.project-context-field textarea { display: block; width: 100%; min-height: 100px; padding: 9px 10px; resize: vertical; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #fbfbfc; color: #505665; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.5; }
.project-context-field textarea:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }
.token-clear { display: flex; align-items: center; gap: 6px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.prompt-master-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.master-prompt-field label { display: block; margin-bottom: 6px; color: #727887; font-size: 10px; font-weight: 700; }
.master-prompt-field textarea { display: block; width: 100%; min-height: 100px; padding: 9px 10px; resize: vertical; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #fbfbfc; color: #505665; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.5; }
.master-prompt-field textarea:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }
.project-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; }
.project-form-footer .query-message { margin: 0; }

.request-card { padding: 21px 23px 17px; }
.section-title { display: flex; align-items: flex-start; gap: 13px; }
.step-number { padding-top: 2px; color: #a6a8b3; font-size: 10px; font-weight: 700; letter-spacing: .6px; }
.section-title h2 { margin-bottom: 5px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; letter-spacing: -.3px; }
.section-title p { font-size: 12px; }
.request-input {
  width: 100%;
  min-height: 91px;
  margin-top: 19px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  color: var(--ink);
  line-height: 1.55;
}

.project-selection { display: flex; align-items: flex-end; gap: 12px; }
.project-selection .repository-field { flex: 1; }
.project-selection .secondary-button { margin-bottom: 0; }
.project-selection select { width: 100%; min-height: 38px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #fff; color: var(--ink); }
.project-selection select:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }

.request-input:focus, .prompt-input:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }
textarea::placeholder { color: #a6aab4; }
.metadata-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.repository-field { margin-top: 15px; }
.repository-field label { display: block; margin-bottom: 7px; color: #727887; font-size: 10px; font-weight: 700; }
.repository-field label span { margin-left: 5px; color: #a0a5b0; font-size: 9px; letter-spacing: .6px; }
.repository-field input { width: 100%; min-height: 38px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; outline: none; color: var(--ink); }
.repository-field input:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }
.repository-field select { width: 100%; min-height: 38px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; }
.repository-field select:focus { outline: none; border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }
.repository-field p { margin: 6px 0 0; color: #989daa; font-size: 10px; }
.request-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.input-hint { color: #989daa; font-size: 11px; }
.saved-output-card { margin-top: 16px; padding: 21px 23px 17px; }
.query-row { display: flex; gap: 9px; margin-top: 17px; }
.query-row input { min-width: 0; flex: 1; min-height: 38px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; outline: none; color: var(--ink); }
.query-row input:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }
.secondary-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: #626979; cursor: pointer; font-size: 12px; font-weight: 700; }
.secondary-button:hover { border-color: #c9c4f3; color: var(--accent); }
.query-message { min-height: 16px; margin-top: 9px; color: #727887; font-size: 11px; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: background .15s, transform .15s;
}

.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .7; transform: none; }
.button-icon { font-size: 10px; }
.error-message { margin-top: 12px; color: #b4233a; font-size: 12px; }
.team-section { margin-top: 30px; }
.team-title { margin: 0 0 16px 2px; }
.agent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.agent-card { min-width: 0; padding: 17px; }
.agent-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.agent-avatar { display: grid; width: 35px; height: 35px; flex: 0 0 35px; place-items: center; border-radius: 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; font-weight: 700; }
.agent-avatar.analyst { background: #eeeaff; color: #6558e8; }
.agent-avatar.frontend { background: #e6f2ff; color: #367ac1; }
.agent-avatar.ui-ux { background: #f8e9ff; color: #a344c4; }
.agent-avatar.backend { background: #e7f6f0; color: #278867; }
.agent-avatar.tester { background: #fff1e6; color: #d47d35; }
.agent-identity { min-width: 0; }
.agent-identity h3 { overflow: hidden; margin-bottom: 3px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.agent-identity span { color: #9a9eaa; font-size: 9px; font-weight: 700; letter-spacing: .8px; }
.agent-state { margin-left: auto; color: #999eaa; font-size: 9px; font-weight: 700; letter-spacing: .65px; }
.agent-state.running { color: var(--accent); }
.agent-state.complete { color: var(--green); }
.agent-card label { display: block; margin-bottom: 7px; color: #727887; font-size: 10px; font-weight: 700; }
.agent-model-field { margin-bottom: 14px; }
.agent-model-field label { display: block; margin-bottom: 7px; color: #727887; font-size: 10px; font-weight: 700; }
.agent-model-input { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: #fbfbfc; color: #505665; font: inherit; font-size: 12px; }
.agent-model-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.agent-model-input:disabled { opacity: .7; cursor: wait; }
.prompt-input {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 10px 11px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: #fbfbfc;
  color: #505665;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.55;
}

.output-heading { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; color: #727887; font-size: 10px; font-weight: 700; }
.copy-button { padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: #777d8a; cursor: pointer; font-size: 10px; font-weight: 600; }
.copy-button:hover { border-color: #c9c4f3; color: var(--accent); }
.output {
  min-height: 126px;
  max-height: 430px;
  overflow: auto;
  margin: 0;
  padding: 11px;
  border: 1px solid #eceef2;
  border-radius: 6px;
  background: #fafbfc;
  color: #525867;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.output-editor { display: block; width: 100%; resize: vertical; outline: none; }
.output-editor:focus { border-color: #a49bf3; box-shadow: 0 0 0 3px rgb(101 88 232 / 9%); }

.repo-context-panel { margin-bottom: 18px; }
.repo-context-panel p { color: #727887; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
#repo-context-cache { color: #727887; font-size: 11px; overflow-wrap: anywhere; }
.repo-context-panel details { margin-top: 14px; }
.repo-context-panel summary { color: #525867; cursor: pointer; font-size: 12px; font-weight: 600; }
.repo-artifact-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.repo-artifact-controls select { flex: 1; min-width: 160px; max-width: 100%; border: 1px solid var(--border); border-radius: 5px; padding: 8px; background: #fff; }
.repo-relationship-scroll { overflow: auto; max-height: 360px; }
.repo-relationship-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.repo-relationship-table th, .repo-relationship-table td { padding: 9px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; min-width: 100px; }
.repo-relationship-table th { position: sticky; top: 0; background: #fafbfc; }
.repo-context-panel button:disabled { opacity: .5; cursor: not-allowed; }

.footer { padding: 20px 2px 0; color: #a1a5af; font-size: 10px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 950px) {
  .sidebar { width: 68px; align-items: center; padding: 20px 10px; }
  .brand { margin: 0 0 38px; }
  .brand > span:last-child, .sidebar-label, .nav-item:not(.active):not(.nav-button), .nav-item span:last-child, .sidebar-bottom { display: none; }
  .nav-item { padding: 10px 14px; }
  .main-content { margin-left: 68px; padding: 0 25px 25px; }
}

@media (max-width: 680px) {
  .sidebar { position: static; inset: auto; display: flex; flex-direction: row; width: 100%; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
  .brand { margin: 0 8px 0 0; }
  .nav-item { flex: 1; min-width: 0; justify-content: center; padding: 9px 5px; }
  .nav-button { width: auto; }
  .nav-item .nav-icon { display: none; }
  .nav-item span:last-child { display: inline; font-size: 11px; text-align: center; }
  .main-content { margin-left: 0; padding: 0 16px 24px; }
  .topbar { height: 55px; }
  .page-heading { align-items: flex-start; gap: 12px; padding: 27px 0 21px; }
  .team-badge { flex: 0 0 auto; }
  .page-heading p { max-width: 390px; font-size: 12px; }
  .agent-grid { grid-template-columns: 1fr; }
  .request-card { padding: 17px 15px 14px; }
  .metadata-fields { grid-template-columns: 1fr; gap: 0; }
  .project-manager-layout, .prompt-master-grid, .project-form-fields { grid-template-columns: 1fr; }
  .project-form-fields .repository-field:nth-child(3) { grid-column: auto; }
  .project-context-field { grid-column: auto; }
  .project-selection { align-items: stretch; flex-direction: column; gap: 0; }
  .project-selection .secondary-button { width: 100%; }
  .query-row { align-items: stretch; flex-direction: column; }
  .request-footer { align-items: flex-start; flex-direction: column; }
  .primary-button { width: 100%; }
}
.use-case-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.knowledge-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 15px; margin: 18px 0; }
.knowledge-filters .repository-field { flex: 1; min-width: 180px; margin: 0; }
.knowledge-layout { display: grid; grid-template-columns: minmax(220px, .9fr) minmax(0, 1.5fr); gap: 24px; }
.knowledge-list { max-height: 650px; overflow: auto; }
.knowledge-list-item { display: grid; gap: 6px; overflow-wrap: anywhere; }
.knowledge-list-item strong { white-space: normal; }
.knowledge-preview { white-space: pre-wrap; line-height: 1.5; }
.knowledge-pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.knowledge-pagination .query-message { margin: 0; }
.knowledge-detail { min-width: 0; }
.knowledge-detail h3 { overflow-wrap: anywhere; }
#knowledge-detail-meta { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.7; }
#knowledge-detail-content { max-height: 650px; min-height: 260px; font-size: 12px; }
#knowledge-manager button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 680px) {
  .knowledge-layout { grid-template-columns: 1fr; }
  .sidebar { flex-wrap: wrap; }
}
