.article-aparat-video {
    width: 100%;
    max-width: 720px;
    aspect-ratio: 16 / 9;
    margin: 1rem auto;
    overflow: hidden;
    border-radius: .5rem;
    background: #eaf2ff;
}

.article-aparat-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.article-aparat-video a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    color: #1d4ed8;
    text-decoration: none;
}

.article-aparat-video a::before {
    content: '▶';
    font-size: 2rem;
}

#richEditor .article-aparat-video {
    position: relative;
    cursor: pointer;
}

#richEditor .article-aparat-controls {
    position: absolute;
    top: .5rem;
    left: .5rem;
    z-index: 1;
    display: flex;
    gap: .35rem;
}

#richEditor .article-aparat-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: .4rem;
    background: #fff;
    color: #1d4ed8;
    box-shadow: 0 1px 5px #0002;
    cursor: pointer;
}

#richEditor .article-aparat-controls button[data-aparat-action="delete"] {
    color: #dc2626;
}

#richEditor .article-aparat-controls svg {
    width: 1.1rem;
    height: 1.1rem;
}

#articleVideoUrl {
    width: 100%;
    padding: .6rem;
    border: 1px solid #cbd5e1;
    border-radius: .4rem;
}

#articleVideoError {
    color: #b91c1c;
}

.callout-exercise, .callout-suggested-article {
    margin: 1rem 0;
    padding: 0.2rem 0.5rem;
    border-inline-start: 4px solid;
    border-radius: .5rem;
    direction: rtl;
    text-align: start;
    overflow-wrap: anywhere;
}

.callout-exercise {
    background-color: #f3f3f3;
    border: 1px solid #dddddd;
}

.callout-tip {
    background-color: var(--article-tip-background, #eff6ff);
    border-color: #bfdbfe;
}

#richEditor .callout-tip {
    background-color: var(--article-tip-background, #eff6ff);
    border-color: #bfdbfe;
}

.callout-suggested-article {
    display: flex;
    align-items: baseline;
    background-color: #f3f3f3;
    border: 1px solid #dddddd;
}

.article-block-title {
    display: inline-block;
    margin-left: 4px;
    font-weight: 700;
    line-height: 1.8rem;
    color: #2a2627;
}

#printableArticle > div.article-content > div.callout-exercise > p,
#richEditor > div.callout-exercise > p {
    display: block;
    margin: 0;
}

.article-content .article-callout-label,
#richEditor .article-callout-label {
    display: inline;
    font-weight: 700;
    line-height: 1.8rem;
    color: #2a2627;
}

.callout-suggested-article a {
    color: #3e3e3e;
}

.callout-suggested-article a:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

/* Show heading hierarchy while instructors compose an article. */
#richEditor h2 {
    font-size: 1.25rem;
    margin: 1rem 0 .5rem;
}

#richEditor h3 {
    font-size: 1.125rem;
    margin: .75rem 0 .375rem;
}

#richEditor :is(h2, h3) {
    font-weight: 700;
    line-height: 1.8;
}

#richEditor :is(h2, h3) * {
    font-size: inherit;
    line-height: inherit;
}

#richEditor u,
#richEditor [style*="underline"],
.article-content u,
.article-content [style*="underline"] {
    text-underline-offset: .4em;
    text-decoration-thickness: 1px;
}

/* Article content — dynamic DB content, must stay as CSS */
.article-content :where(:not(.katex, .katex *)) {
    line-height: 1.8rem;
}

.article-content sup:not(.katex *, .article-math *),
.article-content sub:not(.katex *, .article-math *) {
    position: relative;
    font-size: 75% !important;
    line-height: 0;
    vertical-align: baseline;
}

.article-content sup:not(.katex *, .article-math *) {
    top: -.5em;
    bottom: auto;
}

.article-content sub:not(.katex *, .article-math *) {
    bottom: -.25em;
    top: auto;
}

.article-content :is(sup, sub):not(.katex *, .article-math *) * {
    font-size: inherit !important;
}

/* Match the editor's justified text while preserving explicit per-block alignment. */
.article-content :where(.callout-warning, .callout-error, .callout-tip, .callout-exercise),
#richEditor :where(.callout-warning, .callout-error, .callout-tip, .callout-exercise),
.article-content .callout-tip,
#richEditor .callout-tip {
    text-align: justify;
}

/* Match the reader inside callouts without changing the editor's other blocks. */
#richEditor :where(.callout-warning, .callout-tip, .callout-exercise, .callout-suggested-article) {
    font-size: .9rem;
    line-height: 1.8rem;
    overflow-wrap: anywhere;
}

#richEditor :where(.callout-warning, .callout-tip, .callout-exercise, .callout-suggested-article) :where(:not(.katex, .katex *)) {
    line-height: 1.8rem;
}

.article-content strong, b,
#richEditor :where(.callout-warning, .callout-tip, .callout-exercise, .callout-suggested-article) strong {
    font-size: 0.8rem;
    font-weight: 700;
}

.article-overview a {
    font-size: 0.8rem;
    text-decoration: none !important;
}

.category-article-sidebar h2 {
    font-weight: 950;
}

@media (min-width: 1024px) {
    .category-article-sidebar {
        top: var(--article-heading-offset, 6rem);
        height: calc(100vh - var(--article-heading-offset, 6rem) - 1rem);
    }
}

.article-sidebar-backdrop {
    pointer-events: none;
}

.article-sidebar-open .article-sidebar-backdrop {
    pointer-events: auto;
}

.category-article-sidebar summary {
    font-weight: 750;
}

.category-article-sidebar a,
.category-article-sidebar a:hover,
.category-article-sidebar a[aria-current="page"] {
    font-weight: 600;
}


.article-content :is(h2, h3, h4, h5, h6),
.article-content :is(h2, h3, h4, h5, h6) :not(.katex, .katex *) {
    font-size: 1rem !important;
    line-height: 1.8rem;
    font-weight: 700;
    border-radius: 14px;
}

.article-content :is(big, .text-lg, .text-xl, .text-2xl, .text-3xl, .text-4xl, .text-5xl, .text-6xl, .text-7xl, .text-8xl, .text-9xl, font[size="4"], font[size="5"], font[size="6"], font[size="7"]) {
    font-size: .8rem !important;
}

.article-content :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: var(--article-heading-offset, 5.75rem);
}

.article-content h2,
.article-content h2 :not(.katex, .katex *) {
    font-weight: 900;
}

.article-content h3,
.article-content h3 :not(.katex, .katex *) {
    font-weight: 600;
}

.article-content p,
#richEditor :where(.callout-warning, .callout-tip, .callout-exercise, .callout-suggested-article) p {
    margin: .75rem 0;
}

.article-content .callout-tip p,
#richEditor .callout-tip p {
    margin: 0;
}

.article-content .callout-tip,
#richEditor .callout-tip {
    position: relative;
    margin: 1rem 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 1rem;
    border: 1px solid #a3a3a3;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-tabs {
    display: flex;
    gap: .25rem;
    padding: .4rem .5rem 0;
    background: var(--article-tip-background, #eff6ff);
}

:is(.article-content, #richEditor) .callout-tip[style*="--article-tip-background"] .article-tip-tabs {
    background: #cbd5e1;
    background: color-mix(in srgb, var(--article-tip-background) 85%, black);
    background: hsl(from var(--article-tip-background) h calc(s * 1.1965) calc(l * .73536));
}

:is(.article-content, #richEditor) .callout-tip[data-tip-code="true"] .article-tip-tabs {
    padding-left: 3rem;
}

:is(.article-content, #richEditor) .callout-tip > .article-tip-copy {
    position: absolute;
    top: .55rem;
    left: .65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .3rem;
    border: 0;
    border-radius: .35rem;
    background: transparent;
    color: #475569;
    cursor: pointer;
}

:is(.article-content, #richEditor) .callout-tip > .article-tip-copy svg {
    width: 1.15rem;
    height: 1.15rem;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-tabs button {
    padding: .5rem 1rem;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    color: #000000;
    font-size: .95rem;
    paint-order: stroke fill;
    line-height: 1.5rem;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-tabs button[hidden] {
    display: none;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-tabs button[aria-selected="true"] {
    border-bottom-color: #1d4ed8;
    color: #000000;
    font-weight: 940;
}

:is(.article-content, #richEditor) .callout-tip[style*="--article-tip-background"] .article-tip-tabs button {
    color: #000000;
}

:is(.article-content, #richEditor) .callout-tip[style*="--article-tip-background"] .article-tip-tabs button[aria-selected="true"] {
    border-bottom-color: #000;
    color: #000000;
    font-weight: 940;
}

:is(.article-content, #richEditor) .callout-tip[style*="--article-tip-background"] > .article-tip-copy {
    color: #fff;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-tabs button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-panel {
    min-height: 1.8rem;
    padding: .8rem 1rem;
    background: var(--article-tip-background, #eff6ff);
    overflow-wrap: anywhere;
}

:is(.article-content, #richEditor) .callout-tip .article-tip-panel[hidden] {
    display: none;
}

#richEditor .callout-tip .article-tip-panel:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.article-content ol {
    list-style: decimal;
    padding-inline-start: 1.5rem;
}

.article-content ul {
    list-style: disc;
    padding-inline-start: 1.5rem;
}

.article-content pre {
    overflow-x: auto;
    white-space: pre-wrap;
    direction: ltr;
    text-align: left;
    background: #eff6ff;
    padding: 1rem;
    border-radius: .5rem;
}

:is(.article-content, #richEditor) pre.code-block {
    position: relative;
    max-width: 100%;
    margin: 1rem 0;
    padding: 3.25rem 1rem 1rem;
    overflow-x: auto;
    border: 1px solid #dbe4f0;
    border-radius: .8rem;
    background: #eff6ff;
    color: #334155;
    direction: ltr;
    text-align: left;
    white-space: pre;
}

#richEditor pre.code-block {
    background-color: #eff6ff;
}

:is(.article-content, #richEditor) pre.code-block > code {
    display: block;
    min-width: max-content;
    white-space: pre;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .875rem;
    line-height: 1.7;
}

:is(.article-content, #richEditor) pre.code-block .article-code-toolbar {
    position: sticky;
    left: 0;
    width: 100%;
    margin: -2.7rem 0 1rem;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: normal;
    font-size: .75rem;
}

:is(.article-content, #richEditor) pre.code-block .article-code-toolbar button {
    padding: .3rem .5rem;
    border: 1px solid #cbd5e1;
    border-radius: .4rem;
    background: #fff;
    color: #475569;
    cursor: pointer;
}

:is(.article-content, #richEditor) pre.code-block .article-code-toolbar button:hover {
    color: #2563eb;
    border-color: #93c5fd;
}

:is(.article-content, #richEditor) pre.code-block .article-code-toolbar button {
    order: 1;
    margin-left: auto;
}

.article-content a,
#richEditor :where(.callout-warning, .callout-tip, .callout-exercise, .callout-suggested-article) a {
    color: #3e3e3e;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.article-content .article-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.article-content table {
    display: table;
    width: max-content;
    min-width: 100%;
    max-width: none;
    border-collapse: collapse;
    margin-inline: auto;
    white-space: normal;
}

.article-content th,
.article-content td {
    border: 1px solid #bfdbfe;
    padding: .5rem;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

#richEditor table,
#richEditor table.editor-table {
    max-width: 100%;
    border-collapse: collapse;
    margin-inline: auto;
}

#richEditor :is(th, td) {
    border: 1px solid #bfdbfe;
    padding: .5rem;
}

#richEditor table.editor-table :is(th, td),
.article-content table.editor-table :is(th, td) {
    border-color: #bfdbfe;
}

#richEditor table :is(th, td),
#richEditor table.editor-table :is(th, td),
.article-content table :is(th, td) {
    text-align: center;
    vertical-align: middle;
}

#richEditor table.editor-table th,
.article-content table th {
    background-color: #eff6ff;
}

#richEditor table.editor-table tr:hover {
    background-color: #f8fbff;
}

.article-content table:is([data-column-resizable="true"], [data-table-layout="true"]) {
    display: table;
    table-layout: fixed;
}

@media print {
    .article-content .article-table-scroll {
        width: 100%;
        max-width: none;
        overflow: visible;
    }

    .article-content table {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        table-layout: auto;
        white-space: normal;
    }

    .article-content table :is(th, td) {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

:is(.article-content, #richEditor) table:is([data-column-resizable="true"], [data-table-layout="true"]) :is(th, td) {
    overflow-wrap: anywhere;
    white-space: normal;
}

.article-content img,
#richEditor img {
    max-width: 100%;
    height: auto;
    border-radius: .75rem;
}

.article-content img {
    margin: 8px auto;
}

.article-exercise {
    margin: 1rem 0;
    overflow: hidden;
    border: 1px solid #bfdbfe;
    border-radius: .85rem;
    background: #fff;
}

.article-exercise-tools {
    display: none;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .5rem;
    border-bottom: 1px solid #dbeafe;
    background: #f8fafc;
}

#richEditor .article-exercise.is-selected > .article-exercise-tools {
    display: flex;
}

.article-exercise-tools button {
    padding: .35rem .65rem;
    border: 1px solid #bfdbfe;
    border-radius: .45rem;
    background: #fff;
    color: #1d4ed8;
    cursor: pointer;
    font-size: .8rem;
}

.article-exercise-tools button[data-exercise-action="delete"] {
    color: #b91c1c;
    border-color: #fecaca;
}

.article-exercise-choices {
    margin: .5rem 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.article-exercise-option {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    margin: .4rem 0;
}

.article-exercise-option input {
    flex: none;
    accent-color: #2563eb;
}

.article-exercise-option-text {
    display: block;
    flex: 1;
    min-width: 0;
    min-height: 1.8em;
}

.article-exercise-option-text:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
}

.article-exercise-choices[data-choice-kind="true-false"] {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem 1rem;
    margin: 0 .5rem;
    vertical-align: baseline;
}

.article-exercise-choices[data-choice-kind="true-false"] .article-exercise-option {
    display: inline-flex;
    flex: none;
    margin: 0;
}

.article-exercise-choices[data-choice-kind="true-false"] .article-exercise-option-text {
    flex: none;
    min-height: 0;
}

.article-exercise-choices[data-choice-kind="true-false"] .article-exercise-choice-hint {
    flex-basis: 100%;
}

.article-exercise-choices[data-choice-kind="true-false"] + .article-exercise-choice-feedback:not(:empty) {
    display: block;
    text-align: start;
}

.article-exercise-choice-hint, .article-exercise-choice-feedback {
    color: #64748b;
    font-size: .75rem;
}

.article-exercise-choice-feedback:is([data-result="correct"], [data-result="incorrect"]) {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: .25rem .65rem;
    border: 1px solid transparent;
    border-radius: .5rem;
    font-weight: 700;
}

.article-exercise-choice-feedback[data-result="correct"] {
    border-color: #bbf7d0;
    background: #dcfce7;
    color: #166534;
}

.article-exercise-choice-feedback[data-result="incorrect"] {
    border-color: #fecaca;
    background: #fee2e2;
    color: #991b1b;
}

.article-exercise-blank {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .35rem;
    max-width: 100%;
    vertical-align: baseline;
}

.article-exercise-blank-input {
    box-sizing: border-box;
    width: 9ch;
    max-width: 100%;
    min-width: 4ch;
    padding: .1rem .35rem;
    border: 0;
    border-bottom: 1px solid #64748b;
    background: transparent;
    color: #1e293b;
}

.article-exercise-check-blanks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    margin-top: .75rem;
}

.article-exercise-check-blanks button {
    padding: .3rem .7rem;
    border: 1px solid #bfdbfe;
    border-radius: .35rem;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: pointer;
}

@media print {
    .article-exercise-check-blanks {
        display: none;
    }
}

@media print {
    .article-exercise-tools {
        display: none !important;
    }
}

.article-exercise-tabs {
    display: flex;
    gap: .25rem;
    padding: .4rem .5rem 0;
    border-bottom: 1px solid #dbeafe;
    background: #eff6ff;
}

.article-exercise-tab {
    padding: .5rem 1rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #64748b;
    cursor: pointer;
}

.article-exercise-tab[aria-selected="true"] {
    border-bottom-color: #2563eb;
    color: #1d4ed8;
    font-weight: 700;
}

.article-exercise-tab:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

.article-exercise-panel {
    min-height: 5rem;
    padding: .8rem 1rem;
    overflow-wrap: anywhere;
    text-align: justify;
    cursor: text;
}

:is(.article-content, #richEditor) .article-exercise-panel p {
    margin: 0;
}

.article-exercise-panel[hidden] {
    display: none;
}

#richEditor .article-exercise-panel:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

#richEditor .article-exercise-panel:focus {
    outline: 2px solid #bfdbfe;
    outline-offset: -2px;
}

#richEditor .article-exercise-question-text {
    display: inline-block;
    box-sizing: border-box;
    min-width: 12ch;
    max-width: 100%;
    min-height: 2rem;
    padding: .15rem .45rem;
    border: 1px solid #bfdbfe;
    border-radius: .35rem;
    background: #fff;
    vertical-align: baseline;
    overflow-wrap: anywhere;
}

#richEditor .article-exercise-question-text:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}

#richEditor .article-exercise-question-text:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

#richEditor .article-exercise-question-text:focus:empty::before {
    content: none;
}

@media print {
    .article-exercise-panel[hidden] {
        display: block;
    }

    .article-exercise-panel + .article-exercise-panel {
        border-top: 1px solid #dbeafe;
    }
}

.article-katex {
    display: inline-block;
    direction: ltr;
    max-width: 100%;
    vertical-align: middle;
    overflow-x: auto;
    overflow-y: hidden;
    text-align: left;
    scrollbar-width: none;
}

.article-content .article-katex .katex {
    font-size: 1em;
}

.article-katex::-webkit-scrollbar {
    display: none;
}

.article-jsxgraph, .article-graph-canvas {
    width: 100%;
    max-width: 600px;
    height: 320px;
    margin: 1rem auto;
    direction: ltr;
    border: 1px solid #cbd5e1;
    border-radius: .75rem;
    background: #fff;
    overflow: hidden;
}

.article-jsxgraph-construction, .article-construction-preview {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 600px;
    min-width: 0;
    height: 320px;
    margin: 1rem auto;
    border: 1px solid #cbd5e1;
    border-radius: .75rem;
    overflow: hidden;
    background: white;
}

.article-jsxgraph-construction iframe, .article-construction-preview iframe {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    height: 100%;
    border: 0;
}

.article-construction-actions {
    position: absolute;
    z-index: 2;
    top: .5rem;
    right: .5rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.article-construction-edit, .article-construction-settings, .article-construction-delete {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: .5rem;
    color: white;
    cursor: pointer;
}

.article-construction-edit {
    background: #2563eb;
}

.article-construction-settings {
    background: #475569;
}

.article-construction-delete {
    background: #dc2626;
}

.article-construction-dialog select {
    width: 100%;
    padding: .5rem;
    border: 1px solid #cbd5e1;
    border-radius: .5rem;
}

.article-construction-option {
    display: inline-flex;
    flex: 0 0 auto !important;
    width: auto !important;
    align-items: center;
    gap: .4rem;
    margin: 0;
    white-space: nowrap;
    font-size: .85rem !important;
    line-height: 1.4;
}

.article-construction-option input {
    accent-color: #2563eb;
}

.article-construction-dialog textarea {
    min-height: 10rem;
    font-family: monospace;
    white-space: pre;
}

.article-katex-dialog.article-construction-dialog {
    box-sizing: border-box;
    width: min(78rem, calc(100% - 2rem));
    height: min(840px, calc(100vh - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
}

.article-construction-dialog form {
    min-width: 0;
}

.article-construction-dialog form > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.article-construction-size {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.article-construction-size label {
    flex: 1 1 10rem;
    font-size: .8rem;
}

.article-construction-size input {
    display: block;
    width: 100%;
    margin-top: .3rem;
    padding: .5rem;
    border: 1px solid #cbd5e1;
    border-radius: .5rem;
    direction: ltr;
}

.article-construction-size select {
    display: block;
    margin-top: .3rem;
}

.article-construction-dialog button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

#richEditor .article-jsxgraph {
    cursor: pointer;
}

.article-graph-dialog input[type="text"] {
    width: 100%;
    padding: .65rem;
    border: 1px solid #cbd5e1;
    border-radius: .5rem;
}

.article-graph-dialog p {
    font-size: .8rem;
    color: #64748b;
}

#articleGraphError {
    color: #b91c1c;
}

@media (max-width: 600px) {
    .article-jsxgraph, .article-graph-canvas, .article-jsxgraph-construction, .article-construction-preview {
        height: 250px;
    }
}

.article-katex[data-display="true"] {
    display: block;
    text-align: center;
    margin: .75rem 0;
}

#richEditor .article-exercise-panel li .article-katex[data-display="true"],
.article-content .article-exercise-panel li .article-katex[data-display="true"] {
    display: inline-block;
    margin: 0;
    text-align: left;
    vertical-align: middle;
}

#richEditor .article-katex {
    cursor: pointer;
}

.article-katex-dialog {
    width: min(32rem, calc(100% - 2rem));
    max-height: 90vh;
    margin: auto;
    padding: 1.25rem;
    border: 1px solid #d4d4d8;
    border-radius: 1rem;
    background: white;
}

.article-katex-dialog::backdrop {
    background: rgb(15 23 42 / .45);
}

.article-katex-dialog form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.article-katex-dialog h2 {
    font-weight: 700;
}

.article-katex-dialog textarea {
    width: 100%;
    min-height: 6rem;
    padding: .7rem;
    border: 1px solid #cbd5e1;
    border-radius: .5rem;
    resize: vertical;
    text-align: left;
}

.article-katex-mode {
    display: flex;
    align-items: center;
    gap: .5rem;
}

#articleKatexPreview {
    min-height: 3.5rem;
    overflow-x: auto;
    padding: .75rem;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    background: #f8fafc;
}

#articleKatexError {
    color: #b91c1c;
    font-size: .8rem;
}

.article-katex-actions {
    display: flex;
    gap: .5rem;
}

.article-katex-actions button {
    padding: .5rem 1rem;
    border-radius: .5rem;
    background: #2563eb;
    color: white;
}

.article-katex-actions button[type="button"] {
    background: #e4e4e7;
    color: #3f3f46;
}

/* JS-generated article overview */
.article-overview {
    font-size: .9rem;
    line-height: 1.8rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e4e4e7;
    border-radius: .75rem;
    background: #fafafa;
    overflow-wrap: anywhere;
}

.article-overview summary {
    padding: .7rem;
    color: #18181b;
    font-weight: 950;
    cursor: pointer;
    font-size: .8rem;
    line-height: 1.8rem;
}

.article-overview[open] summary {
    border-bottom: 1px solid #e4e4e7;
}

.article-overview nav {
    padding: .7rem;
}

.article-overview ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.article-overview a {
    display: block;
    padding: .125rem 0;
    color: #2563eb;
    font-size: .9rem;
    line-height: 1.8rem;
    font-weight: 600;
}

.article-overview summary:focus-visible,
.article-overview a:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
    border-radius: .25rem;
}

/* Article content opacity when loading */
.category-article-reader[aria-busy="true"] .category-article-main {
    opacity: .6;
}

/* Mobile sidebar */
@media (max-width: 1023px) {
    #categoryArticleReader {
        flex-direction: column;
        gap: 1.25rem;
        margin-top: 1rem;
        width: 100%;
        max-width: 100%;
    }

    .category-article-sidebar {
        flex: none;
        position: fixed;
        inset: 0 0 0 auto;
        z-index: 70;
        width: min(320px, 85vw);
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 1rem 0 0 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        overscroll-behavior: contain;
        visibility: hidden;
        transform: translateX(100%);
        transition: transform .25s ease, visibility .25s;
    }

    .article-sidebar-toggle {
        display: flex;
        align-items: center;
        gap: .5rem;
        position: fixed;
        right: 1rem;
        bottom: max(1.5rem, env(safe-area-inset-bottom));
        z-index: 40;
        padding: .875rem 1rem;
        border-radius: 999px;
        background: #2563eb;
        color: #fff;
        font-weight: 700;
        box-shadow: 0 4px 16px rgb(0 0 0 / .2);
        cursor: pointer;
    }

    .article-page-sidebar-toggle {
        display: flex;
        align-items: center;
        gap: .5rem;
        position: fixed;
        top: 5.5rem;
        right: 1rem;
        z-index: 40;
        padding: .65rem .9rem;
        border: 1px solid #bfdbfe;
        border-radius: .75rem;
        background: #eff6ff;
        color: #1d4ed8;
        font-size: .8rem;
        font-weight: 700;
        cursor: pointer;
    }

    .article-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 60;
        background: rgb(0 0 0 / .4);
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility .25s;
    }

    .article-sidebar-open .category-article-sidebar {
        visibility: visible;
        transform: translateX(0);
    }

    .article-sidebar-open .article-sidebar-backdrop {
        visibility: visible;
        opacity: 1;
    }

    body.article-sidebar-open {
        overflow: hidden;
    }

    .category-article-main {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    #printableArticle {
        min-width: 0;
        max-width: 100%;
    }

    #printableArticle h1 {
        overflow-wrap: anywhere;
    }

    .article-meta, .article-meta-details {
        flex-wrap: wrap;
    }

    .article-meta-details {
        min-width: 0;
    }

    .article-meta-details p {
        overflow-wrap: anywhere;
    }

    .article-actions {
        flex-shrink: 0;
        margin-right: auto;
    }

    .article-content {
        max-width: 100%;
        overflow-x: auto;
    }

    .article-content :is(iframe, video, canvas, svg) {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .category-article-sidebar,
    .article-sidebar-backdrop {
        transition: none;
    }
}

@media (max-width: 1023px) {
    .article-page-sidebar-toggle {
        display: none;
    }
}

/* Inline mathematical structures in both the editor and published articles. */
.article-math {
    display: inline-flex;
    direction: ltr;
    align-items: center;
    vertical-align: middle;
    gap: .15em;
    margin-inline: .12em;
    text-align: center;
    white-space: nowrap;
    unicode-bidi: isolate;
    line-height: 1 !important;
}

.article-math-power > .article-math-slot,
.article-math-subscript > .article-math-slot,
.article-math-power sup .article-math-slot,
.article-math-subscript sub .article-math-slot {
    line-height: 1 !important;
}

.article-content .article-math-power sup .article-math-slot,
.article-content .article-math-subscript sub .article-math-slot {
    font-size: inherit !important;
}

.article-math-fraction {
    flex-direction: column;
    gap: 0;
}

.article-math-fraction > span {
    display: block;
    padding: .02em .25em;
    line-height: 1.1 !important;
}

.article-math-fraction > span :not(.article-math) {
    line-height: 1.1 !important;
}

#richEditor .article-math-fraction > .article-math-slot {
    min-height: 1em;
}

.article-math-numerator {
    border-bottom: 1px solid currentColor;
}

.article-math-vector-bar, .article-math-vector-arrow {
    position: relative;
    padding-top: .3em;
}

.article-math-vector-bar::before, .article-math-vector-arrow::before {
    content: "";
    position: absolute;
    top: .1em;
    left: 0;
    right: 0;
    border-top: 1px solid currentColor;
}

.article-math-vector-arrow::after {
    content: "";
    position: absolute;
    top: .1em;
    right: 0;
    width: .32em;
    height: .32em;
    border-top: 1px solid currentColor;
    border-right: 1px solid currentColor;
    transform: translateY(-50%) rotate(45deg);
}

.article-math-vector-content {
    line-height: 1.2 !important;
}

.article-math-root {
    position: relative;
    gap: 0;
    padding: .12em 0 0 .55em;
    align-items: stretch;
}

.article-math-root-index {
    position: absolute;
    right: calc(100% - .62em);
    top: .15em;
    font-size: .6em;
    line-height: 1 !important;
    white-space: nowrap;
}

.article-math-radical {
    display: inline-flex;
    align-items: flex-end;
    font-size: 1.35em;
    line-height: 1 !important;
    margin-right: -.08em;
}

.article-math-radicand {
    border-top: 1px solid currentColor;
    padding: .12em .2em .04em;
    line-height: 1.25 !important;
}

.article-math-power sup {
    align-self: flex-start;
    font-size: .7em !important;
    line-height: 1 !important;
}

.article-math-operator {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1 !important;
}

.article-math-operator > span {
    line-height: 1 !important;
}

.article-math-upper, .article-math-lower {
    font-size: .65em;
    min-height: .7em;
}

.article-math-sign {
    font-size: 1.5em;
}

.article-math-differential {
    margin-left: .25em;
}

.article-math-cells {
    display: inline-grid;
    grid-template-columns: repeat(2, auto);
    gap: .1em .7em;
}

.article-math-cells > span {
    line-height: 1.4 !important;
}

.article-math-bracket {
    font-size: 2.5em;
    line-height: 1 !important;
    font-weight: 200;
}

#richEditor .article-math-slot {
    display: inline-block;
    min-width: 1em;
    min-height: 1.1em;
    outline: 1px dotted #94a3b8;
    cursor: text;
}

#richEditor .article-math-slot:empty::before {
    content: "\25a1";
    color: #94a3b8;
}

#richEditor .article-math-slot:focus {
    outline: 2px solid #60a5fa;
}

.article-math-subscript sub {
    align-self: flex-end;
    font-size: .7em !important;
    line-height: 1 !important;
}

#richEditor .article-math-root-index {
    min-width: .7em;
    min-height: .8em;
}

.article-math-matrix > .article-math-bracket {
    align-self: stretch;
    width: .3rem;
    font-size: 0;
    line-height: normal !important;
    border-block: 1px solid currentColor;
}

.article-math-matrix > .article-math-bracket:first-child {
    border-left: 1px solid currentColor;
}

.article-math-matrix > .article-math-bracket:last-child {
    border-right: 1px solid currentColor;
}

.article-math-chem-right, .article-math-chem-left, .article-math-chem-both {
    gap: .08em;
}

.article-math-chemical-scripts {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: .68em;
    line-height: 1 !important;
}

.article-math-chemical-scripts > span {
    line-height: 1 !important;
}

.article-math-logarithm {
    gap: .08em;
}

.article-math-log-base {
    align-self: flex-end;
    font-size: .68em;
    line-height: 1 !important;
    margin-right: .12em;
}

#richEditor .article-math-chemical-scripts > .article-math-slot, #richEditor .article-math-log-base > .article-math-slot {
    min-width: .8em;
    min-height: 1em;
}

.article-math-reaction-arrow {
    display: inline-flex;
    flex-direction: column;
    gap: .15em;
    align-items: stretch;
}

.article-math-arrow-label {
    font-size: .7em;
    line-height: 1.15 !important;
    text-align: center;
}

.article-math-reaction-arrow .article-math-arrow-sign {
    position: relative;
    display: block;
    align-self: stretch;
    min-width: 2.2rem;
    height: .65rem;
    font-size: 0;
    line-height: 0 !important;
    background: linear-gradient(currentColor, currentColor) center / calc(100% - .3rem) 1px no-repeat;
}

.article-math-reaction-arrow .article-math-arrow-sign::before, .article-math-reaction-arrow .article-math-arrow-sign::after {
    content: "";
    display: none;
    position: absolute;
    top: 50%;
    width: .42rem;
    height: .42rem;
}

.article-math-reaction-arrow:is([data-math-template^="chem-arrow-0-"], [data-math-template^="chem-arrow-2-"], [data-math-template^="chem-arrow-4-"], [data-math-template^="chem-arrow-5-"]) .article-math-arrow-sign::before {
    display: block;
    left: .08rem;
    border-left: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: translateY(-50%) rotate(45deg);
}

.article-math-reaction-arrow:is([data-math-template^="chem-arrow-1-"], [data-math-template^="chem-arrow-3-"], [data-math-template^="chem-arrow-4-"], [data-math-template^="chem-arrow-5-"]) .article-math-arrow-sign::after {
    display: block;
    right: .08rem;
    border-right: 1px solid currentColor;
    border-top: 1px solid currentColor;
    transform: translateY(-50%) rotate(45deg);
}

.article-math-reaction-arrow:is([data-math-template^="chem-arrow-2-"], [data-math-template^="chem-arrow-3-"], [data-math-template^="chem-arrow-5-"]) .article-math-arrow-sign {
    background: linear-gradient(currentColor, currentColor) center calc(50% - 1px) / calc(100% - .3rem) 1px no-repeat, linear-gradient(currentColor, currentColor) center calc(50% + 1px) / calc(100% - .3rem) 1px no-repeat;
}

#richEditor .article-math-arrow-label {
    min-width: 1em;
    min-height: 1em;
}
