/* Hosted dashboard: Missionplane's own blocks, drawn with the Sendplane
 * design system's tokens and recipes (docs/design-system.md). */

/* ─── Rendered Markdown ───
 * Renders stored conversation messages. It sets its own type and colour
 * instead of relying on the message bubble around it. */
.chat-markdown {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: break-word;
}

/* The hosted dashboard also gives this element .hosted-wrap, whose pre-wrap
 * would render the newlines between block elements as blank lines. The doubled
 * class outranks it: the content is HTML, so whitespace collapses normally
 * (line breaks arrive as <br>, code blocks keep their own pre). */
.chat-markdown.chat-markdown {
  white-space: normal;
}

.chat-markdown > :first-child {
  margin-top: 0;
}

.chat-markdown > :last-child {
  margin-bottom: 0;
}

.chat-markdown p {
  margin: 0 0 .6em;
}

/* The last paragraph of any container (blockquote, list item) sheds its gap. */
.chat-markdown p:last-child {
  margin-bottom: 0;
}

.chat-markdown strong {
  font-weight: 650;
}

.chat-markdown del {
  color: var(--muted);
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 {
  margin: 1.1em 0 .4em;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.chat-markdown h1 { font-size: 18px; }
.chat-markdown h2 { font-size: 16px; }
.chat-markdown h3 { font-size: 15px; }

.chat-markdown ul,
.chat-markdown ol {
  margin: .5em 0;
  padding-left: 1.5em;
}

.chat-markdown li + li {
  margin-top: .2em;
}

.chat-markdown li > ul,
.chat-markdown li > ol {
  margin: .2em 0;
}

.chat-markdown li::marker {
  color: var(--quiet);
}

.chat-markdown a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition: color 120ms var(--ease-out), text-decoration-color 120ms var(--ease-out);
}

.chat-markdown blockquote {
  margin: .6em 0;
  padding: .1em 0 .1em var(--space-3);
  border-left: 3px solid var(--border-default);
  color: var(--muted);
}

.chat-markdown hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* Inline code is a chip. */
.chat-markdown code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-code);
  color: var(--muted);
  background: var(--soft);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

/* Code blocks use the always-dark code surface. The vendored highlight theme
 * paints its own background and padding on code.hljs, so both selectors reset
 * it (the second outranks the theme's own rule). */
.chat-markdown pre {
  position: relative;
  margin: .7em 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-button);
  color: var(--studio-code-fg);
  background: var(--studio-code-bg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  tab-size: 2;
}

.chat-markdown pre code,
.chat-markdown pre code.hljs {
  display: block;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font-size: inherit;
  line-height: inherit;
  overflow-wrap: normal;
}

.chat-markdown table {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: .7em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-callout);
  border-collapse: collapse;
  font-size: 13px;
}

.chat-markdown th {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--quiet);
  background: var(--surface-elevated);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: .035em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.chat-markdown td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: top;
}

.chat-markdown tbody tr:last-child td {
  border-bottom: 0;
}

@media (hover: hover) and (pointer: fine) {
  .chat-markdown a:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
  }
}

.hosted-dashboard { width: min(1240px, 100%); }
.hosted-wrap { overflow-wrap: anywhere; white-space: pre-wrap; }
.hosted-count { font-variant-numeric: tabular-nums; }
.hosted-id { font-family: var(--font-mono); font-size: 11px; overflow-wrap: anywhere; }
td > code.hosted-id, th > code.hosted-id { overflow-wrap: normal; white-space: nowrap; }
.hosted-dashboard > .panel, .hosted-dashboard > section, .hosted-dashboard > form { margin-bottom: 18px; }
.hosted-dashboard .hosted-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.hosted-form-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.hosted-form-columns > .form-group { margin-bottom: 17px; }
.hosted-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.hosted-fields:disabled { opacity: .7; }
.hosted-prompt { min-height: 170px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
.hosted-over-limit { color: var(--danger); }
.inline-field { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; font-weight: 650; }
.inline-field .form-select { width: auto; min-width: 160px; padding-block: 7px; }

/* A heading inside a panel body: a small title with its action. */
.subsection-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
.subsection-heading h3 { margin: 0; }
.panel-subheading { margin: 0; padding: 14px 20px 0; }
.detail-section { display: grid; gap: 10px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-section > * { margin: 0; }
.detail-section h3 { margin-top: 8px; }
.detail-text { color: var(--muted); font-size: 13px; }
.detail-grid { border: 1px solid var(--line); border-radius: var(--radius-callout); }
.panel-body > .hosted-advanced, .panel-body > .detail-section { margin: 0; }

/* Inline confirmations follow the Dialog's bands without a scrim. */
.confirmation { display: grid; gap: 8px; margin: 0; padding: 16px 20px; border: 0; border-top: 1px solid var(--warning-border); border-radius: 0; color: var(--ink); background: var(--warning-bg); }
.confirmation h3 { margin: 0; color: var(--warning-fg); }
.confirmation p { margin: 0; color: var(--ink); }
.confirmation-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 6px; }
.confirmation-panel { border-color: var(--danger-border); }

/* The create and edit form reads like a dialog: header, fields, actions. */
.hosted-editor { scroll-margin-top: 24px; }
.editor-fields { padding: 22px 20px 6px; }
.editor-fields > .notice { margin-bottom: 17px; }
.editor-fields > .form-hint { margin-bottom: 14px; }
.editor-actions .editor-archive { margin-right: auto; }
.hosted-research h3 { margin: 22px 0 12px; }
.hosted-research-topic { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto; align-items: end; gap: 14px; margin-bottom: 14px; }
.hosted-research-topic .form-group { margin: 0; }
.hosted-sources.choice-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.hosted-sources legend { width: 100%; }
.hosted-editor .contract-preview { margin: 14px 0; }
.hosted-editor .hosted-actions { margin: 10px 0 14px; }
.hosted-advanced { margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius-callout); background: var(--surface-elevated); }
.hosted-advanced > summary { display: flex; align-items: center; gap: 8px; padding: 12px 14px; color: var(--ink); font-size: 13px; font-weight: 650; cursor: pointer; list-style: none; }
.hosted-advanced > summary::-webkit-details-marker { display: none; }
/* Disclosure uses the design system's › glyph, turned when open. */
.hosted-advanced > summary::before { content: "›"; width: 10px; color: var(--quiet); font-size: 16px; line-height: 1; transition: transform 140ms var(--ease-out); }
.hosted-advanced[open] > summary::before { transform: rotate(90deg); }
.hosted-advanced[open] > summary { border-bottom: 1px solid var(--line); }
.hosted-advanced > :not(summary) { margin: 14px; }
.hosted-inline-form { display: grid; gap: 10px; padding: 18px 20px; border-top: 1px solid var(--line); background: var(--surface-elevated); }
.hosted-inline-form h3 { margin: 0; }
.form-actions, .inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 9px; }
.form-actions { justify-content: flex-end; }
.inline-form { margin: 4px 0; }
.inline-form .form-group { margin: 0; }
.inline-form .form-hint { flex-basis: 100%; }

/* Connection lists: one row per connection. */
.connection-list:empty { display: none; }
.hosted-connection { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.connection-list .hosted-connection:last-child { border-bottom: 0; }
.connection-list + .table-footnote, .connection-list + .panel-body { border-top: 1px solid var(--line); }
.hosted-connection h3 { margin: 0 0 3px; font-size: 13px; }
.hosted-connection p { margin: 0; color: var(--muted); font-size: 12px; }
.connection-actions { display: flex; align-items: center; gap: 10px; }

/* Slack management. */
.hosted-slack-route .subsection-heading { margin: 0; padding: 14px 20px; border-top: 1px solid var(--line); }
.hosted-slack-route .usage-list { border-top: 1px solid var(--line); }
.hosted-slack-stat .hosted-count { color: var(--ink); font-size: 20px; font-weight: 690; }
.panel-notes { gap: 4px; border-top: 1px solid var(--line); }
.panel-notes p { color: var(--muted); font-size: 12px; }

/* Automations: one row per scheduled agent. */
.automation-list { display: grid; }
.automation-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.automation-row:last-child { border-bottom: 0; }
.automation-summary { min-width: 0; display: grid; gap: 7px; }
.automation-summary > * { margin: 0; }
.automation-summary h3 { margin: 0; font-size: 14px; }
.automation-summary > p { color: var(--muted); font-size: 12px; }
.automation-summary > p strong { color: var(--ink); font-weight: 650; }
.automation-limits { font-variant-numeric: tabular-nums; }
.automation-actions { display: grid; justify-items: stretch; gap: 7px; min-width: 150px; }

/* Conversations: the list beside the thread. */
.hosted-conversations { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); align-items: start; gap: 18px; }
.hosted-session-panel { position: sticky; top: 0; }
.hosted-session-form { display: grid; gap: 0; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.hosted-session-form .form-group { margin-bottom: 12px; }
.hosted-session-form .button { justify-self: start; margin-bottom: 10px; }
.hosted-session-form .notice { margin: 10px 0 0; }
.hosted-session-list { max-height: min(560px, 60vh); overflow-y: auto; padding: 7px; }
.hosted-session-list:empty { display: none; }
.hosted-session-row { display: flex; align-items: center; gap: 6px; border-radius: var(--radius-control); }
.hosted-session-button {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.hosted-session-button strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.hosted-session-button small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.hosted-session-button.hosted-selected { background: var(--interactive-selected); }
.hosted-session-button.hosted-selected small { color: var(--ink); }
.hosted-session-button:active { transform: scale(.97); }
.hosted-session-row .button { flex: 0 0 auto; }

.hosted-history { min-width: 0; }
.hosted-thread { display: grid; gap: 14px; padding: 20px; }
.hosted-message { max-width: 760px; display: grid; gap: 6px; }
.hosted-message-role { margin: 0; color: var(--quiet); font-size: 10px; font-weight: 680; letter-spacing: .045em; text-transform: uppercase; }
.hosted-message-agent .chat-markdown { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-callout); background: var(--surface-elevated); }
.hosted-message-user { justify-self: end; justify-items: end; }
.hosted-message-user .chat-markdown { padding: 10px 14px; border-radius: var(--radius-callout); color: var(--ink); background: var(--interactive-selected); }
.hosted-history .chat-markdown pre { max-width: 100%; overflow: auto; white-space: pre; }
.hosted-thread-notes { display: grid; gap: 12px; padding: 0 20px 4px; }
.hosted-thread-notes > * { margin: 0; }
.hosted-live-run { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-callout); background: var(--surface-elevated); }
.hosted-live-run > * { margin: 0; }
.hosted-live-run .subsection-heading { margin: 0; }
.hosted-progress-event { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.hosted-progress-event code { width: fit-content; }
.hosted-event-error { margin: 0; color: var(--danger); font-size: 12px; font-weight: 600; }
.hosted-composer { display: grid; gap: 8px; margin-top: 8px; padding: 16px 20px 20px; border-top: 1px solid var(--line); background: var(--surface-elevated); }
.hosted-composer textarea { min-height: 110px; resize: vertical; }
.hosted-composer textarea:disabled { opacity: .65; }
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.composer-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

/* Runs. */
.hosted-activity-table td:last-child { overflow-wrap: anywhere; }
.hosted-run-detail .metadata-grid { border-bottom: 1px solid var(--line); }
.hosted-run-detail .metadata-grid:last-child { border-bottom: 0; }
.hosted-events { counter-reset: none; }
.panel-notice { margin: 14px 20px 0; }
.hosted-topic-list { margin: 0; padding-left: 18px; }
.hosted-topic-list li + li { margin-top: 3px; }

@media (hover: hover) and (pointer: fine) {
  .hosted-session-button:not(.hosted-selected):hover { background: var(--soft); }
  .context-menu-footer button:hover { color: var(--ink); }
}

@media (max-width: 900px) {
  .hosted-conversations { grid-template-columns: 1fr; }
  .hosted-session-panel { position: static; }
}

@media (max-width: 760px) {
  .automation-row { grid-template-columns: 1fr; }
  .automation-actions { grid-auto-flow: row; justify-items: start; min-width: 0; }
  .hosted-research-topic { grid-template-columns: minmax(0, 1fr) 100px; }
  .hosted-research-topic > .button { grid-column: 1 / -1; justify-self: start; }
  .hosted-table-scroll .hosted-activity-table { min-width: 760px; }
  .hosted-table-scroll { overscroll-behavior-inline: contain; }
  .hosted-thread, .hosted-composer { padding-inline: 16px; }
  .hosted-thread-notes { padding-inline: 16px; }
  .inline-field { width: 100%; }
  .inline-field .form-select { flex: 1; }
  .editor-fields { padding-inline: 18px; }
}

.claude-managed-events { max-height: 480px; overflow: auto; display: grid; gap: 14px; }
.claude-managed-events pre { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
