/* Подсветка кода (Prism), спойлеры и таблицы в сообщениях */

/* ---------- блок кода ---------- */

.codeblock {
    position: relative;
    margin: 0 0 12px;
}

.code-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    padding: 2px 10px;
    border: 1px solid #d5dde6;
    border-radius: 4px;
    background: #ffffff;
    color: #5a6b80;
    font-size: 11px;
    line-height: 18px;
    cursor: pointer;
}

.code-copy:hover {
    background: #eef3f8;
    color: #2c3e50;
}

.postcontent pre[class*="language-"] {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #e3e8ee;
    border-radius: 4px;
    background: #f7f9fc;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
}

.postcontent pre[class*="language-"] code {
    font-size: 13px;
}

/* нумерация строк (плагин Prism) */
.postcontent pre[class*="language-"].line-numbers {
    padding-left: 3.8em;
}

.postcontent pre.line-numbers > code {
    white-space: pre;
}

/* ---------- спойлер ---------- */

details.spoiler {
    margin: 0 0 12px;
    border: 1px solid #e3e8ee;
    border-radius: 4px;
    background: #fafbfd;
}

details.spoiler > summary {
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 600;
    color: #2c3e50;
    list-style: none;
    user-select: none;
}

details.spoiler > summary::-webkit-details-marker {
    display: none;
}

details.spoiler > summary:before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.15s ease;
}

details.spoiler[open] > summary:before {
    transform: rotate(90deg);
}

details.spoiler > summary:hover {
    color: #1d5c99;
}

details.spoiler > *:not(summary) {
    margin-left: 12px;
    margin-right: 12px;
}

details.spoiler > *:last-child {
    margin-bottom: 10px;
}

details.code-fold > summary {
    font-weight: 500;
    font-size: 13px;
    color: #5a6b80;
}

/* ---------- таблицы в сообщениях ---------- */

.postcontent table {
    width: auto;
    max-width: 100%;
    margin: 0 0 12px;
    border-collapse: collapse;
    font-size: 14px;
}

.postcontent table th,
.postcontent table td {
    padding: 6px 10px;
    border: 1px solid #e3e8ee;
    vertical-align: top;
}

.postcontent table th {
    background: #f2f6fa;
    font-weight: 600;
}

/* ---------- тёмная тема ---------- */

html[data-theme="dark"] .code-copy {
    border-color: #39434f;
    background: #232b34;
    color: #a9b6c6;
}

html[data-theme="dark"] .code-copy:hover {
    background: #2c3540;
    color: #d7dde5;
}

html[data-theme="dark"] .postcontent pre[class*="language-"] {
    border-color: #2c3540;
    background: #1b2128;
}

html[data-theme="dark"] details.spoiler {
    border-color: #2c3540;
    background: #181e24;
}

html[data-theme="dark"] details.spoiler > summary {
    color: #d7dde5;
}

html[data-theme="dark"] details.spoiler > summary:hover {
    color: #cfe0ff;
}

html[data-theme="dark"] details.code-fold > summary {
    color: #a9b6c6;
}

html[data-theme="dark"] .postcontent table th,
html[data-theme="dark"] .postcontent table td {
    border-color: #2c3540;
}

html[data-theme="dark"] .postcontent table th {
    background: #232b34;
}

/* ---------- палитра Prism для тёмной темы ---------- */

html[data-theme="dark"] .postcontent .token.comment,
html[data-theme="dark"] .postcontent .token.prolog,
html[data-theme="dark"] .postcontent .token.doctype,
html[data-theme="dark"] .postcontent .token.cdata {
    color: #7f8c98;
}

html[data-theme="dark"] .postcontent .token.punctuation {
    color: #c3ccd6;
}

html[data-theme="dark"] .postcontent .token.property,
html[data-theme="dark"] .postcontent .token.tag,
html[data-theme="dark"] .postcontent .token.boolean,
html[data-theme="dark"] .postcontent .token.number,
html[data-theme="dark"] .postcontent .token.constant,
html[data-theme="dark"] .postcontent .token.symbol {
    color: #f0a43a;
}

html[data-theme="dark"] .postcontent .token.selector,
html[data-theme="dark"] .postcontent .token.attr-name,
html[data-theme="dark"] .postcontent .token.string,
html[data-theme="dark"] .postcontent .token.char,
html[data-theme="dark"] .postcontent .token.builtin {
    color: #8fd18a;
}

html[data-theme="dark"] .postcontent .token.operator,
html[data-theme="dark"] .postcontent .token.entity,
html[data-theme="dark"] .postcontent .token.url,
html[data-theme="dark"] .postcontent .language-css .token.string,
html[data-theme="dark"] .postcontent .style .token.string {
    color: #c3ccd6;
}

html[data-theme="dark"] .postcontent .token.atrule,
html[data-theme="dark"] .postcontent .token.attr-value,
html[data-theme="dark"] .postcontent .token.keyword {
    color: #7fb3ff;
}

html[data-theme="dark"] .postcontent .token.function,
html[data-theme="dark"] .postcontent .token.class-name {
    color: #e0c46c;
}

html[data-theme="dark"] .postcontent .token.regex,
html[data-theme="dark"] .postcontent .token.important,
html[data-theme="dark"] .postcontent .token.variable {
    color: #f08a7a;
}

html[data-theme="dark"] .postcontent .line-numbers .line-numbers-rows > span:before {
    color: #55606b;
}
/* у скина Prism у части токенов светлый фон — на тёмной теме он выглядит как плашка */
html[data-theme="dark"] .postcontent .token {
    background: none;
}
/* у темы Prism есть text-shadow под светлый фон — на тёмном он даёт «двоение» */
.postcontent pre[class*="language-"],
.postcontent pre[class*="language-"] code,
.postcontent pre[class*="language-"] .token {
    text-shadow: none;
}