.controls .action {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.controls .action.secondary {
  background: rgba(210, 107, 52, 0.08);
  color: var(--accent-strong);
  border-color: rgba(210, 107, 52, 0.4);
}

.controls .action:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(210, 107, 52, 0.2);
}

.icon-button {
  border: 1px solid rgba(210, 107, 52, 0.35);
  background: rgba(210, 107, 52, 0.12);
  color: var(--accent-strong);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  box-shadow: 0 10px 18px rgba(210, 107, 52, 0.16);
  transform: translateY(-1px);
}

.stage-action {
  border: 1px solid rgba(210, 107, 52, 0.35);
  background: rgba(210, 107, 52, 0.08);
  color: var(--accent-strong);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stage-action.secondary {
  background: transparent;
}

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

.stage-action.danger {
  border-color: rgba(208, 68, 47, 0.4);
  color: #b13222;
  background: rgba(208, 68, 47, 0.1);
}

.stage-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.stage-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(210, 107, 52, 0.16);
}

.stage-action.run-agent-btn {
  background: rgba(47, 159, 99, 0.12);
  border-color: rgba(47, 159, 99, 0.4);
  color: var(--low);
}

.stage-action.run-agent-btn:hover:not(:disabled) {
  background: rgba(47, 159, 99, 0.2);
  box-shadow: 0 10px 18px rgba(47, 159, 99, 0.16);
}

.stage-action.run-agent-btn.running {
  background: rgba(47, 159, 99, 0.08);
  border-color: rgba(47, 159, 99, 0.25);
  cursor: wait;
}

@keyframes pulse-agent {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.stage-action.run-agent-btn.running {
  animation: pulse-agent 1.5s ease-in-out infinite;
}

.stage-modal {
  position: absolute;
  inset: 0;
  background: rgba(255, 250, 245, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 5;
}

.stage-modal[hidden] {
  display: none;
}

.board-modal {
  position: fixed;
  inset: 0;
  background: rgba(247, 236, 225, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 6;
}

.board-modal[hidden] {
  display: none;
}

.board-modal-card {
  background: var(--surface-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 100%);
  box-shadow: var(--shadow);
}

.board-modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.board-modal-card label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 700;
}

.board-modal-card .required-indicator {
  color: var(--destructive, #d9534f);
  font-size: 0.8rem;
}

.board-modal-card input {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.95rem;
}

.board-modal-status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1rem;
}

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

.stage-modal-card {
  background: var(--surface-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 100%);
  box-shadow: var(--shadow);
}

#stage-edit-modal .stage-modal-card {
  width: min(900px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
}

.stage-modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.stage-modal-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stage-modal-card label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 700;
}

.stage-modal-card select {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.9rem;
}

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

/* Stage edit modal — section layout */
.stage-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.stage-section-heading {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 700;
  margin: 0;
}

.stage-section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stage-section-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.stage-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stage-section-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: flex-start;
}

.stage-modal-card .stage-checkbox-label {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 500;
}

.stage-modal-card input[type="text"],
.stage-modal-card input[type="number"] {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.9rem;
}

/* Responsive — collapse to single column on small screens */
@media (max-width: 600px) {
  #stage-edit-modal .stage-modal-card {
    width: 100%;
  }

  .stage-section-grid {
    grid-template-columns: 1fr !important;
  }

  .stage-section-row {
    flex-direction: column;
  }
}

/* MCP Tools section — heading row and bulk actions */
.mcp-tools-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mcp-tools-bulk-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
}

.mcp-tools-bulk-actions a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}

.mcp-tools-bulk-actions a:hover {
  text-decoration: underline;
}

.mcp-tools-separator {
  color: var(--muted);
}

/* MCP Tool chips */
.mcp-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mcp-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  border: 1px solid transparent;
  user-select: none;
}

.mcp-chip.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(210, 107, 52, 0.25);
}

.mcp-chip.active:hover {
  filter: brightness(1.1);
}

.mcp-chip.inactive {
  background: var(--surface-strong);
  color: var(--muted);
  border-color: var(--border);
}

.mcp-chip.inactive:hover {
  filter: brightness(1.08);
}

.mcp-tools-empty {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

.stage-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.stage-composer {
  border-radius: 16px;
  border: 1px dashed rgba(210, 107, 52, 0.4);
  padding: 12px;
  display: grid;
  gap: 10px;
  background: rgba(210, 107, 52, 0.05);
  flex-shrink: 0;
}

.stage-composer input,
.stage-composer select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.9rem;
}

.stage-composer button {
  justify-self: start;
}

.stage-composer .composer-status {
  color: var(--muted);
  font-size: 0.8rem;
}

.card {
  background: var(--surface-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: card-in 0.6s ease both;
  animation-delay: var(--delay, 0ms);
  position: relative;
  cursor: grab;
}

.card.selected {
  border-color: rgba(210, 107, 52, 0.5);
  box-shadow: 0 18px 30px rgba(210, 107, 52, 0.15);
}

.card.dragging {
  opacity: 0.6;
  cursor: grabbing;
}

/* Indented child cards when parent-only filter is OFF */
.card.card-indented {
  margin-left: 20px;
}

.card.drop-above::before,
.card.drop-below::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(210, 107, 52, 0.35);
}

.card.drop-above::before {
  top: -7px;
}

.card.drop-below::after {
  bottom: -7px;
}

.order-inline {
  color: var(--muted);
  font-weight: 600;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.9rem;
  margin-right: 6px;
}

.card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
}

.badge.low {
  background: var(--low);
}

.badge.medium {
  background: var(--medium);
}

.badge.high {
  background: var(--high);
}

.order-index {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.drag-handle {
  margin-left: auto;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  font-weight: 700;
  color: var(--muted);
  background: rgba(27, 27, 27, 0.08);
  border-radius: 999px;
  padding: 4px 10px 4px 12px;
  cursor: grab;
  user-select: none;
}

.card.dragging .drag-handle {
  cursor: grabbing;
}

.card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.preview {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.view {
  margin-left: auto;
  border: none;
  background: rgba(210, 107, 52, 0.12);
  color: var(--accent-strong);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.view:hover {
  background: rgba(210, 107, 52, 0.2);
}

.detail-actions .action {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.detail-actions .action.secondary {
  background: rgba(210, 107, 52, 0.08);
  color: var(--accent-strong);
  border-color: rgba(210, 107, 52, 0.4);
}

.detail-actions .action.danger {
  background: rgba(208, 68, 47, 0.12);
  color: var(--high);
  border-color: rgba(208, 68, 47, 0.32);
}

.detail-actions .action:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(210, 107, 52, 0.18);
}

.detail-actions .action.danger:hover {
  box-shadow: 0 10px 18px rgba(208, 68, 47, 0.2);
}

.detail-form label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
}

.detail-form input,
.detail-form select,
.detail-form textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface-strong);
  color: var(--ink);
}

.detail-form textarea {
  min-height: 140px;
  resize: vertical;
}


.message-item {
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid rgba(27, 27, 27, 0.08);
  position: relative;
  margin-left: calc(var(--depth, 0) * 18px);
}

.message-body {
  margin: 0 0 8px;
  white-space: pre-wrap;
  color: var(--ink);
}

.message-meta {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.message-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.message-item-actions {
  display: flex;
  gap: 8px;
}

.todo-action {
  border: none;
  background: rgba(27, 27, 27, 0.08);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

.todo-action:hover {
  background: rgba(27, 27, 27, 0.16);
}

.todo-action.todo-submit {
  background: rgba(210, 107, 52, 0.16);
  color: var(--accent-strong);
}

.todo-action.todo-submit:hover {
  background: rgba(210, 107, 52, 0.26);
}

.todo-action.todo-edit {
  background: rgba(47, 159, 99, 0.12);
  color: var(--low);
}

.todo-action.todo-edit:hover {
  background: rgba(47, 159, 99, 0.22);
}

.todo-action.todo-delete,
.todo-action.todo-cancel {
  background: rgba(208, 68, 47, 0.12);
  color: var(--high);
}

.todo-action.todo-delete:hover,
.todo-action.todo-cancel:hover {
  background: rgba(208, 68, 47, 0.22);
}

.todo-form.disabled .todo-action {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.message-action {
  border: none;
  background: rgba(27, 27, 27, 0.08);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.message-action:hover {
  background: rgba(27, 27, 27, 0.16);
}

.message-action.message-edit {
  background: rgba(210, 107, 52, 0.16);
  color: var(--accent-strong);
}

.message-action.message-edit:hover {
  background: rgba(210, 107, 52, 0.26);
}

.message-action.message-delete {
  background: rgba(208, 68, 47, 0.12);
  color: var(--high);
}

.message-action.message-delete:hover {
  background: rgba(208, 68, 47, 0.22);
}

.message-action.message-ask-ai {
  background: rgba(99, 102, 241, 0.16);
  color: #6366f1;
}

.message-action.message-ask-ai:hover {
  background: rgba(99, 102, 241, 0.26);
}

.message-item.message-placeholder {
  opacity: 0.7;
  border-style: dashed;
  border-color: rgba(99, 102, 241, 0.3);
}

.message-placeholder-body {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6366f1;
  font-style: italic;
}

.placeholder-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: placeholder-spin 0.8s linear infinite;
}

@keyframes placeholder-spin {
  to { transform: rotate(360deg); }
}

.message-item.reply-target {
  border-color: rgba(210, 107, 52, 0.45);
  box-shadow: 0 12px 18px rgba(210, 107, 52, 0.12);
}

.message-item.edit-target {
  border-color: rgba(47, 159, 99, 0.45);
  box-shadow: 0 12px 18px rgba(47, 159, 99, 0.12);
}

.message-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.message-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-form textarea {
  min-height: 90px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-family: "Source Sans 3", "Trebuchet MS", sans-serif;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

.message-form textarea:focus {
  outline: 2px solid rgba(210, 107, 52, 0.3);
  border-color: rgba(210, 107, 52, 0.6);
}

.message-actions {
  display: flex;
  justify-content: flex-end;
}

.reply-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(210, 107, 52, 0.12);
  color: var(--accent-strong);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.reply-preview {
  color: var(--ink);
  font-weight: 600;
}

.reply-cancel {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.edit-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(47, 159, 99, 0.12);
  color: var(--low);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.edit-preview {
  color: var(--ink);
  font-weight: 600;
}

.edit-cancel {
  border: none;
  background: transparent;
  color: var(--low);
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.message-form.disabled textarea {
  background: rgba(27, 27, 27, 0.04);
  color: var(--muted);
}

.message-form.disabled .action {
  opacity: 0.6;
  cursor: not-allowed;
}

.message-add-wrapper {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.message-add-btn {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(210, 107, 52, 0.4);
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.message-add-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(210, 107, 52, 0.16);
  background: rgba(210, 107, 52, 0.08);
}

.message-add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
  font-size: 0.9rem;
}

.toast[hidden] {
  display: none;
}

.toast-action {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

.toast-action:hover {
  background: var(--accent-strong);
}

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

  .order {
    grid-row: auto;
    width: 40px;
    height: 40px;
  }
}

/* Markdown content styling for messages */
.message-body {
  white-space: normal;
  line-height: 1.6;
}

.message-body p {
  margin: 0 0 0.75em;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  margin: 1em 0 0.5em;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

.message-body h1:first-child,
.message-body h2:first-child,
.message-body h3:first-child,
.message-body h4:first-child,
.message-body h5:first-child,
.message-body h6:first-child {
  margin-top: 0;
}

.message-body h1 { font-size: 1.5em; }
.message-body h2 { font-size: 1.3em; }
.message-body h3 { font-size: 1.15em; }
.message-body h4 { font-size: 1em; }
.message-body h5 { font-size: 0.95em; }
.message-body h6 { font-size: 0.9em; color: var(--muted); }

/* Inline code */
.message-body code {
  background: rgba(27, 27, 27, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.9em;
}

/* Code blocks */
.message-body pre {
  background: #1e1e1e;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0.75em 0;
  position: relative;
}

.message-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  color: #d4d4d4;
  display: block;
  white-space: pre;
}

/* Copy button for code blocks */
.message-body pre .code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #a0a0a0;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.message-body pre:hover .code-copy-btn {
  opacity: 1;
}

.message-body pre .code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.message-body pre .code-copy-btn.copied {
  background: rgba(47, 159, 99, 0.3);
  color: #6ddb9a;
}

/* Tables */
.message-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0;
  font-size: 0.9em;
}

.message-body th,
.message-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.message-body th {
  background: rgba(27, 27, 27, 0.06);
  font-weight: 600;
}

.message-body tr:nth-child(even) td {
  background: rgba(27, 27, 27, 0.025);
}

.message-body tr:hover td {
  background: rgba(210, 107, 52, 0.06);
}

/* Blockquotes */
.message-body blockquote {
  margin: 0.75em 0;
  padding: 0.5em 0 0.5em 1em;
  border-left: 4px solid var(--accent);
  background: rgba(210, 107, 52, 0.06);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

.message-body blockquote p {
  margin: 0;
}

.message-body blockquote blockquote {
  margin-top: 0.5em;
}

/* Lists */
.message-body ul,
.message-body ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.message-body li {
  margin: 0.25em 0;
}

.message-body li > ul,
.message-body li > ol {
  margin: 0.25em 0;
}

/* Links */
.message-body a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-color: rgba(180, 83, 31, 0.4);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease;
}

.message-body a:hover {
  text-decoration-color: var(--accent-strong);
}

.message-body a:visited {
  color: #8a4a2a;
}

/* Horizontal rules */
.message-body hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 1em 0;
}

/* Images */
.message-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Mermaid diagrams */
.mermaid-diagram {
  margin: 0.75em 0;
  padding: 16px;
  background: #1f2937;
  border-radius: 10px;
  text-align: center;
  overflow-x: auto;
  cursor: pointer;
}

.mermaid-diagram:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.mermaid-diagram-light {
  background: #ffffff;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.mermaid-error {
  margin: 0.75em 0;
  padding: 12px 16px;
  background: rgba(208, 68, 47, 0.1);
  border: 1px solid rgba(208, 68, 47, 0.3);
  border-radius: 10px;
  color: var(--high);
}

.mermaid-error-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.mermaid-error-icon {
  font-size: 1.1em;
  flex-shrink: 0;
}

.mermaid-error-text {
  font-size: 0.9em;
  word-break: break-word;
}

/* Mermaid diagram expand modal */
.mermaid-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.mermaid-modal[hidden] {
  display: none;
}

.mermaid-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 300;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mermaid-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.mermaid-modal-content {
  max-width: 95vw;
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  background: #1f2937;
  border-radius: 12px;
  text-align: center;
}

.mermaid-modal-content svg {
  max-width: 100%;
  height: auto;
}

/* Message composer modal */
.message-composer-modal {
  position: fixed;
  inset: 0;
  background: rgba(247, 236, 225, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.message-composer-modal[hidden] {
  display: none;
}

.message-composer-card {
  background: var(--surface-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(600px, 100%);
  max-height: 80vh;
  box-shadow: var(--shadow);
}

.message-composer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-composer-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.message-composer-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(27, 27, 27, 0.08);
  color: var(--muted);
  font-size: 1.3rem;
  font-weight: 300;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.message-composer-close:hover {
  background: rgba(27, 27, 27, 0.16);
  transform: scale(1.1);
}

.message-composer-reply-context {
  background: rgba(210, 107, 52, 0.08);
  border: 1px solid rgba(210, 107, 52, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
}

.message-composer-reply-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  margin-bottom: 6px;
}

.message-composer-reply-preview {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  max-height: 80px;
  overflow: hidden;
}

.message-composer-tabs {
  display: flex;
  gap: 4px;
  background: rgba(27, 27, 27, 0.06);
  padding: 4px;
  border-radius: 10px;
}

.message-composer-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.message-composer-tab:hover {
  color: var(--ink);
}

.message-composer-tab.active {
  background: var(--surface-strong);
  color: var(--accent-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-composer-body {
  flex: 1;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.message-composer-textarea {
  flex: 1;
  min-height: 200px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
  line-height: 1.6;
}

.message-composer-textarea:focus {
  outline: 2px solid rgba(210, 107, 52, 0.3);
  border-color: rgba(210, 107, 52, 0.6);
}

.message-composer-preview {
  flex: 1;
  min-height: 200px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  background: var(--surface-alt);
  overflow-y: auto;
  line-height: 1.6;
}

.message-composer-preview[hidden] {
  display: none;
}

/* Inherit markdown styling from message-body */
.message-composer-preview p,
.message-composer-preview h1,
.message-composer-preview h2,
.message-composer-preview h3,
.message-composer-preview h4,
.message-composer-preview h5,
.message-composer-preview h6,
.message-composer-preview ul,
.message-composer-preview ol,
.message-composer-preview li,
.message-composer-preview blockquote,
.message-composer-preview pre,
.message-composer-preview code,
.message-composer-preview table,
.message-composer-preview th,
.message-composer-preview td,
.message-composer-preview hr,
.message-composer-preview a,
.message-composer-preview img {
  /* Same styling as message-body */
}

.message-composer-preview p {
  margin: 0 0 0.75em;
}

.message-composer-preview p:last-child {
  margin-bottom: 0;
}

.message-composer-preview h1,
.message-composer-preview h2,
.message-composer-preview h3,
.message-composer-preview h4,
.message-composer-preview h5,
.message-composer-preview h6 {
  margin: 1em 0 0.5em;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

.message-composer-preview h1:first-child,
.message-composer-preview h2:first-child,
.message-composer-preview h3:first-child {
  margin-top: 0;
}

.message-composer-preview h1 { font-size: 1.5em; }
.message-composer-preview h2 { font-size: 1.3em; }
.message-composer-preview h3 { font-size: 1.15em; }

.message-composer-preview code {
  background: rgba(27, 27, 27, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.9em;
}

.message-composer-preview pre {
  background: #1e1e1e;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0.75em 0;
}

.message-composer-preview pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  color: #d4d4d4;
  display: block;
  white-space: pre;
}

.message-composer-preview blockquote {
  margin: 0.75em 0;
  padding: 0.5em 0 0.5em 1em;
  border-left: 4px solid var(--accent);
  background: rgba(210, 107, 52, 0.06);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

.message-composer-preview ul,
.message-composer-preview ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.message-composer-preview a {
  color: var(--accent-strong);
  text-decoration: underline;
}

.message-composer-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5em 0;
  display: block;
}

.message-composer-status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1rem;
}

.message-composer-status.error {
  color: var(--high);
}

.message-composer-status.busy {
  color: var(--accent);
}

.message-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Timestamp relative time with hover tooltip */
.timestamp-relative {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  text-decoration-color: var(--border);
}

/* Timezone indicator badge */
.timezone-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(210, 107, 52, 0.3);
  background: rgba(210, 107, 52, 0.08);
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  vertical-align: middle;
  margin-left: 8px;
}

.timezone-indicator:hover {
  background: rgba(210, 107, 52, 0.16);
  box-shadow: 0 6px 14px rgba(210, 107, 52, 0.15);
  transform: translateY(-1px);
}

.timezone-indicator[hidden] {
  display: none;
}

.timezone-indicator::before {
  content: "\1F310"; /* Globe emoji */
  font-size: 0.8rem;
}

/* Collapse toggle button for parent cards */
.collapse-toggle {
  border: none;
  background: rgba(27, 27, 27, 0.08);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.collapse-toggle:hover {
  background: rgba(210, 107, 52, 0.12);
  color: var(--accent-strong);
}

.collapse-toggle .collapse-arrow {
  font-size: 0.65rem;
}

.collapse-toggle .collapse-count {
  font-size: 0.7rem;
  font-weight: 700;
}

/* Archive Card Confirmation Modal */
.archive-card-modal {
  position: fixed;
  inset: 0;
  background: rgba(247, 236, 225, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.archive-card-modal[hidden] {
  display: none;
}

.archive-card-modal-content {
  background: var(--surface-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(400px, 100%);
  box-shadow: var(--shadow);
}

.archive-card-modal-content h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.archive-card-modal-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.archive-card-modal-text strong {
  color: var(--text);
}

.archive-card-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* Move Card Confirmation Modal */
.move-card-modal {
  position: fixed;
  inset: 0;
  background: rgba(247, 236, 225, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.move-card-modal[hidden] {
  display: none;
}

.move-card-modal-content {
  background: var(--surface-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(400px, 100%);
  box-shadow: var(--shadow);
}

.move-card-modal-content h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.move-card-modal-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.move-card-modal-text strong {
  color: var(--text);
}

.move-card-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* Card changed indicator - shows a pulsing dot for changed cards */
.card.card-changed::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse-changed 1.5s ease-in-out infinite;
}

/* Blue dot for moved cards */
.card.card-changed-moved::after {
  background: #3b82f6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

/* Green dot for updated cards */
.card.card-changed-updated::after {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

/* Blue-green for added cards (uses blue as primary indicator for new items) */
.card.card-changed-added::after {
  background: #3b82f6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

@keyframes pulse-changed {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

/* Polling toast notification - appears bottom-right corner */
.polling-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 0.9rem;
  max-width: 320px;
  animation: polling-toast-slide-in 0.25s ease-out;
}

.polling-toast[hidden] {
  display: none;
}

.polling-toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3b82f6;
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
}

.polling-toast-message {
  flex: 1;
  color: var(--text);
  line-height: 1.4;
}

.polling-toast-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.polling-toast-close:hover {
  background: var(--surface);
  color: var(--text);
}

@keyframes polling-toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Inactivity indicator - subtle fixed indicator when polling paused due to user inactivity */
.inactivity-indicator {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: inactivity-fade-in 0.3s ease-out;
}

.inactivity-indicator[hidden] {
  display: none;
}

.inactivity-indicator:hover {
  background: rgba(234, 179, 8, 0.25);
  border-color: rgba(234, 179, 8, 0.6);
  transform: scale(1.02);
}

.inactivity-indicator:focus {
  outline: 2px solid rgba(234, 179, 8, 0.6);
  outline-offset: 2px;
}

.inactivity-indicator-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  color: #b45309;
}

.inactivity-indicator-text {
  color: #b45309;
  font-weight: 500;
  line-height: 1.3;
}

@keyframes inactivity-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Polling toggle button styles */
.polling-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.polling-toggle-icon {
  display: inline-block;
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.3s ease;
}

.polling-toggle-text {
  font-size: inherit;
  text-transform: uppercase;
  letter-spacing: inherit;
}

/* Enabled state - polling active (Auto) */
.polling-toggle.polling-enabled {
  background: rgba(47, 159, 99, 0.12);
  border-color: rgba(47, 159, 99, 0.4);
  color: var(--low);
}

.polling-toggle.polling-enabled:hover:not(:disabled) {
  background: rgba(47, 159, 99, 0.2);
  box-shadow: 0 10px 18px rgba(47, 159, 99, 0.16);
}

/* Pulse animation for active polling */
.polling-toggle.polling-enabled .polling-toggle-icon {
  animation: polling-icon-spin 2s linear infinite;
}

@keyframes polling-icon-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Disabled state - manual mode */
.polling-toggle:not(.polling-enabled) {
  background: transparent;
  border-color: rgba(210, 107, 52, 0.4);
  color: var(--accent-strong);
}

.polling-toggle:not(.polling-enabled) .polling-toggle-icon {
  opacity: 0.6;
}

/* Paused state - when user is busy editing */
.polling-toggle.polling-paused {
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(234, 179, 8, 0.4);
  color: #b45309;
}

.polling-toggle.polling-paused .polling-toggle-icon {
  animation: none;
  opacity: 0.8;
}

/* Polling interval selector */
.polling-interval-select {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(47, 159, 99, 0.4);
  border-radius: 6px;
  background: rgba(47, 159, 99, 0.08);
  color: var(--low);
  cursor: pointer;
  transition: all 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%232f9f63' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.5rem;
}

.polling-interval-select:hover:not(:disabled) {
  background-color: rgba(47, 159, 99, 0.15);
  box-shadow: 0 4px 12px rgba(47, 159, 99, 0.12);
}

.polling-interval-select:focus {
  outline: none;
  border-color: var(--low);
  box-shadow: 0 0 0 2px rgba(47, 159, 99, 0.2);
}

.polling-interval-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════
   Tooltip System (position:fixed singleton)
   Rendered by tooltip.js into a single #app-tooltip element
   appended to <body>. Uses position:fixed to escape
   overflow:hidden containers.
   ═══════════════════════════════════════════════════════ */
#app-tooltip {
  display: none;
  position: fixed;
  z-index: 99999;
  background: var(--surface-strong);
  color: var(--ink);
  font-family: "Source Sans 3", "Trebuchet MS", sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  max-width: 200px;
  width: max-content;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* ─── Chat Sessions ─── */

.chat-start-btn {
  font-size: 0.72rem;
  padding: 2px 10px;
}

.chat-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Session list items */
.session-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  cursor: pointer;
  transition: border-color 0.15s;
}

.session-item:hover {
  border-color: var(--accent);
}

.session-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.session-item-skill {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.session-item-objective {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

/* Session status badges */
.chat-session-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chat-session-status-badge[data-status="starting"] {
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
}

.chat-session-status-badge[data-status="active"] {
  background: rgba(34, 197, 94, 0.16);
  color: #22c55e;
}

.chat-session-status-badge[data-status="completed"] {
  background: rgba(99, 102, 241, 0.16);
  color: #6366f1;
}

.chat-session-status-badge[data-status="timed_out"] {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
}

/* Start session modal */
.chat-session-modal[hidden],
.chat-view-overlay[hidden] {
  display: none !important;
}

.chat-session-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.chat-session-modal-card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 420px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-session-modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.chat-session-modal-card label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.chat-session-modal-card select,
.chat-session-modal-card textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
}

.chat-session-modal-status {
  font-size: 0.8rem;
  min-height: 1.2em;
}

.chat-session-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Chat view overlay */
.chat-view-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.chat-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
  flex-shrink: 0;
}

.chat-view-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-view-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
}

.chat-view-back:hover {
  border-color: var(--accent);
}

.chat-view-title {
  margin: 0;
  font-size: 1rem;
}

.chat-view-end-session {
  background: none;
  border: 1px solid var(--high);
  color: var(--high);
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.chat-view-end-session:hover {
  background: var(--high);
  color: #fff;
}

.chat-view-doc-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.chat-view-doc-toggle:hover,
.chat-view-doc-toggle.active {
  border-color: var(--accent);
  color: var(--ink);
}

.chat-view-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.chat-view-messages-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 8px;
  min-width: 0;
}

/* Chat message list */
.chat-message-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.chat-msg[data-role="user"] {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg[data-role="assistant"] {
  align-self: flex-start;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-msg-body {
  overflow-wrap: break-word;
}

.chat-msg-body .markdown {
  font-size: inherit;
}

.chat-msg[data-role="user"] .chat-msg-body a {
  color: #fff;
  text-decoration: underline;
}

.chat-msg-meta {
  font-size: 0.68rem;
  opacity: 0.6;
}

.chat-msg[data-role="user"] .chat-msg-meta {
  text-align: right;
}

/* Agent thinking indicator / accordion */
.chat-thinking {
  padding: 8px 14px;
  font-size: 0.85em;
  color: var(--muted);
  font-style: italic;
}

.chat-thinking-frozen {
  padding: 4px 14px;
  font-size: 0.85em;
  color: var(--muted);
  font-style: italic;
}

.thinking-accordion {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.thinking-no-toggle .thinking-text {
  opacity: 0.7;
}

.thinking-collapsed-view .thinking-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}

.thinking-expanded-view {
  flex-direction: column;
}

.thinking-block {
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.7;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.thinking-block:last-of-type {
  border-bottom: none;
}

.thinking-toggle {
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  font-style: normal;
  opacity: 0.5;
  font-size: 0.75em;
  padding: 2px 4px;
}

.thinking-toggle:hover {
  opacity: 1;
}

/* Document panel */
.chat-view-doc-panel {
  width: 400px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--surface-strong);
  flex-shrink: 0;
}

.chat-view-doc-panel[hidden] {
  display: none;
}

.chat-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.chat-doc-download {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  margin-left: auto;
  padding: 0 4px;
}
.chat-doc-download:hover {
  color: var(--accent);
}

.chat-doc-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
}

.chat-doc-close:hover {
  color: var(--ink);
}

.chat-doc-content {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

/* Chat input */
.chat-view-input {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-strong);
  flex-shrink: 0;
}

.chat-view-input textarea {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 80px;
  max-height: 300px;
}

.chat-view-input textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-send-btn {
  align-self: flex-end;
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-send-btn:not(:disabled):hover {
  background: var(--accent-strong);
}

.chat-resume-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}
.chat-resume-btn:hover {
  background: var(--accent-strong);
}
