.ri-dialog { width: min(1440px, calc(100vw - 48px)); height: min(920px, calc(100dvh - 48px)); max-width: none;
  max-height: none; padding: 0; margin: auto; border: 1px solid var(--st-line); border-radius: 20px;
  color: var(--st-ink); background: var(--st-surface); box-shadow: var(--st-sh-pop); overflow: hidden; }
.ri-dialog[open] { display: flex; flex-direction: column; }
.ri-dialog::backdrop { background: rgb(12 18 27 / .62); backdrop-filter: blur(3px); }
.ri-dialog *, .ri-dialog *::before, .ri-dialog *::after { box-sizing: border-box; }
.ri-dialog [hidden] { display: none !important; }
.ri-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 26px 16px; flex: none; }
.ri-heading { min-width: 0; }
.ri-eyebrow { color: var(--st-accent-text); font: 700 11px/1.5 var(--st-font); letter-spacing: .12em; }
.ri-heading h2 { margin: 4px 0 6px; font-size: 24px; line-height: 1.3; }
.ri-heading p { margin: 0; color: var(--st-ink-muted); font-size: 12px; overflow-wrap: anywhere; }
.ri-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.ri-button { min-height: 44px; padding: 8px 12px; border: 1px solid var(--st-line); border-radius: 8px; background: var(--st-surface);
  color: var(--st-ink); font: 500 13px/1.3 var(--st-font); cursor: pointer; transition: background 160ms, border-color 160ms; }
.ri-button:hover:not(:disabled) { background: var(--st-surface-2); border-color: var(--st-accent); }
.ri-button:disabled { opacity: .45; cursor: default; }
.ri-button:focus-visible, .ri-dialog summary:focus-visible, .ri-answer-scroll:focus-visible {
  outline: 2px solid var(--st-focus); outline-offset: 2px; }
.ri-close { color: var(--st-ink-muted); }
.ri-stats { display: flex; flex-wrap: wrap; gap: 12px 30px; padding: 0 26px 18px; flex: none; }
.ri-stat { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.ri-stat > span { color: var(--st-ink-muted); }
.ri-stat > strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.ri-notice { flex: none; margin: 0; padding: 10px 26px; max-height: 100px; overflow: auto;
  color: var(--st-warn-text); background: var(--st-warn-tint); font-size: 13px; overflow-wrap: anywhere; }
.ri-state { flex: 1; min-height: 160px; display: grid; place-content: center; justify-items: center; padding: 24px; color: var(--st-ink-muted); }
.ri-mobile-switch { display: none; }
.ri-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 42%) minmax(0, 1fr); border-top: 1px solid var(--st-line); }
.ri-context, .ri-answer { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ri-context { background: var(--st-bg); border-right: 1px solid var(--st-line); }
.ri-section-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--st-line-soft); min-height: 74px; }
.ri-section-head h3 { margin: 0 0 4px; font-size: 15px; }
.ri-section-head p { margin: 0; font-size: 12px; color: var(--st-ink-muted); }
.ri-context-scroll, .ri-answer-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.ri-context-scroll { padding: 18px; }
.ri-answer-scroll { padding: 24px 28px; }
.ri-answer-head { flex-wrap: wrap; }
.ri-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ri-tabs .ri-button { border-color: transparent; background: transparent; }
.ri-tabs [aria-selected="true"] { background: var(--st-accent-tint); color: var(--st-accent-text); }
.ri-message { margin-bottom: 12px; background: var(--st-surface); border: 1px solid var(--st-line); border-radius: 12px; overflow: hidden; }
.ri-message--latest { border-left: 3px solid var(--st-accent); }
.ri-message-head { position: relative; list-style: none; padding: 14px 36px 14px 14px; cursor: pointer; min-height: 52px; }
.ri-message-head::-webkit-details-marker { display: none; }
.ri-message-head::after { content: "+"; position: absolute; top: 16px; right: 14px; color: var(--st-ink-muted); font-size: 18px; }
.ri-message[open] > .ri-message-head::after { content: "−"; }
.ri-message-head:hover { background: var(--st-surface-2); }
.ri-message-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.ri-role { border-radius: 5px; padding: 3px 7px; font-weight: 600; color: var(--st-ink-soft); background: var(--st-surface-2); }
[data-role="user"] > summary .ri-role { color: var(--st-accent-text); background: var(--st-accent-tint); }
[data-role="assistant"] > summary .ri-role { color: var(--st-info-text); background: var(--st-info-tint); }
[data-role="tool"] > summary .ri-role { color: var(--st-warn-text); background: var(--st-warn-tint); }
.ri-message-index, .ri-tool-name { color: var(--st-ink-muted); overflow-wrap: anywhere; }
.ri-latest-label { color: var(--st-accent-text); }
.ri-message-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 9px; font-size: 13px; line-height: 1.6; color: var(--st-ink-muted); overflow-wrap: anywhere; }
.ri-message[open] > summary .ri-message-preview { display: none; }
.ri-message-body { padding: 0 16px 16px; min-width: 0; }
.ri-pager { display: flex; flex: none; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px;
  border-top: 1px solid var(--st-line-soft); color: var(--st-ink-muted); font-size: 12px; }
.ri-text { min-width: 0; }
.ri-text + .ri-text, .ri-fold + .ri-text { margin-top: 16px; }
.ri-prose { font-size: 15px; line-height: 1.85; overflow-wrap: anywhere; }
.ri-prose > :first-child { margin-top: 0; }
.ri-prose > :last-child { margin-bottom: 0; }
.ri-prose p { margin: 0 0 16px; }
.ri-prose h3 { font-size: 19px; margin: 24px 0 12px; line-height: 1.5; }
.ri-prose h4 { font-size: 16px; margin: 20px 0 10px; }
.ri-prose ul, .ri-prose ol { padding-left: 24px; margin: 12px 0 20px; }
.ri-prose li + li { margin-top: 6px; }
.ri-prose blockquote { border-left: 3px solid var(--st-accent); padding: 6px 14px; margin: 16px 0; color: var(--st-ink-muted); }
.ri-prose hr { border: 0; border-top: 1px solid var(--st-line); margin: 24px 0; }
.ri-prose code.inline { border-radius: 4px; padding: 2px 5px; background: var(--st-surface-2); font: .88em var(--st-font-mono); }
.ri-prose .st-code { margin: 16px 0; }
.ri-prose .st-code .st-btn { min-width: 44px; min-height: 44px; }
.ri-table-scroll { max-width: 100%; overflow-x: auto; margin: 16px 0; }
.ri-prose table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.6; }
.ri-prose th, .ri-prose td { padding: 10px 12px; border: 1px solid var(--st-line); text-align: left; min-width: 80px; }
.ri-prose th { background: var(--st-surface-2); }
.ri-raw { font: 13px/1.8 var(--st-font-mono); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.ri-help { font-size: 12px; line-height: 1.7; color: var(--st-ink-muted); margin: 0 0 12px; }
.ri-empty { padding: 30px 10px; color: var(--st-ink-muted); font-size: 14px; line-height: 1.8; }
.ri-inline-notice { color: var(--st-warn-text); background: var(--st-warn-tint); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.ri-format-label { color: var(--st-accent-text); font-size: 12px; margin-bottom: 12px; }
.ri-json-node { font: 13px/1.7 var(--st-font-mono); }
.ri-json-node > summary { padding: 9px 4px; cursor: pointer; overflow-wrap: anywhere; color: var(--st-ink-soft); }
.ri-json-children { padding-left: 16px; border-left: 1px solid var(--st-line); margin-left: 5px; }
.ri-json-row { padding: 7px 4px; overflow-wrap: anywhere; }
.ri-json-key { color: var(--st-info-text); }
.ri-json-string { color: var(--st-accent-text); }
.ri-json-string > summary { cursor: pointer; min-height: 44px; padding: 9px 0; }
.ri-json-number, .ri-json-boolean { color: var(--st-warn-text); }
.ri-fold { border: 1px solid var(--st-line-soft); border-radius: 8px; margin-top: 12px; }
.ri-fold > summary { padding: 12px; min-height: 44px; cursor: pointer; font-size: 13px; overflow-wrap: anywhere; }
.ri-part { padding: 12px; border-top: 1px solid var(--st-line-soft); }
.ri-attachment { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; margin-top: 10px;
  border: 1px dashed var(--st-line); border-radius: 8px; font-size: 13px; }
.ri-image { max-width: 100%; max-height: 240px; object-fit: contain; }
.ri-footer { display: flex; justify-content: space-between; gap: 16px; padding: 10px 26px; flex: none;
  border-top: 1px solid var(--st-line); font-size: 11px; color: var(--st-ink-muted); }
@media (max-width: 1000px) {
  .ri-dialog { width: calc(100vw - 24px); height: calc(100dvh - 24px); }
  .ri-workspace { grid-template-columns: minmax(260px, 40%) minmax(0, 1fr); }
  .ri-answer-head { gap: 6px; } .ri-answer-scroll { padding: 20px; }
  .ri-section-head { padding: 12px; } .ri-context-scroll { padding: 12px; }
}
@media (max-width: 680px) {
  .ri-dialog { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .ri-header { padding: max(14px, env(safe-area-inset-top)) 14px 12px; gap: 10px; }
  .ri-header .ri-actions { flex-direction: column-reverse; gap: 4px; }
  .ri-heading h2 { font-size: 21px; } .ri-heading p { font-size: 11px; }
  .ri-stats { padding: 0 14px 12px; gap: 8px 16px; } .ri-stat { font-size: 12px; }
  .ri-notice { padding: 10px 14px; }
  .ri-mobile-switch { display: flex; padding: 0 14px 10px; gap: 8px; flex: none; }
  .ri-mobile-switch [aria-pressed="true"] { background: var(--st-accent-tint); border-color: var(--st-accent); color: var(--st-accent-text); }
  .ri-workspace { display: flex; overflow: hidden; }
  .ri-context, .ri-answer { flex: 1; border: 0; }
  .ri-dialog[data-mobile-pane="reply"] .ri-context, .ri-dialog[data-mobile-pane="context"] .ri-answer { display: none; }
  .ri-answer-scroll { padding: 18px 14px; }
  .ri-tabs .ri-button { padding-inline: 9px; } .ri-prose { font-size: 16px; }
  .ri-footer { padding: 9px 14px max(9px, env(safe-area-inset-bottom)); }
  .ri-footer > span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ri-button { transition: none; } }
