/* World-class dialog styles for create/delete/confirm flows. */

.cstl-dialog-scrim {
  position: fixed;
  inset: 0;
  background: oklch(20% 0.02 264 / 0.55);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: cstl-fade-in 140ms ease-out;
}

.cstl-dialog {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow:
    0 1px 0 oklch(100% 0 0 / 0.6) inset,
    0 24px 48px oklch(0% 0 0 / 0.18),
    0 4px 12px oklch(0% 0 0 / 0.08);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cstl-pop-in 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cstl-dialog-form {
  max-width: 540px;
}

.cstl-dialog-head {
  padding: 18px 22px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.cstl-dialog-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  flex: 1;
  line-height: 1.35;
}
.cstl-dialog-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 22px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -2px -4px 0 0;
  line-height: 1;
  transition: background 120ms, color 120ms;
}
.cstl-dialog-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.cstl-dialog-body {
  padding: 18px 22px 8px;
  overflow-y: auto;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cstl-dialog-body p {
  margin: 0;
}
.cstl-dialog-body-text {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.cstl-dialog-foot {
  padding: 14px 22px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, oklch(from var(--bg-sunken) l c h / 0.5));
}

.cstl-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cstl-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.cstl-field-req {
  color: var(--warn-text);
  margin-left: 3px;
}
.cstl-field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.cstl-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 13px;
  padding: 8px 30px 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%) calc(100% - 14px) 50%/5px 5px no-repeat,
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%) calc(100% - 9px) 50%/5px 5px no-repeat,
    var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms;
}
.cstl-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.cstl-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}
.cstl-agent-tile {
  appearance: none;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms, background 120ms, transform 80ms;
}
.cstl-agent-tile:hover {
  background: var(--bg-sunken);
}
.cstl-agent-tile.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.cstl-agent-tile-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.cstl-agent-tile-label {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn.danger {
  background: var(--warn);
  color: white;
  border-color: var(--warn);
}
.btn.danger:hover {
  filter: brightness(1.05);
}
.btn.danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Hover-only inline action affordances */

.side-row .row-action {
  opacity: 0;
  transition: opacity 120ms;
  margin-left: 4px;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  line-height: 1;
}
.side-row:hover .row-action {
  opacity: 1;
}
.side-row .row-action:hover {
  color: var(--warn-text);
  background: oklch(from var(--warn) l c h / 0.1);
}

/* New project / new task affordance */

.side-row.add {
  color: var(--text-faint);
  cursor: pointer;
  border-radius: 6px;
  margin-top: 2px;
  transition: background 120ms, color 120ms;
}
.side-row.add:hover {
  background: var(--bg-sunken);
  color: var(--text);
}
.side-row.add .icon {
  color: var(--accent-text);
}

.column-add {
  appearance: none;
  font: inherit;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms;
}
.column-add:hover {
  background: var(--bg-sunken);
  color: var(--accent-text);
}

@keyframes cstl-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cstl-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* In-drawer decision answer composer (for ask_human / validate_findings) */

.decision-card {
  position: relative;
  border-radius: 10px;
  padding: 12px 14px 14px;
  background: oklch(from var(--warn) l c h / 0.06);
  border: 1px solid oklch(from var(--warn) l c h / 0.3);
  box-shadow: 0 0 0 1px oklch(from var(--warn) l c h / 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.decision-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warn-text);
  font-weight: 600;
}
.decision-prompt {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
}

.decision-text-input {
  width: 100%;
  appearance: none;
  font: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: border-color 120ms, box-shadow 120ms;
}
.decision-text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.decision-inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.decision-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.decision-options .decision-opt {
  appearance: none;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: border-color 120ms, background 120ms;
}
.decision-options .decision-opt:hover {
  background: var(--bg-sunken);
}
.decision-options .decision-opt.picked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.decision-options .decision-opt .num {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-muted);
}
.decision-options .decision-opt.picked .num {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Markdown rendered in CoT messages */
.msg-md {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.msg-md p { margin: 0 0 8px; }
.msg-md p:last-child { margin-bottom: 0; }
.msg-md h1, .msg-md h2, .msg-md h3, .msg-md h4 {
  margin: 12px 0 6px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.msg-md h1 { font-size: 16px; }
.msg-md h2 { font-size: 15px; }
.msg-md h3 { font-size: 14px; }
.msg-md h4 { font-size: 13.5px; color: var(--text-muted); }
.msg-md ul, .msg-md ol { margin: 4px 0 8px; padding-left: 18px; }
.msg-md li { margin: 2px 0; }
.msg-md code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg-md pre {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: 6px 0 8px;
}
.msg-md pre code {
  background: transparent;
  border: none;
  padding: 0;
}
.msg-md a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.msg-md blockquote {
  border-left: 3px solid var(--border);
  padding: 2px 10px;
  color: var(--text-muted);
  margin: 6px 0;
}
.msg-md table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 12.5px;
}
.msg-md th, .msg-md td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.msg-md th { background: var(--bg-sunken); }
.msg-md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.msg-md strong { font-weight: 600; }
.msg-md em { font-style: italic; }

/* Shared knowledge / findings panel */
.findings-panel {
  margin-top: 8px;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}
.finding-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.finding-item:hover {
  border-color: var(--accent);
  background: var(--bg-sunken);
}
.finding-body { flex: 1; min-width: 0; }
.finding-text {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.finding-meta {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-faint);
  flex-wrap: wrap;
}
.finding-tag {
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}
