:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --canvas: #f5f3ed;
    --surface: #fffefa;
    --surface-subtle: #efede6;
    --ink: #20211e;
    --ink-soft: #605d56;
    --ink-faint: #817d74;
    --line: #d8d4c9;
    --line-strong: #bdb7ab;
    --forest: #26352d;
    --forest-hover: #18271f;
    --rust: #7a4732;
    --rust-soft: #f1e5de;
    --danger: #8d2e27;
    --success: #315c45;
    --shadow-sm: 0 1px 2px rgb(35 32 26 / 5%), 0 0.35rem 1rem rgb(35 32 26 / 4%);
    --shadow-md: 0 1rem 3rem rgb(35 32 26 / 8%);
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 20rem;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 80% -10%, rgb(122 71 50 / 5%), transparent 28rem),
        var(--canvas);
    line-height: 1.5;
}

a {
    color: inherit;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 0.07em;
}

:where(a.q-external-link, a[rel~="external"])::after {
    display: inline-block;
    margin-left: 0.22em;
    color: var(--rust);
    content: "↗";
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.72em;
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    vertical-align: 0.16em;
}

:where(a.q-external-link, a[rel~="external"]):hover::after {
    color: currentColor;
}

a,
button,
summary,
select,
input[type="button"],
input[type="file"]::file-selector-button,
input[type="reset"],
input[type="submit"] {
    cursor: pointer;
}

button,
input,
select,
textarea {
    font: inherit;
}

button:disabled,
input:disabled,
select:disabled {
    cursor: not-allowed;
}

::selection {
    color: #181b17;
    background: #dbc8a7;
}

:where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid rgb(122 71 50 / 28%);
    outline-offset: 3px;
}

.workspace-header {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 4.25rem;
    border-bottom: 1px solid rgb(216 212 201 / 88%);
    background: color-mix(in srgb, var(--canvas) 90%, transparent);
    backdrop-filter: blur(16px);
}

.workspace-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: min(92rem, 100%);
    min-height: 4.25rem;
    margin: 0 auto;
    padding: 0 2rem;
}

.workspace-header--anonymous .workspace-header__inner {
    grid-template-columns: 1fr;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    text-decoration: none;
}

.wordmark img {
    display: block;
    width: auto;
    height: 2rem;
}

.workspace-header__inner nav {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.25rem;
    border: 1px solid rgb(216 212 201 / 80%);
    border-radius: 999px;
    background: rgb(255 254 250 / 55%);
    font-size: 0.84rem;
    font-weight: 600;
}

.workspace-header__inner nav a {
    padding: 0.42rem 0.75rem;
    border-radius: 999px;
    text-decoration: none;
    transition: color 140ms ease, background 140ms ease;
}

.workspace-header__inner nav a:hover {
    color: var(--rust);
    background: var(--surface);
}

.identity {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    justify-self: end;
    color: var(--ink-soft);
    font-size: 0.82rem;
}

.identity a {
    padding-left: 0.7rem;
    border-left: 1px solid var(--line);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.identity a:hover {
    color: var(--rust);
}

.workspace-main {
    min-height: calc(100vh - 4.25rem);
}

.welcome {
    max-width: 54rem;
    margin: 0 auto;
    padding: 14vh 2rem 4rem;
}

.welcome h1 {
    max-width: 12ch;
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(3rem, 7vw, 6.5rem);
    font-weight: 500;
    letter-spacing: -0.055em;
    line-height: 0.92;
}

.welcome > p:not(.eyebrow) {
    max-width: 42rem;
    margin: 2rem 0;
    color: #56534c;
    font-family: Georgia, serif;
    font-size: 1.25rem;
    line-height: 1.65;
}

.eyebrow {
    margin: 0 0 1rem;
    color: #7a4732;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--forest);
    border-radius: 0.35rem;
    color: #fff;
    background: var(--forest);
    box-shadow: 0 1px 1px rgb(0 0 0 / 12%);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.primary-action:hover {
    border-color: var(--forest-hover);
    background: var(--forest-hover);
    box-shadow: 0 0.4rem 1rem rgb(38 53 45 / 16%);
    transform: translateY(-1px);
}

.primary-action:active {
    box-shadow: none;
    transform: translateY(0);
}

.secondary-action,
.text-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    color: #34332e;
    background: var(--surface);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    transition: border-color 140ms ease, color 140ms ease, background 140ms ease, transform 140ms ease;
}

.secondary-action:hover {
    border-color: #918a7c;
    color: var(--rust);
    background: #fff;
    transform: translateY(-1px);
}

.text-button {
    display: inline;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--rust);
    background: transparent;
    font-size: 0.82rem;
    line-height: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.danger-action {
    min-height: 2.35rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d7aaa5;
    border-radius: 0.35rem;
    color: var(--danger);
    background: #fff8f6;
    font-size: 0.82rem;
    font-weight: 650;
}

.danger-action:hover {
    border-color: #bc7770;
    background: #ffefec;
}

.button-row,
.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.notice {
    display: grid;
    gap: 0.25rem;
    margin: 0 0 1.5rem;
    padding: 0.9rem 1rem;
    border: 1px solid #d3bcae;
    border-left: 0.25rem solid var(--rust);
    border-radius: 0.35rem;
    background: #fff9f3;
    color: #4f453f;
}

.notice--success {
    border-color: #b7ccbd;
    border-left-color: var(--success);
    background: #f3faf4;
    color: #294738;
}

.panel {
    margin-bottom: clamp(3rem, 7vw, 5.5rem);
}

.panel-heading,
.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
}

.panel-heading {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e4e0d7;
}

.panel-heading h2,
.section-heading h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(1.65rem, 4vw, 2.15rem);
    font-weight: 500;
    letter-spacing: -0.025em;
}

.panel-heading > p {
    max-width: 30rem;
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.86rem;
    line-height: 1.5;
    text-align: right;
}

.section-heading {
    margin-bottom: 1rem;
}

.section-heading--compact {
    margin: 0;
}

.section-heading--compact h2 {
    font-size: 1.35rem;
}

.item-count {
    display: inline-flex;
    align-items: center;
    min-height: 1.8rem;
    padding: 0.25rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    background: rgb(255 254 250 / 65%);
    font-size: 0.75rem;
    font-weight: 650;
    white-space: nowrap;
}

.upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 1rem;
}

.upload-form .validation-summary {
    grid-column: 1 / -1;
}

.file-field input[type="file"] {
    width: 100%;
    min-height: 3rem;
    padding: 0.35rem;
    overflow: hidden;
    border: 1px dashed var(--line-strong);
    border-radius: 0.4rem;
    color: var(--ink-soft);
    background: #faf8f2;
}

.file-field input[type="file"]:hover {
    border-color: var(--rust);
    background: #fffaf6;
}

.file-field input[type="file"]::file-selector-button {
    min-height: 2.25rem;
    margin-right: 0.75rem;
    padding: 0.45rem 0.75rem;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0.25rem;
    color: var(--ink);
    background: #ebe7dd;
    font-weight: 650;
}

.resource-list + .resource-list {
    margin-top: 4rem;
}

.data-table-shell {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.data-table thead {
    color: var(--ink-faint);
    background: #efede6;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.data-table th,
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #e5e1d8;
    vertical-align: middle;
}

.data-table tbody tr:last-child > * {
    border-bottom: 0;
}

.data-table tbody tr {
    transition: background 120ms ease;
}

.data-table tbody tr:hover {
    background: #fcfaf5;
}

.data-table tbody th {
    font-size: 0.9rem;
    font-weight: 500;
}

.data-table td {
    color: #514f49;
    font-size: 0.82rem;
}

.data-table small,
.data-table time,
.data-table .record-id {
    display: block;
}

.data-table small {
    margin-top: 0.25rem;
    color: var(--ink-faint);
    font-size: 0.72rem;
}

.assets-table {
    table-layout: fixed;
}

.assets-table th:first-child {
    width: 30%;
}

.assets-table th:nth-child(2) {
    width: 16%;
}

.assets-table th:nth-child(3) {
    width: 9%;
}

.assets-table th:nth-child(4) {
    width: 22%;
}

.assets-table th:nth-child(5) {
    width: 23%;
}

.assets-table td {
    min-width: 0;
}

.assets-table td:nth-child(2) {
    overflow: hidden;
}

.asset-name-cell {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.asset-name-cell > span:last-child {
    min-width: 0;
}

.asset-file-icon {
    display: inline-grid;
    flex: 0 0 2rem;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid #d6cec0;
    border-radius: 0.35rem;
    color: var(--rust);
    background: #f4eee6;
    font-size: 1rem;
    font-weight: 700;
}

.asset-download {
    display: block;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-download:hover {
    color: var(--rust);
}

.asset-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    margin-top: 0.35rem;
}

.asset-meta code,
.record-id {
    overflow: hidden;
    color: var(--ink-faint);
    font-size: 0.65rem;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.version-badge,
.content-type {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    background: #f5f2eb;
    font-size: 0.68rem;
    font-weight: 650;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.digest {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--ink-faint);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-fields-form {
    display: grid;
    grid-template-columns: minmax(14rem, 1.5fr) minmax(12rem, 1fr) auto;
    align-items: end;
    gap: 1rem;
}

.inline-fields-form .validation-summary {
    grid-column: 1 / -1;
}

html[data-settings-dialog-open] {
    overflow: hidden;
}

dialog.settings-dialog {
    width: min(32rem, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100dvh - 2rem);
    margin: auto;
    padding: 0;
    overflow: auto;
    border: 1px solid var(--line-strong);
    border-radius: 0.7rem;
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 1.5rem 5rem rgb(24 25 22 / 26%);
}

dialog.settings-dialog::backdrop {
    background: rgb(24 25 22 / 52%);
    backdrop-filter: blur(0.12rem);
}

dialog.settings-dialog--wide {
    width: min(52rem, calc(100vw - 2rem));
}

.settings-dialog__surface {
    display: grid;
    min-width: 0;
    background: var(--surface);
}

.settings-dialog__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.settings-dialog__header .eyebrow {
    margin-bottom: 0.45rem;
}

.settings-dialog__header h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: -0.035em;
    line-height: 1.05;
}

.settings-dialog__close {
    display: inline-grid;
    flex: 0 0 2.4rem;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--ink-soft);
    background: transparent;
    font-size: 1.55rem;
    font-weight: 400;
    line-height: 1;
}

.settings-dialog__close:hover {
    border-color: var(--line);
    color: var(--ink);
    background: var(--surface-subtle);
}

.settings-dialog__body {
    display: grid;
    gap: 1.25rem;
    padding: 1.5rem;
}

.user-create-form input[type="email"],
.agent-token-create-form input,
.agent-token-create-form select,
.credential-dialog__body input,
.credential-dialog__body textarea {
    width: 100%;
    min-height: 2.85rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    color: inherit;
    background: var(--surface);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.document-delete-dialog__body p {
    margin: 0;
}

.document-delete-dialog__body p + p {
    color: var(--ink-soft);
}

.recycle-bin-list {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.recycle-bin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.15rem 1.25rem;
}

.recycle-bin-item + .recycle-bin-item {
    border-top: 1px solid var(--line);
}

.recycle-bin-item h2,
.recycle-bin-item p {
    margin: 0;
}

.recycle-bin-item h2 {
    font-family: Georgia, serif;
    font-size: 1.35rem;
    font-weight: 500;
}

.recycle-bin-item p {
    margin-top: 0.25rem;
    color: var(--ink-soft);
    font-size: 0.82rem;
}

.comment-attribution {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.comment-attribution__agent {
    padding: 0.08rem 0.35rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-subtle);
}

.user-create-form input[type="email"]:hover,
.agent-token-create-form input:hover,
.agent-token-create-form select:hover,
.credential-dialog__body input:hover,
.credential-dialog__body textarea:hover {
    border-color: #938c7f;
}

.user-create-form input[type="email"]:focus,
.agent-token-create-form input:focus,
.agent-token-create-form select:focus,
.credential-dialog__body input:focus,
.credential-dialog__body textarea:focus {
    border-color: var(--rust);
    outline: 0;
    box-shadow: 0 0 0 3px rgb(122 71 50 / 13%);
}

.user-role-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.user-role-field legend {
    margin-bottom: 0.45rem;
    padding: 0;
    font-weight: 650;
}

.user-admin-option {
    display: grid;
    grid-template-columns: 1.1rem minmax(0, 1fr);
    align-items: start;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    background: #faf8f3;
    cursor: pointer;
}

.user-admin-option:hover {
    border-color: var(--line-strong);
    background: #fffdf8;
}

.user-admin-option input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    min-height: 0;
    margin: 0.18rem 0 0;
    padding: 0;
    accent-color: var(--forest);
}

.user-admin-option span,
.user-admin-option small {
    display: block;
    min-width: 0;
}

.user-admin-option small {
    margin-top: 0.15rem;
    color: var(--ink-faint);
    font-size: 0.78rem;
    font-weight: 400;
}

.settings-dialog__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--line);
    background: #fbfaf6;
}

.async-form-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.async-action-spinner {
    display: none;
    width: 0.82rem;
    height: 0.82rem;
    border: 2px solid rgb(255 255 255 / 35%);
    border-top-color: currentcolor;
    border-radius: 50%;
    animation: document-pdf-spin 650ms linear infinite;
}

.htmx-request .async-action-spinner,
.async-action-spinner.htmx-request {
    display: inline-block;
}

.user-create-form.htmx-request,
.agent-token-create-form.htmx-request {
    cursor: wait;
}

.credential-dialog__body > p {
    margin: 0;
}

.credential-dialog__body input,
.credential-dialog__body textarea {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
}

.credential-dialog__body textarea {
    min-height: min(24rem, 48dvh);
    resize: vertical;
    line-height: 1.5;
}

.agent-token-empty-state {
    display: grid;
    justify-items: center;
}

.agent-token-empty-state .eyebrow {
    margin-bottom: 0.55rem;
}

.agent-credential-dialog__body > div:first-child p {
    margin: 0;
}

.agent-credential-dialog__body > div:first-child .field-hint {
    margin-top: 0.3rem;
}

.token-reveal {
    margin-bottom: 2rem;
    padding: 1.25rem;
}

.token-reveal h2 {
    margin: 0 0 0.25rem;
    font-family: Georgia, serif;
    font-weight: 500;
}

.token-reveal p {
    margin: 0.25rem 0 0.75rem;
}

.token-reveal input {
    margin-top: 0.4rem;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.78rem;
}

.tokens-table th:first-child {
    width: 24%;
}

.users-table th:first-child {
    width: 28%;
}

.users-table th:nth-child(2),
.users-table th:nth-child(3) {
    width: 14%;
}

.users-table th:nth-child(4) {
    width: 18%;
}

.users-table th:last-child {
    width: 26%;
}

.user-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-actions form {
    margin: 0;
}

.user-actions button {
    min-height: 2.75rem;
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
    line-height: 1;
    white-space: nowrap;
}

.tokens-table .status-pill + small {
    margin-top: 0.45rem;
}

.table-action {
    text-align: right;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.button-row form {
    margin: 0;
}

.workspace-index,
.space-page,
.history-page,
.discussions-page,
.form-page,
.content-page {
    width: min(76rem, calc(100% - 3rem));
    margin: 0 auto;
    padding: clamp(3rem, 6vw, 5.5rem) 0 8rem;
}

.page-title-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: clamp(2.5rem, 5vw, 4.5rem);
}

.page-title-row h1,
.form-page h1,
.history-page h1,
.content-page h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(2.75rem, 6vw, 5rem);
    font-weight: 500;
    letter-spacing: -0.045em;
    line-height: 1;
}

.page-title-row p:last-child {
    max-width: 42rem;
    margin: 1rem 0 0;
    color: var(--ink-soft);
    font-family: Georgia, serif;
    font-size: 1.12rem;
    line-height: 1.6;
}

.page-lede {
    max-width: 40rem;
    margin: 1.25rem 0 0;
    color: var(--ink-soft);
    font-family: Georgia, serif;
    font-size: 1.12rem;
    line-height: 1.6;
}

.resource-page-header {
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--line);
}

.settings-page {
    padding-top: clamp(2rem, 4vw, 3rem);
}

.settings-page > .resource-page-header {
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
}

.settings-page > .resource-page-header h1 {
    font-size: clamp(2.25rem, 4vw, 3.25rem);
    letter-spacing: -0.035em;
}

.space-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 24rem));
    gap: 1.15rem;
}

.space-card {
    display: grid;
    gap: 0.7rem;
    min-height: 12.5rem;
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.space-card:hover {
    border-color: #bdb4a5;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.space-card strong {
    align-self: end;
    font-family: Georgia, serif;
    font-size: 1.65rem;
    font-weight: 500;
}

.space-card > span:last-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ink-faint);
    font-size: 0.82rem;
}

.page-tree,
.revision-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-tree-shell {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.page-tree-shell .section-heading {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.page-tree li {
    margin-left: calc(var(--depth) * 1.35rem);
    padding-left: calc(var(--depth) * 0.2rem);
    border-bottom: 1px solid #e7e3da;
}

.page-tree li:last-child {
    border-bottom: 0;
}

.page-tree a {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    text-decoration: none;
}

.page-tree a {
    align-items: center;
    min-height: 3.8rem;
    padding-right: 1.5rem;
    padding-left: 1.5rem;
    transition: color 140ms ease, background 140ms ease;
}

.page-tree a:hover {
    color: var(--rust);
    background: #fbf8f1;
}

.page-tree span {
    color: #77736b;
    font-size: 0.82rem;
}

.empty-state {
    padding: clamp(2.5rem, 7vw, 5rem);
    border: 1px dashed var(--line-strong);
    border-radius: 0.55rem;
    background: rgb(255 254 250 / 46%);
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 0.75rem;
    font-family: Georgia, serif;
    font-size: 2rem;
    font-weight: 500;
}

.empty-state h3 {
    margin: 0 0 0.5rem;
    font-family: Georgia, serif;
    font-size: 1.5rem;
    font-weight: 500;
}

.empty-state p:not(.eyebrow) {
    max-width: 34rem;
    margin: 0 auto 1.5rem;
    color: var(--ink-soft);
}

.empty-state--compact {
    padding: 3rem 2rem;
}

.form-page {
    width: min(52rem, calc(100% - 3rem));
}

.form-page__header {
    max-width: 44rem;
}

.stacked-form {
    display: grid;
    gap: 1.25rem;
    max-width: 42rem;
    margin-top: 2rem;
}

.stacked-form input,
.stacked-form select,
.inline-fields-form input,
.inline-fields-form select,
.token-reveal input,
.comment-form textarea,
.reply-form textarea,
.filter-form select {
    width: 100%;
    min-height: 2.85rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    color: inherit;
    background: var(--surface);
    font: inherit;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.stacked-form input:hover,
.stacked-form select:hover,
.inline-fields-form input:hover,
.inline-fields-form select:hover,
.token-reveal input:hover,
.filter-form select:hover {
    border-color: #938c7f;
}

.stacked-form input:focus,
.stacked-form select:focus,
.inline-fields-form input:focus,
.inline-fields-form select:focus,
.token-reveal input:focus,
.filter-form select:focus {
    border-color: var(--rust);
    outline: 0;
    box-shadow: 0 0 0 3px rgb(122 71 50 / 13%);
}

.active-filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin: -1.25rem 0 2rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 0.45rem;
    background: rgb(255 254 250 / 62%);
    color: var(--ink-soft);
    font-size: 0.86rem;
}

.active-filter a {
    color: var(--rust);
    font-weight: 650;
}

.active-filter > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.stacked-form input::placeholder,
.inline-fields-form input::placeholder {
    color: #969188;
}

.form-card,
.panel {
    padding: clamp(1.25rem, 4vw, 2rem);
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.form-field {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.form-field label,
.token-reveal label {
    font-weight: 650;
}

.stacked-form [data-valmsg-for],
.inline-fields-form [data-valmsg-for],
.file-field [data-valmsg-for],
.validation-summary {
    color: #93251d;
    font-size: 0.85rem;
}

.validation-summary:empty {
    display: none;
}

.field-hint {
    margin: -0.15rem 0 0;
    color: var(--ink-faint);
    font-size: 0.82rem;
    line-height: 1.45;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e6e2d9;
}

.auth-page {
    width: min(44rem, calc(100% - 3rem));
}

.auth-page .form-card {
    max-width: 36rem;
}

.auth-page .notice {
    max-width: 36rem;
    margin-top: 1.5rem;
}

.sign-out-card {
    max-width: 32rem;
    margin-top: 2rem;
}

.sign-out-card .form-actions {
    margin: 0;
    padding: 0;
    border: 0;
}

.error-page .primary-action {
    margin-top: 2rem;
}

.historical-notice {
    margin-bottom: 2rem;
    padding: 0.8rem 1rem;
    border-left: 0.2rem solid #b27b31;
    background: #fff5dd;
}

.discussion-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin: -1.5rem 0 3rem;
    padding: 0.7rem 0.85rem;
    border-block: 1px solid var(--line);
    color: var(--ink-soft);
    background: color-mix(in srgb, var(--surface-subtle) 58%, transparent);
    font-size: 0.78rem;
    line-height: 1.35;
}

.discussion-summary-bar p {
    margin: 0;
}

.discussion-summary-bar__counts,
.discussion-summary-counts {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem 0.7rem;
}

.discussion-summary-bar__counts > span,
.discussion-summary-counts > span {
    white-space: nowrap;
}

.discussion-summary-bar__counts > :not(:first-child)::before,
.discussion-summary-counts > :not(:first-child)::before {
    margin-right: 0.7rem;
    color: var(--line-strong);
    content: "\00b7";
}

.discussion-summary-bar strong {
    color: var(--ink);
    font-weight: 700;
}

.discussion-summary-bar__action,
.discussion-summary-bar > a {
    flex: 0 0 auto;
    color: var(--rust);
    font-weight: 700;
    text-decoration: none;
}

.discussion-summary-bar__action:hover,
.discussion-summary-bar > a:hover {
    text-decoration: underline;
}

.annotation-gutter,
.discussion-footer {
    min-height: 0;
    margin-top: clamp(4.5rem, 10vw, 7rem);
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    scroll-margin-top: 7rem;
}

.page-discussion > header,
.discussion-footer__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-discussion > header .eyebrow,
.discussion-footer__header .eyebrow {
    margin-bottom: 0;
}

.discussion-footer__header h2 {
    margin: 0.2rem 0 0;
    font-family: Georgia, serif;
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.15;
}

.discussion-footer__header > p {
    max-width: 24rem;
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.78rem;
    text-align: right;
}

.discussion-page-composer {
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    background: color-mix(in srgb, var(--surface) 68%, transparent);
}

.discussion-page-composer .button-row {
    justify-content: flex-end;
}

.discussion-empty-state {
    margin: 1rem 0 0;
    padding: 0.8rem 0;
    color: var(--ink-soft);
    font-size: 0.84rem;
}

.comment-form,
.reply-form {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.selection-comment {
    padding: 0.8rem;
    border: 1px solid #be977e;
    border-radius: 0.35rem;
    background: #fff8f2;
}

.thread-list {
    position: relative;
}

.thread-card {
    position: static;
    padding: 0.8rem;
    border: 1px solid #d3cec3;
    border-radius: 0.35rem;
    background: #fffefa;
    box-shadow: 0 0.5rem 1.5rem rgb(40 35 28 / 7%);
}

.thread-card.resolved {
    opacity: 0.72;
}

.thread-card header,
.inbox-thread header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.thread-card blockquote,
.inbox-thread blockquote {
    margin: 0.65rem 0;
    color: #706b62;
    font-family: Georgia, serif;
    font-size: 0.85rem;
}

.comment-message {
    padding: 0.65rem 0;
    border-top: 1px solid #e2ded5;
}

.comment-message p {
    margin: 0 0 0.3rem;
    color: #34322e;
}

.status-pill {
    display: inline-block;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    color: #5d5952;
    background: #e9e5dc;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.status-pill.outdated,
.status-pill.ambiguous {
    color: #8d2e27;
    background: #ffe0db;
}

.status-pill.modified {
    color: #735016;
    background: #ffedc3;
}

.status-pill--active {
    color: #2f5f45;
    background: #e0f0e5;
}

.status-pill--muted {
    color: #6a665f;
    background: #e9e5dc;
}

.discussion-inbox {
    display: grid;
    gap: 1rem;
}

.inbox-thread {
    padding: 1.2rem;
    border: 1px solid #d4d0c6;
    border-radius: 0.4rem;
    background: #fffefa;
}

.inbox-thread header a {
    min-width: 0;
    margin-right: auto;
    overflow-wrap: anywhere;
}

.history-header .page-title-row {
    margin-bottom: clamp(2rem, 4vw, 3.5rem);
}

.revision-list {
    display: grid;
    gap: 1rem;
}

.revision-card {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr) auto;
    align-items: start;
    gap: 1.15rem;
    min-width: 0;
    padding: 1.3rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.revision-card:focus-within,
.revision-card:has(.revision-card__title:hover, .revision-compare-link:hover) {
    border-color: #bdb4a5;
    box-shadow: 0 0.75rem 2rem rgb(35 32 26 / 7%);
}

.revision-card--published {
    border-color: #b9cbbf;
}

.revision-card__number {
    display: grid;
    place-items: center;
    width: 2.7rem;
    height: 2.7rem;
    border: 1px solid #d0c9bc;
    border-radius: 999px;
    color: var(--rust);
    background: #f4eee7;
    font-size: 0.86rem;
    font-weight: 750;
    line-height: 1;
}

.revision-card--published .revision-card__number {
    border-color: var(--forest);
    color: #fff;
    background: var(--forest);
}

.revision-card__content {
    min-width: 0;
}

.revision-card__heading,
.revision-card__badges,
.revision-card__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.revision-card__heading {
    gap: 0.7rem;
}

.revision-card__badges {
    gap: 0.35rem;
}

.revision-card__title {
    font-family: Georgia, serif;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.revision-card__title:hover {
    color: var(--rust);
    text-decoration: underline;
}

.revision-card__summary {
    max-width: 52rem;
    margin: 0.55rem 0 0.75rem;
    color: #383730;
    font-family: Georgia, serif;
    font-size: 1rem;
    line-height: 1.55;
}

.revision-card__meta {
    gap: 0.35rem;
    margin: 0;
    color: var(--ink-faint);
    font-size: 0.76rem;
}

.revision-card__meta code {
    padding: 0.12rem 0.3rem;
    border-radius: 0.25rem;
    background: var(--surface-subtle);
    font-size: 0.72rem;
    overflow-wrap: anywhere;
}

.revision-card__actions {
    align-self: center;
}

.revision-card__actions .revision-compare-link {
    white-space: nowrap;
}

.comparison-page .page-title-row {
    margin-bottom: clamp(2rem, 4vw, 3rem);
}

.comparison-range {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1rem;
}

.comparison-revision {
    min-width: 0;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.comparison-revision--to {
    border-color: #b9cbbf;
}

.comparison-revision__label {
    margin: 0 0 0.4rem;
    color: var(--ink-faint);
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.comparison-revision__title {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 1.35rem;
    font-weight: 600;
}

.comparison-revision__summary {
    margin: 0.65rem 0 0.8rem;
    color: #45433d;
    font-family: Georgia, serif;
    line-height: 1.5;
}

.comparison-revision__meta {
    display: grid;
    gap: 0.22rem;
    margin: 0;
    color: var(--ink-faint);
    font-size: 0.74rem;
}

.comparison-revision__meta code {
    padding: 0.1rem 0.28rem;
    border-radius: 0.25rem;
    background: var(--surface-subtle);
    font-size: 0.7rem;
    overflow-wrap: anywhere;
}

.comparison-arrow {
    display: grid;
    place-items: center;
    align-self: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--rust);
    background: var(--surface);
    font-size: 1.1rem;
}

.comparison-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin: 0 0 1rem;
}

.comparison-stat {
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
}

.comparison-stat--added {
    color: #285d28;
    background: #dff0dc;
}

.comparison-stat--deleted {
    color: #842f28;
    background: #f7ded9;
}

.diff-list {
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #d4d0c6;
    border-radius: 0.4rem;
    background: #fffefa;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
    line-height: 1.55;
    list-style: none;
}

.diff-line {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr);
    min-height: 1.75rem;
    border-bottom: 1px solid #ece8df;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.diff-line:last-child {
    border-bottom: 0;
}

.diff-line > :last-child {
    padding: 0.18rem 0.65rem;
}

.diff-marker {
    padding: 0.18rem 0.5rem;
    color: #77736b;
    background: #f1eee7;
    text-align: center;
    user-select: none;
}

.diff-added {
    background: #eaf7e8;
}

.diff-added .diff-marker {
    color: #285d28;
    background: #cfe9cb;
}

.diff-added ins {
    text-decoration: none;
}

.diff-deleted {
    background: #fff0ed;
}

.diff-deleted .diff-marker {
    color: #842f28;
    background: #f5d5d0;
}

.document-workspace {
    width: min(52rem, calc(100% - 3rem));
    margin: 0 auto;
    padding: clamp(2.75rem, 5vw, 4rem) 0 8rem;
}

.document-outline {
    display: none;
}

.document-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.65rem 1.25rem;
    margin-bottom: 2.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.78rem;
    line-height: 1.35;
}

.document-breadcrumbs {
    min-width: 0;
}

.document-breadcrumbs ol,
.document-breadcrumbs ul {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.document-breadcrumbs li {
    min-width: 0;
    overflow-wrap: anywhere;
}

.document-breadcrumbs li + li::before {
    margin-right: 0.5rem;
    color: var(--line-strong);
    content: "/";
}

.document-breadcrumbs a,
.document-context-actions a,
.document-context__actions a,
.document-tools a {
    text-decoration: none;
}

.document-breadcrumbs a:hover {
    color: var(--rust);
    text-decoration: underline;
}

.document-context-actions,
.document-context__actions,
.document-tools {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem;
    margin-left: auto;
}

.document-context-actions a,
.document-context-actions button,
.document-context__actions a,
.document-tools a {
    padding: 0.38rem 0.55rem;
    border: 0;
    border-radius: 0.3rem;
    color: var(--ink-soft);
    background: transparent;
    font-weight: 650;
    line-height: inherit;
    text-decoration: none;
}

.document-context-actions a:hover,
.document-context-actions button:hover,
.document-context__actions a:hover,
.document-tools a:hover {
    color: var(--rust);
    background: var(--surface);
}

.document-context-actions .document-pdf-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-left: 0.25rem;
    padding-inline: 0.7rem;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
}

.document-context-actions .document-pdf-action:hover {
    border-color: var(--rust);
}

.document-context-actions .document-pdf-action:disabled {
    border-color: var(--line);
    color: var(--ink-soft);
    opacity: 0.82;
}

.document-links-action__count {
    display: inline-grid;
    min-width: 1.3rem;
    height: 1.3rem;
    margin-left: 0.22rem;
    place-items: center;
    padding: 0 0.32rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-faint);
    background: var(--surface);
    font-size: 0.67rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.document-links-action[aria-expanded="true"] {
    color: var(--rust);
    background: var(--surface);
}

.document-pdf-action__spinner {
    width: 0.78rem;
    height: 0.78rem;
    border: 2px solid rgb(122 71 50 / 22%);
    border-top-color: var(--rust);
    border-radius: 50%;
    animation: document-pdf-spin 650ms linear infinite;
}

.document-pdf-action__spinner[hidden] {
    display: none;
}

.document-pdf-status {
    position: absolute;
    z-index: 5;
    top: calc(100% + 0.55rem);
    right: 0;
    width: max-content;
    max-width: min(22rem, calc(100vw - 2rem));
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--success);
    line-height: 1.4;
}

.document-pdf-status[data-state="error"] {
    border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
    color: var(--danger);
}

@keyframes document-pdf-spin {
    to {
        transform: rotate(360deg);
    }
}

.document-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 4rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #d8d4c9;
}

.document-header h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(2.75rem, 5vw, 4.75rem);
    font-weight: 500;
    letter-spacing: -0.045em;
    line-height: 1;
}

.document-header button:not(.primary-action):not(.secondary-action) {
    flex: 0 0 auto;
    padding: 0.55rem 0.8rem;
    border: 1px solid #b8b3a7;
    border-radius: 0.25rem;
    color: #77736b;
    background: transparent;
}

.document-column {
    min-width: 0;
}

.q-document {
    font-family: Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.q-section + .q-section {
    margin-top: 4rem;
}

.q-document h2 {
    margin: 0 0 1rem;
    font-size: 1.8rem;
    font-weight: 500;
    letter-spacing: -0.025em;
}

.q-document blockquote {
    margin: 2rem 0;
    padding: 0.25rem 0 0.25rem 1.5rem;
    border-left: 0.2rem solid #a25638;
    color: #514e47;
    font-style: italic;
}

.q-document pre {
    box-sizing: border-box;
    max-width: 100%;
    margin: 2rem 0;
    padding: 1rem 1.1rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 0.45rem;
    color: #333129;
    background: #f3f0e8;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    scrollbar-color: var(--line-strong) transparent;
}

.q-document pre code {
    font: inherit;
    white-space: pre;
}

.q-table-scroll {
    max-width: 100%;
    margin: 2.25rem 0;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    scrollbar-color: var(--line-strong) transparent;
}

.q-table-scroll:focus-visible {
    outline: 3px solid rgb(122 71 50 / 28%);
    outline-offset: 3px;
}

.q-document .q-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: left;
}

.q-document .q-table caption {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink-soft);
    background: #f7f4ed;
    font-family: Georgia, serif;
    font-size: 0.96rem;
    font-weight: 600;
    text-align: left;
}

.q-document .q-table th,
.q-document .q-table td {
    min-width: 8rem;
    padding: 0.8rem 0.9rem;
    border-right: 1px solid #e3dfd5;
    border-bottom: 1px solid #e3dfd5;
    vertical-align: top;
}

.q-document .q-table tr > :last-child {
    border-right: 0;
}

.q-document .q-table tbody tr:last-child > * {
    border-bottom: 0;
}

.q-document .q-table thead th {
    color: #4e4940;
    background: #ece9e1;
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.q-document .q-table tbody th {
    color: var(--ink);
    background: #f7f4ed;
    font-weight: 700;
}

.q-document .q-table tbody tr:nth-child(even) td {
    background: #fbfaf6;
}

.q-document .q-table p {
    margin: 0;
}

.q-document .q-table p + p {
    margin-top: 0.55rem;
}

.q-diagram {
    box-sizing: border-box;
    max-width: 100%;
    margin: 3rem 0;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.q-diagram > figcaption {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 1rem;
    margin-bottom: 0.8rem;
}

.q-diagram > figcaption strong {
    grid-column: 1;
    color: var(--ink);
    font-family: Georgia, serif;
    font-size: 1.15rem;
    font-weight: 600;
}

.q-diagram-description {
    grid-column: 1;
    max-width: 68ch;
    color: var(--ink-soft);
    font-size: 0.84rem;
    line-height: 1.55;
}

.q-diagram-actions {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    gap: 0.4rem;
}

.q-diagram-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2rem;
    padding: 0.32rem 0.55rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    color: var(--ink-soft);
    background: var(--surface);
    font: 650 0.72rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
    text-decoration: none;
}

.q-diagram-action:hover {
    border-color: #918a7c;
    color: var(--rust);
    background: #fff;
}

.q-diagram-action:focus-visible {
    outline: 3px solid rgb(122 71 50 / 28%);
    outline-offset: 2px;
}

.q-diagram-scroll {
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    background:
        linear-gradient(rgb(255 254 250 / 88%), rgb(255 254 250 / 88%)),
        repeating-linear-gradient(0deg, transparent 0 23px, rgb(35 51 42 / 5%) 23px 24px),
        repeating-linear-gradient(90deg, transparent 0 23px, rgb(35 51 42 / 5%) 23px 24px);
    box-shadow: var(--shadow-sm);
    scrollbar-color: var(--line-strong) transparent;
}

.q-diagram-scroll:focus-visible {
    outline: 3px solid rgb(122 71 50 / 28%);
    outline-offset: 3px;
}

.q-diagram-scroll svg {
    display: block;
    max-width: none;
    color: #45564d;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.q-diagram-scroll marker path {
    fill: currentColor;
}

.q-diagram-group rect {
    fill: rgb(237 233 222 / 72%);
    stroke: #b9b2a4;
    stroke-dasharray: 5 4;
}

.q-diagram-group-label {
    fill: #665f54;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.035em;
}

.q-diagram-edge path,
.q-diagram-message path,
.q-diagram-message line {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
}

.q-diagram-line--dashed path,
.q-diagram-line--dashed line {
    stroke-dasharray: 7 5;
}

.q-diagram-edge-label,
.q-diagram-message-label {
    fill: #514d45;
    paint-order: stroke;
    stroke: #fffefa;
    stroke-linejoin: round;
    stroke-width: 5px;
    font-size: 12px;
    font-weight: 600;
}

.q-diagram-node rect,
.q-diagram-node polygon,
.q-diagram-node > path,
.q-diagram-participant rect {
    fill: #fffefa;
    stroke: #617269;
    stroke-width: 1.6;
    filter: drop-shadow(0 3px 4px rgb(28 39 33 / 9%));
}

.q-diagram-node--decision polygon {
    fill: #f4e6dc;
    stroke: #a25638;
}

.q-diagram-node--terminal rect {
    fill: #26352d;
    stroke: #26352d;
}

.q-diagram-node--document > path {
    fill: #f1eee6;
}

.q-diagram-node-label,
.q-diagram-participant-label {
    fill: #282b27;
    font-size: 12px;
    font-weight: 650;
}

.q-diagram-node--terminal .q-diagram-node-label {
    fill: #fff;
}

.q-diagram-participant--actor rect {
    fill: #f2e6dc;
    stroke: #9b634d;
}

.q-diagram-lifeline {
    stroke: #9c9a91;
    stroke-dasharray: 5 5;
    stroke-width: 1.2;
}

.q-diagram-phase {
    fill: rgb(184 119 92 / 10%);
    stroke: rgb(162 86 56 / 35%);
}

.q-diagram-phase-label {
    fill: #7a4732;
    font-size: 12px;
    font-weight: 750;
}

.q-diagram-transcript {
    margin-top: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    color: var(--ink-soft);
    background: #f7f4ed;
    font-size: 0.78rem;
    line-height: 1.55;
}

.q-diagram-transcript summary {
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.q-diagram-transcript ol,
.q-diagram-transcript ul {
    margin-bottom: 0;
    padding-left: 1.4rem;
}

.q-diagram .q-diagram-source {
    margin-top: 0.75rem;
}

html[data-diagram-gallery-open] {
    overflow: hidden;
}

dialog.q-diagram-gallery {
    position: fixed;
    inset: 0;
    z-index: 80;
    box-sizing: border-box;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    color: var(--ink);
    background: var(--canvas);
}

dialog.q-diagram-gallery::backdrop {
    background: rgb(22 24 21 / 72%);
    backdrop-filter: blur(0.15rem);
}

.q-diagram-gallery__shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
}

.q-diagram-gallery__header {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(16rem, 1fr) auto;
    align-items: center;
    gap: 1rem 2rem;
    min-height: 5.4rem;
    padding: max(0.9rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 0.9rem max(1.25rem, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: rgb(247 245 238 / 96%);
    box-shadow: 0 0.35rem 1.5rem rgb(32 31 27 / 8%);
}

.q-diagram-gallery__identity {
    min-width: 0;
}

.q-diagram-gallery__identity .eyebrow {
    margin-bottom: 0.3rem;
}

.q-diagram-gallery__identity h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(1.25rem, 2.2vw, 1.8rem);
    font-weight: 500;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.q-diagram-gallery__description {
    max-width: 76ch;
    margin: 0.35rem 0 0;
    color: var(--ink-soft);
    font-size: 0.75rem;
    line-height: 1.4;
}

.q-diagram-gallery__controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.q-diagram-gallery__controls button,
.q-diagram-gallery__controls a,
.q-diagram-gallery__zoom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    margin: 0;
    border-radius: 0.35rem;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
}

.q-diagram-gallery__controls button,
.q-diagram-gallery__controls a {
    border: 1px solid var(--line-strong);
    color: var(--ink-soft);
    background: var(--surface);
    text-decoration: none;
}

.q-diagram-gallery__controls button:hover,
.q-diagram-gallery__controls a:hover {
    border-color: #918a7c;
    color: var(--rust);
    background: #fff;
}

.q-diagram-gallery__controls button:focus-visible,
.q-diagram-gallery__controls a:focus-visible {
    outline: 3px solid rgb(122 71 50 / 28%);
    outline-offset: 2px;
}

.q-diagram-gallery__icon {
    width: 2.25rem;
    padding: 0;
    font-size: 1rem !important;
}

.q-diagram-gallery__control,
.q-diagram-gallery__close {
    padding: 0.55rem 0.7rem;
}

.q-diagram-gallery__close {
    border-color: var(--forest) !important;
    color: #fff !important;
    background: var(--forest) !important;
}

.q-diagram-gallery__zoom {
    min-width: 3.5rem;
    color: var(--ink-faint);
}

.q-diagram-gallery__divider {
    width: 1px;
    height: 1.5rem;
    margin: 0 0.1rem;
    background: var(--line);
}

.q-diagram-gallery__stage {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #e9e6dd;
}

.q-diagram-gallery__stage > .q-diagram-scroll {
    width: 100%;
    max-width: none;
    height: 100%;
    overflow: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    cursor: grab;
    overscroll-behavior: contain;
    touch-action: none;
    user-select: none;
}

.q-diagram-gallery__stage > .q-diagram-scroll[data-diagram-panning] {
    cursor: grabbing;
}

.q-diagram-gallery__stage > .q-diagram-scroll svg {
    margin: 1.5rem auto 4rem;
}

.q-document .q-image {
    width: 100%;
    max-width: 100%;
    margin: 2.5rem 0;
}

.q-document .q-image img {
    display: block;
    max-width: 100%;
    height: auto;
}

.q-document .q-file {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    margin: 0.35rem 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    background: var(--surface);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.84rem;
    font-weight: 650;
    line-height: 1.35;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.q-document .q-file::before {
    flex: 0 0 auto;
    color: var(--rust);
    content: "↓";
    font-weight: 800;
}

.q-document .q-file:hover {
    border-color: #918a7c;
    color: var(--rust);
    background: #fff;
}

[hidden] {
    display: none !important;
}

.selection-comment-popover {
    position: fixed;
    z-index: 40;
    filter: drop-shadow(0 0.65rem 1rem rgb(24 28 24 / 20%));
}

.selection-comment-popover[data-placement="above"] {
    transform: translate(-50%, calc(-100% - 0.65rem));
}

.selection-comment-popover[data-placement="below"] {
    transform: translate(-50%, 0.65rem);
}

.selection-comment-popover::after {
    position: absolute;
    left: 50%;
    width: 0;
    height: 0;
    border-right: 0.38rem solid transparent;
    border-left: 0.38rem solid transparent;
    content: "";
    transform: translateX(-50%);
}

.selection-comment-popover[data-placement="above"]::after {
    top: 100%;
    border-top: 0.38rem solid var(--forest);
}

.selection-comment-popover[data-placement="below"]::after {
    bottom: 100%;
    border-bottom: 0.38rem solid var(--forest);
}

.selection-comment-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.25rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid #101c16;
    border-radius: 0.35rem;
    color: #fff;
    background: var(--forest);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
}

.selection-comment-trigger::before {
    width: 0.75rem;
    height: 0.6rem;
    border: 1px solid currentColor;
    border-radius: 0.18rem;
    content: "";
    box-shadow: 0.18rem 0.16rem 0 -0.08rem var(--forest), 0.18rem 0.16rem 0 0 currentColor;
}

.selection-comment-trigger:hover {
    background: var(--forest-hover);
}

[data-qprins-static-document] .q-document {
    position: relative;
}

[data-selection-comment-target="pending"],
[data-selection-comment-target="composing"] {
    border-radius: 0.18rem;
    outline: 3px solid rgb(122 71 50 / 14%);
    outline-offset: 0.25rem;
    background: rgb(237 218 191 / 18%);
}

[data-selection-comment-target="composing"] {
    outline-color: rgb(122 71 50 / 24%);
    background: rgb(237 218 191 / 28%);
}

[data-has-discussions],
[data-has-open-discussions] {
    position: relative;
    border-radius: 0.18rem;
}

[data-has-discussions]::before,
[data-has-open-discussions]::before {
    position: absolute;
    top: 0.12em;
    bottom: 0.12em;
    left: -0.8rem;
    width: 0.18rem;
    border-radius: 999px;
    background: #b8775c;
    content: "";
}

[data-has-discussions][data-annotation-active="true"],
[data-has-open-discussions][data-annotation-active="true"] {
    background: linear-gradient(90deg, rgb(235 211 194 / 48%), transparent 80%);
}

[data-has-discussions][data-annotation-active="true"]::before,
[data-has-open-discussions][data-annotation-active="true"]::before {
    background: var(--rust);
}

.annotation-indicators {
    position: static;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: auto;
    margin: 0.35rem 0 1.1rem;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.annotation-indicator,
.annotation-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 1.9rem;
    max-width: 100%;
    min-height: 1.9rem;
    padding: 0.34rem 0.55rem;
    border: 1px solid #c7a38f;
    border-radius: 999px;
    color: #6b3e2d;
    background: #fff8f2;
    box-shadow: 0 2px 0.6rem rgb(68 45 34 / 10%);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    transition: color 120ms ease, background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.annotation-indicator:hover,
.annotation-indicator[data-annotation-active="true"],
.annotation-inline:hover,
.annotation-inline[aria-expanded="true"] {
    border-color: var(--rust);
    color: #5e3424;
    background: #f7e7dd;
    transform: translateY(-1px);
}

.annotation-indicator[data-annotation-state="resolved"] {
    border-color: var(--line);
    color: var(--ink-faint);
    background: var(--surface-subtle);
    box-shadow: none;
}

.annotation-indicator__reference,
.annotation-inline__reference {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    min-width: 1.15rem;
    height: 1.15rem;
    padding-inline: 0.18rem;
    border-radius: 999px;
    color: #fff;
    background: var(--rust);
    font-size: 0.62rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.annotation-indicator__excerpt,
.annotation-inline__excerpt {
    min-width: 0;
    max-width: min(31rem, 60vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.annotation-inline__meta {
    flex: 0 0 auto;
    color: var(--ink-faint);
    font-size: 0.66rem;
    font-weight: 600;
    white-space: nowrap;
}

.annotation-reference {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    border: 1px solid #c7a38f;
    border-radius: 999px;
    color: #6b3e2d;
    background: #fff8f2;
    box-shadow: none;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.62rem;
    font-weight: 750;
    line-height: 1;
}

.thread-card[data-annotation-active="true"] {
    border-color: #b77b61;
    box-shadow: 0 0 0 3px rgb(122 71 50 / 10%), 0 0.75rem 2rem rgb(40 35 28 / 10%);
}

.discussion-thread-index {
    display: grid;
    gap: 0.45rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}

.discussion-footer .thread-card {
    padding: 0.55rem 0.65rem;
    box-shadow: none;
}

.discussion-footer .thread-card > :not(header) {
    display: none;
}

.discussion-footer .thread-card > header {
    justify-content: space-between;
    min-width: 0;
}

.discussion-footer .discussion-index-item__status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-width: 0;
}

.discussion-index-item__open {
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    color: var(--rust);
    background: transparent;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.discussion-index-item__open:hover,
.discussion-index-item__open[aria-expanded="true"] {
    color: var(--ink);
}

.discussion-index-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    color: var(--ink-soft);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    font-size: 0.76rem;
    text-align: left;
    text-decoration: none;
}

.discussion-index-item:hover,
.discussion-index-item[aria-expanded="true"] {
    border-color: #b77b61;
    color: var(--ink);
    background: var(--surface);
}

.discussion-index-item__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.discussion-index-item__status {
    flex: 0 0 auto;
    color: var(--ink-faint);
    font-size: 0.68rem;
    font-weight: 650;
    white-space: nowrap;
}

dialog.discussion-drawer {
    position: fixed;
    z-index: 20;
    inset: 4.25rem 0 0 auto;
    width: min(28rem, calc(100vw - 1rem));
    max-width: none;
    height: calc(100dvh - 4.25rem);
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-left: 1px solid var(--line);
    color: var(--ink);
    background: var(--surface);
    box-shadow: -1rem 0 3rem rgb(35 32 26 / 18%);
}

dialog.page-links-drawer {
    position: fixed;
    z-index: 20;
    inset: 4.25rem 0 0 auto;
    width: min(31rem, calc(100vw - 1rem));
    max-width: none;
    height: calc(100dvh - 4.25rem);
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-left: 1px solid var(--line);
    color: var(--ink);
    background: var(--surface);
    box-shadow: -1rem 0 3rem rgb(35 32 26 / 18%);
}

dialog.page-links-drawer[open] {
    display: flex;
    flex-direction: column;
}

.page-links-drawer__header {
    position: sticky;
    z-index: 1;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
}

.page-links-drawer__header .eyebrow {
    margin-bottom: 0.2rem;
}

.page-links-drawer__header h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 1.25rem;
    font-weight: 500;
}

.page-links-drawer__close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    height: 2.5rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    color: var(--ink-soft);
    background: var(--surface);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
}

.page-links-drawer__close:hover {
    border-color: var(--line-strong);
    color: var(--rust);
}

.page-links-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.page-link-map {
    padding: 1rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-subtle) 46%, transparent);
}

.page-link-map__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.65rem;
}

.page-link-map__header h3 {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 750;
}

.page-link-map__header p {
    margin: 0.15rem 0 0;
    color: var(--ink-faint);
    font-size: 0.7rem;
}

.page-link-map__expand {
    min-height: 2rem;
    padding: 0.38rem 0.65rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    color: var(--ink-soft);
    background: var(--surface);
    font-size: 0.72rem;
    font-weight: 700;
}

.page-link-map__expand:hover,
.page-link-map__expand[aria-expanded="true"] {
    border-color: var(--rust);
    color: var(--rust);
}

.page-link-map__viewport {
    position: relative;
    width: 100%;
    height: 17rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    outline: 0;
    background:
        radial-gradient(circle at center, rgb(255 255 255 / 88%), rgb(244 241 233 / 70%)),
        repeating-linear-gradient(0deg, transparent 0 23px, rgb(64 60 53 / 4%) 23px 24px),
        repeating-linear-gradient(90deg, transparent 0 23px, rgb(64 60 53 / 4%) 23px 24px);
}

.page-link-map__viewport:focus-visible {
    box-shadow: 0 0 0 3px rgb(122 71 50 / 16%);
}

.page-link-graph-svg {
    display: block;
    width: 100%;
    height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.page-link-graph-edge {
    fill: none;
    stroke-width: 2.2;
    opacity: 0.78;
    vector-effect: non-scaling-stroke;
}

.page-link-graph-edge--incoming {
    stroke: #a86043;
}

.page-link-graph-edge--outgoing {
    stroke: #2f5a49;
}

.page-link-graph-arrow--incoming {
    fill: #a86043;
}

.page-link-graph-arrow--outgoing {
    fill: #2f5a49;
}

.page-link-graph-node {
    color: var(--ink);
    cursor: default;
}

.page-link-graph-node[href] {
    cursor: pointer;
}

.page-link-graph-node rect {
    fill: #fffefa;
    stroke: #afa99d;
    stroke-width: 1.5;
    transition: fill 120ms ease, stroke 120ms ease, stroke-width 120ms ease;
    vector-effect: non-scaling-stroke;
}

.page-link-graph-node--incoming rect {
    fill: #fff8f3;
    stroke: #b8795f;
}

.page-link-graph-node--outgoing rect {
    fill: #f3f8f5;
    stroke: #547566;
}

.page-link-graph-node--mutual rect {
    fill: #f8f3e8;
    stroke: #8b7750;
}

.page-link-graph-node--current rect {
    fill: var(--forest);
    stroke: #172b22;
    stroke-width: 2;
}

.page-link-graph-node[href]:hover rect,
.page-link-graph-node[href]:focus rect {
    fill: #fff;
    stroke: var(--rust);
    stroke-width: 2.5;
}

.page-link-graph-node__title {
    fill: var(--ink);
    font-size: 14px;
    font-weight: 720;
    pointer-events: none;
}

.page-link-graph-node__meta {
    fill: #716d65;
    font-size: 10.5px;
    font-weight: 600;
    pointer-events: none;
}

.page-link-graph-node--current .page-link-graph-node__title,
.page-link-graph-node--current .page-link-graph-node__meta {
    fill: #fff;
}

.page-link-graph-node--unavailable {
    opacity: 0.62;
}

.page-link-map__legend {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.8rem;
    margin-top: 0.55rem;
    color: var(--ink-faint);
    font-size: 0.66rem;
    font-weight: 650;
}

.page-link-map__legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.page-link-map__key {
    display: inline-block;
    width: 1.15rem;
    height: 0.16rem;
    border-radius: 999px;
}

.page-link-map__key--incoming {
    background: #a86043;
}

.page-link-map__key--outgoing {
    background: #2f5a49;
}

.page-link-map__key--mutual {
    height: 0.7rem;
    border: 1px solid #8b7750;
    background: #f8f3e8;
}

dialog.page-link-graph-gallery {
    z-index: 60;
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    color: var(--ink);
    background: #eae7df;
}

dialog.page-link-graph-gallery::backdrop {
    background: rgb(24 23 20 / 72%);
}

dialog.page-link-graph-gallery[open] {
    display: block;
}

.page-link-graph-gallery__shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
}

.page-link-graph-gallery__header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    min-height: 5.25rem;
    padding: 0.75rem clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid #cbc6bb;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 0.4rem 1.25rem rgb(38 35 30 / 10%);
    backdrop-filter: blur(14px);
}

.page-link-graph-gallery__header .eyebrow {
    margin-bottom: 0.18rem;
}

.page-link-graph-gallery__header h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(1.25rem, 2.4vw, 1.8rem);
    font-weight: 500;
}

.page-link-graph-gallery__header p:not(.eyebrow) {
    margin: 0.2rem 0 0;
    color: var(--ink-faint);
    font-size: 0.72rem;
}

.page-link-graph-gallery__controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
}

.page-link-graph-gallery__controls button,
.page-link-graph-gallery__controls output {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.35rem;
    min-height: 2.35rem;
    margin: 0;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    color: var(--ink-soft);
    background: var(--surface);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
}

.page-link-graph-gallery__controls output {
    min-width: 3.6rem;
    border-color: transparent;
    background: transparent;
}

.page-link-graph-gallery__controls button:hover {
    border-color: var(--rust);
    color: var(--rust);
}

.page-link-graph-gallery__controls .page-link-graph-gallery__close {
    border-color: var(--forest);
    color: #fff;
    background: var(--forest);
}

.page-link-graph-gallery__stage {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.page-link-map__viewport[data-page-link-graph-expanded] {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 0;
    border-radius: 0;
    cursor: grab;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    touch-action: none;
    user-select: none;
}

.page-link-map__viewport[data-page-link-graph-panning] {
    cursor: grabbing;
}

.page-link-map__viewport[data-page-link-graph-expanded] .page-link-graph-svg {
    flex: 0 0 auto;
    margin: auto;
    max-width: none;
    max-height: none;
}

.page-links-section {
    padding: 1.2rem 1rem 1.5rem;
}

.page-links-section + .page-links-section {
    border-top: 1px solid var(--line);
}

.page-links-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.page-links-section__header h3 {
    margin: 0;
    font-size: 0.73rem;
    font-weight: 750;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.page-links-section__header span {
    min-width: 1.5rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-faint);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.page-link-groups,
.page-link-occurrences {
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-link-groups {
    display: grid;
    gap: 0.65rem;
}

.page-link-group {
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 0.45rem;
    background: color-mix(in srgb, var(--surface-subtle) 52%, var(--surface));
}

.page-link-group__title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.page-link-group__title a,
.page-link-group__title > span {
    min-width: 0;
    color: var(--ink);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.page-link-group__title a:hover {
    color: var(--rust);
}

.page-link-group__title small {
    flex: 0 0 auto;
    color: var(--ink-faint);
    font-size: 0.7rem;
    font-weight: 600;
}

.page-link-group__space {
    margin: 0.18rem 0 0;
    color: var(--ink-faint);
    font-size: 0.72rem;
}

.page-link-occurrences {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.page-link-occurrences li {
    color: var(--ink-soft);
    font-size: 0.79rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.page-links-empty {
    margin: 0;
    padding: 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: 0.45rem;
    color: var(--ink-faint);
    font-size: 0.82rem;
}

dialog.discussion-drawer[open] {
    display: flex;
    flex-direction: column;
}

.discussion-drawer__header {
    position: sticky;
    z-index: 1;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
}

.discussion-drawer__header .eyebrow {
    margin-bottom: 0.2rem;
}

.discussion-drawer__header h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-family: Georgia, serif;
    font-size: 1.25rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.discussion-drawer__close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 2.75rem;
    height: 2.5rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    color: var(--ink-soft);
    background: var(--surface);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.discussion-drawer__close:hover {
    border-color: var(--line-strong);
    color: var(--rust);
}

.discussion-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.discussion-drawer .thread-list {
    display: grid;
    gap: 0.8rem;
}

.discussion-drawer .thread-card {
    margin: 0;
    box-shadow: var(--shadow-sm);
}

.discussion-drawer .discussion-index-item__open {
    display: none;
}

.discussion-drawer [data-drawer-thread][hidden] {
    display: none !important;
}

.pagination {
    justify-content: flex-end;
    margin-top: 1.5rem;
}

@media (max-width: 52rem) {
    .q-diagram-gallery__header {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }

    .q-diagram-gallery__controls {
        justify-content: flex-start;
    }

    .workspace-header,
    .workspace-header__inner {
        min-height: 6.75rem;
    }

    .workspace-header__inner {
        grid-template-columns: 1fr auto;
        grid-template-rows: 3.6rem auto;
        padding: 0 1.25rem 0.7rem;
    }

    .workspace-header__inner nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        justify-content: center;
    }

    .workspace-header--anonymous,
    .workspace-header--anonymous .workspace-header__inner {
        min-height: 4.25rem;
    }

    .workspace-header--anonymous .workspace-header__inner {
        grid-template-columns: 1fr;
        grid-template-rows: 4.25rem;
        padding-bottom: 0;
    }

    dialog.discussion-drawer {
        inset-block-start: 6.75rem;
        height: calc(100dvh - 6.75rem);
    }

    dialog.page-links-drawer {
        inset-block-start: 6.75rem;
        height: calc(100dvh - 6.75rem);
    }

    .panel-heading {
        align-items: start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .panel-heading > p {
        text-align: left;
    }

    .upload-form,
    .inline-fields-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .upload-form .validation-summary,
    .inline-fields-form .validation-summary {
        grid-column: auto;
    }

    .upload-form .primary-action,
    .inline-fields-form .primary-action {
        width: 100%;
    }

    .data-table-shell {
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr {
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        margin-bottom: 0.8rem;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 0.5rem;
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .data-table th,
    .data-table td {
        display: grid;
        grid-template-columns: 6rem minmax(0, 1fr);
        gap: 1rem;
        width: 100% !important;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #e7e3da;
        text-align: left;
    }

    .data-table [data-label]::before {
        align-self: start;
        color: var(--ink-faint);
        content: attr(data-label);
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .data-table .table-action {
        text-align: left;
    }

    .data-table .table-action form,
    .data-table .table-action button {
        width: 100%;
    }

    .asset-name-cell {
        min-width: 0;
    }

    .asset-download {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .revision-card {
        grid-template-columns: 2.7rem minmax(0, 1fr);
    }

    .revision-card__actions {
        grid-column: 2;
        justify-self: start;
    }

    .comparison-range {
        grid-template-columns: minmax(0, 1fr);
    }

    .comparison-arrow {
        justify-self: center;
        transform: rotate(90deg);
    }
}

@media (max-width: 40rem) {
    .q-diagram > figcaption {
        grid-template-columns: minmax(0, 1fr);
    }

    .q-diagram-actions {
        grid-column: 1;
        grid-row: auto;
        margin-top: 0.25rem;
    }

    .q-diagram-action {
        flex: 1;
    }

    .q-diagram-gallery__header {
        max-height: 46dvh;
        padding-inline: 0.8rem;
        overflow-y: auto;
    }

    .q-diagram-gallery__description {
        display: none;
    }

    .q-diagram-gallery__controls {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        width: 100%;
    }

    .q-diagram-gallery__controls > * {
        width: 100%;
    }

    .q-diagram-gallery__divider {
        display: none;
    }

    .q-diagram-gallery__control,
    .q-diagram-gallery__close {
        grid-column: span 2;
    }

    .q-diagram-gallery__zoom {
        grid-column: span 2;
    }

    .identity > span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .page-tree li {
        margin-left: min(calc(var(--depth) * 0.75rem), 2.25rem);
        padding-left: 0;
    }

    .page-tree a {
        align-items: flex-start;
        padding-inline: 1rem;
    }

    .page-tree strong {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .page-tree .status-pill {
        flex: 0 0 auto;
    }

    .document-workspace {
        width: calc(100% - 2rem);
        padding: 2rem 0 5rem;
    }

    .document-context {
        align-items: stretch;
        flex-direction: column;
        gap: 0.65rem;
        margin-bottom: 1.75rem;
    }

    .document-context-actions,
    .document-context__actions,
    .document-tools {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        margin-left: 0;
    }

    .document-context-actions a,
    .document-context-actions button,
    .document-context__actions a,
    .document-tools a {
        min-width: 0;
        padding: 0.5rem 0.35rem;
        overflow: hidden;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .document-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 1.25rem;
        margin-bottom: 3rem;
    }

    .document-header > .button-row {
        width: 100%;
    }

    .document-header > .button-row > * {
        flex: 1 1 0;
    }

    .document-header > .button-row form button {
        width: 100%;
    }

    .discussion-summary-bar {
        align-items: flex-start;
        flex-direction: column;
        margin: -1rem 0 2.5rem;
    }

    .discussion-summary-bar__action,
    .discussion-summary-bar > a {
        align-self: stretch;
        padding-top: 0.35rem;
        border-top: 1px solid var(--line);
        text-align: right;
    }

    .annotation-indicators {
        align-items: stretch;
        flex-direction: column;
    }

    .annotation-indicator,
    .annotation-inline {
        width: 100%;
        border-radius: 0.35rem;
    }

    .annotation-indicator__excerpt,
    .annotation-inline__excerpt {
        max-width: none;
    }

    .annotation-inline__meta {
        margin-left: auto;
    }

    .page-discussion > header,
    .discussion-footer__header {
        align-items: flex-start;
        flex-direction: column;
    }

    .discussion-footer__header > p {
        text-align: left;
    }

    dialog.discussion-drawer {
        inset: 0;
        width: 100%;
        height: 100dvh;
        border-left: 0;
    }

    dialog.page-links-drawer {
        inset: 0;
        width: 100%;
        height: 100dvh;
        border-left: 0;
    }

    .discussion-drawer__header {
        min-height: max(4rem, calc(3rem + env(safe-area-inset-top)));
        padding-top: max(0.8rem, env(safe-area-inset-top));
    }

    .discussion-drawer__body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .page-links-drawer__header {
        min-height: max(4rem, calc(3rem + env(safe-area-inset-top)));
        padding-top: max(0.8rem, env(safe-area-inset-top));
    }

    .page-links-drawer__body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .page-link-graph-gallery__header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.65rem;
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }

    .page-link-graph-gallery__controls {
        width: 100%;
        justify-content: stretch;
    }

    .page-link-graph-gallery__controls > * {
        flex: 1 1 auto;
    }

    .page-title-row {
        align-items: start;
        flex-direction: column;
    }

    .page-title-row > .primary-action,
    .page-title-row > .secondary-action,
    .page-title-row > .button-row {
        width: 100%;
    }

    .page-title-row > .button-row > * {
        flex: 1;
    }

    dialog.settings-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    .settings-dialog__header,
    .settings-dialog__body {
        padding-inline: 1.1rem;
    }

    .settings-dialog__actions {
        align-items: stretch;
        flex-direction: column-reverse;
        padding-inline: 1.1rem;
    }

    .settings-dialog__actions > * {
        width: 100%;
    }

    .form-page,
    .content-page,
    .workspace-index,
    .space-page,
    .history-page,
    .discussions-page {
        width: min(100% - 2rem, 76rem);
    }

    .form-card,
    .panel {
        padding: 1.1rem;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .form-actions > * {
        width: 100%;
    }

    .section-heading {
        align-items: center;
        gap: 1rem;
    }

    .data-table th,
    .data-table td {
        grid-template-columns: 4.5rem minmax(0, 1fr);
    }

    .selection-comment-trigger {
        padding: 0.42rem 0.55rem;
        font-size: 0.72rem;
    }

    .revision-card {
        grid-template-columns: 2.25rem minmax(0, 1fr);
        gap: 0.8rem;
        padding: 1rem;
    }

    .revision-card__number {
        width: 2.25rem;
        height: 2.25rem;
    }

    .revision-card__heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.45rem;
    }

    .revision-card__meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.25rem;
    }

    .revision-card__meta > [aria-hidden="true"] {
        display: none;
    }

    .revision-card__actions {
        grid-column: 1 / -1;
        width: 100%;
    }

    .revision-card__actions a {
        width: 100%;
    }

    .comparison-stats {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .comparison-stat {
        text-align: center;
    }
}

@media print {
    .document-workspace {
        width: auto;
        padding: 0;
    }

    .document-context,
    .workspace-header,
    .document-header > .button-row,
    .q-diagram-actions,
    dialog.q-diagram-gallery,
    dialog.page-link-graph-gallery,
    dialog.settings-dialog,
    .page-link-map,
    .discussion-summary-bar,
    .annotation-indicators,
    .annotation-gutter,
    .discussion-footer,
    dialog.discussion-drawer,
    dialog.page-links-drawer {
        display: none !important;
    }

    .workspace-main {
        min-height: 0;
    }

    :where(a.q-external-link, a[rel~="external"])::after {
        content: " [" attr(href) "]";
        display: inline;
        margin-inline-start: 0;
        color: inherit;
        font-size: 0.72em;
        font-weight: 400;
        overflow-wrap: anywhere;
        vertical-align: baseline;
        white-space: normal;
        word-break: break-all;
    }

    .q-document .q-file::before {
        content: "Download:";
    }

    .q-table-scroll {
        overflow: visible;
        border-color: #999;
        box-shadow: none;
    }

    .q-document .q-table {
        min-width: 0;
        font-size: 8pt;
    }

    .q-document .q-table tr {
        break-inside: avoid;
    }

    .q-diagram-scroll {
        overflow: visible;
        border-color: #999;
        box-shadow: none;
    }

    .q-diagram-scroll svg {
        width: 100%;
        height: auto;
        max-width: 100%;
    }
}
