.agreement-document {
    scroll-behavior: smooth;
}

.agreement-page {
    width: 100%;
}

.agreement-eyebrow {
    margin: 0 0 6px;
    color: #b5bdc7;
    font-size: 14px;
    font-weight: 500;
}

.agreement-heading-note {
    margin: 7px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.agreement-heading-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agreement-editor-button,
.agreement-toolbar button,
.agreement-editor-views button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 11px;
    border: 1px solid #696971;
    border-radius: 5px;
    background: #232325;
    color: #e8e9eb;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.agreement-editor-button:hover,
.agreement-toolbar button:hover:enabled,
.agreement-editor-views button[aria-pressed="true"] {
    background: #3a4149;
    border-color: #8b9baa;
    color: #fff;
}

.agreement-page :is(a, button):focus-visible,
.agreement-editor :is(a, button, textarea):focus-visible {
    outline: 2px solid #a0afc1;
    outline-offset: 2px;
}

.agreement-layout {
    display: grid;
    grid-template-columns: minmax(220px, 278px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.agreement-sidebar {
    padding: 8px;
    background: rgb(4 4 4 / 25%);
    box-shadow: none;
}

.agreement-toc-group {
    padding: 5px 3px 7px;
}

.agreement-toc-group + .agreement-toc-group {
    border-top: 1px solid rgb(136 138 141 / 20%);
}

.agreement-toc-points {
    display: grid;
    gap: 2px;
    margin: 2px 3px 1px 8px;
    border-inline-start: 1px solid rgb(136 138 141 / 25%);
}

.agreement-toc-points:empty { display: none; }

.agreement-toc :is(.agreement-toc-heading, .agreement-toc-point) {
    border: 1px solid transparent;
    border-radius: 4px;
    color: #dde0e4;
    line-height: 1.4;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.agreement-toc-heading {
    display: block;
    padding: 6px 8px;
    font-size: 15px;
    font-weight: 500;
}

.agreement-toc .agreement-toc-point {
    display: grid;
    align-items: baseline;
    min-width: 0;
    padding: 4px 7px;
    color: #c3cad3;
    font-size: 14px;
}

.agreement-toc-point:has(.agreement-toc-number + span) {
    grid-template-columns: 3em minmax(0, 1fr);
    gap: 4px;
}

.agreement-toc .agreement-toc-point--nested { margin-inline-start: 7px; }

.agreement-toc-number {
    color: #b6bec8;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.agreement-toc a:hover {
    background: rgb(71 72 75 / 25%);
    color: #ecf0f1;
}

.agreement-toc a[aria-current="location"] {
    background: rgb(136 138 141 / 25%);
    color: #ecf0f1;
}

.agreement-toc a[aria-current="location"] .agreement-toc-number { color: inherit; }

.agreement-toc:focus-visible {
    outline: 2px solid #8cabe7;
    outline-offset: 2px;
}

.agreement-content,
.agreement-preview {
    color: #e3e5e8;
    font-size: 16px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.agreement-content {
    padding: clamp(16px, 2.7vw, 34px);
}
.agreement-section { scroll-margin-top: var(--sidebar-top); }

.agreement-section + .agreement-level-2 {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgb(105 105 113 / 65%);
}

.agreement-section:is(.agreement-level-3, .agreement-level-4) {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 4px;
}

.agreement-level-4 {
    margin-inline-start: 10px;
    border-inline-start: 1px solid rgb(136 138 141 / 35%);
}

.agreement-section:is(.agreement-level-3, .agreement-level-4):target {
    background: rgb(136 138 141 / 16%);
}

.agreement-section :is(h2, h3, h4),
.agreement-preview > h2 {
    margin: 0 0 10px;
    color: #fff;
    line-height: 1.35;
}

.agreement-section h2, .agreement-preview > h2 { font-size: 19px; }
.agreement-section h3 { font-size: 16px; }
.agreement-section h4 { font-size: 16px; }
.agreement-section:target > :is(h2, h3, h4) { color: #c3d3e7; }

:is(.agreement-content, .agreement-preview) p { margin: 0 0 10px; }
:is(.agreement-content, .agreement-preview) ul {
    margin: 0 0 10px;
    padding-left: 22px;
    list-style: disc;
}
:is(.agreement-content, .agreement-preview) li { margin: 4px 0; }
:is(.agreement-content, .agreement-preview) a { color: #bdd1ed; }
:is(.agreement-content, .agreement-preview) code {
    padding: 1px 4px;
    border-radius: 4px;
    background: rgb(140 171 231 / 16%);
    color: #d7e4f7;
    font: inherit;
}
.agreement-section > :last-child { margin-bottom: 0; }

.agreement-editor {
    position: fixed;
    inset: 0;
    width: min(1160px, calc(100% - 40px));
    height: min(780px, calc(100dvh - 40px));
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #696971;
    border-radius: 8px;
    background: #2e2e30;
    color: #e8e9eb;
    box-shadow: 0 20px 60px rgb(0 0 0 / 55%);
    font: inherit;
}

.agreement-editor::backdrop { background: rgb(0 0 0 / 68%); }
.agreement-document:has(.agreement-editor[open]) { overflow: hidden; }
.agreement-editor [hidden] { display: none; }

.agreement-editor-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 0;
}

.agreement-editor-heading,
.agreement-editor-tools,
.agreement-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid rgb(105 105 113 / 65%);
}

.agreement-editor-heading h2 { margin: 0; color: #fff; font-size: 20px; }
.agreement-editor-close { min-width: 36px; padding: 4px; font-size: 23px; line-height: 1; }
.agreement-editor-tools { background: #272729; }
.agreement-toolbar, .agreement-editor-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.agreement-editor-views { display: none; gap: 6px; }
.agreement-editor :is(button, textarea):disabled { opacity: 0.55; cursor: default; }

.agreement-editor-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    flex: 1;
    min-height: 0;
}

.agreement-source-pane,
.agreement-preview-pane {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    min-width: 0;
    padding: 14px 18px;
}

.agreement-preview-pane { border-left: 1px solid rgb(105 105 113 / 65%); }
.agreement-source-pane label, .agreement-editor-label { margin: 0; font-size: 15px; font-weight: 600; }

.agreement-source-pane textarea,
.agreement-preview {
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 14px;
    overflow: auto;
    border: 1px solid #696971;
    border-radius: 5px;
    background: #232325;
}

.agreement-source-pane textarea {
    resize: none;
    color: #e8e9eb;
    font: 13px/1.6 ui-monospace, Consolas, monospace;
    tab-size: 4;
}

#agreement-markdown-help { margin: 0; color: #bfc6ce; font-size: 14px; }
.agreement-editor-footer { border-bottom: 0; border-top: 1px solid rgb(105 105 113 / 65%); }
.agreement-editor-feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#agreement-editor-status { margin: 0; color: #d2d7dd; font-size: 15px; }
#agreement-editor-status.is-error { color: #ffabab; }
.agreement-editor-actions { margin-left: auto; flex: none; }
.agreement-save { min-height: 34px; margin: 0; }

@media (max-width: 800px) {
    .main.agreement-page { padding: 18px 14px; }
    .agreement-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .agreement-sidebar { margin-bottom: 0; }
    .agreement-toc {
        max-height: min(45dvh, 320px);
        padding-inline-end: 5px;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: #77797c transparent;
    }
    .agreement-toc .agreement-toc-point { min-height: 26px; }
    .agreement-content { padding: 16px; }
    .agreement-editor { width: calc(100% - 16px); height: calc(100dvh - 16px); }
    .agreement-editor-tools { flex-wrap: wrap; }
    .agreement-editor-views { display: flex; }
    .agreement-editor-body { grid-template-columns: minmax(0, 1fr); }
    .agreement-editor-body[data-view="source"] .agreement-preview-pane,
    .agreement-editor-body[data-view="preview"] .agreement-source-pane,
    .agreement-editor[data-view="preview"] .agreement-toolbar { display: none; }
    .agreement-preview-pane { border-left: 0; }
}

@media (max-width: 480px) {
    .agreement-editor-heading, .agreement-editor-tools, .agreement-editor-footer,
    .agreement-source-pane, .agreement-preview-pane { padding-inline: 10px; }
    .agreement-editor-footer { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    .agreement-document { scroll-behavior: auto; }
}
