:root {
  color-scheme: dark;
  --sidebar-width: clamp(360px, 27vw, 440px);
  --bg-0: #0f1115;
  --bg-1: #13161d;
  --bg-2: #171b22;
  --panel: #171b22;
  --panel-strong: #1d222b;
  --line: #2a303a;
  --line-strong: #3a414d;
  --text: #e8ebf0;
  --muted: #98a2b3;
  --accent: #7cb8ff;
  --accent-2: #5dd8b0;
  --success: #55c07c;
  --warn: #d6a04e;
  --danger: #d96a61;
  --shadow: none;
  --radius: 12px;
  --radius-sm: 8px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "JetBrains Mono", "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
  background: var(--bg-0);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

code,
pre {
  font-family: var(--font-mono);
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  position: relative;
  min-height: 0;
  height: 100vh;
  padding: 16px 14px 20px;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  padding: 20px 22px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand h1,
.topbar h1,
.card h2,
.card h3 {
  margin: 0;
  line-height: 1.12;
}

.brand h1 {
  font-size: 1.15rem;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sidebar__cta {
  margin: 18px 0 24px;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.search-box label {
  color: #bfd0eb;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.search-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-section {
  margin-bottom: 22px;
}

.sidebar-section--collapsible {
  display: grid;
  gap: 10px;
}

.sidebar-section--collapsed .project-list,
.sidebar-section--collapsed [data-sidebar-body] {
  display: none;
}

.sidebar-section__titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.sidebar-section__titlebar .sidebar-section__title {
  margin-bottom: 0;
}

.sidebar-section__title {
  margin-bottom: 10px;
  color: #bfd0eb;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-section__chevron {
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 140ms ease;
}

.sidebar-section--collapsed .sidebar-section__chevron {
  transform: rotate(-90deg);
}

.project-list,
.mini-list {
  display: grid;
  gap: 8px;
}

.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: start;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  transition: border-color 120ms ease, background 120ms ease;
  min-width: 0;
}

.project-item:hover,
.project-item--active {
  border-color: var(--accent);
  background: var(--panel-strong);
}

.project-item--favorite {
  border-color: rgba(214, 160, 78, 0.44);
}

.project-item__content {
  min-width: 0;
}

.project-item__link {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.project-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.project-item__top strong {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.project-item__sub,
.project-item__foot {
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.project-item__pin-form {
  display: flex;
  align-items: flex-start;
}

.project-item__pin-btn {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
}

.project-item__pin-btn:hover {
  border-color: var(--accent);
  background: var(--panel-strong);
}

.project-item__pin-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

.project-item__archive-form {
  display: flex;
  align-items: flex-start;
}

.project-item__archive-btn {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}

.project-item__archive-btn:hover {
  border-color: var(--accent);
  background: var(--panel-strong);
}

.project-summary,
.mini-list__item {
  display: grid;
  gap: 6px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.project-summary span,
.mini-list__item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.project-summary code {
  color: #dfe8f8;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

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

.topbar p {
  max-width: 72ch;
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar__logout-form {
  margin: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.tab:hover,
.tab--active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(124, 184, 255, 0.12);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--hero {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
  margin-bottom: 16px;
}

.grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.chat-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.75fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.chat-panel {
  display: grid;
  gap: 16px;
  min-height: 0;
  grid-template-rows: auto minmax(320px, 1fr) auto;
}

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

.chat-panel__lede {
  margin: 6px 0 0;
  color: var(--muted);
}

.chat-thread {
  display: grid;
  gap: 14px;
  min-height: 320px;
  padding: 4px 0 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 0;
  width: 100%;
}

.chat-row__content {
  display: grid;
  gap: 6px;
}

.chat-row--outbound .chat-row__content {
  justify-items: end;
}

.chat-row__stamp {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 0 6px;
}

.chat-row--outbound {
  justify-content: flex-end;
}

.chat-row--inbound {
  justify-content: flex-start;
}

.chat-bubble {
  display: grid;
  gap: 8px;
  max-width: min(720px, calc(100% - 50px));
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.chat-row--outbound .chat-bubble {
  border-color: rgba(93, 216, 176, 0.24);
}

.chat-row--inbound .chat-bubble {
  border-color: rgba(124, 184, 255, 0.22);
}

.chat-row--pending .chat-bubble {
  opacity: 0.72;
  border-style: dashed;
}

.chat-bubble__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-bubble__role {
  color: var(--text);
  font-weight: 700;
}

.chat-bubble__direction {
  color: var(--accent);
}

.chat-bubble__body {
  margin: 0;
  color: #f2f7ff;
  font-size: 0.96rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble__error {
  padding-top: 8px;
  color: #ffb6ae;
  font-size: 0.88rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-composer {
  display: grid;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

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

.chat-composer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chat-rail {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 24px;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-toggle {
  display: none;
}

.project-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.main-column,
.side-column {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.card {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card__header h2 {
  margin-top: 4px;
  font-size: 1.24rem;
}

.lede {
  margin: 0 0 16px;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.metric {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.metric strong {
  font-size: 1.55rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
}

.task-list,
.bullet-stack,
.artifact-list,
.log-list,
.workflow-list,
.timeline,
.agent-grid {
  display: grid;
  gap: 10px;
}

.task-list--stacked {
  gap: 12px;
}

.task-card {
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.task-card--muted {
  border-color: var(--line);
  background: var(--panel);
}

.task-card strong {
  display: block;
  margin-bottom: 8px;
}

.task-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.task-card li + li {
  margin-top: 6px;
}

.featured-project {
  margin-top: 14px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.featured-project__title {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.featured-project p {
  margin: 8px 0 0;
  color: var(--muted);
}

.featured-project__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.bullet-stack__item {
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.bullet-stack--compact .bullet-stack__item {
  padding: 10px 12px;
}

.agent-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.agent-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  margin-top: 14px;
}

.agent-card {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.agent-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: #c8d5e8;
  font-size: 0.9rem;
}

.field--full {
  grid-column: 1 / -1;
}

.stack {
  display: grid;
  gap: 12px;
}

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

input,
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-1);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 184, 255, 0.12);
  background: var(--bg-1);
}

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

.actions--chat {
  grid-column: 1 / -1;
  padding-top: 4px;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.btn:hover,
button:hover {
  border-color: var(--accent);
  background: var(--panel-strong);
}

.btn-primary {
  border-color: var(--accent);
  background: rgba(124, 184, 255, 0.16);
}

.btn-danger {
  border-color: rgba(217, 106, 97, 0.85);
  background: rgba(217, 106, 97, 0.14);
}

.btn-block {
  width: 100%;
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 0.84rem;
  white-space: nowrap;
}

.badge-accent,
.chip-success {
  border-color: rgba(93, 216, 176, 0.34);
  background: rgba(93, 216, 176, 0.12);
}

.badge-neutral {
  color: #cad4e6;
}

.tag-row,
.state-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.status-row dt {
  color: var(--muted);
}

.status-row dd {
  margin: 0;
  text-align: right;
  word-break: break-word;
}

.mono-block {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.mono-block div {
  display: grid;
  gap: 6px;
}

.mono-block span {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mono-block code {
  color: #deebff;
  font-size: 0.8rem;
  word-break: break-all;
}

.timeline-item,
.workflow-row,
.artifact-item,
.log-item {
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.timeline-item {
  display: grid;
  gap: 10px;
}

.timeline-item--outbound {
  border-color: rgba(72, 215, 184, 0.24);
}

.timeline-item--inbound {
  border-color: rgba(105, 183, 255, 0.22);
}

.timeline-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.timeline-item__role {
  color: #f1f6ff;
  font-weight: 700;
}

.timeline-item__body {
  white-space: pre-wrap;
  word-break: break-word;
}

.timeline-item__error {
  color: #ff9a90;
}

.workflow-create {
  margin-bottom: 14px;
}

.workflow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.workflow-row__copy {
  display: grid;
  gap: 6px;
}

.workflow-row__copy span {
  color: var(--muted);
  font-size: 0.84rem;
}

.workflow-row__form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-row__form select {
  min-width: 110px;
}

.artifact-item,
.log-item {
  display: grid;
  gap: 6px;
}

.artifact-item span,
.log-item__head span {
  color: var(--muted);
  font-size: 0.84rem;
}

.artifact-item code {
  color: #dce5f4;
  font-size: 0.8rem;
  word-break: break-word;
}

.log-item__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-item__body {
  color: #dfe7f5;
}

.log-item pre {
  padding-top: 8px;
  color: #b8c7db;
  font-size: 0.8rem;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 10px;
  border: 1px dashed var(--line-strong);
  background: var(--bg-1);
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
}

.project-empty {
  padding: 12px 13px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: var(--bg-1);
}

.sidebar a {
  color: inherit;
}

@media (max-width: 1240px) {
  .shell {
    grid-template-columns: clamp(320px, 30vw, 380px) minmax(0, 1fr);
  }

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

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

@media (max-width: 1040px) {
  .grid--hero,
  .grid--two {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 390px);
    height: 100vh;
    max-width: 100vw;
    transform: translateX(-102%);
    transition: transform 180ms ease;
    z-index: 60;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: none;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(3, 6, 12, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .workspace {
    padding: 18px 16px 28px;
    height: auto;
    overflow: visible;
  }

  .chat-panel,
  .chat-rail {
    position: static;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .topbar__meta {
    justify-content: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

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

  .status-row dd {
    text-align: left;
  }

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

  .workflow-row__form {
    flex-wrap: wrap;
  }

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