/* rich-blocks.css — headings, lists, quotes, code blocks, tables and alignment,
   both while writing (the editor's per-line <div data-b data-a>) and when read
   (rendered .kc-h / .kc-ul / .kc-table …). Colours follow the surrounding text
   so it looks right inside chat bubbles of any colour, posts and the dark theme. */
:root { --kc-blk-line: rgba(127,127,142,.38); --kc-blk-fill: rgba(127,127,142,.16); --kc-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

[data-a="r"] { text-align: right; }
[data-a="c"] { text-align: center; }

/* ---------- rendered ---------- */
.kc-p { margin: 0; }
.kc-gap { height: .55em; }
.kc-h { font-weight: 800; letter-spacing: -.01em; line-height: 1.25; margin: .5em 0 .25em; }
.kc-h:first-child { margin-top: 0; }
.kc-h1 { font-size: 1.35em; }
.kc-h2 { font-size: 1.12em; opacity: .94; }
.kc-ul, .kc-ol { margin: .3em 0; padding-left: 1.45em; }
.kc-ul { list-style: disc; }
.kc-ol { list-style: decimal; }
.kc-ul li, .kc-ol li { margin: .12em 0; padding-left: .1em; }
.kc-ul li[data-a="r"], .kc-ol li[data-a="r"] { list-style-position: inside; }
.kc-ul li[data-a="c"], .kc-ol li[data-a="c"] { list-style-position: inside; }
.kc-quote { border-left: 3px solid #7868e9; border-radius: 3px; margin: .35em 0; opacity: .92; padding: .1em 0 .1em .75em; }
.kc-pre { background: var(--kc-blk-fill); border: 1px solid var(--kc-blk-line); border-radius: 10px; font-family: var(--kc-mono); font-size: .88em; line-height: 1.5; margin: .4em 0; overflow-x: auto; padding: .6em .8em; text-align: left; white-space: pre; }
.kc-pre code { background: none; font: inherit; padding: 0; }
.kc-table-wrap { margin: .4em 0; max-width: 100%; overflow-x: auto; }
.kc-table { border-collapse: separate; border-spacing: 0; border: 1px solid var(--kc-blk-line); border-radius: 10px; font-size: .94em; max-width: none; overflow: hidden; }
.kc-table th, .kc-table td { border-bottom: 1px solid var(--kc-blk-line); border-right: 1px solid var(--kc-blk-line); min-width: 3.2em; padding: .4em .7em; text-align: left; vertical-align: top; }
.kc-table th { background: var(--kc-blk-fill); font-weight: 800; }
.kc-table tr > *:last-child { border-right: 0; }
.kc-table tbody tr:last-child > * { border-bottom: 0; }
.kc-table [data-a="r"] { text-align: right; }
.kc-table [data-a="c"] { text-align: center; }

/* chat bubbles: blocks sit inside an inline-level bubble, so make them behave */
.thread-bubble .kc-table-wrap, .thread-bubble .kc-pre { max-width: 100%; }
.thread-bubble .kc-h1 { font-size: 1.2em; }
.thread-bubble .kc-quote { border-left-color: currentColor; }

/* post cards: a tall rich post is trimmed with a soft fade, "Read more" opens it */
.kc-rich-render.is-clamped { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); max-height: 11.5em; overflow: hidden; }

/* ---------- editor lines ---------- */
.kc-rich > div[data-b], .kc-rich > div[data-a] { min-height: 1.3em; }
.kc-rich > div[data-b="h1"] { font-size: 1.35em; font-weight: 800; line-height: 1.25; }
.kc-rich > div[data-b="h2"] { font-size: 1.12em; font-weight: 800; line-height: 1.25; }
.kc-rich > div[data-b="ul"], .kc-rich > div[data-b="ol"], .kc-rich > div[data-b="quote"] { padding-left: 1.6em; position: relative; }
.kc-rich > div[data-b="ul"]::before { content: "•"; font-weight: 800; left: .45em; position: absolute; }
.kc-rich { counter-reset: kcol; }
.kc-rich > div { counter-reset: kcol; }
.kc-rich > div[data-b="ol"] { counter-reset: none; counter-increment: kcol; }
.kc-rich > div[data-b="ol"]::before { content: counter(kcol) "."; font-weight: 700; left: 0; min-width: 1.3em; position: absolute; text-align: right; }
.kc-rich > div[data-b="quote"]::before { background: #7868e9; border-radius: 3px; bottom: 1px; content: ""; left: .3em; position: absolute; top: 1px; width: 3px; }
.kc-rich > div[data-b="code"] { background: var(--kc-blk-fill); font-family: var(--kc-mono); font-size: .9em; padding: 0 .7em; white-space: pre-wrap; }
.kc-rich > div[data-b="code"]:not([data-b="code"] + [data-b="code"]) { border-radius: 8px 8px 0 0; padding-top: .35em; }
.kc-rich > div[data-b="code"]:not(:has(+ [data-b="code"])) { border-radius: 0 0 8px 8px; padding-bottom: .35em; }
.kc-rich > div[data-b="code"]:not([data-b="code"] + [data-b="code"]):not(:has(+ [data-b="code"])) { border-radius: 8px; }
.kc-rich > div[data-a="r"] { text-align: right; }
.kc-rich > div[data-a="c"] { text-align: center; }
.kc-rich > div[data-b="ul"][data-a="r"], .kc-rich > div[data-b="ol"][data-a="r"] { padding-left: 0; padding-right: 1.6em; }
.kc-rich > div[data-b="ul"][data-a="r"]::before { left: auto; right: .45em; }
.kc-rich > div[data-b="ol"][data-a="r"]::before { left: auto; right: 0; text-align: left; }

/* ---------- editor tables ---------- */
.kc-tbl { margin: 6px 0; position: relative; -webkit-user-select: none; user-select: none; }
.kc-tbl-scroll { max-width: 100%; overflow-x: auto; }
.kc-tbl .kc-table { width: 100%; }
.kc-tbl .kc-cell { -webkit-user-select: text; user-select: text; cursor: text; min-width: 4.5em; outline: 0; white-space: pre-wrap; word-break: break-word; }
.kc-tbl .kc-cell:focus { background: rgba(120,104,233,.14); box-shadow: inset 0 0 0 2px #7868e9; }
.kc-tbl .kc-cell:empty::before { content: ""; }
.kc-tbl-tools { display: none; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.kc-tbl:focus-within .kc-tbl-tools { display: flex; }
.kc-tbl-tools button { background: rgba(120,104,233,.13); border: 0; border-radius: 8px; color: #5c51d1; cursor: pointer; font: 700 11.5px/1 inherit; font-family: inherit; padding: 7px 10px; }
.kc-tbl-tools button.is-danger { background: rgba(224,69,106,.13); color: #d63a5f; }
.kc-tbl-tools button:active { transform: scale(.95); }
body[data-theme="dark"] .kc-tbl-tools button { background: rgba(255,255,255,.1); color: #c9c2ff; }
body[data-theme="dark"] .kc-tbl-tools button.is-danger { background: rgba(255,90,120,.16); color: #ff8aa3; }

/* ---------- toolbar ---------- */
.kc-tb { align-items: center; background: #fff; border: 1px solid rgba(120,104,233,.2); border-radius: 12px; box-shadow: 0 6px 20px rgba(28,35,61,.12); display: flex; gap: 2px; max-width: 100%; overflow-x: auto; padding: 4px; scrollbar-width: none; }
.kc-tb::-webkit-scrollbar { display: none; }
.kc-tb-btn { align-items: center; background: none; border: 0; border-radius: 8px; color: #3b4263; cursor: pointer; display: inline-flex; flex: 0 0 auto; font-size: 14px; height: 34px; justify-content: center; min-width: 34px; padding: 0; transition: background .12s, color .12s, transform .1s; }
.kc-tb-btn:hover { background: rgba(120,104,233,.12); }
.kc-tb-btn:active { transform: scale(.9); }
.kc-tb-btn.is-on { background: rgba(120,104,233,.22); color: #4a3fc2; }
.kc-tb-btn svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 18px; }
.kc-tb-btn svg text { fill: currentColor; stroke: none; }
.kc-tb-btn code { background: none; font: 700 11px var(--kc-mono); padding: 0; }
.kc-tb-txt { font-size: 13px; font-weight: 800; letter-spacing: -.02em; }
.kc-tb-txt.is-sm { font-size: 11.5px; }
.kc-tb-div { background: rgba(127,127,142,.3); flex: 0 0 auto; height: 18px; margin: 0 3px; width: 1px; }
body[data-theme="dark"] .kc-tb { background: #1b2033; border-color: rgba(255,255,255,.12); }
body[data-theme="dark"] .kc-tb-btn { color: #d5d9ee; }
body[data-theme="dark"] .kc-tb-btn.is-on { background: rgba(139,123,255,.3); color: #fff; }

/* post form: toolbar on top of a roomy writing box */
.kc-post-editor-wrap .kc-tb { box-shadow: none; margin-bottom: 8px; }
.kc-rich-input.kc-post-rich { background: #fafbfe; border: 1px solid #cdd3e3; border-radius: 10px; box-sizing: border-box; color: #303748; font-size: 14px; line-height: 1.5; max-height: 420px; min-height: 150px; outline: 0; overflow-y: auto; padding: 11px 12px; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.kc-rich-input.kc-post-rich:focus { border-color: #7868e9; box-shadow: 0 0 0 3px rgba(120,104,233,.1); }
.kc-rich-input.kc-post-rich:empty::before { color: #a3a9ba; content: attr(data-placeholder); pointer-events: none; }
body[data-theme="dark"] .kc-rich-input.kc-post-rich { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.14); color: #eef0f6; }

.kc-compose-form { position: relative; }
.kc-editor-card > .kc-tb { border-radius: 0; border-width: 0 0 1px; box-shadow: none; flex: 0 0 auto; padding: 4px 8px; }
.kc-editor-input > div[data-b], .kc-editor-input > div[data-a] { min-height: 1.3em; }

/* ---------- chat messages: bigger, clearer headings / lists / tables (Telegram-like) ---------- */
.thread-bubble .kc-h { line-height: 1.22; margin: .65em 0 .3em; }
.thread-bubble .kc-h1 { font-size: 1.6em; letter-spacing: -.02em; }
.thread-bubble .kc-h2 { font-size: 1.32em; opacity: 1; }
.thread-bubble .kc-ul, .thread-bubble .kc-ol { margin: .45em 0; padding-left: 1.6em; }
.thread-bubble .kc-ul li, .thread-bubble .kc-ol li { font-size: 1.08em; line-height: 1.45; margin: .22em 0; }
.thread-bubble .kc-quote { font-size: 1.05em; margin: .5em 0; padding: .2em 0 .2em .85em; }
.thread-bubble .kc-pre { font-size: .95em; padding: .75em .95em; }
.thread-bubble .kc-table-wrap { margin: .6em 0; }
.thread-bubble .kc-table { font-size: 1.05em; }
.thread-bubble .kc-table th, .thread-bubble .kc-table td { line-height: 1.4; min-width: 4em; padding: .6em .9em; }
.chat-page .thread-bubble:has(.kc-table-wrap), .chat-page .thread-bubble:has(.kc-pre) { max-width: min(94%, 560px); }

/* full-screen editor: keep the system copy/paste bubble out of the way */
.kc-editor-input { -webkit-touch-callout: none; }

/* ---------- checklist ---------- */
/* rendered */
.kc-todo { list-style: none; margin: .35em 0; padding: 0; }
.kc-todo-item { align-items: flex-start; display: flex; gap: .6em; margin: .22em 0; }
.kc-check { background: transparent; border: 1.8px solid currentColor; border-radius: .3em; box-sizing: border-box; flex: 0 0 auto; height: 1.15em; margin-top: .12em; opacity: .55; position: relative; transition: background .2s, border-color .2s, opacity .2s; width: 1.15em; }
.kc-todo-item.is-done .kc-check { background: #22a05a; border-color: #22a05a; opacity: 1; }
.kc-todo-item.is-done .kc-check::after { border: solid #fff; border-width: 0 2.2px 2.2px 0; content: ""; height: .5em; left: .36em; position: absolute; top: .12em; transform: rotate(45deg); width: .26em; }
.kc-todo-item.is-done .kc-todo-text { opacity: .6; text-decoration: line-through; }
.kc-todo-item[data-a="r"] { justify-content: flex-end; }
.kc-todo-item[data-a="c"] { justify-content: center; }
.thread-bubble .kc-todo-item { font-size: 1.06em; }
/* editor */
.kc-rich > div[data-b="todo"] { padding-left: 1.95em; position: relative; }
.kc-rich > div[data-b="todo"]::before { background: transparent; border: 1.8px solid currentColor; border-radius: .3em; box-sizing: border-box; content: ""; cursor: pointer; height: 1.1em; left: .3em; opacity: .6; position: absolute; top: .16em; transition: background .18s, border-color .18s, opacity .18s; width: 1.1em; }
.kc-rich > div[data-b="todo"][data-chk]::before { background: #22a05a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5.5 12.8 4.2 4.2L18.5 8'/%3E%3C/svg%3E") center / 88% no-repeat; border-color: #22a05a; opacity: 1; }
.kc-rich > div[data-b="todo"][data-chk] { opacity: .65; text-decoration: line-through; }

/* ---------- toggle block ---------- */
/* rendered: a real expandable section */
.kc-toggle { border-radius: 10px; margin: .4em 0; }
.kc-toggle-sum { align-items: flex-start; cursor: pointer; display: flex; font-weight: 700; gap: .45em; list-style: none; padding: .15em 0; -webkit-tap-highlight-color: transparent; }
.kc-toggle-sum::-webkit-details-marker { display: none; }
.kc-toggle-sum::before { border-color: transparent transparent transparent currentColor; border-style: solid; border-width: .38em 0 .38em .62em; content: ""; flex: 0 0 auto; margin: .38em .25em 0 .1em; opacity: .75; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.kc-toggle[open] > .kc-toggle-sum::before { transform: rotate(90deg); }
.kc-toggle-body { border-left: 2px solid var(--kc-blk-line); margin: .15em 0 .1em .5em; padding: .1em 0 .1em .85em; animation: kc-toggle-in .24s ease-out; }
@keyframes kc-toggle-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.thread-bubble .kc-toggle-sum { font-size: 1.06em; }
/* editor: title line + indented hidden lines */
.kc-rich > div[data-b="toggle"] { font-weight: 700; padding-left: 1.55em; position: relative; }
.kc-rich > div[data-b="toggle"]::before { border-color: transparent transparent transparent currentColor; border-style: solid; border-width: .36em 0 .36em .6em; content: ""; left: .4em; opacity: .75; position: absolute; top: .42em; transform: rotate(90deg); }
.kc-rich > div[data-b="tbody"] { border-left: 2px solid var(--kc-blk-line); margin-left: .55em; padding-left: .95em; }
.kc-rich > div[data-b="toggle"]:has(> br:only-child)::after { content: "Toggle title"; opacity: .4; pointer-events: none; position: absolute; }
.kc-rich > div[data-b="tbody"]:has(> br:only-child)::after { content: "Hidden content — shown when the toggle is opened"; opacity: .4; pointer-events: none; position: absolute; }

/* ---------- table title ---------- */
.kc-table-title { font-size: .98em; font-weight: 800; letter-spacing: -.005em; margin: 0 0 .4em; padding: 0 .15em; }
.thread-bubble .kc-table-title { font-size: 1.08em; }
.kc-tbl-title { -webkit-user-select: text; background: transparent; border-radius: 8px; cursor: text; font-weight: 800; margin: 0 0 6px; min-height: 1.4em; outline: 0; padding: 3px 6px; user-select: text; white-space: pre-wrap; word-break: break-word; transition: background .2s, box-shadow .2s; }
.kc-tbl-title:empty::before { content: attr(data-ph); font-weight: 600; opacity: .38; pointer-events: none; }
.kc-tbl-title:focus { background: rgba(120,104,233,.1); box-shadow: inset 0 0 0 2px #7868e9; }

/* ---------- toolbar: separators between the new groups stay tidy ---------- */
.kc-tb-btn[data-tb="todo"] svg, .kc-tb-btn[data-tb="toggle"] svg, .kc-tb-btn[data-tb="mono"] svg { height: 19px; width: 19px; }
