* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
}

body {
  background: var(--cp-bg);
  color: var(--cp-text);
  font-family: "Segoe UI", Aptos, Calibri, -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

button {
  cursor: pointer;
}

a {
  color: var(--cp-link);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  background: var(--cp-bg-elevated);
  border-right: 1px solid var(--cp-border);
  z-index: 20;
}

.brand-row,
.topbar,
.dialog-header,
.preview-actions,
.message-meta,
.artifact-actions,
.run-summary,
.step-heading {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 11px;
  padding: 4px 8px 18px;
}

.brand-row strong,
.brand-row span {
  display: block;
}

.brand-row span,
.topbar p,
.dialog-header p,
.model-label,
.composer-hint,
.message-meta span,
.artifact-meta,
.step-detail {
  color: var(--cp-text-muted);
}

.brand-row span,
.topbar p,
.dialog-header p {
  margin-top: 3px;
  font-size: 12px;
}

.brand-mark,
.welcome-orb,
.avatar {
  display: grid;
  place-items: center;
  color: var(--cp-accent-fg);
  background: var(--cp-accent);
  font-weight: 700;
}

.brand-mark,
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 0.625rem;
}

.welcome-orb {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  font-size: 23px;
}

.new-chat,
.settings-button,
.secondary-button,
.primary-button,
.danger-button,
.agent-chip,
.artifact-button {
  border-radius: 0.625rem;
  font-weight: 600;
}

.new-chat,
.settings-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cp-border);
  background: var(--cp-surface);
  color: var(--cp-text);
}

.sidebar-footer .settings-button + .settings-button {
  margin-top: 8px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 14px 0;
  padding: 4px;
  background: var(--cp-surface-soft);
  border-radius: 0.625rem;
}

.mode-switch button {
  padding: 8px;
  border: 0;
  border-radius: 0.625rem;
  background: transparent;
  color: var(--cp-text-muted);
}

.mode-switch button.active {
  background: var(--cp-surface);
  color: var(--cp-text);
  box-shadow: var(--cp-shadow);
  font-weight: 600;
}

.sidebar-section {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 7px;
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.text-button,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--cp-text-muted);
}

.conversation-list {
  max-height: calc(100vh - 285px);
  overflow-y: auto;
}

.conversation-empty {
  padding: 12px 10px;
  color: var(--cp-text-muted);
  font-size: 0.82rem;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 2px;
}

.conversation-item {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 0.625rem;
  background: transparent;
  color: var(--cp-text);
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--cp-surface);
}

.conversation-item strong,
.conversation-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item strong {
  font-size: 13px;
}

.conversation-item span {
  margin-top: 3px;
  color: var(--cp-text-muted);
  font-size: 11px;
}

.conversation-delete {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--cp-text-muted);
  font-size: 1.15rem;
}

.conversation-delete:hover {
  background: var(--cp-accent-soft);
  color: var(--cp-danger);
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--cp-border);
}

.model-label {
  margin-top: 9px;
  text-align: center;
  font-size: 11px;
}

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

.topbar {
  justify-content: space-between;
  gap: 12px;
  padding: 15px 28px;
  border-bottom: 1px solid var(--cp-border);
  background: var(--cp-panel-strong);
  z-index: 10;
}

.topbar h1,
.dialog-header h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 16px;
}

.topbar p,
.dialog-header p {
  margin-bottom: 0;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 999px;
  background: var(--cp-surface);
  color: var(--cp-text-muted);
  font-size: 11px;
}

.status-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cp-success);
}

.chat-canvas {
  overflow-y: auto;
  padding: 34px max(24px, calc((100% - 900px) / 2));
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 720px;
  margin: 8vh auto 0;
  text-align: center;
}

.welcome[hidden] {
  display: none;
}

.welcome h2 {
  margin: 20px 0 8px;
  font-size: clamp(25px, 4vw, 38px);
  letter-spacing: -0.035em;
}

.welcome > p {
  max-width: 540px;
  margin: 0;
  color: var(--cp-text-muted);
  line-height: 1.55;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 30px;
}

.suggestions button {
  min-height: 105px;
  padding: 15px;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-surface);
  color: var(--cp-text);
  text-align: left;
  line-height: 1.35;
  box-shadow: var(--cp-shadow);
}

.suggestions button:hover {
  border-color: var(--cp-border-strong);
}

.suggestions button span {
  display: block;
  margin-bottom: 14px;
  color: var(--cp-accent);
  font-size: 21px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

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

.message.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.message.user .message-body {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px 16px 4px 16px;
  background: var(--cp-accent-soft);
}

.message-body {
  min-width: 0;
}

.message-meta {
  gap: 8px;
  margin-bottom: 7px;
  font-size: 12px;
}

.message-content {
  color: var(--cp-text);
  line-height: 1.66;
  overflow-wrap: anywhere;
}

.message-content pre,
.preview-code {
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-bg-elevated);
  color: var(--cp-text);
  font-family: Consolas, "Courier New", Courier, monospace;
  white-space: pre-wrap;
}

.message-content code {
  font-family: Consolas, "Courier New", Courier, monospace;
}

.typing::after {
  content: "▋";
  color: var(--cp-accent);
}

.run-panel {
  margin: 12px 0;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
}

.run-summary {
  display: flex;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.run-summary::-webkit-details-marker {
  display: none;
}

.run-summary strong {
  display: flex;
  align-items: center;
  gap: 7px;
}

.run-summary > span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.run-state {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--cp-surface-soft);
  color: var(--cp-text-muted);
  font-weight: 600;
  text-transform: capitalize;
}

.run-progress-value {
  min-width: 38px;
  color: var(--cp-text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.run-toggle {
  color: var(--cp-link);
}

.run-details {
  padding: 0 14px 14px;
}

.progress-track {
  height: 6px;
  margin: 11px 0 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--cp-surface-soft);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--cp-accent);
  transition: width 0.25s ease;
}

.run-steps {
  display: grid;
  gap: 12px;
}

.run-step {
  position: relative;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--cp-border);
  border-left: 4px solid var(--cp-border-strong);
  border-radius: 0.625rem;
  background: var(--cp-bg-elevated);
}

.run-step.running {
  border-left-color: var(--cp-warning);
}

.run-step.completed {
  border-left-color: var(--cp-success);
}

.run-step.failed {
  border-left-color: var(--cp-danger);
}

.step-heading {
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.step-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.step-title strong {
  overflow-wrap: anywhere;
}

.step-sequence {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border: 1px solid var(--cp-border);
  border-radius: 50%;
  background: var(--cp-surface);
  color: var(--cp-text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.step-status {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--cp-surface-soft);
  color: var(--cp-text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.run-step.running .step-status {
  color: var(--cp-warning);
}

.run-step.completed .step-status {
  color: var(--cp-success);
}

.run-step.failed .step-status {
  color: var(--cp-danger);
}

.step-result-label {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--cp-border);
  color: var(--cp-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.step-detail {
  max-width: 100%;
  margin-top: 6px;
  overflow-x: auto;
  color: var(--cp-text);
  font-size: 12px;
  line-height: 1.6;
}

.step-detail > :first-child,
.message-content > :first-child {
  margin-top: 0;
}

.step-detail > :last-child,
.message-content > :last-child {
  margin-bottom: 0;
}

.step-detail p,
.message-content p {
  margin: 8px 0;
}

.step-detail h1,
.step-detail h2,
.step-detail h3,
.step-detail h4,
.step-detail h5,
.step-detail h6 {
  margin: 14px 0 7px;
  color: var(--cp-text);
  line-height: 1.3;
}

.step-detail h1 {
  font-size: 18px;
}

.step-detail h2 {
  font-size: 16px;
}

.step-detail h3,
.step-detail h4,
.step-detail h5,
.step-detail h6 {
  font-size: 14px;
}

.step-detail ul,
.step-detail ol {
  margin: 5px 0;
  padding-left: 20px;
}

.step-detail li + li {
  margin-top: 3px;
}

.step-detail blockquote {
  margin: 7px 0;
  padding: 6px 9px;
  border-left: 3px solid var(--cp-accent);
  background: var(--cp-surface-soft);
}

.step-detail pre {
  margin: 7px 0;
  padding: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
  border-radius: 6px;
  background: var(--cp-surface-soft);
  font-family: Consolas, "Courier New", Courier, monospace;
}

.step-detail code {
  font-family: Consolas, "Courier New", Courier, monospace;
}

.step-empty {
  color: var(--cp-text-muted);
  font-style: italic;
}

.markdown-table-wrap {
  max-width: 100%;
  margin: 7px 0;
  overflow-x: auto;
}

.markdown-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-table-wrap th,
.markdown-table-wrap td {
  padding: 5px 7px;
  border: 1px solid var(--cp-border);
  text-align: left;
  vertical-align: top;
}

.markdown-table-wrap th {
  background: var(--cp-surface-soft);
}

.step-detail table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
}

.step-detail th,
.step-detail td {
  padding: 7px 9px;
  border: 1px solid var(--cp-border);
  text-align: left;
  vertical-align: top;
}

.step-detail th {
  background: var(--cp-surface-soft);
}

.step-artifacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.step-artifacts:empty {
  display: none;
}

.artifact-section {
  margin-top: 14px;
}

.token-usage {
  margin-top: 10px;
  color: var(--cp-text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.artifact-section[hidden] {
  display: none;
}

.artifact-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.artifact-card {
  padding: 11px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-bg-elevated);
}

.artifact-name {
  overflow: hidden;
  color: var(--cp-text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-meta {
  margin: 4px 0 9px;
  font-size: 11px;
}

.artifact-actions {
  gap: 7px;
}

.artifact-button,
.secondary-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-decoration: none;
}

.artifact-button,
.secondary-button {
  border: 1px solid var(--cp-border);
  background: var(--cp-surface);
  color: var(--cp-text);
}

.primary-button {
  border: 1px solid var(--cp-accent);
  background: var(--cp-accent);
  color: var(--cp-accent-fg);
}

.danger-button {
  margin-right: auto;
  border: 1px solid var(--cp-danger);
  background: var(--cp-surface);
  color: var(--cp-danger);
}

.composer-wrap {
  padding: 10px max(24px, calc((100% - 900px) / 2)) 14px;
  background: var(--cp-bg);
}

.agent-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 5px 2px 8px;
}

.agent-chips[hidden] {
  display: none;
}

.agent-chip {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--cp-border);
  background: var(--cp-surface);
  color: var(--cp-text-muted);
  font-size: 11px;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--cp-border-strong);
  border-radius: 16px;
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
}

.mention-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(420px, calc(100vw - 32px));
  max-height: 280px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
  z-index: 30;
}

.mention-menu[hidden] {
  display: none;
}

.mention-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 9px;
  border: 0;
  border-radius: 0.625rem;
  background: transparent;
  color: var(--cp-text);
  text-align: left;
}

.mention-option:hover,
.mention-option.active {
  background: var(--cp-accent-soft);
}

.mention-option strong,
.mention-option span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option strong {
  font-size: 12px;
}

.mention-option span {
  margin-top: 3px;
  color: var(--cp-text-muted);
  font-size: 11px;
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--cp-text);
  line-height: 1.5;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mode-badge {
  color: var(--cp-text-muted);
  font-size: 11px;
}

.send-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 0.625rem;
  background: var(--cp-accent);
  color: var(--cp-accent-fg);
  font-size: 19px;
}

.send-button:disabled {
  opacity: 0.45;
}

.composer-hint {
  margin: 7px 0 0;
  text-align: center;
  font-size: 10px;
}

dialog {
  width: min(920px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-bg-elevated);
  color: var(--cp-text);
  box-shadow: var(--cp-shadow);
}

dialog::backdrop {
  background: var(--cp-overlay);
}

.dialog-header {
  justify-content: space-between;
  gap: 12px;
  padding: 19px 22px;
  border-bottom: 1px solid var(--cp-border);
}

.icon-button {
  width: 34px;
  height: 34px;
  font-size: 20px;
}

.agent-manager {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  min-height: 540px;
}

.agent-list-panel {
  padding: 14px;
  border-right: 1px solid var(--cp-border);
  background: var(--cp-surface-soft);
  overflow-y: auto;
}

.agent-list-toolbar {
  position: sticky;
  top: -14px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -14px -14px 12px;
  padding: 14px;
  border-bottom: 1px solid var(--cp-border);
  background: var(--cp-surface-soft);
}

.agent-add-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--cp-accent);
  border-radius: 50%;
  background: var(--cp-accent);
  color: var(--cp-accent-fg);
  font-size: 22px;
  line-height: 1;
}

.agent-list-group + .agent-list-group {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--cp-border);
}

.agent-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin-bottom: 8px;
}

.agent-group-heading h4 {
  margin: 0 0 8px;
  color: var(--cp-text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.agent-group-heading h4 {
  margin-bottom: 0;
}

.agent-list-empty {
  margin: 0;
  padding: 10px;
  color: var(--cp-text-muted);
  font-size: 12px;
}

.managed-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 7px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 0.625rem;
  background: transparent;
  color: var(--cp-text);
  text-align: left;
}

.managed-agent:hover {
  border-color: var(--cp-border);
  background: var(--cp-surface);
}

.managed-agent.active {
  border-color: var(--cp-accent);
  background: var(--cp-accent-soft);
}

.managed-agent strong,
.managed-agent span {
  display: block;
}

.managed-agent span {
  margin-top: 2px;
  color: var(--cp-text-muted);
  font-size: 11px;
}

.agent-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 20px;
  overflow-y: auto;
}

.agent-form-status {
  padding: 9px 11px;
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.agent-form label,
.agent-form legend {
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.agent-form input,
.agent-form textarea,
.agent-form select {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  outline: none;
  background: var(--cp-surface);
  color: var(--cp-text);
}

.agent-form input:disabled,
.agent-form textarea:disabled,
.agent-form select:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.agent-form.read-only input,
.agent-form.read-only textarea,
.agent-form.read-only select {
  user-select: text;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

fieldset {
  display: flex;
  gap: 16px;
  border: 0;
  padding: 0;
}

.capability-fieldset {
  flex-direction: column;
  gap: 9px;
}

.agent-skill-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.skill-option {
  align-items: flex-start;
  padding: 9px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
}

.skill-option span {
  display: grid;
  gap: 3px;
}

.skill-option strong {
  color: var(--cp-text);
}

.skill-option small {
  color: var(--cp-text-muted);
  font-weight: 400;
  line-height: 1.35;
}

.cli-sandbox-status.warning {
  color: var(--cp-warning);
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500 !important;
}

.check-label input {
  width: auto;
  margin: 0;
}

.form-actions,
.remote-row {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.remote-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cp-text-muted);
  font-size: 11px;
}

.remote-divider::before,
.remote-divider::after {
  height: 1px;
  flex: 1;
  background: var(--cp-border);
  content: "";
}

.remote-row input {
  margin: 0;
}

.preview-dialog {
  width: min(1080px, calc(100vw - 28px));
  height: min(820px, calc(100vh - 28px));
}

.agent-create-dialog {
  width: min(780px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
}

.agent-create-dialog .agent-form {
  max-height: calc(100vh - 150px);
  padding: 18px;
  background: var(--cp-bg-elevated);
}

.agent-form-section {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-surface);
}

.agent-form-section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--cp-border);
}

.agent-form-section-heading > span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--cp-accent);
  color: var(--cp-accent-fg);
  font-size: 12px;
  font-weight: 700;
}

.agent-form-section-heading div {
  display: grid;
  gap: 2px;
}

.agent-form-section-heading strong {
  color: var(--cp-text);
  font-size: 14px;
}

.agent-form-section-heading small {
  color: var(--cp-text-muted);
  font-size: 11px;
}

.agent-identity-grid,
.agent-tool-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.agent-tool-options .check-label,
.agent-enabled-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
}

.agent-tool-options .check-label > span,
.agent-enabled-option > span {
  display: grid;
  gap: 3px;
}

.agent-tool-options strong,
.agent-enabled-option strong {
  color: var(--cp-text);
}

.agent-tool-options small,
.agent-enabled-option small {
  color: var(--cp-text-muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
}

.agent-enabled-option input {
  width: auto;
  margin: 2px 0 0;
}

.agent-create-actions {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  margin: 2px -18px -18px;
  padding: 12px 18px;
  border-top: 1px solid var(--cp-border);
  background: var(--cp-panel-strong);
}

.settings-dialog {
  width: min(980px, calc(100vw - 28px));
  height: min(860px, calc(100dvh - 28px));
  max-height: min(860px, calc(100vh - 28px));
  overflow: hidden;
}

.settings-dialog[open] {
  display: flex;
  flex-direction: column;
}

.network-panel {
  padding: 20px;
}

.network-intro,
.network-mode-form,
.network-rule-card,
.network-rule-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.network-intro h3,
.network-intro p {
  margin: 0;
}

.network-intro p,
.network-rule-card span,
.network-status,
.network-empty {
  color: var(--cp-text-muted);
  font-size: 12px;
}

.network-mode-form,
.network-rule-form {
  margin: 18px 0 10px;
  align-items: end;
}

.network-mode-form label,
.network-rule-form label {
  flex: 1;
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.network-mode-form select,
.network-rule-form input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
  color: var(--cp-text);
}

.network-mode-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--cp-warning);
  border-radius: 0.625rem;
  background: color-mix(in srgb, var(--cp-warning) 12%, transparent);
  color: var(--cp-text);
  font-size: 12px;
}

.network-status {
  margin-bottom: 12px;
}

.network-status.error {
  color: var(--cp-danger);
}

.network-rule-list {
  display: grid;
  gap: 8px;
}

.network-rule-card {
  padding: 11px 12px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
}

.network-rule-card strong,
.network-rule-card span {
  display: block;
}

.settings-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--cp-border);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.settings-tabs button {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--cp-text-muted);
}

.settings-tabs button.active {
  border-bottom-color: var(--cp-accent);
  color: var(--cp-text);
  font-weight: 700;
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel {
  min-height: 0;
  flex: 1 1 auto;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.settings-form {
  padding: 20px;
  overflow-y: auto;
}

.settings-section {
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--cp-border);
}

.settings-section:first-child {
  padding-top: 0;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

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

.settings-grid label {
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.settings-grid input,
.settings-grid select {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  outline: none;
  background: var(--cp-surface);
  color: var(--cp-text);
}

.sandbox-settings-form {
  border-bottom: 1px solid var(--cp-border);
}

.sandbox-status-card {
  display: flex;
  min-height: 68px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
}

.sandbox-status-card span {
  color: var(--cp-text-muted);
  font-size: 11px;
  font-weight: 600;
}

.sandbox-status-card strong,
.sandbox-status-card a {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.sandbox-provider-fields[hidden] {
  display: none;
}

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

.field-note {
  display: block;
  margin-top: 5px;
  color: var(--cp-text-muted);
  font-size: 11px;
  font-weight: 400;
}

.settings-warning {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--cp-warning);
  border-radius: 0.625rem;
  background: var(--cp-surface);
  color: var(--cp-text);
  font-size: 12px;
}

.settings-actions {
  position: sticky;
  bottom: 0;
  padding-top: 16px;
  background: var(--cp-bg-elevated);
}

.settings-panel .agent-manager {
  min-height: 560px;
}

.skills-panel {
  padding: 20px;
}

.skills-intro h3 {
  margin: 0;
}

.skills-intro p {
  margin: 6px 0 18px;
  color: var(--cp-text-muted);
  font-size: 12px;
}

.skills-list {
  display: grid;
  gap: 10px;
}

.skill-upload {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(220px, 1.2fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px dashed var(--cp-border-strong);
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
}

.skill-upload input[type="file"],
.skill-upload input[type="text"] {
  min-width: 0;
}

.skill-upload input[type="text"] {
  padding: 9px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
  color: var(--cp-text);
}

.skill-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
}

.skill-card strong,
.skill-card code {
  display: inline-block;
  margin-right: 8px;
}

.skill-card code {
  color: var(--cp-text-muted);
  font-size: 11px;
}

.skill-kind {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--cp-accent-soft);
  color: var(--cp-text-muted);
  font-size: 10px;
}

.skill-card p {
  margin: 7px 0 0;
  color: var(--cp-text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.skill-command {
  color: var(--cp-link) !important;
  font-family: Consolas, "Courier New", monospace;
}

.skill-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 12px;
}

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

.skill-delete {
  padding: 6px 9px;
  border: 1px solid var(--cp-danger);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--cp-danger);
}

.claw-panel {
  padding: 20px;
}

.claw-intro,
.claw-task-heading,
.claw-task-actions {
  display: flex;
  align-items: center;
}

.claw-intro {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.claw-intro h3 {
  margin: 0;
}

.claw-intro p,
.claw-task-card p,
.claw-empty {
  color: var(--cp-text-muted);
  font-size: 12px;
}

.claw-intro p {
  margin: 5px 0 0;
}

.claw-task-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
}

.claw-task-form label {
  color: var(--cp-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.claw-task-form input,
.claw-task-form select,
.claw-task-form textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  outline: none;
  background: var(--cp-surface);
  color: var(--cp-text);
}

.claw-task-form textarea {
  resize: vertical;
}

.claw-task-form .claw-enabled {
  align-self: end;
  padding-bottom: 10px;
}

.claw-task-form .claw-enabled input {
  width: auto;
  margin: 0;
}

.claw-task-list {
  display: grid;
  gap: 10px;
}

.claw-task-card {
  padding: 15px;
  border: 1px solid var(--cp-border);
  border-left: 4px solid var(--cp-border-strong);
  border-radius: 0.625rem;
  background: var(--cp-surface);
}

.claw-task-card.running {
  border-left-color: var(--cp-warning);
}

.claw-task-card.failed {
  border-left-color: var(--cp-danger);
}

.claw-task-heading {
  justify-content: space-between;
  gap: 12px;
}

.claw-task-heading strong,
.claw-task-heading span {
  display: block;
}

.claw-task-heading span {
  margin-top: 3px;
  color: var(--cp-text-muted);
  font-size: 11px;
  text-transform: capitalize;
}

.claw-status {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--cp-accent-soft);
}

.claw-task-card code {
  display: block;
  margin-top: 12px;
  padding: 9px 10px;
  overflow-wrap: anywhere;
  border-radius: 0.5rem;
  background: var(--cp-surface-soft);
  color: var(--cp-text);
  font-size: 11px;
  white-space: pre-wrap;
}

.claw-task-card p {
  margin: 8px 0 0;
}

.claw-task-card .claw-error {
  color: var(--cp-danger);
}

.claw-task-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.claw-task-actions .skill-toggle {
  margin-right: auto;
}

.preview-dialog .dialog-header {
  position: sticky;
  top: 0;
  background: var(--cp-bg-elevated);
  z-index: 2;
}

.preview-body {
  height: calc(100% - 78px);
  padding: 20px;
  overflow: auto;
}

.preview-body:has(.preview-pdf) {
  padding: 0;
  overflow: hidden;
}

.preview-zoom-actions {
  align-items: center;
  gap: 4px;
}

.preview-zoom-actions .secondary-button {
  min-width: 34px;
  padding: 7px 9px;
}

.preview-zoom-actions .preview-zoom-value {
  min-width: 64px;
}

.preview-image-stage {
  min-width: 100%;
  min-height: 100%;
  text-align: center;
}

.preview-image {
  display: block;
  max-width: none;
  height: auto;
  margin: 0 auto;
  border-radius: 0.625rem;
  box-shadow: var(--cp-shadow);
  transition: width 0.15s ease;
}

.preview-pdf {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--cp-surface);
}

.preview-document {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
  line-height: 1.65;
  white-space: pre-wrap;
}

.preview-slide {
  margin-bottom: 14px;
  padding: 24px;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-surface);
  white-space: pre-wrap;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table td {
  padding: 7px;
  border: 1px solid var(--cp-border);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(380px, calc(100vw - 44px));
  padding: 11px 15px;
  border-radius: 0.625rem;
  background: var(--cp-text);
  color: var(--cp-bg);
  box-shadow: var(--cp-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-only {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    min-width: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  body:has(dialog[open]) {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 310px);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--cp-shadow);
  }

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

  .mobile-only {
    display: inline-grid;
    place-items: center;
  }

  .workspace {
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }

  .topbar,
  .chat-canvas,
  .composer-wrap {
    width: auto;
    min-width: 0;
    max-width: 100%;
  }

  .topbar {
    padding: 12px 14px;
  }

  .topbar > div {
    min-width: 0;
  }

  .topbar h1,
  .topbar p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-pill {
    display: none;
  }

  .chat-canvas {
    width: 100%;
    min-width: 0;
    padding: 20px 14px;
  }

  .messages,
  .message,
  .message-body,
  .message-content,
  .run-slot,
  .run-panel,
  .run-details,
  .run-steps,
  .run-step,
  .artifact-section,
  .artifact-grid,
  .artifact-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .message-content code,
  .message-content a,
  .step-detail,
  .artifact-name,
  .artifact-meta {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .run-summary,
  .step-heading,
  .artifact-actions {
    min-width: 0;
    flex-wrap: wrap;
  }

  .run-summary > span {
    min-width: 0;
    margin-left: auto;
  }

  .welcome {
    margin-top: 4vh;
  }

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

  .suggestions button {
    min-height: 78px;
  }

  .composer-wrap {
    padding: 8px 10px 10px;
  }

  .composer,
  .agent-chips,
  .composer-hint {
    min-width: 0;
    max-width: 100%;
  }

  .message.user .message-body {
    max-width: 92%;
  }

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

  .agent-manager {
    grid-template-columns: 1fr;
    max-height: 78vh;
    overflow-y: auto;
  }

  .agent-list-panel {
    max-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--cp-border);
  }

  fieldset {
    flex-direction: column;
    gap: 8px;
  }

  .agent-skill-options {
    grid-template-columns: 1fr;
  }

  .agent-create-dialog {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .agent-create-dialog .agent-form {
    max-height: calc(100dvh - 78px);
    padding: 12px;
  }

  .agent-form-section {
    padding: 13px;
  }

  .agent-identity-grid,
  .agent-tool-options {
    grid-template-columns: 1fr;
  }

  .agent-create-actions {
    bottom: -12px;
    margin: 2px -12px -12px;
    padding: 12px;
  }

  .settings-dialog {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .settings-dialog .dialog-header {
    flex: 0 0 auto;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  }

  .settings-dialog .dialog-header p {
    display: none;
  }

  .settings-dialog .icon-button {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .settings-tabs {
    gap: 0;
    padding: 0 4px;
  }

  .settings-tabs button {
    flex: 1 1 auto;
    min-height: 48px;
    padding: 10px 6px;
    font-size: 14px;
  }

  .settings-panel {
    max-height: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .settings-form,
  .skills-panel,
  .claw-panel {
    padding: 14px;
  }

  .settings-section {
    padding: 12px 0 16px;
  }

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

  .settings-grid input,
  .settings-grid select,
  .agent-form input,
  .agent-form textarea,
  .agent-form select,
  .claw-task-form input,
  .claw-task-form textarea,
  .claw-task-form select,
  .network-mode-form select,
  .network-rule-form input,
  .skill-upload input {
    min-height: 44px;
    font-size: 16px;
  }

  .settings-actions {
    margin: 0 -14px -14px;
    padding: 12px 14px max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--cp-border);
  }

  .settings-actions button,
  .form-actions button {
    min-height: 44px;
    flex: 1;
  }

  .settings-panel[data-settings-panel="agents"] {
    overflow: hidden;
  }

  .settings-panel .agent-manager {
    grid-template-rows: minmax(140px, 32%) minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .agent-list-panel {
    max-height: none;
  }

  .agent-form {
    min-height: 0;
    padding: 14px;
  }

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

  .remote-row,
  .network-intro,
  .network-mode-form,
  .network-rule-form,
  .network-rule-card,
  .claw-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .remote-row input,
  .remote-row button,
  .network-intro button,
  .network-mode-form button,
  .network-rule-form button {
    width: 100%;
    min-height: 44px;
  }

  .network-panel {
    padding: 14px;
  }

  .network-panel > .settings-form {
    padding: 0 0 14px;
  }

  .skill-upload {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .skill-upload button {
    min-height: 44px;
  }

  .skill-card {
    min-width: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .skill-card > div {
    min-width: 0;
  }

  .skill-card code,
  .skill-card p {
    overflow-wrap: anywhere;
  }

  .skill-card .skill-toggle {
    align-self: flex-start;
  }

  .claw-task-form {
    grid-template-columns: 1fr;
  }

  .claw-task-form .wide-field {
    grid-column: auto;
  }

  .claw-task-actions .skill-toggle {
    width: 100%;
  }

  .wide-field {
    grid-column: auto;
  }
}
