:root {
  --ink: #17211f;
  --muted: #64716e;
  --line: #dde7e1;
  --paper: #ffffff;
  --panel: #f7faf8;
  --accent: #0f766e;
  --blue: #2563eb;
  --shadow: 0 18px 42px rgba(19, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef3f1;
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

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

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 210px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: #0b1220;
  color: #8fd3ff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 10px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.back,
.button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
}

.nav-item,
.back {
  display: flex;
  align-items: center;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.active,
.nav-item:hover,
.back:hover {
  border-color: rgba(15, 118, 110, 0.18);
  background: #e9f7f3;
  color: var(--accent);
}

.back {
  margin-top: auto;
}

.main {
  padding: 22px clamp(18px, 3vw, 38px);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
}

h2 {
  font-size: 17px;
}

.account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--paper);
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
}

.dot.online {
  background: #10b981;
}

.notice,
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.notice {
  margin-bottom: 16px;
  padding: 16px;
}

.notice p {
  margin: 6px 0 12px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(360px, 1.12fr);
  gap: 14px;
}

.panel {
  margin-bottom: 14px;
  padding: 16px;
}

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

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

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

.pill {
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
}

pre {
  min-height: 364px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: 8px;
  background: #0b1220;
  color: #dbeafe;
  padding: 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.task-list,
.session-list,
.workspace-list,
.cards {
  display: grid;
  gap: 10px;
}

.task-item,
.session-item,
.workspace-item,
.cards article {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  padding: 12px;
}

.task-item {
  cursor: pointer;
}

.session-item {
  cursor: pointer;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.task-item:hover,
.session-item:hover,
.session-item.active {
  border-color: rgba(15, 118, 110, 0.35);
}

.session-item.pinned {
  background: #eefbf7;
  border-color: rgba(15, 118, 110, 0.24);
}

.session-main {
  min-width: 0;
}

.session-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.session-item:hover .session-actions,
.session-item.active .session-actions,
.session-item.pinned .session-actions {
  opacity: 1;
}

.session-action {
  min-height: 24px;
  border-radius: 7px;
  padding: 0 7px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.session-action:hover {
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.35);
}

.session-action.delete:hover {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.35);
}

.task-item strong,
.session-item strong,
.workspace-item strong,
.cards article strong {
  display: block;
  margin-bottom: 4px;
}

.task-item span,
.session-item span,
.workspace-item span,
.cards article span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.task-item p,
.session-item p,
.workspace-item p,
.cards article p {
  margin: 6px 0 0;
  color: var(--muted);
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 150px);
}

.chat-sessions-panel,
.chat-panel {
  margin-bottom: 0;
}

.chat-sessions-panel {
  display: flex;
  min-height: 560px;
  flex-direction: column;
}

.session-list {
  overflow: auto;
  padding-right: 2px;
}

.chat-panel {
  display: grid;
  min-height: 560px;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

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

.chat-controls {
  display: grid;
  width: min(520px, 52vw);
  grid-template-columns: minmax(150px, 1fr) 120px 120px;
  gap: 8px;
}

.chat-messages {
  min-height: 360px;
  max-height: calc(100vh - 340px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfa;
  padding: 14px;
}

.message {
  width: min(760px, 92%);
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.message.user {
  margin-left: auto;
  border-color: rgba(15, 118, 110, 0.22);
  background: #e9f7f3;
}

.message span {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.message p {
  margin: 0;
  white-space: pre-wrap;
}

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

.approval-card {
  display: grid;
  gap: 8px;
  margin: 10px 0 2px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  background: #f1faf7;
  padding: 10px;
}

.approval-card strong {
  color: var(--ink);
  font-size: 13px;
}

.approval-card p {
  color: var(--muted);
  font-size: 12px;
}

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

.button.danger {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #fff;
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.chat-input-wrap {
  display: grid;
  gap: 8px;
}

.chat-composer textarea {
  min-height: 84px;
  max-height: 160px;
}

.chat-send-stack {
  display: grid;
  gap: 8px;
}

.chat-attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-attachment-chip {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 280px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 6px 8px;
}

.chat-attachment-chip img {
  width: 42px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  background: #e2e8f0;
}

.chat-attachment-chip div {
  min-width: 0;
}

.chat-attachment-chip strong,
.chat-attachment-chip small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment-chip strong {
  font-size: 12px;
}

.chat-attachment-chip small {
  color: var(--muted);
  font-size: 11px;
}

.chat-attachment-chip button {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
}

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

.workbench-panel {
  padding: 14px;
}

.workbench-actions {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto;
  gap: 8px;
}

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(360px, 1.34fr) minmax(260px, 0.88fr);
  gap: 12px;
  min-height: 560px;
}

.workbench-column {
  display: grid;
  min-width: 0;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfc;
}

.workbench-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
}

.workbench-column-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench-column-head span {
  overflow: hidden;
  max-width: 60%;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tree,
.run-list,
.diff-list {
  overflow: auto;
  padding: 8px;
}

.file-row,
.diff-row {
  display: grid;
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.file-row {
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
}

.file-row:disabled {
  cursor: default;
}

.file-row:hover:not(:disabled),
.diff-row:hover {
  background: #e9f7f3;
}

.file-row.directory {
  color: var(--accent);
  font-weight: 800;
}

.file-name,
.diff-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row small,
.diff-row span {
  color: var(--muted);
  font-size: 11px;
}

.file-preview pre,
pre.file-preview {
  height: 100%;
  min-height: 500px;
  border-radius: 0;
  box-shadow: none;
}

.run-list {
  max-height: 268px;
}

.run-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  padding: 9px;
}

.run-item + .run-item {
  margin-top: 8px;
}

.run-item.ok {
  border-color: rgba(16, 185, 129, 0.28);
}

.run-item.bad {
  border-color: rgba(239, 68, 68, 0.28);
}

.run-item strong,
.run-item span,
.run-item p {
  display: block;
}

.run-item span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.run-item p {
  display: -webkit-box;
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.workbench-diff-head {
  border-top: 1px solid var(--line);
}

.diff-list {
  max-height: 220px;
}

.diff-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin-bottom: 6px;
  padding: 7px 8px;
}

.empty-row {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 12px;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .grid,
  .chat-layout,
  .workbench-grid,
  .cards {
    grid-template-columns: 1fr;
  }

  .workbench-actions {
    grid-template-columns: 1fr;
  }

  .chat-controls {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .chat-head,
  .chat-composer {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
