:root {
  color-scheme: dark;
  --bg: #191919;
  --sidebar: #202020;
  --sidebar-hover: #2c2c2c;
  --panel: #222222;
  --panel-2: #262626;
  --bubble: #303030;
  --text: #e9e9e9;
  --muted: #a7a7a7;
  --faint: #6f6f6f;
  --line: #313131;
  --line-strong: #3d3d3d;
  --success: #6bd65d;
  --danger: #ff6b6b;
  --blue: #8fb4ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

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

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px 10px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand-row,
.workspace-header,
.dock-head,
.task-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-row {
  padding: 0 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark,
.assistant-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #303030;
  color: #f2f2f2;
  font-size: 11px;
  font-weight: 800;
}

.brand strong {
  display: block;
  color: #f0f0f0;
  font-size: 21px;
  font-weight: 740;
  line-height: 1;
}

.sidebar-icons {
  display: flex;
  gap: 8px;
}

.sidebar-icons span {
  position: relative;
  width: 27px;
  height: 27px;
  border-radius: 8px;
}

.sidebar-icons span::before,
.sidebar-icons span::after {
  position: absolute;
  content: "";
}

.sidebar-icons span:first-child::before {
  inset: 6px;
  border: 2px solid #9b9b9b;
  border-radius: 999px;
}

.sidebar-icons span:first-child::after {
  right: 4px;
  bottom: 5px;
  width: 8px;
  height: 2px;
  border-radius: 2px;
  background: #9b9b9b;
  transform: rotate(45deg);
}

.sidebar-icons span:last-child::before {
  inset: 6px;
  border: 2px solid #9b9b9b;
  border-radius: 3px;
}

.sidebar-icons span:last-child::after {
  top: 6px;
  bottom: 6px;
  left: 12px;
  width: 2px;
  background: #9b9b9b;
}

.side-nav,
.project-dock,
.task-dock,
.sidebar-bottom,
.login-grid,
.task-list,
.seed-composer,
.event-timeline {
  display: grid;
}

.side-nav {
  gap: 4px;
}

.side-nav a,
.project-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  border-radius: 11px;
  padding: 0 12px;
  color: #d6d6d6;
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
}

.side-nav a:hover,
.side-nav a.is-active,
.project-link:hover,
.task-card:hover,
.task-card.is-selected {
  background: var(--sidebar-hover);
}

.nav-icon {
  width: 22px;
  color: #a6a6a6;
  font-size: 18px;
  text-align: center;
}

.project-dock,
.task-dock {
  align-content: start;
  gap: 8px;
}

.task-dock {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.dock-head {
  min-height: 28px;
  padding: 0 12px;
  color: #8f8f8f;
  font-size: 14px;
  font-weight: 740;
}

.dock-head a,
.icon-button {
  border: 0;
  background: transparent;
  color: #9a9a9a;
  cursor: pointer;
  text-decoration: none;
}

.dock-head a {
  font-size: 22px;
  line-height: 1;
}

.icon-button {
  min-height: 28px;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 13px;
}

.icon-button:hover {
  background: var(--sidebar-hover);
}

.task-list {
  min-height: 0;
  align-content: start;
  gap: 4px;
  overflow: auto;
  padding-right: 2px;
}

.task-list .muted {
  min-height: 52px;
  display: grid;
  align-items: center;
  padding: 10px 12px;
}

.task-card {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.task-card h3 {
  overflow: hidden;
  margin: 5px 0 3px;
  color: #eeeeee;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-card p {
  overflow: hidden;
  color: #a2a2a2;
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge,
.detail-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #bbbbbb;
  font-size: 11px;
  font-weight: 720;
}

.badge.status-running,
.badge.status-claimed,
.badge.status-needs_retry,
.detail-status.status-running,
.detail-status.status-claimed,
.detail-status.status-needs_retry {
  background: rgba(143, 180, 255, 0.15);
  color: #a9c4ff;
}

.badge.status-completed,
.detail-status.status-completed {
  background: rgba(107, 214, 93, 0.14);
  color: var(--success);
}

.badge.status-blocked,
.badge.status-failed,
.detail-status.status-blocked,
.detail-status.status-failed {
  background: rgba(255, 107, 107, 0.14);
  color: var(--danger);
}

.sidebar-bottom {
  gap: 10px;
}

.identity-gate,
.user-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #242424;
}

.gate-copy h2 {
  margin-top: 2px;
  color: #f0f0f0;
  font-size: 17px;
  line-height: 1.15;
}

.eyebrow,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.login-grid {
  gap: 8px;
  margin-top: 10px;
}

.open-gate,
.member-login {
  display: none;
}

.user-box {
  gap: 8px;
}

.user-box:empty {
  display: none;
}

.user-box span {
  overflow: hidden;
  color: #ededed;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
}

.workspace-header {
  height: 60px;
  border-bottom: 1px solid var(--line);
  padding: 0 26px;
  background: #1d1d1d;
}

.workspace-title {
  max-width: min(560px, 55vw);
  overflow: hidden;
  border: 0;
  border-radius: 9px;
  padding: 0;
  background: transparent;
  color: #eeeeee;
  font-size: 19px;
  font-weight: 780;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.workspace-title::after {
  content: "⌄";
  margin-left: 7px;
  color: #9a9a9a;
  font-size: 15px;
}

.member-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: #242424;
  color: #d8d8d8;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.home-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 58px 28px 72px;
}

.stage-inner {
  width: min(100%, 940px);
  display: grid;
  justify-items: center;
  gap: 26px;
  margin-top: -4vh;
}

.stage-inner > h1 {
  color: #efefef;
  font-size: clamp(34px, 4.2vw, 52px);
  font-weight: 540;
  line-height: 1.15;
  text-align: center;
}

.task-composer {
  width: min(100%, 840px);
}

.seed-composer {
  gap: 12px;
}

.prompt-field {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: #222222;
  box-shadow: var(--shadow);
}

.prompt-field span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.prompt-field textarea {
  display: block;
  width: 100%;
  min-height: 96px;
  max-height: 280px;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 22px 24px 8px;
  background: transparent;
  color: #efefef;
  font-size: 18px;
  line-height: 1.45;
  outline: none;
  resize: vertical;
}

.prompt-field textarea::placeholder {
  color: #858585;
}

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -64px;
  padding: 0 16px 14px;
  pointer-events: none;
}

.tool-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.tool-button,
.send-button,
.login-grid button,
.user-box button {
  cursor: pointer;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  background: #242424;
  color: #d8d8d8;
  font-size: 14px;
  font-weight: 700;
}

.tool-button input {
  display: none;
}

.tool-button span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 20px;
  line-height: 1;
}

.send-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: #393939;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  pointer-events: auto;
}

.feature-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.feature-card {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 17px;
  background: #222222;
  color: #d8d8d8;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.feature-card:hover,
.feature-card.is-active {
  border-color: #575757;
  background: #2a2a2a;
}

.chip-icon {
  margin-right: 7px;
  color: #9d9d9d;
}

.skill-card {
  width: min(100%, 650px);
  min-height: 112px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 20px;
  align-items: center;
  margin-top: 20vh;
  border-radius: 14px;
  padding: 24px 28px;
  background: #232323;
  color: #cfcfcf;
}

.skill-card h2 {
  color: #f0f0f0;
  font-size: 21px;
}

.skill-card p {
  margin-top: 4px;
  color: #a6a6a6;
  font-size: 15px;
}

.skill-lines {
  display: grid;
  gap: 12px;
}

.skill-lines span {
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(90deg, #3a3a3a 0 28%, rgba(255, 255, 255, 0.08) 28% 100%);
}

.task-detail {
  width: min(100%, 840px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  background: #222222;
  box-shadow: var(--shadow);
}

.task-detail-head h2 {
  margin-top: 8px;
  color: #f0f0f0;
  font-size: 24px;
  line-height: 1.15;
}

.task-detail-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.task-detail-head button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #242424;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin-top: 18px;
  border-radius: 999px;
  background: #303030;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #e6e6e6;
  transition: width 180ms ease;
}

.task-detail-summary {
  margin-top: 14px;
  color: #c8c8c8;
}

.event-timeline {
  gap: 20px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

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

.event-dot {
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 999px;
  background: #8b8b8b;
}

.event-item.severity-success .event-dot {
  background: var(--success);
}

.event-item.severity-warning .event-dot {
  background: #d69943;
}

.event-item.severity-error .event-dot {
  background: var(--danger);
}

.event-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.event-title strong {
  color: #f0f0f0;
  font-size: 15px;
}

.event-title span,
.event-phase {
  color: var(--muted);
  font-size: 12px;
}

.event-item p {
  margin-top: 3px;
  color: #c8c8c8;
  font-size: 14px;
}

.event-empty {
  color: var(--muted);
  font-size: 14px;
}

.evidence-cloud {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 16px;
  background: #222222;
}

.evidence-cloud[open] {
  padding-bottom: 16px;
  box-shadow: var(--shadow);
}

.evidence-cloud summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  color: #d8d8d8;
  cursor: pointer;
  font-weight: 700;
}

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

label {
  display: block;
  margin-bottom: 12px;
  color: #ededed;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 12px;
  background: #202020;
  color: #ededed;
  font-size: 15px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

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

input::placeholder,
textarea::placeholder {
  color: #777777;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(143, 180, 255, 0.14);
}

button {
  font-weight: 700;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.login-grid input {
  min-height: 38px;
  border-radius: 10px;
  font-size: 14px;
}

.login-grid button,
.user-box button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #242424;
  color: #d8d8d8;
}

.login-grid button[type="submit"] {
  background: #383838;
  color: #fff;
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--success);
}

body.is-chat-open .home-stage {
  place-items: stretch center;
  padding: 0 28px;
}

body.is-chat-open .stage-inner {
  width: min(100%, 1040px);
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 auto;
}

body.is-chat-open .stage-inner > h1,
body.is-chat-open .feature-strip,
body.is-chat-open .skill-card {
  display: none;
}

body.is-chat-open .task-detail {
  order: 1;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  padding: 44px 0 148px;
  background: transparent;
  box-shadow: none;
}

body.is-chat-open .task-detail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 14px;
  background: linear-gradient(#191919 70%, rgba(25, 25, 25, 0));
}

body.is-chat-open .task-detail-head h2 {
  margin-top: 8px;
  font-size: 18px;
}

body.is-chat-open .progress-track,
body.is-chat-open .task-detail-summary {
  display: none;
}

body.is-chat-open .event-timeline {
  width: min(100%, 760px);
  margin: 0 auto;
  gap: 34px;
}

.chat-message {
  display: grid;
}

.user-message {
  justify-content: end;
}

.chat-bubble {
  max-width: min(520px, 76vw);
  border-radius: 18px;
  padding: 13px 18px;
  background: #343434;
  color: #f0f0f0;
  font-size: 17px;
  line-height: 1.55;
}

.assistant-message {
  justify-content: start;
  gap: 10px;
}

.assistant-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #ededed;
}

.assistant-brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
}

.assistant-body {
  max-width: min(760px, 82vw);
  color: #d8d8d8;
  font-size: 17px;
  line-height: 1.62;
}

.assistant-main {
  color: #dfdfdf;
  font-weight: 650;
}

.assistant-meta {
  margin-top: 8px;
  border-left: 3px solid #555555;
  padding-left: 14px;
  color: #969696;
}

.assistant-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: #9d9d9d;
}

.assistant-step span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #333333;
  color: #a8a8a8;
  font-size: 13px;
}

.assistant-step.is-done span {
  background: rgba(107, 214, 93, 0.14);
  color: var(--success);
}

.assistant-step strong {
  overflow: hidden;
  color: #cfcfcf;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-step small {
  color: #7d7d7d;
  font-size: 12px;
}

.delivery-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 42px;
  margin-top: 14px;
  border: 1px solid #6bd65d;
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(107, 214, 93, 0.12);
  color: #e9ffe5;
  font-size: 14px;
  font-weight: 780;
  text-decoration: none;
}

.delivery-download:hover {
  background: rgba(107, 214, 93, 0.18);
}

.delivery-download span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #6bd65d;
  color: #141414;
  font-size: 16px;
  line-height: 1;
}

body.is-chat-open .task-composer {
  position: sticky;
  bottom: 0;
  order: 2;
  width: min(100%, 820px);
  margin: -112px auto 0;
  padding: 16px 0 22px;
  background: linear-gradient(to top, #191919 82%, rgba(25, 25, 25, 0));
}

body.is-chat-open .prompt-field {
  border-radius: 22px;
  background: #202020;
}

body.is-chat-open .prompt-field textarea {
  min-height: 88px;
  padding: 19px 24px 8px;
  font-size: 16px;
}

body.is-chat-open .evidence-cloud,
body.is-chat-open .message {
  display: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace-header {
    padding: 0 16px;
  }

  .home-stage {
    padding: 38px 16px 54px;
  }

  .stage-inner {
    gap: 20px;
    margin-top: 0;
  }

  .composer-tools,
  .tool-left {
    align-items: stretch;
  }

  .composer-tools {
    display: grid;
    margin-top: 0;
    padding: 0;
    pointer-events: auto;
  }

  .tool-left {
    display: grid;
  }

  .send-button {
    width: 100%;
  }

  .optional-field-grid,
  .skill-card {
    grid-template-columns: 1fr;
  }

  .skill-card {
    margin-top: 8vh;
  }

  body.is-chat-open .home-stage {
    padding: 0 16px;
  }

  body.is-chat-open .task-detail {
    padding-bottom: 170px;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 12px;
  }

  .stage-inner > h1 {
    font-size: 32px;
  }

  .prompt-field {
    border-radius: 22px;
  }

  .prompt-field textarea {
    min-height: 120px;
    padding: 18px;
    font-size: 16px;
  }

  .feature-strip {
    justify-content: flex-start;
  }

  .assistant-step {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .assistant-step small {
    grid-column: 2;
  }
}
