body.document-open {
    overflow: hidden;
}

.document-reader {
    width: min(1000px, calc(100% - 2rem));
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh;
    margin: auto;
    padding: 0;
    border: 1px solid var(--border-hard);
    border-radius: 22px;
    background: #10192f;
    color: var(--text-primary);
    box-shadow: 0 24px 100px rgba(0, 0, 0, 0.6);
}

.document-reader[open] {
    display: flex;
    flex-direction: column;
}

.document-reader::backdrop {
    background: rgba(2, 6, 20, 0.78);
}

.document-reader-header,
.document-reader-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

.document-reader-header h1 {
    margin: 0;
    font-size: 1.6rem;
    text-align: left;
}

.document-close,
.document-tabs button {
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
}

.document-close {
    flex-shrink: 0;
}

.document-tabs,
.document-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.document-tabs {
    padding: 0 1.5rem 0.75rem;
    flex-shrink: 0;
}

.document-tabs button[aria-pressed="true"] {
    background: rgba(139, 92, 246, 0.2);
    border-color: #b3a0ff;
}

.document-notice,
.document-synced {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.document-reader .document-notice,
.document-reader .document-synced {
    padding: 0 1.5rem 0.5rem;
}

.document-notice[data-state="error"],
.document-notice[data-state="stale"] {
    color: #fdca94;
}

.document-reader .document-body {
    min-height: 6rem;
    padding: 0.5rem 1.5rem 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.document-reader-footer {
    border-top: 1px solid var(--border-soft);
    font-size: 0.9rem;
}

.document-reader-footer a,
.document-links a,
.document-reload {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.document-body {
    min-width: 0;
    overflow-wrap: anywhere;
    line-height: 1.85;
}

.document-body h2,
.document-body h3,
.document-body h4,
.document-body h5,
.document-body h6 {
    margin: 1.75rem 0 0.75rem;
    line-height: 1.5;
}

.document-body h2 {
    font-size: 1.35rem;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.6rem;
}

.document-body h3 {
    font-size: 1.15rem;
}

.document-body ul,
.document-body ol {
    padding-left: 1.5rem;
}

.document-body li + li {
    margin-top: 0.65rem;
}

.document-body p {
    margin: 0.75rem 0;
}

.document-body code {
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
    background: rgba(148, 163, 255, 0.13);
    color: #cbdfff;
}

.document-body pre {
    padding: 1rem;
    white-space: pre-wrap;
    background: rgba(3, 6, 20, 0.5);
    border-radius: 10px;
}

.document-body pre code {
    padding: 0;
    background: transparent;
}

.document-body blockquote {
    margin: 1rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--accent-strong);
    color: var(--text-muted);
}

.document-table {
    max-width: 100%;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}

.document-table-hint {
    display: none;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.document-table table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.document-table th,
.document-table td {
    padding: 0.75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-soft);
}

.document-table th {
    background: rgba(139, 92, 246, 0.15);
}

.document-table td:first-child {
    width: 25%;
}

.document-table td:nth-child(2) {
    width: 24%;
    color: #bfe5ff;
}

.document-page {
    gap: 1.5rem;
}

.document-page-header h1 {
    margin: 1rem 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.document-links a[aria-current="page"] {
    color: var(--text-primary);
    font-weight: 700;
}

@media (max-width: 600px) {
    .document-table-hint {
        display: block;
    }

    .document-reader {
        width: calc(100% - 1rem);
        max-height: 94vh;
        max-height: 94dvh;
        border-radius: 16px;
    }

    .document-reader-header,
    .document-reader-footer {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .document-tabs,
    .document-reader .document-notice,
    .document-reader .document-synced,
    .document-reader .document-body {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .document-reader-header h1 {
        font-size: 1.35rem;
    }
}
