.rich-text-content {
    --rtc-text: #475569;
    --rtc-heading: #0f172a;
    --rtc-accent: #4B88E6;
    --rtc-link: #2563eb;
    --rtc-font-size: 1.02rem;
    --rtc-line-height: 1.82;
    --rtc-block-space: 1rem;
    --rtc-heading-top: 2rem;
    --rtc-heading-bottom: 0.8rem;
    --rtc-list-space: 1.15rem;
    --rtc-list-indent: 1.35rem;
    --rtc-h1-size: clamp(2.05rem, 3.4vw, 2.65rem);
    --rtc-h2-size: clamp(1.7rem, 2.7vw, 2.1rem);
    --rtc-h3-size: clamp(1.34rem, 2vw, 1.6rem);
    --rtc-h4-size: clamp(1.15rem, 1.7vw, 1.35rem);
    --rtc-h5-size: 1.02rem;
    --rtc-h6-size: 0.92rem;
    color: var(--rtc-text);
    font-size: var(--rtc-font-size);
    line-height: var(--rtc-line-height);
    overflow-wrap: anywhere;
}

.rich-text-content > :first-child {
    margin-top: 0 !important;
}

.rich-text-content > :last-child {
    margin-bottom: 0 !important;
}

.rich-text-content > :where(p, ul, ol, blockquote, pre, table, figure, iframe) {
    margin: 0 0 var(--rtc-block-space);
}

.rich-text-content :where(h1, h2, h3, h4, h5, h6) {
    color: var(--rtc-heading);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin: var(--rtc-heading-top) 0 var(--rtc-heading-bottom);
    padding: 0;
    border: 0;
    text-wrap: balance;
}

.rich-text-content h1 {
    font-size: var(--rtc-h1-size);
    line-height: 1.14;
    margin-top: 0;
    margin-bottom: 1rem;
}

.rich-text-content h2 {
    font-size: var(--rtc-h2-size);
    margin-top: 2.35rem;
}

.rich-text-content h3 {
    font-size: var(--rtc-h3-size);
    margin-top: 1.55rem;
    margin-bottom: 0.6rem;
}

.rich-text-content h4 {
    font-size: var(--rtc-h4-size);
}

.rich-text-content h5 {
    font-size: var(--rtc-h5-size);
}

.rich-text-content h6 {
    font-size: var(--rtc-h6-size);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.rich-text-content p:empty {
    display: none;
}

.rich-text-content p {
    margin-bottom: var(--rtc-block-space);
}

.rich-text-content h1 + p,
.rich-text-content h2 + p,
.rich-text-content h3 + p,
.rich-text-content h4 + p,
.rich-text-content h5 + p,
.rich-text-content h6 + p,
.rich-text-content p + p {
    margin-top: 0;
}

.rich-text-content :where(ul, ol) {
    padding-left: var(--rtc-list-indent);
    margin-left: 0;
    margin-bottom: var(--rtc-list-space);
}

.rich-text-content ul {
    list-style: disc;
}

.rich-text-content ol {
    list-style: decimal;
}

.rich-text-content li {
    margin-bottom: 0.6rem;
    padding-left: 0.3rem;
    line-height: 1.75;
}

.rich-text-content li > :last-child {
    margin-bottom: 0;
}

.rich-text-content li::marker {
    color: var(--rtc-accent);
    font-weight: 700;
}

.rich-text-content ul + p,
.rich-text-content ol + p {
    margin-top: 0.15rem;
}

.rich-text-content :where(ul, ol) :where(ul, ol) {
    margin-top: 0.65rem;
    margin-bottom: 0;
}

.rich-text-content strong,
.rich-text-content b {
    color: var(--rtc-heading);
    font-weight: 700;
}

.rich-text-content a {
    color: var(--rtc-link);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.35);
    text-underline-offset: 0.18em;
}

.rich-text-content a:hover {
    color: #1d4ed8;
    text-decoration-color: currentColor;
}

.rich-text-content blockquote {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(14, 165, 233, 0.04));
    border-left: 4px solid var(--rtc-accent);
    border-radius: 18px;
    color: #334155;
}

.rich-text-content hr {
    border: 0;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    margin: 2rem 0;
    opacity: 1;
}

.rich-text-content pre {
    white-space: pre-wrap;
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem 1.15rem;
    border-radius: 16px;
    overflow-x: auto;
}

.rich-text-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem auto;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.rich-text-content figure {
    margin: 1.75rem 0;
}

.rich-text-content figcaption {
    margin-top: 0.75rem;
    font-size: 0.92rem;
    color: #64748b;
    text-align: center;
}

.rich-text-content table {
    width: 100%;
    display: block;
    overflow-x: auto;
    border-collapse: collapse;
    border-radius: 18px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: #ffffff;
}

.rich-text-content th,
.rich-text-content td {
    min-width: 160px;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(226, 232, 240, 0.85);
    vertical-align: top;
}

.rich-text-content th {
    background: #f8fafc;
    color: var(--rtc-heading);
    font-weight: 700;
}

.rich-text-content iframe {
    width: 100%;
    max-width: 100%;
    border: 0;
    border-radius: 18px;
    aspect-ratio: 16 / 9;
}

.rich-text-content--compact {
    --rtc-text: inherit;
    --rtc-heading: inherit;
    --rtc-font-size: 0.95rem;
    --rtc-line-height: 1.72;
    --rtc-block-space: 0.75rem;
    --rtc-heading-top: 1.15rem;
    --rtc-heading-bottom: 0.45rem;
    --rtc-list-space: 0.85rem;
    --rtc-list-indent: 1.15rem;
    --rtc-h1-size: 1.3rem;
    --rtc-h2-size: 1.15rem;
    --rtc-h3-size: 1.05rem;
    --rtc-h4-size: 1rem;
    --rtc-h5-size: 0.96rem;
    --rtc-h6-size: 0.88rem;
}

.rich-text-content--compact blockquote {
    padding: 0.9rem 1rem;
    border-radius: 14px;
}

.rich-text-content--compact img {
    margin: 0.75rem auto;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.rich-text-content--compact li {
    margin-bottom: 0.45rem;
}

@media (max-width: 768px) {
    .rich-text-content {
        --rtc-font-size: 0.98rem;
        --rtc-line-height: 1.76;
        --rtc-list-indent: 1.15rem;
        --rtc-h1-size: 1.95rem;
        --rtc-h2-size: 1.55rem;
        --rtc-h3-size: 1.24rem;
    }

    .rich-text-content :where(h1, h2, h3, h4, h5, h6) {
        text-wrap: initial;
    }

    .rich-text-content h2 {
        margin-top: 2rem;
    }

    .rich-text-content h3 {
        margin-top: 1.35rem;
    }

    .rich-text-content--compact {
        --rtc-font-size: 0.93rem;
        --rtc-line-height: 1.68;
    }
}
