/* Shared reading chrome for blog, forum, and community articles */

.np-reader-chrome {
    position: sticky;
    top: 5rem;
    z-index: 40;
    margin-bottom: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.np-reading-toolbar {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #e8edf3;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(10px);
    width: fit-content;
    max-width: 100%;
}

.np-reading-toolbar .tnews-tool-btn {
    min-width: 2.35rem;
    height: 2.35rem;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.np-reading-toolbar .tnews-tool-btn.active-tool,
.np-reading-toolbar .tnews-tool-btn[aria-pressed="true"] {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.np-reading-toolbar__divider {
    width: 1px;
    height: 1.5rem;
    background: #e2e8f0;
    margin: 0 0.15rem;
    flex-shrink: 0;
}

/* In-article search — collapsed by default */
.np-reading-search {
    display: none;
    width: 100%;
    max-width: 36rem;
}

.np-reading-search[hidden] {
    display: none !important;
}

.np-reading-search.is-open {
    display: block;
    animation: npReadingSearchIn 0.22s ease-out;
}

@keyframes npReadingSearchIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.np-reading-search__panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem 0.45rem 0.65rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow:
        0 4px 6px -1px rgba(15, 23, 42, 0.05),
        0 12px 28px -8px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(12px);
}

.np-reading-search__field {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    cursor: text;
}

.np-reading-search__icon {
    color: #94a3b8;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.np-reading-search__field:focus-within .np-reading-search__icon {
    color: #6366f1;
}

.np-reading-search input,
.np-reading-search input[type="search"],
.np-reading-search input:hover,
.np-reading-search input:focus,
.np-reading-search input:active {
    display: block;
    height: auto !important;
    min-height: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    color: #0f172a !important;
    font-size: 0.92rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    padding: 0.2rem 0 !important;
    -webkit-appearance: none;
    appearance: none;
}

.np-reading-search input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.np-reading-search__count {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    white-space: nowrap;
}

.np-reading-search__count[hidden] {
    display: none !important;
}

.np-reading-search__hint {
    display: none;
    flex-shrink: 0;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.15rem 0.35rem;
    line-height: 1.2;
}

.np-reading-search__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.np-reading-search__close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.np-reading-search mark.np-in-article-hit {
    background: #fde68a;
    color: inherit;
    padding: 0 0.12em;
    border-radius: 3px;
    box-decoration-break: clone;
}

html.dark-theme .np-reading-search__panel {
    background: rgba(24, 24, 27, 0.96);
    border-color: #3f3f46;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.25),
        0 12px 28px -8px rgba(0, 0, 0, 0.45);
}

html.dark-theme .np-reading-search input,
html.dark-theme .np-reading-search input[type="search"],
html.dark-theme .np-reading-search input:focus {
    color: #f4f4f5 !important;
    background: transparent !important;
}

html.dark-theme .np-reading-search input::placeholder {
    color: #71717a;
}

html.dark-theme .np-reading-search__icon {
    color: #71717a;
}

html.dark-theme .np-reading-search__field:focus-within .np-reading-search__icon {
    color: #a5b4fc;
}

html.dark-theme .np-reading-search__count {
    background: #27272a;
    color: #a1a1aa;
}

html.dark-theme .np-reading-search__hint {
    background: #27272a;
    border-color: #3f3f46;
    color: #71717a;
}

html.dark-theme .np-reading-search__close {
    color: #a1a1aa;
}

html.dark-theme .np-reading-search__close:hover {
    background: #27272a;
    color: #fafafa;
}

html.dark-theme .np-reading-search mark.np-in-article-hit {
    background: #854d0e;
    color: #fef3c7;
}

html.dark-theme .np-reading-toolbar__divider {
    background: #3f3f46;
}

@media (min-width: 576px) {
    .np-reading-search__hint {
        display: inline-block;
    }
}

@media (prefers-reduced-motion: reduce) {
    .np-reading-search.is-open {
        animation: none;
    }
}

@media (max-width: 575.98px) {
    .np-reading-search {
        max-width: 100%;
    }

    .np-reading-search__panel {
        border-radius: 12px;
        padding: 0.4rem 0.45rem 0.4rem 0.55rem;
    }
}

.np-resume-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    color: #312e81;
}

.np-resume-bar[hidden] { display: none !important; }

.np-resume-bar__text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.np-resume-bar__text strong { font-size: 0.88rem; }
.np-resume-bar__text span {
    font-size: 0.8rem;
    color: #4338ca;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 42ch;
}

.np-resume-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.np-resume-bar__go {
    border: 0;
    background: #6366f1;
    color: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.np-resume-bar__dismiss {
    border: 0;
    background: transparent;
    color: #4338ca;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
}

[data-reading-body] {
    width: 100%;
    max-width: none;
    --reading-font-size: 1.125rem;
    --reading-line-height: 1.8;
    font-size: var(--reading-font-size) !important;
    line-height: var(--reading-line-height) !important;
    font-kerning: normal;
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
    quotes: "«" "»" "‹" "›";
    -webkit-hyphens: auto;
    hyphens: auto;
    word-break: break-word;
}

[data-reading-body] :where(p, li, blockquote, td, th, div, span, a, em, strong, u, s, mark, small, figcaption, dt, dd, pre, code) {
    font-size: inherit !important;
    line-height: inherit !important;
}

[data-reading-body] :where(h2, h3, h4, h5, h6) {
    line-height: 1.35 !important;
}

[data-reading-body] h2 { font-size: 1.45em !important; }
[data-reading-body] h3 { font-size: 1.22em !important; }
[data-reading-body] h4 { font-size: 1.08em !important; }

#forum-tw .forum-civis-post__content[data-reading-body],
.community-article__body[data-reading-body] {
    font-size: var(--reading-font-size) !important;
    line-height: var(--reading-line-height) !important;
}

html[data-reading-size="small"] [data-reading-body] {
    --reading-font-size: 1rem;
    --reading-line-height: 1.7;
}

html[data-reading-size="medium"] [data-reading-body] {
    --reading-font-size: 1.125rem;
    --reading-line-height: 1.8;
}

html[data-reading-size="large"] [data-reading-body] {
    --reading-font-size: 1.28rem;
    --reading-line-height: 1.85;
}

html[data-reading-size="xlarge"] [data-reading-body] {
    --reading-font-size: 1.42rem;
    --reading-line-height: 1.9;
}

[data-reading-body].tnews-font-size-small {
    --reading-font-size: 1rem;
    --reading-line-height: 1.7;
}
[data-reading-body].tnews-font-size-medium {
    --reading-font-size: 1.125rem;
    --reading-line-height: 1.8;
}
[data-reading-body].tnews-font-size-large {
    --reading-font-size: 1.28rem;
    --reading-line-height: 1.85;
}
[data-reading-body].tnews-font-size-xlarge {
    --reading-font-size: 1.42rem;
    --reading-line-height: 1.9;
}

html.np-reading-serif [data-reading-body],
html.np-reading-serif [data-reading-body] p,
html.np-reading-serif [data-reading-body] li,
html.np-reading-serif [data-reading-body] blockquote {
    font-family: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif !important;
}

html.tnews-focus-mode-active [data-reading-chrome],
html.tnews-focus-mode-active .th-header,
html.tnews-focus-mode-active .th-footer,
html.tnews-focus-mode-active .breadcumb-wrapper {
    display: none !important;
}

html.tnews-focus-mode-active .np-reader-chrome { top: 0.6rem; }

html.tnews-focus-mode-active #forum-tw main.lg\:col-span-8,
html.tnews-focus-mode-active #forum-tw .grid > main {
    grid-column: 1 / -1;
}

html.tnews-focus-mode-active .community-layout .col-md-8 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

html.tnews-focus-mode-active .video-show-page .vp-main {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

/* Shared comfort modes for non-blog reading surfaces */
html[data-reading-line="compact"] [data-reading-body] {
    --reading-line-height: 1.6;
}

html[data-reading-line="normal"] [data-reading-body] {
    --reading-line-height: 1.8;
}

html[data-reading-line="relaxed"] [data-reading-body] {
    --reading-line-height: 2;
}

html[data-reading-width="narrow"] [data-reading-body] {
    max-width: 38rem;
    margin-inline: auto;
}

html[data-reading-width="normal"] [data-reading-body] {
    max-width: 46rem;
    margin-inline: auto;
}

html[data-reading-width="wide"] [data-reading-body] {
    max-width: none;
}

/* Video article details stay full main-column width (toolbar/channel aligned). */
.video-show-page [data-reading-body],
html[data-reading-width="narrow"] .video-show-page [data-reading-body],
html[data-reading-width="normal"] .video-show-page [data-reading-body],
html[data-reading-width="wide"] .video-show-page [data-reading-body] {
    max-width: none !important;
    width: 100% !important;
    margin-inline: 0 !important;
}

html.np-reading-sepia [data-reading-body],
html.np-reading-sepia .np-reader-chrome .np-reading-toolbar {
    background-color: #f4ecd8;
    color: #5b4636;
}

html.np-reading-sepia [data-reading-body] a {
    color: #8a4b08;
}

html.dark-theme.np-reading-sepia [data-reading-body],
html.dark-theme.np-reading-sepia .np-reader-chrome .np-reading-toolbar {
    background-color: #2a2418;
    color: #e8dcc4;
}

html.np-reading-dyslexia [data-reading-body],
html.np-reading-dyslexia [data-reading-body] p,
html.np-reading-dyslexia [data-reading-body] li {
    font-family: "Atkinson Hyperlegible", "Comic Sans MS", Verdana, sans-serif !important;
    letter-spacing: 0.03em;
    word-spacing: 0.08em;
}

html.np-text-only-mode .video-show-page .vp-player-wrap,
html.np-text-only-mode [data-reading-body] img,
html.np-text-only-mode [data-reading-body] video,
html.np-text-only-mode [data-reading-body] iframe,
html.np-text-only-mode [data-reading-body] figure {
    display: none !important;
}

html.dark-theme .np-reading-toolbar {
    background: rgba(24, 24, 27, 0.92);
    border-color: #3f3f46;
    color: #e4e4e7;
}

html.dark-theme .np-reading-toolbar .tnews-tool-btn { color: #e4e4e7; }

html.dark-theme .np-resume-bar {
    background: #1e1b4b;
    border-color: #4338ca;
    color: #e0e7ff;
}

@media (max-width: 575.98px) {
    .np-reading-toolbar { border-radius: 14px; }
    .np-resume-bar { flex-direction: column; align-items: flex-start; }

    .np-reader-chrome {
        position: static;
        top: auto;
        margin-bottom: 0.85rem;
    }

    .np-reading-toolbar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        max-width: 100%;
        border-radius: 14px;
        padding: 0.4rem;
        gap: 0.25rem;
    }

    .np-reading-toolbar::-webkit-scrollbar { display: none; }

    .np-reading-toolbar .tnews-tool-btn {
        flex: 0 0 auto;
        min-width: 2.75rem;
        min-height: 2.75rem;
        height: 2.75rem;
    }

    .np-reading-toolbar__divider {
        flex: 0 0 auto;
        align-self: center;
        height: 1.5rem;
    }
}

/* ---------------------------------------------------------------
   Community margin notes (reader-visible public annotations).
   Intentionally visually distinct from private highlights/notes.
   Anchors are superscript, use no text content (offset-safe), and
   render a hover footnote using a fixed-position pop outside flow.
   --------------------------------------------------------------- */
sup.np-margin-note-anchor {
    position: relative;
    display: inline-block;
    top: -0.5em;
    vertical-align: baseline;
    margin-inline-start: 0.15rem;
    font-size: 0.7em;
    line-height: 1;
    font-weight: 700;
    color: #0f766e;
    background: rgba(20, 184, 166, 0.14);
    border: 1px solid rgba(20, 184, 166, 0.35);
    border-radius: 0.5rem;
    padding: 0.05rem 0.35rem;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
sup.np-margin-note-anchor::before { content: "?"; }
sup.np-margin-note-anchor::after { content: ""; }
sup.np-margin-note-anchor:hover,
sup.np-margin-note-anchor:focus-visible {
    background: rgba(20, 184, 166, 0.28);
    border-color: #14b8a6;
    outline: none;
}
html.dark-theme sup.np-margin-note-anchor { color: #6ee7b7; }

.np-selection-actions__btn.np-selection-actions__btn--margin {
    color: #0f766e;
}
.np-selection-actions__btn.np-selection-actions__btn--margin:hover {
    color: #0d9488;
}

/* Floating footnote popover (owned by the margin-note script). */
span.np-margin-note-pop {
    position: fixed;
    z-index: 1080;
    display: none;
    max-width: 320px;
    min-width: 220px;
    padding: 0.55rem 0.7rem 0.6rem;
    border-radius: 12px;
    background: #fefce8;
    color: #44403c;
    border: 1px solid rgba(20, 184, 166, 0.4);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    font-size: 0.9rem;
    line-height: 1.45;
}
.np-margin-note-pop__close {
    position: absolute;
    top: 0.25rem;
    right: 0.35rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    line-height: 1;
    color: #a8a29e;
    cursor: pointer;
    padding: 0.1rem 0.2rem;
}
.np-margin-note-pop__close:hover { color: #57534e; }
.np-margin-note-pop__quote {
    font-style: italic;
    font-size: 0.8rem;
    color: #0f766e;
    margin-bottom: 0.4rem;
    padding-right: 0.9rem;
}
.np-margin-note-pop__body { word-break: break-word; }
.np-margin-note-pop__meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed rgba(20, 184, 166, 0.35);
    font-size: 0.72rem;
    color: #78716c;
}
.np-margin-note-pop__author { font-weight: 700; color: #0f766e; }
html.dark-theme .np-margin-note-pop {
    background: #134e4a;
    color: #ccfbf1;
    border-color: #2dd4bf;
}
html.dark-theme .np-margin-note-pop__quote { color: #99f6e4; }
html.dark-theme .np-margin-note-pop__meta { color: #a7f3d0; }

@media (max-width: 575.98px) {
    span.np-margin-note-pop {
        max-width: calc(100vw - 24px);
        left: 12px !important;
        right: 12px;
    }
}

/* ---------------------------------------------------------------------------
 * Reader "Correction / Inaccuracy Suggest" floating affordance
 * Self-contained pill; voluntarily distinct from the private highlight/share
 * toolbar so its flow never couples to that markup.
 * ------------------------------------------------------------------------- */
button.np-correction-suggest {
    position: fixed;
    z-index: 9400;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    color: #0f3e3a;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(15, 62, 58, 0.18);
    cursor: pointer;
    white-space: nowrap;
    max-width: min(92vw, 320px);
    overflow: hidden;
    text-overflow: ellipsis;
}
button.np-correction-suggest:hover,
button.np-correction-suggest:focus-visible {
    background: #ccfbf1;
    border-color: #14b8a6;
    outline: none;
}
html.dark-theme button.np-correction-suggest {
    color: #eafff8;
    background: #134e4a;
    border-color: #0d9488;
}
html.dark-theme button.np-correction-suggest:hover {
    background: #0d9488;
}

/* Swal dialog niceties reused only from this feature's prompt. */
.np-corr-swal-label {
    text-align: left;
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 2px;
    color: #555;
}
.swal2-popup .swal2-title.np-corr-swal-title { font-size: 1.05rem; }
#npCorrSuggested.swal2-textarea {
    min-height: 92px;
    margin-top: 4px;
    white-space: pre-wrap;
}

/* ---------------------------------------------------------------------------
 * Admin corrections queue accents
 * ------------------------------------------------------------------------- */
.swal2-html-container .np-corr-swal-old {
    text-align: left;
    font-style: italic;
    color: #b91c1c;
    background: #fff7f7;
    border-left: 3px solid #fca5a5;
    padding: 6px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    word-break: break-word;
}



/* ---- Sandboxed in-article Code Run (dormant until opted in) ------ */
.np-code-run-bar {
    --cr-border: rgba(100,116,139,.24);
    --cr-bg: #fbfbfc;
    --cr-ink: #1f2937;
    margin: 0.4rem 0 0.7rem;
    border: 1px solid var(--cr-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--cr-bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.np-code-run-toggle {
    display: block;
    width: 100%;
    text-align: left;
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0.4rem 0.7rem;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    color: #475569;
    cursor: pointer;
    position: relative;
}
.np-code-run-toggle::after {
    content: "";
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-top-color: currentColor;
    transition: transform .15s ease;
}
.np-code-run-bar[data-open="true"] .np-code-run-toggle::after { transform: translateY(-50%) rotate(-180deg); }
.np-code-run-controls {
    display: none;
    padding: 0.15rem 0.6rem 0.35rem;
}
.np-code-run-toggle[aria-expanded="true"] + .np-code-run-controls { display: block; }
.np-code-run-go {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 6px;
    padding: 0.26rem 0.7rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: #2563eb;
    cursor: pointer;
}
.np-code-run-go:hover { border-color: #2563eb; background: #eff6ff; }
.np-code-run-outputwrap { padding: 0 0.6rem 0.5rem; }
.np-code-run-iframe {
    width: 100%;
    height: 220px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    margin: 0;
}
.np-code-run-error { font-size: 0.78rem; color: #b91c1c; }
