.rich-code,.rich-equation { margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.rich-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 40px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); font-family: var(--font); font-size: var(--font-size-ui); }
.rich-language { flex: 1; white-space: nowrap; min-width: fit-content; color: var(--muted); padding-right: 8px; }
.rich-action { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 7px; min-height: 30px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font: inherit; cursor: pointer; }
.rich-action:hover { background: var(--border); color: var(--ink); }
.rich-action:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.rich-icon-action { width: 30px; height: 30px; padding: 7px; flex: 0 0 auto; }
.rich-icon-action .rich-action-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.rich-action .icon { width: var(--icon-size-meta); height: var(--icon-size-meta); flex-shrink: 0; }
.markdown-content .rich-code pre { margin: 0; border: 0; border-radius: 0; padding: 16px; overflow: auto; background: var(--paper); }
.markdown-content .rich-code code { font-family: var(--font-code); font-size: var(--font-size-code); line-height: 1.65; color: var(--ink); }
.markdown-content .rich-table .markdown-table { margin: 0; border: 0; border-radius: 0; }
.markdown-content .rich-table table { margin: 0; min-width: 0; width: 100%; }
.markdown-content .rich-table th { background: transparent; }
.markdown-content .rich-table th,.markdown-content .rich-table td { padding: 10px 12px; }
.markdown-content .rich-table th:first-child,.markdown-content .rich-table td:first-child { padding-left: 0; }
.markdown-content .rich-table th:last-child,.markdown-content .rich-table td:last-child { padding-right: 0; }
.rich-table,.rich-code.rich-diagram-block { position: relative; margin: 32px 0 18px; border: 0; border-radius: 0; overflow: visible; background: transparent; }
.rich-actions { position: absolute; top: -30px; right: 0; display: flex; align-items: center; gap: 2px; color: var(--muted); background: var(--paper); border-radius: var(--radius-sm); opacity: 0; transition: opacity .12s ease; }
.rich-table:hover > .rich-actions,.rich-table:focus-within > .rich-actions,.rich-diagram-block:hover > .rich-actions,.rich-diagram-block:focus-within > .rich-actions { opacity: 1; pointer-events: auto; }
.rich-math-block { display: block; padding: 8px 16px; overflow-x: auto; max-width: 100%; }
.rich-math .katex { font-size: 1.08em; }
.rich-equation .katex-display { margin: 12px 0; }
.rich-diagram { display: block; width: 100%; height: 240px; border: 0; background: var(--paper); }
.rich-diagram-preview { overflow: auto; }
.rich-diagram-preview[hidden],.rich-code pre[hidden] { display: none; }
.rich-dialog { width: min(1120px,calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.rich-dialog::backdrop { background: color-mix(in srgb, var(--ink) 25%, transparent); }
.rich-dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-family: var(--font); }
.rich-dialog-content { padding: 16px; overflow: auto; max-height: calc(100dvh - 120px); }
.rich-dialog-content table { border-collapse: collapse; min-width: 100%; font-size: var(--font-size-ui); }
.rich-dialog-content th,.rich-dialog-content td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.rich-dialog-content .markdown-table { overflow-x: auto; }
.rich-code .hljs-keyword,.rich-code .hljs-selector-tag,.rich-code .hljs-literal { color: var(--accent); }
.rich-code .hljs-string,.rich-code .hljs-regexp,.rich-code .hljs-addition { color: var(--connection-online); }
.rich-code .hljs-number,.rich-code .hljs-symbol,.rich-code .hljs-bullet { color: color-mix(in srgb, var(--accent) 65%, var(--ink)); }
.rich-code .hljs-title,.rich-code .hljs-attr,.rich-code .hljs-built_in { color: var(--link); }
.rich-code .hljs-comment,.rich-code .hljs-quote { color: var(--muted); }
.rich-code .hljs-meta,.rich-code .hljs-deletion { color: var(--accent); }
@media (hover:none),(pointer:coarse) { .rich-actions { opacity: 1; pointer-events: auto; }.rich-icon-action { width: 36px; height: 36px; }.rich-actions { top: -36px; }.rich-table,.rich-code.rich-diagram-block { margin-top: 40px; } }
@media (prefers-reduced-motion:reduce) { .rich-actions { transition: none; } }
@media(max-width:640px) { .rich-toolbar { padding: 6px 8px; }.rich-action { min-height: 36px; }.rich-icon-action { width: 36px; height: 36px; }.rich-actions { top: -36px; opacity: 1; pointer-events: auto; }.rich-table,.rich-code.rich-diagram-block { margin-top: 40px; }.rich-dialog { width: calc(100vw - 16px); max-width: calc(100vw - 16px); }.rich-dialog-content { padding: 8px; } }
