/* News UI refinement. Loaded last; does not replace the existing dark theme. */
.site-heading {
    min-width: 0;
    margin: 0;
    font-size: 1.4em;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.3;
    color: #e9e9e9;
    overflow-wrap: anywhere;
}
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
    border: 0;
}
.document-article-title {
    color: #f0f3fa;
    font-size: clamp(1.5rem, 3.2vw, 2.15rem);
    line-height: 1.25;
    margin: 0 0 1rem;
    overflow-wrap: break-word;
}
#ssr-back-link { margin-top: 2rem; }
/* Grid columns can now shrink below 300px rather than being clipped on small screens. */
#articles-grid-view .articles-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    min-width: 0;
}
#articles-grid-view .article-card,
#articles-grid-view .article-card-content { min-width: 0; }
#articles-grid-view .article-card-title { overflow-wrap: anywhere; }
/* Buttons stay keyboard accessible and match their old icon styling. */
body.dark-theme .modal .close-button,
.modal .close-button {
    border: 0;
    background: transparent;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}
.modal .close-button:focus-visible,
#editor-toolbar button:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 3px;
}
.modal .modal-content {
    width: min(550px, calc(100% - 24px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    margin: min(8vh, 40px) auto;
}
.modal .news-table-modal-content { max-width: 400px; }
.modal .modal-button-secondary { background: #6c757d; }
.modal .modal-button-secondary:hover { background: #5c636a; }
/* Sticky position needs ancestors without overflow:hidden scroll containers.
   Use clip only while editing; this preserves horizontal clipping elsewhere. */
html:has(body.editor-mode),
body.editor-mode,
body.editor-mode main,
body.editor-mode #docs-section,
body.editor-mode #content-area {
    overflow-x: clip !important;
}
/* Error pages also need a main heading after removing the header H1. */
.ssr-error h1 {
    color: var(--accent-red, #ef4444);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Keep the toolbar in the editor flow on desktop: no hidden actions behind a fixed scroll strip. */
@media (min-width: 760px) {
    body.editor-mode #editor-view { padding-top: 0.75rem !important; }
    body.editor-mode #editor-toolbar {
        position: sticky !important;
        top: 8px !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        transform: none !important;
        flex-wrap: wrap !important;
        overflow: visible !important;
        max-height: none !important;
    }
}
@media (max-width: 759px) {
    .site-heading { font-size: 1.3em; }
    body.editor-mode #editor-toolbar {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        scroll-padding-inline: 12px;
        scrollbar-width: thin;
    }
    body.editor-mode .editor-toolbar-hint {
        font-size: 0.82rem;
        line-height: 1.35;
        color: #cbd5e1;
        text-align: right;
        margin: 0.15rem 0 0.55rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    #articles-grid-view .article-card { transition: none; }
    #editor-toolbar button { transition: none; }
}
