/* DC-6: conversation and flow panes. Each pane scrolls on its own; updates replace
   server-rendered parts by ID and never the composer or the message history. */
body.dialogue-screen { height: 100vh; height: 100dvh; overflow: hidden; }
.dialogue-screen .app-layout { min-height: 0; }
.dialogue-screen .app-main { display: flex; flex-direction: column; min-height: 0; max-width: none; padding: 16px 24px; }
.dialogue-screen .app-footer { display: none; }
#dialogue-workspace { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
#dialogue-workspace p:not(.report p) { white-space: pre-wrap; overflow-wrap: anywhere; }
#dialogue-workspace dd { overflow-wrap: anywhere; }
#dialogue-workspace .btn { white-space: normal; overflow-wrap: anywhere; min-height: 44px; text-align: center; }
#dialogue-workspace button:disabled { cursor: default; }
#dialogue-workspace h3:not(.report h3) { font-size: 15px; line-height: 22px; margin: 0; }
#dialogue-workspace .notice, #dialogue-workspace .form-feedback { margin: 8px 0; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* Header */
.dialogue-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.dialogue-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.dialogue-title h1 { font-size: 20px; line-height: 28px; overflow-wrap: anywhere; }
.dialogue-breadcrumb { font-size: 14px; color: var(--gray-500); }
.dialogue-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.dialogue-header-actions .muted { font-size: 13px; }
.dialogue-header-actions [data-dialogue-close-open] > .icon { display: none; }
/* The workflow detail's lifecycle, compact: the screen has a fixed height. It spans the
   conversation pane (same widths as .dialogue-layout) so the steps are not spread apart. */
.dialogue-progress { flex: 1 0 100%; min-width: 0; }
.dialogue-edit-note { flex: 1 0 100%; margin: 0; font-size: 13px; }
.dialogue-lifecycle { padding: 10px 20px; }
@media (min-width: 1024px) { .dialogue-lifecycle { max-width: calc(100% - clamp(420px, 36vw, 520px) - 16px); } }
.dialogue-lifecycle .lifecycle-number { width: 26px; height: 26px; flex-basis: 26px; }
.dialogue-lifecycle .is-current .lifecycle-number { box-shadow: 0 0 0 3px var(--brand-100); }
.dialogue-notice { padding: 12px 16px; border: 1px solid var(--brand-100); border-radius: var(--radius-control); background: var(--brand-50); font-size: 14px; }
.dialogue-notice [role=alert] { color: #8f1d14; }
.dialogue-recovery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dialogue-recovery:not(:has(button:not([hidden]))) { display: none; }

/* Two panes */
.dialogue-switch { display: none; }
.dialogue-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 36vw, 520px); gap: 16px; }
.dialogue-pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: white; border: 1px solid var(--gray-200); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.dialogue-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; }

/* Conversation */
.dialogue-empty { color: var(--gray-600); }
.dialogue-messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.dialogue-message { display: flex; }
.dialogue-bubble { max-width: min(85%, 640px); padding: 10px 14px; border-radius: 14px; background: var(--gray-100); }
.dialogue-user { justify-content: flex-end; }
.dialogue-user .dialogue-bubble { background: var(--brand-50); border: 1px solid var(--brand-100); border-bottom-right-radius: 4px; }
.dialogue-assistant .dialogue-bubble { border-bottom-left-radius: 4px; }
.dialogue-system { justify-content: center; }
.dialogue-system .dialogue-bubble { background: white; border: 1px solid var(--gray-300); font-size: 14px; }
.dialogue-past-question { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--gray-200); }
.dialogue-past-question .muted { font-size: 12px; margin-top: 6px; }
/* Past choices stay readable (4.5:1) although they cannot be pressed. */
.dialogue-past-question .btn:disabled { opacity: 1; color: var(--gray-700); background: var(--gray-50); border-style: dashed; }
.dialogue-more { margin-top: 12px; }
.dialogue-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.dialogue-defer { color: var(--gray-600); }
/* An answer the choices do not cover, for this question only (QC-2). */
.dialogue-other { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 4px; }
.dialogue-other label { font-size: 14px; }
.dialogue-other .dialogue-actions { margin-top: 4px; }
/* Time picker: choosing a time means automatic execution (DC-6 §4.4). */
.dialogue-schedule-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 12px 0 4px; }
.dialogue-schedule-picker .dialogue-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 14px; white-space: nowrap; }
.dialogue-schedule-picker .dialogue-pick[hidden] { display: none; }
.dialogue-schedule-picker .input { width: auto; }

/* Status and the current action; the conversation pane holds no results or forms. */
.dialogue-line { display: block; }
.dialogue-notes { margin: 8px 0; padding-left: 20px; font-size: 14px; }
.dialogue-status { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 14px; color: var(--gray-600); }
.dialogue-status .creation-spinner { width: 20px; height: 20px; flex-basis: 20px; border-width: 2px; }
.dialogue-status strong { color: var(--gray-900); }
.dialogue-action { margin-top: 12px; padding: 16px; border: 1px solid var(--gray-200); border-radius: var(--radius-card); background: var(--gray-50); }
.dialogue-action > h2 { font-size: 16px; line-height: 24px; margin-bottom: 8px; }
/* A Trinity comment rather than a card; the icon marks it as new news. */
.dialogue-action-comment { padding: 0; border: 0; background: none; }
.dialogue-comment { align-items: center; gap: 8px; }
.dialogue-comment-icon { flex: 0 0 24px; display: inline-flex; }
.dialogue-comment-icon svg, .dialogue-heading-failure svg { width: 24px; height: 24px; flex: 0 0 24px; }
.dialogue-comment-success .dialogue-comment-icon { color: #166534; }
.dialogue-comment-failure .dialogue-comment-icon, .dialogue-heading-failure svg { color: #991b1b; }
.dialogue-comment-done .dialogue-comment-icon { color: var(--brand-600); }
.dialogue-heading-failure { display: flex; align-items: center; gap: 8px; }
.dialogue-action form { margin-top: 12px; }
.dialogue-action label { display: block; margin: 8px 0; font-size: 14px; }
.dialogue-action .input { margin-top: 4px; background: white; }
.dialogue-question-text { font-weight: 500; }
/* "View the flow" is for the tabbed layout; side by side, the flow is already in view. */
.dialogue-to-flow { display: none; }
.dialogue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
/* A button in a form sits on the same line as a link button; the row's gap is the only spacing. */
.dialogue-actions form, .dialogue-actions form > .btn { margin-top: 0; }
.duplicate-candidate { padding: 12px 0; border-top: 1px solid var(--gray-200); }
.difference-heading { margin: 8px 0 0; font-weight: 600; }
.difference-list { display: grid; gap: 8px; margin: 8px 0; }
.difference-list dd { display: grid; gap: 4px; margin: 0; overflow-wrap: anywhere; }

/* Composer */
.dialogue-composer { padding: 12px 16px; border-top: 1px solid var(--gray-200); background: white; }
.dialogue-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.dialogue-composer textarea { flex: 1; min-height: 44px; resize: none; font: inherit; line-height: 20px; overflow-y: auto; }
.dialogue-composer .muted { font-size: 12px; margin-top: 6px; }

/* Flow pane */
.dialogue-board { padding-top: 12px; }
.board-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding-bottom: 8px; }
.board-head h2 { font-size: 17px; }
.board-remaining { font-size: 13px; font-weight: 600; color: #92400e; }
.board-purpose { font-size: 14px; color: var(--gray-700); }
.board-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; font-weight: 500; }
.board-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200); font-size: 14px; }
.board-section details { margin-top: 8px; font-size: 13px; }
.dialogue-board summary { color: var(--gray-600); min-height: 44px; padding: 12px 0; cursor: pointer; }
.dialogue-board label { display: block; margin: 8px 0; font-size: 14px; }
.dialogue-board .input { margin-top: 4px; }
.board-issues { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.dialogue-example, .dialogue-flow-report iframe { width: 100%; height: 320px; margin-top: 8px; border: 1px solid var(--gray-200); border-radius: 8px; background: white; }
/* RJ-2: a report view in the board; the rules above leave its own headings and paragraphs alone. */
.report-preview.dialogue-example, .dialogue-flow-report .report-preview { height: auto; max-height: 320px; margin-top: 8px; background: var(--gray-100); }

/* Flow: vertical, so any number of steps keeps its width on every screen. */
.dialogue-flow { list-style: none; margin: 10px 0 0; padding: 0; }
.dialogue-flow-step { position: relative; display: flex; gap: 12px; padding-bottom: 12px; font-size: 14px; }
.dialogue-flow-step:not(:last-child)::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--gray-200); }
.dialogue-flow-marker { flex: 0 0 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--brand-600); background: white; z-index: 1; }
.dialogue-flow-label { font-weight: 500; }
.dialogue-flow-step .muted { font-size: 13px; }
.dialogue-flow-step > div { min-width: 0; flex: 1; }
/* A finished trial's result, on the step it belongs to. */
.dialogue-flow-result { margin-top: 2px; font-size: 13px; color: var(--gray-700); }
.dialogue-flow-report { margin-top: 4px; }
.flow-proposed .dialogue-flow-marker { border-style: dashed; }
.flow-unresolved .dialogue-flow-marker { border-color: #b45309; border-style: dashed; }
.flow-placeholder .dialogue-flow-label { color: #92400e; }
.dialogue-run-state { font-size: 12px; font-weight: 600; margin-top: 2px; }
[data-run-state=succeeded] .dialogue-flow-marker, [data-run-state=passed] .dialogue-flow-marker { background: #16a34a; border-color: #16a34a; }
[data-run-state=running] .dialogue-flow-marker { background: var(--brand-100); animation: dialogue-pulse 1.2s ease-in-out infinite; }
[data-run-state=failed] .dialogue-flow-marker { background: #b42318; border-color: #b42318; }
[data-run-state=zero] .dialogue-flow-marker, [data-run-state=zero_skipped] .dialogue-flow-marker, [data-run-state=skipped] .dialogue-flow-marker { background: var(--gray-300); border-color: var(--gray-500); }
.run-succeeded, .run-passed { color: #166534; }
.run-failed { color: #991b1b; }
.run-running, .run-queued { color: var(--brand-700); }
.run-zero, .run-zero_skipped, .run-skipped { color: var(--gray-700); }
@keyframes dialogue-pulse { 50% { box-shadow: 0 0 0 4px var(--brand-100); } }
@media (prefers-reduced-motion: reduce) { [data-run-state=running] .dialogue-flow-marker { animation: none; } }

/* Main button, fixed at the bottom of the board */
.dialogue-primary { padding: 12px 16px; border-top: 1px solid var(--gray-200); background: white; }
.dialogue-primary > .btn, .dialogue-primary .dialogue-actions .btn-primary { width: 100%; }
.dialogue-primary .dialogue-actions { margin-top: 0; }
.dialogue-primary .muted { font-size: 13px; margin-top: 6px; }
.dialogue-primary .creation-spinner { width: 16px; height: 16px; flex-basis: 16px; border-width: 2px; }
/* DC-7: mostly a status line; Trinity tries and registers without a button. */
.dialogue-primary-status { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--gray-700); }
.dialogue-connection-choices { flex-direction: column; align-items: stretch; }
.dialogue-connection-choice p { margin: 4px 0 0; font-size: 13px; }
.dialogue-connection-select { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 4px; }
.dialogue-completed { margin-bottom: 8px; font-size: 14px; }

/* One pane at a time below 1024px, switched by tabs (the sidebar leaves too little room). */
@media (max-width: 1023px) {
  .dialogue-switch { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-control); background: var(--gray-100); }
  .dialogue-switch [role=tab] { flex: 1; min-height: 44px; border: 0; border-radius: 6px; background: transparent; color: var(--gray-700); font-weight: 500; }
  .dialogue-switch [aria-selected=true] { background: white; color: var(--brand-700); box-shadow: var(--shadow-sm); }
  .dialogue-layout { grid-template-columns: minmax(0, 1fr); }
  [data-view=conversation] #dialogue-board-pane, [data-view=board] #dialogue-chat { display: none; }
  .dialogue-to-flow { display: inline-flex; align-items: center; justify-content: center; margin-top: 8px; }
}
@media (max-width: 767px) {
  /* The breadcrumb leads back to the workflow list; the stacked menu would take the screen. */
  .dialogue-screen .sidebar { display: none; }
  .dialogue-screen .app-layout { display: flex; flex-direction: column; flex: 1; }
  .dialogue-header-actions .muted { font-size: 12px; }
  /* Four in a row; only the current step keeps its words. */
  .dialogue-lifecycle { grid-template-columns: repeat(4, auto); justify-content: space-between; padding: 8px 12px; gap: 8px; }
  .dialogue-lifecycle li:not(.is-current) > div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dialogue-screen .app-main { padding: 12px 16px; }
  #dialogue-workspace { gap: 8px; }
  .dialogue-title h1 { font-size: 18px; line-height: 26px; }
  .dialogue-scroll { padding: 12px 14px; }
  .dialogue-bubble { max-width: 92%; }
  .dialogue-composer { padding: 10px 12px; }
  /* Two lines, so the placeholder that wraps on a phone is not cut. */
  .dialogue-composer textarea { min-height: 62px; }
}
@media (max-width: 479px) {
  [data-dialogue-send-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  [data-dialogue-send] { width: 48px; padding: 0; }
}
@media (max-width: 767px) {
  /* #30: one title row (back link, title, badge), a slim step line and the tabs, then the chat. */
  .dialogue-header { gap: 8px; }
  .dialogue-title { flex: 1 1 0; flex-wrap: nowrap; gap: 6px; }
  .dialogue-breadcrumb a { display: inline-grid; place-items: center; width: 32px; height: 32px; font-size: 0; }
  .dialogue-breadcrumb a::before { content: "‹"; font-size: 24px; line-height: 1; }
  .dialogue-breadcrumb span { display: none; }
  .dialogue-title h1 { min-width: 0; font-size: 16px; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dialogue-header-actions .muted { display: none; }
  .dialogue-header-actions .btn { min-height: 36px; padding: 4px 10px; font-size: 13px; }
  /* The progress as four dots at the right of the title row (its words stay for screen readers). */
  .dialogue-title { order: 0; }
  .dialogue-progress { order: 1; flex: none; }
  .dialogue-header-actions { order: 2; flex: none; }
  .dialogue-edit-note { order: 3; }
  .dialogue-screen .dialogue-lifecycle { display: flex; gap: 6px; padding: 0; border: 0; background: none; box-shadow: none; }
  .dialogue-screen .dialogue-lifecycle li { gap: 0; }
  .dialogue-screen .dialogue-lifecycle li > div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dialogue-screen .dialogue-lifecycle .lifecycle-number { width: 10px; height: 10px; flex-basis: 10px; font-size: 0; border-color: var(--gray-300); background: white; }
  .dialogue-screen .dialogue-lifecycle .lifecycle-number .icon { display: none; }
  .dialogue-screen .dialogue-lifecycle .is-done .lifecycle-number { background: #1f7a4d; border-color: #1f7a4d; }
  .dialogue-screen .dialogue-lifecycle .is-current .lifecycle-number { background: var(--brand-600); border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-100); }
  /* 会話を終了 as an icon; its words stay as the accessible name. */
  .dialogue-header-actions [data-dialogue-close-open] > .icon { display: inline-block; }
  .dialogue-header-actions [data-dialogue-close-open] { width: 40px; min-height: 40px; padding: 0; }
  .dialogue-close-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  /* The conversation/flow switch at the bottom, under the composer. */
  .dialogue-switch { order: 10; margin-bottom: env(safe-area-inset-bottom); }
  .dialogue-switch [role=tab] { position: relative; min-height: 44px; }
  .dialogue-unread:not([hidden]) { display: inline-block; width: 8px; height: 8px; margin-left: 3px; overflow: hidden; vertical-align: top; border-radius: 50%; background: #dc2626; font-size: 0; }
  .dialogue-title .dialogue-badge { flex: none; white-space: nowrap; }
}
