/* Novel Exporter — aligns with studio / profile purples */

.ne-body {
    box-sizing: border-box;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 50% -10%, var(--ne-body-spot, rgba(109, 40, 217, 0.22)) 0%, transparent 42%),
        linear-gradient(180deg, #0d1426 0%, #0b1220 55%);
    color: #f9fafb;
    overflow-x: hidden;
}

.ne-body *,
.ne-body *::before,
.ne-body *::after {
    box-sizing: border-box;
}

.ne-header {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
    align-self: center;
    padding: 14px clamp(14px, 2vw, 24px) 12px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    /* Opaque strip so scroll never shows “through” the sticky header (avoids the toolbar looking detached). */
    background: linear-gradient(180deg, rgba(13, 20, 38, 0.98) 0%, rgba(11, 18, 32, 0.96) 55%, rgba(11, 18, 32, 0.92) 100%);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
}

.ne-user-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(8px, 2vw, 16px);
    margin-bottom: 12px;
    padding-bottom: 12px;
}

.ne-user-row::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(245, 212, 137, 0.4) 24%,
        rgba(196, 181, 253, 0.55) 50%,
        rgba(245, 212, 137, 0.4) 76%,
        transparent 100%
    );
    pointer-events: none;
}

.ne-user-left {
    justify-self: start;
    min-width: 0;
}

.ne-user-right {
    justify-self: end;
    min-width: 0;
}

.ne-title-cluster {
    justify-self: center;
    text-align: center;
    max-width: min(340px, 52vw);
}

.ne-page-title {
    margin: 0;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3.2vw, 1.7rem);
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: #faf5ff;
    text-shadow:
        0 2px 16px rgba(109, 40, 217, 0.4),
        0 1px 0 rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.ne-page-subtitle {
    margin: 6px 0 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.02em;
    color: rgba(233, 213, 255, 0.82);
}

@media (max-width: 380px) {
    .ne-page-title {
        white-space: normal;
        max-width: 34vw;
        font-size: 1.05rem;
        letter-spacing: 0.02em;
    }

    .ne-title-cluster {
        max-width: 38vw;
    }

    .ne-page-subtitle {
        font-size: 10px;
    }
}

.ne-logo-link {
    display: block;
    flex-shrink: 0;
    line-height: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(80, 20, 140, 0.28);
    transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.ne-logo-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(80, 20, 140, 0.36);
}

.ne-logo-link:focus-visible {
    outline: 2px solid #f5d489;
    outline-offset: 3px;
}

.ne-logo {
    display: block;
    width: auto;
    height: 52px;
    max-width: min(200px, 44vw);
    object-fit: contain;
    object-position: left center;
}

.ne-username {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #c4b5fd;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.ne-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(
        135deg,
        var(--ne-header-1) 0%,
        var(--ne-header-2) 38%,
        var(--ne-header-3) 72%,
        var(--ne-header-4) 100%
    );
    box-shadow:
        0 4px 22px rgba(91, 33, 182, 0.45),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.ne-toolbar-kicker {
    justify-self: center;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 247, 237, 0.38);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    pointer-events: none;
    user-select: none;
}

@media (max-width: 400px) {
    .ne-toolbar-kicker {
        font-size: 9px;
        letter-spacing: 0.1em;
    }
}

.ne-bar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: #fff7ed;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}

.ne-bar-btn:hover {
    background: rgba(0, 0, 0, 0.32);
    border-color: rgba(255, 255, 255, 0.22);
}

.ne-bar-btn:active {
    transform: scale(0.98);
}

.ne-bar-btn:focus-visible {
    outline: 2px solid #f5d489;
    outline-offset: 2px;
}

.ne-bar-btn-export {
    border-color: rgba(245, 212, 137, 0.45);
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--purple-bright) 45%, transparent),
        color-mix(in srgb, var(--theme-header-end) 32%, transparent)
    );
}

.ne-bar-btn-export:hover {
    border-color: rgba(245, 212, 137, 0.6);
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--purple-bright) 58%, transparent),
        color-mix(in srgb, var(--theme-header-end) 42%, transparent)
    );
}

.ne-bar-btn-export:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* Off-screen render target for raster PDF export (matches on-screen trim in inches). */
.ne-pdf-export-host {
    position: fixed;
    left: -32000px;
    top: 0;
    pointer-events: none;
    z-index: 999999;
    width: max-content;
    height: max-content;
    overflow: visible;
}

.ne-pdf-export-host .ne-preview-page {
    margin: 0 !important;
    float: none !important;
    box-sizing: border-box !important;
}

.ne-pdf-export-host .ne-preview-page[data-format="5x8"] {
    width: 5in !important;
    height: 8in !important;
    min-width: 5in !important;
    max-width: none !important;
    aspect-ratio: unset !important;
}

.ne-pdf-export-host .ne-preview-page[data-format="6x9"] {
    width: 6in !important;
    height: 9in !important;
    min-width: 6in !important;
    max-width: none !important;
    aspect-ratio: unset !important;
}

.ne-pdf-export-host .ne-preview-page[data-format="letter"] {
    width: 8.5in !important;
    height: 11in !important;
    min-width: 8.5in !important;
    max-width: none !important;
    aspect-ratio: unset !important;
}

.ne-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 22px clamp(14px, 2vw, 24px) 44px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    /* Do not vertically center the workspace: it breaks `position: sticky` on the header and makes the toolbar
       appear to “float” mid-screen while scrolling long side panels. */
    justify-content: flex-start;
    min-height: 0;
}

.ne-workspace {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(320px, 1fr) minmax(250px, 320px);
    align-items: start;
    gap: clamp(16px, 2vw, 28px);
}

.ne-side-panel {
    position: sticky;
    top: 118px;
    z-index: 2;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 138px);
    overflow: auto;
    padding: 22px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(165deg, rgba(17, 24, 39, 0.96) 0%, rgba(15, 23, 42, 0.9) 100%);
    box-shadow:
        0 18px 44px rgba(0, 0, 0, 0.38),
        0 0 0 1px rgba(109, 40, 217, 0.12) inset;
}

.ne-meta-panel.ne-side-panel {
    left: auto;
}

.ne-layout-panel.ne-side-panel {
    right: auto;
    left: auto;
}

.ne-layout-hint {
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
    color: rgba(148, 163, 184, 0.95);
}

.ne-page-format-group .ne-page-format-heading {
    margin-bottom: 10px;
}

.ne-format-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.ne-format-option:last-of-type {
    margin-bottom: 0;
}

.ne-format-option:hover {
    border-color: rgba(196, 181, 253, 0.28);
    background: rgba(0, 0, 0, 0.3);
}

.ne-format-option:focus-within {
    border-color: rgba(167, 139, 250, 0.45);
}

.ne-format-option input {
    margin-top: 3px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: #9333ea;
}

.ne-format-option:has(input:checked) {
    border-color: rgba(167, 139, 250, 0.5);
    background: rgba(109, 40, 217, 0.12);
}

.ne-format-option-body {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.ne-format-option-title {
    font-size: 13px;
    font-weight: 800;
    color: #f1f5f9;
}

.ne-format-option-desc {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    color: rgba(148, 163, 184, 0.95);
}

.ne-typo-hint {
    margin: 0 0 16px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
    color: rgba(148, 163, 184, 0.95);
}

.ne-field-select {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 12px 36px 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background-color: rgba(0, 0, 0, 0.28);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23cbd5e1' d='M3 4.5L6 8l3-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    color: #f9fafb;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    outline: none;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}

.ne-field-select-display {
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
}

.ne-field-select:hover {
    border-color: rgba(196, 181, 253, 0.35);
    background-color: rgba(0, 0, 0, 0.34);
}

.ne-field-select:focus-visible {
    border-color: rgba(167, 139, 250, 0.55);
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.28);
}

.ne-input-with-suffix {
    display: flex;
    align-items: stretch;
    margin-top: 8px;
    width: 100%;
    max-width: 100%;
}

.ne-input-with-suffix .ne-field-input {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0;
    border-radius: 12px 0 0 12px;
}

.ne-input-suffix {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: none;
    border-radius: 0 12px 12px 0;
    background: rgba(0, 0, 0, 0.35);
    color: #94a3b8;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
}

.ne-input-with-suffix:focus-within .ne-input-suffix {
    border-color: rgba(167, 139, 250, 0.55);
}

.ne-input-with-suffix .ne-field-input:focus,
.ne-input-with-suffix .ne-field-input:focus-visible {
    outline: none;
    border-color: rgba(167, 139, 250, 0.55);
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.28);
}

.ne-field + .ne-field {
    margin-top: 20px;
}

.ne-field-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #c4b5fd;
}

.ne-field-input {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.28);
    color: #f9fafb;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.35;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ne-field-input::placeholder {
    color: rgba(148, 163, 184, 0.85);
    font-weight: 500;
}

.ne-field-input-title {
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.ne-field-input:hover {
    border-color: rgba(196, 181, 253, 0.35);
    background: rgba(0, 0, 0, 0.34);
}

.ne-field-input:focus {
    border-color: rgba(167, 139, 250, 0.55);
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.28);
}

.ne-field-input:focus-visible {
    outline: none;
}

.ne-fold-details + .ne-fold-details {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ne-fold-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 4px 14px 2px;
    list-style: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    user-select: none;
}

.ne-fold-summary::-webkit-details-marker {
    display: none;
}

.ne-fold-summary::marker {
    content: "";
}

.ne-fold-summary-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #c4b5fd;
}

.ne-fold-summary-chev {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    margin-top: -2px;
    border-right: 2px solid rgba(196, 181, 253, 0.82);
    border-bottom: 2px solid rgba(196, 181, 253, 0.82);
    transform: rotate(45deg);
    transition: transform 0.18s ease, margin 0.18s ease;
}

.ne-fold-details[open] .ne-fold-summary-chev {
    transform: rotate(-135deg);
    margin-top: 3px;
}

.ne-fold-summary:focus-visible {
    outline: 2px solid #f5d489;
    outline-offset: 4px;
    border-radius: 8px;
}

.ne-fold-body {
    padding: 0 2px 12px;
}

.ne-copyright-hint {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
    color: rgba(148, 163, 184, 0.95);
}

.ne-copyright-scroll {
    margin-top: 0;
    padding-right: 4px;
    max-height: min(46vh, 440px);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: rgba(139, 92, 246, 0.45) rgba(0, 0, 0, 0.18);
}

.ne-copy-p {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.52;
    color: rgba(226, 232, 240, 0.92);
}

.ne-copy-p:last-child {
    margin-bottom: 0;
}

.ne-field.ne-field--copyright-optional {
    margin-top: 16px;
    margin-bottom: 0;
}

.ne-field.ne-field--copyright-optional .ne-copy-textarea.ne-field-input {
    margin-top: 10px;
}

.ne-copy-check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    color: rgba(226, 232, 240, 0.95);
}

.ne-copy-check-row input {
    width: 17px;
    height: 17px;
    margin: 1px 0 0;
    flex-shrink: 0;
    accent-color: #9333ea;
    cursor: pointer;
}

.ne-copy-check-text {
    flex: 1 1 auto;
    min-width: 0;
}

.ne-copy-textarea.ne-field-input:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.ne-copy-inline.ne-field-input {
    display: inline-block;
    width: auto;
    max-width: 100%;
    margin-top: 0;
    margin-bottom: 2px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 600;
    vertical-align: baseline;
}

.ne-copy-inline--year {
    width: 5.25rem;
    min-width: 4.75rem;
}

.ne-copy-inline--name {
    min-width: 7rem;
    width: min(11rem, 42vw);
}

.ne-copy-inline--wide {
    min-width: 8rem;
    width: min(15rem, 58vw);
}

.ne-copy-inline--isbn {
    min-width: 8rem;
    width: min(14rem, 55vw);
}

.ne-copy-inline--country {
    min-width: 5.5rem;
    width: min(11rem, 40vw);
}

.ne-copy-line.ne-field-input {
    display: block;
    width: 100%;
    margin-top: 8px;
    margin-bottom: 0;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
}

.ne-copy-textarea.ne-field-input {
    display: block;
    margin-top: 8px;
    min-height: 4.25rem;
    resize: vertical;
    font-family: inherit;
    line-height: 1.45;
    font-size: 12px;
}

.ne-preview-track {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: 0;
}

.ne-preview-stage {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

.ne-preview-page {
    position: relative;
    /* Chapter title sizing uses cqw so type scales with the trim box, not the browser viewport. */
    container-type: inline-size;
    container-name: ne-preview-trim;
    margin: 0 auto;
    box-sizing: border-box;
    background: linear-gradient(180deg, #fdfefe 0%, #f1f5f9 100%);
    border-radius: 3px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.75) inset,
        0 24px 48px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    text-align: left;
    color: #1e293b;
}

.ne-preview-placeholder {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    max-width: none;
    color: #64748b;
    pointer-events: none;
}

.ne-preview-placeholder[hidden] {
    display: none;
}

.ne-preview-scroll {
    position: absolute;
    z-index: 3;
    box-sizing: border-box;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-color: rgba(100, 116, 139, 0.55) transparent;
    padding: 0;
}

.ne-preview-scroll[hidden] {
    display: none;
}

.ne-preview-scroll:not([hidden]) {
    top: calc(100% * var(--guide-mt, 0) / var(--guide-pgh));
    bottom: calc(100% * var(--guide-mb, 0) / var(--guide-pgh));
    left: calc(100% * var(--guide-mi, 0) / var(--guide-pgw));
    right: calc(100% * var(--guide-mo, 0) / var(--guide-pgw));
}

.ne-preview-page--verso .ne-preview-scroll:not([hidden]) {
    left: calc(100% * var(--guide-mo, 0) / var(--guide-pgw));
    right: calc(100% * var(--guide-mi, 0) / var(--guide-pgw));
}

.ne-preview-manuscript {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 11pt;
    line-height: 1.48;
}

.ne-preview-page-frame {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/*
 * Small bottom gutter inside the live (clip) box: enough for descenders + subpixel rounding under
 * overflow:hidden. A full line + fixed px was overly conservative and left a visible band above the folio.
 */
.ne-preview-scroll > .ne-preview-page-frame {
    box-sizing: border-box;
    padding-bottom: max(0.42em, 12px);
}

/*
 * Pagination measure tree only: drop min-height:100% flex stretch there so scrollHeight matches real content flow.
 */
[data-ne-measure="1"] .ne-preview-scroll > .ne-preview-page-frame {
    min-height: 0 !important;
}

/* Avoid flex-shrink shortening the measured column vs what pagination assumed. */
.ne-preview-page-frame.ne-preview-manuscript > .ne-ms-ch--book {
    flex-shrink: 0;
}

.ne-preview-scroll > .ne-preview-page-frame.ne-preview-manuscript {
    position: relative;
}

.ne-ms-page-print {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 0 0.35rem 3px;
    font-family: var(--ne-print-pg-font, Georgia, "Times New Roman", Times, serif);
    font-size: 9pt;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.04em;
    text-align: center;
    color: rgba(15, 23, 42, 0.42);
    pointer-events: none;
    user-select: none;
}

.ne-preview-page-title {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    padding: 16% 6% 8%;
}

.ne-preview-title-author {
    margin: 0 0 1.15rem;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 11pt;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.82);
}

.ne-preview-title-rule {
    width: min(68%, 15rem);
    height: 1px;
    background: rgba(15, 23, 42, 0.35);
    margin: 0 0 1.15rem;
}

.ne-preview-title-work {
    margin: 0;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 22pt;
    line-height: 1.05;
    letter-spacing: 0.03em;
    color: #0f172a;
}

.ne-preview-page-copyright {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.8rem 0.95rem;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 9.25pt;
    line-height: 1.38;
    color: rgba(15, 23, 42, 0.88);
}

.ne-preview-page-copyright p {
    margin: 0 0 0.65em;
}

.ne-preview-page-extra {
    padding: 1rem 0.95rem;
    font-size: 10.75pt;
    line-height: 1.48;
    color: rgba(15, 23, 42, 0.92);
}

.ne-extra-h2 {
    margin: 0 0 0.75rem;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 15pt;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    color: #0f172a;
}

.ne-extra-body .ne-ms-para {
    margin: 0 0 0.65em;
    text-align: left;
    text-indent: 0;
}

.ne-preview-page-toc {
    padding: 1.1rem 1.05rem;
    font-family: Georgia, "Times New Roman", Times, serif;
}

.ne-preview-toc-title {
    margin: 0 0 0.85rem;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 16pt;
    letter-spacing: 0.04em;
    color: #0f172a;
    text-align: center;
}

.ne-preview-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 10.75pt;
    line-height: 1.45;
}

.ne-preview-toc-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.15rem 0;
}

.ne-preview-toc-dots {
    border-bottom: 1px dotted rgba(15, 23, 42, 0.35);
    transform: translateY(-0.15em);
}

.ne-preview-pager {
    width: 100%;
    max-width: min(560px, 100%);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.18);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.ne-preview-pager-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: #fff7ed;
    font-weight: 800;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
}

.ne-preview-pager-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ne-preview-pager-status {
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.86);
    user-select: none;
}

.ne-ms-ch + .ne-ms-ch {
    margin-top: 0.85rem;
}

.ne-preview-page[data-chapter-new-page="true"] .ne-ms-ch + .ne-ms-ch {
    margin-top: 2.25rem;
    padding-top: 1.85rem;
    border-top: 1px solid rgba(15, 23, 42, 0.1);
}

/* Book-style chapter opening (trade paperback / literary) */
.ne-ms-ch--book .ne-chapter-head {
    text-align: center;
    padding: 0.28in 0.12in 0;
    margin: 0 0 0.14in;
}

.ne-ms-ch--book .ne-chapter-num {
    margin: 0 0 0.42rem;
    padding: 0;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 9pt;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.48);
}

.ne-ms-ch--book .ne-chapter-num-inner {
    display: inline-block;
    padding-bottom: 0.06rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.18);
}

.ne-ms-ch--book .ne-ms-ch-title {
    margin: 0;
    padding: 0 0.12rem;
    font-weight: 700;
    font-size: clamp(15pt, 3.8vw, 18pt);
    line-height: 1.14;
    letter-spacing: 0.035em;
    color: #0f172a;
    text-wrap: balance;
    font-kerning: normal;
    font-feature-settings: "kern" 1, "liga" 1;
}

@supports (font-size: 1cqw) {
    .ne-ms-ch--book .ne-ms-ch-title {
        font-size: clamp(15pt, 5cqw, 18pt);
    }
}

.ne-ms-ch--book .ne-ms-ch-title-text {
    display: inline-block;
    max-width: 100%;
}

.ne-ms-ch--book .ne-chapter-rule {
    width: min(3.25rem, 42%);
    height: 2px;
    margin: 0.55rem auto 0;
    border-radius: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(15, 23, 42, 0.22) 18%,
        rgba(15, 23, 42, 0.55) 50%,
        rgba(15, 23, 42, 0.22) 82%,
        transparent 100%
    );
}

.ne-ms-ch--book .ne-ms-ch-body {
    margin-top: 0.2rem;
}

.ne-ms-ch-title {
    margin: 0 0 0.55rem;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 13pt;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #0f172a;
}

.ne-ms-ch-body {
    font-size: inherit;
    line-height: inherit;
}

.ne-ms-ch-body p {
    margin: 0 0 0.65em;
    text-indent: 0.25in;
}

.ne-ms-ch-body p:first-child {
    text-indent: 0;
}

/* Chapter body only: trade spacing — no extra gap between paragraphs (indent carries the rhythm). */
.ne-ms-ch--book .ne-ms-ch-body > p {
    margin: 0;
    text-indent: 0.25in;
}

.ne-ms-ch--book .ne-ms-ch-body > p:first-child {
    text-indent: 0;
}

/* Continuation of a paragraph split across preview pages — read as one block, not a new indented ¶ */
.ne-ms-ch--book .ne-ms-ch-body > p.ne-ms-para--split-cont {
    text-indent: 0;
}

.ne-preview-page[data-chapter-drop-cap="true"] .ne-ms-ch-body > p:first-child:not(.ne-ms-para--split-cont)::first-letter {
    float: left;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 2.85em;
    line-height: 0.82;
    font-weight: 700;
    padding-right: 0.06em;
    margin-top: 0.04em;
    color: #0f172a;
}

.ne-ms-ch-body ul,
.ne-ms-ch-body ol {
    margin: 0.4em 0 0.65em;
    padding-left: 1.25em;
}

.ne-ms-ch-body blockquote {
    margin: 0.5em 0 0.65em;
    padding-left: 0.75em;
    border-left: 2px solid rgba(100, 116, 139, 0.35);
    color: #334155;
}

.ne-workspace.ne-print-guides-on .ne-preview-track,
.ne-workspace.ne-print-guides-on .ne-preview-stage {
    overflow: visible;
}

.ne-workspace.ne-print-guides-on .ne-preview-page {
    overflow: visible;
}

.ne-preview-print-guides {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.ne-workspace.ne-print-guides-on .ne-preview-print-guides {
    display: block;
}

.ne-guide-bleeds {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.ne-print-guides-no-bleed .ne-guide-bleeds {
    display: none;
}

.ne-guide-bleed-top,
.ne-guide-bleed-bot,
.ne-guide-bleed-out {
    position: absolute;
    box-sizing: border-box;
    background: rgba(236, 72, 153, 0.26);
    border: 1px solid rgba(236, 72, 153, 0.5);
}

.ne-guide-bleed-top {
    left: 0;
    top: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgh));
    width: calc(100% + 100% * var(--guide-bleed, 0) / var(--guide-pgw));
    height: calc(100% * var(--guide-bleed, 0) / var(--guide-pgh));
}

.ne-guide-bleed-bot {
    left: 0;
    bottom: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgh));
    width: calc(100% + 100% * var(--guide-bleed, 0) / var(--guide-pgw));
    height: calc(100% * var(--guide-bleed, 0) / var(--guide-pgh));
}

.ne-guide-bleed-out {
    top: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgh));
    bottom: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgh));
    right: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgw));
    width: calc(100% * var(--guide-bleed, 0) / var(--guide-pgw));
}

.ne-guide-trim {
    position: absolute;
    inset: 0;
    z-index: 1;
    outline: 2px dashed rgba(147, 51, 234, 0.95);
    outline-offset: -1px;
    border-radius: 1px;
}

.ne-guide-live {
    position: absolute;
    z-index: 2;
    box-sizing: border-box;
    top: calc(100% * var(--guide-mt, 0) / var(--guide-pgh));
    bottom: calc(100% * var(--guide-mb, 0) / var(--guide-pgh));
    left: calc(100% * var(--guide-mi, 0) / var(--guide-pgw));
    right: calc(100% * var(--guide-mo, 0) / var(--guide-pgw));
    border: 2px dashed rgba(59, 130, 246, 0.92);
    border-radius: 1px;
}

/* Verso (left-hand): mirror inner vs outer horizontally; bleed on spine-adjacent top/bottom shifts to the opposite fore edge. */
.ne-preview-page--verso .ne-guide-bleed-top,
.ne-preview-page--verso .ne-guide-bleed-bot {
    left: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgw));
    right: auto;
    width: calc(100% + 100% * var(--guide-bleed, 0) / var(--guide-pgw));
}

.ne-preview-page--verso .ne-guide-bleed-out {
    right: auto;
    left: calc(-100% * var(--guide-bleed, 0) / var(--guide-pgw));
    width: calc(100% * var(--guide-bleed, 0) / var(--guide-pgw));
}

.ne-preview-page--verso .ne-guide-live {
    left: calc(100% * var(--guide-mo, 0) / var(--guide-pgw));
    right: calc(100% * var(--guide-mi, 0) / var(--guide-pgw));
}

.ne-hand-group {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ne-hand-heading {
    margin-bottom: 6px;
}

.ne-hand-hint {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
    color: rgba(148, 163, 184, 0.95);
}

.ne-hand-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 11px;
    margin-bottom: 8px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.ne-hand-option:last-of-type {
    margin-bottom: 0;
}

.ne-hand-option:hover {
    border-color: rgba(196, 181, 253, 0.25);
    background: rgba(0, 0, 0, 0.28);
}

.ne-hand-option:focus-within {
    border-color: rgba(167, 139, 250, 0.4);
}

.ne-hand-option input {
    margin-top: 3px;
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    accent-color: #9333ea;
}

.ne-hand-option:has(input:checked) {
    border-color: rgba(167, 139, 250, 0.45);
    background: rgba(109, 40, 217, 0.1);
}

.ne-hand-option-body {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.ne-hand-option-title {
    font-size: 13px;
    font-weight: 800;
    color: #f1f5f9;
}

.ne-hand-option-desc {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    color: rgba(148, 163, 184, 0.95);
}

.ne-guide-toggle-row {
    margin-top: 16px;
}

.ne-chapter-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ne-chapter-stack .ne-guide-toggle-row {
    margin-top: 0;
}

.ne-toggle-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.22);
    color: #e2e8f0;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.ne-toggle-switch:hover {
    border-color: rgba(196, 181, 253, 0.3);
    background: rgba(0, 0, 0, 0.28);
}

.ne-toggle-switch[aria-pressed="true"] {
    border-color: rgba(167, 139, 250, 0.45);
}

.ne-toggle-switch:focus-visible {
    outline: 2px solid #f5d489;
    outline-offset: 3px;
}

.ne-toggle-copy {
    text-align: left;
    line-height: 1.35;
}

.ne-toggle-rail {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    transition: background 0.18s ease;
}

.ne-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #f8fafc;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease;
}

.ne-toggle-switch[aria-pressed="true"] .ne-toggle-rail {
    background: linear-gradient(135deg, var(--theme-header-mid) 0%, var(--theme-header-end) 100%);
}

.ne-toggle-switch[aria-pressed="true"] .ne-toggle-thumb {
    transform: translateX(16px);
}

/* Preview capped at literal trim inches (CSS in); scales down only when viewport is smaller. PDF export uses the same dimensions via data-page-*-in. */
.ne-preview-page[data-format="5x8"] {
    aspect-ratio: 5 / 8;
    width: min(5in, 100%, calc(75vh * 5 / 8));
}

.ne-preview-page[data-format="6x9"] {
    aspect-ratio: 6 / 9;
    width: min(6in, 100%, calc(75vh * 6 / 9));
}

.ne-preview-page[data-format="letter"] {
    aspect-ratio: 8.5 / 11;
    width: min(8.5in, 100%, calc(75vh * 8.5 / 11));
}

@media (max-width: 1240px) {
    .ne-workspace {
        grid-template-columns: minmax(220px, 280px) minmax(300px, 1fr) minmax(220px, 280px);
        gap: 16px;
    }

    .ne-side-panel {
        padding: 18px 16px;
    }

    .ne-field-label,
    .ne-fold-summary-title {
        letter-spacing: 0.09em;
    }

    .ne-preview-page[data-format="5x8"] {
        width: min(5in, calc(100% - 12px), calc(72vh * 5 / 8));
    }

    .ne-preview-page[data-format="6x9"] {
        width: min(6in, calc(100% - 12px), calc(72vh * 6 / 9));
    }

    .ne-preview-page[data-format="letter"] {
        width: min(8.5in, calc(100% - 12px), calc(72vh * 8.5 / 11));
    }
}

@media (max-width: 1040px) {
    .ne-header {
        position: sticky;
    }

    .ne-workspace {
        display: flex;
        flex-direction: column;
        gap: 18px;
    }

    .ne-preview-track {
        order: -1;
    }

    .ne-side-panel,
    .ne-meta-panel.ne-side-panel,
    .ne-layout-panel.ne-side-panel {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        width: 100%;
        max-width: none;
        max-height: none;
        margin: 0;
    }

    .ne-preview-stage {
        width: 100%;
    }

    .ne-preview-page[data-format="5x8"] {
        width: min(5in, calc(100vw - 36px), calc(75vh * 5 / 8));
    }

    .ne-preview-page[data-format="6x9"] {
        width: min(6in, calc(100vw - 36px), calc(75vh * 6 / 9));
    }

    .ne-preview-page[data-format="letter"] {
        width: min(8.5in, calc(100vw - 36px), calc(75vh * 8.5 / 11));
    }
}

@media (max-width: 720px) {
    .ne-header {
        padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
    }

    .ne-user-row {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "logo title"
            "user user";
        align-items: center;
        gap: 8px 12px;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .ne-user-left {
        grid-area: logo;
    }

    .ne-title-cluster {
        grid-area: title;
        justify-self: end;
        max-width: none;
        text-align: right;
    }

    .ne-user-right {
        grid-area: user;
        justify-self: stretch;
    }

    .ne-logo {
        height: 40px;
        max-width: 132px;
    }

    .ne-page-title {
        white-space: normal;
        font-size: clamp(1.05rem, 5.5vw, 1.45rem);
    }

    .ne-page-subtitle {
        font-size: 11px;
    }

    .ne-username {
        display: block;
        width: fit-content;
        max-width: 100%;
        margin-left: auto;
        padding: 5px 10px;
        border-radius: 999px;
        background: rgba(0, 0, 0, 0.22);
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ne-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
        border-radius: 14px;
    }

    .ne-toolbar-kicker {
        display: none;
    }

    .ne-bar-btn {
        flex: 1 1 0;
        min-height: 46px;
        padding: 0 12px;
    }

    .ne-main {
        padding: 14px max(12px, env(safe-area-inset-right, 0px)) 32px max(12px, env(safe-area-inset-left, 0px));
    }

    .ne-workspace {
        gap: 14px;
    }

    .ne-side-panel {
        padding: 16px;
        border-radius: 18px;
    }

    .ne-fold-summary {
        min-height: 48px;
        padding: 12px 2px;
    }

    .ne-field + .ne-field,
    .ne-fold-details + .ne-fold-details {
        margin-top: 14px;
    }

    .ne-fold-details + .ne-fold-details {
        padding-top: 14px;
    }

    .ne-field-input,
    .ne-field-select {
        min-height: 46px;
        font-size: 16px;
    }

    .ne-format-option,
    .ne-hand-option,
    .ne-toggle-switch {
        padding: 12px;
    }

    .ne-copy-p,
    .ne-copyright-hint,
    .ne-layout-hint,
    .ne-hand-hint,
    .ne-format-option-desc,
    .ne-hand-option-desc {
        font-size: 12px;
    }

    .ne-preview-page[data-format="5x8"] {
        width: min(5in, calc(100vw - 28px), calc(64vh * 5 / 8));
    }

    .ne-preview-page[data-format="6x9"] {
        width: min(6in, calc(100vw - 28px), calc(64vh * 6 / 9));
    }

    .ne-preview-page[data-format="letter"] {
        width: min(8.5in, calc(100vw - 28px), calc(64vh * 8.5 / 11));
    }

    .ne-preview-pager {
        gap: 8px;
        padding: 8px;
    }

    .ne-preview-pager-btn {
        min-height: 44px;
        padding: 9px 12px;
    }
}

@media (max-width: 430px) {
    .ne-user-row {
        grid-template-columns: 1fr;
        grid-template-areas:
            "logo"
            "title"
            "user";
    }

    .ne-user-left,
    .ne-title-cluster,
    .ne-user-right {
        justify-self: center;
    }

    .ne-title-cluster {
        text-align: center;
    }

    .ne-page-subtitle {
        display: none;
    }

    .ne-toolbar {
        gap: 8px;
    }

    .ne-bar-btn {
        flex-basis: 100%;
    }

    .ne-side-panel {
        padding: 14px;
    }

    .ne-preview-pager {
        display: flex;
        flex-wrap: wrap;
    }

    .ne-preview-pager-status {
        flex: 1 0 100%;
        order: -1;
        padding: 4px 0;
    }

    .ne-preview-pager-btn {
        flex: 1 1 0;
    }

    .ne-copy-inline.ne-field-input {
        display: block;
        width: 100%;
        min-width: 0;
        margin: 6px 0;
        padding: 9px 10px;
        font-size: 16px;
    }
}

