html,body{
    overflow:hidden;
}

.editScreen {
    position: fixed;
    top: 150px;
    bottom: 6%;
    left: 10%;
    width: 80%;
    display: flex;
    flex-direction: row;
    gap: 40px;
}

/* Panels (shared header + body) */

.editSidebar {
    width: 46%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
}

.documentsPanel,
.assistantPanel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.documentsPanel {
    flex: 1 1 0;
}

.assistantPanel {
    flex: 1.25 1 0;
}

.panelHeader {
    height: 70px;
    flex-shrink: 0;
    padding: 0 30px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f2f2f2;
    border-radius: 16px;
    box-shadow: 0px 7px 0px #9dc8aa;
    position: relative;
    z-index: 2;
}

.panelHeader h2 {
    white-space: nowrap;
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 1.5em;
    color: #004930;
    font-weight: 600;
    margin: unset;
}

.panelBody {
    flex: 1;
    min-height: 0;
    margin: -16px 10px 0;
    padding-top: 16px;
    background-color: #ffffff;
    border-radius: 0 0 16px 16px;
    overflow-y: auto;
}

.emptyMessage {
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 1.2em;
    color: #004930;
    font-weight: 400;
    text-align: center;
    margin: 40px 0;
    opacity: 0.6;
}

/* Export buttons */

.exportProjectButton {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 16px;
    padding: 8px 12px;
    background-color: #ffffff;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 0.95em;
    color: #004930;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.2s ease;
}

.exportProjectButton svg,
.exportDocumentButton svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: #004930;
}

.exportProjectButton:hover,
.exportDocumentButton:hover {
    transform: scale(1.05);
}

.exportDocumentButton {
    position: absolute;
    right: 24px;
    bottom: 24px;
    z-index: 4;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background-color: #004930;
    border: none;
    border-radius: 16px;
    box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.exportDocumentButton svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

.exportProjectButton:disabled,
.exportDocumentButton:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

.exportProjectButton.busy,
.exportDocumentButton.busy {
    opacity: 0.7;
    cursor: progress;
}

.exportDocumentButton.busy svg {
    animation: exportPulse 1s ease-in-out infinite;
}

@keyframes exportPulse {
    50% { transform: translateY(3px); }
}

/* Grid / list toggle */

.viewToggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.viewButton {
    display: flex;
    align-items: center;
    padding: 4px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.viewButton svg {
    width: auto;
    height: 18px;
}

.viewButton:hover {
    transform: scale(1.1);
}

.viewButton.active {
    opacity: 1;
}

/* Documents */

.documentList {
    padding: 20px;
}

.documentList.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.documentList.view-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.documentItem {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background-color: transparent;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 1em;
    color: #004930;
    font-weight: 400;
    text-align: center;
    transition: background-color 0.2s ease;
}

.documentItem:hover {
    background-color: #f2f2f2;
}

.documentItem.active {
    background-color: #d9e9de;
    font-weight: 700;
}

/* Thumbnail: PNG of the first page (modo-edicion.js); a blank page until it exists */
.documentThumb {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1.414;
    overflow: hidden;
    background-color: #ffffff;
    border-radius: 4px;
    box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.18);
}

.documentThumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

/* Where thumbnails are drawn: off-screen, one editor page (fixed margins, whatever the screen size) */
.thumbStage {
    position: fixed;
    top: 0;
    left: -10000px;
    pointer-events: none;
}

.thumbStage .thumbRender {
    width: 560px;
    max-width: none;
    height: 792px;
    padding: 60px 55px;
    overflow: hidden;
    box-shadow: none;
}

.documentTitle {
    overflow-wrap: break-word;
    hyphens: auto;
}

.view-list .documentItem {
    flex-direction: row;
    gap: 14px;
    padding: 10px 16px;
    text-align: left;
}

.view-list .documentThumb {
    width: 24px;
    flex-shrink: 0;
    border-radius: 2px;
}

/* Assistant chat */

.assistantPanel .panelBody {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatMessages {
    position: relative; /* offsetTop of each message is measured from here (scroll to a reply's top) */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 30px 30px 10px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatMessage {
    max-width: 75%;
    padding: 14px 20px;
    background-color: #f2f2f2;
    border-radius: 16px;
}

.chatMessage.bot {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background-color: #a4d3a7;
}

.chatMessage.user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatMessage p {
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 1.05em;
    color: #004930;
    font-weight: 400;
    margin: unset;
    white-space: pre-wrap;
}

/* Assistant replies rendered from Markdown */

.chatText {
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 1.05em;
    color: #004930;
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.chatMessage .chatText p {
    font-size: 1em;
    white-space: normal;
}

.chatText > * {
    margin-top: 0;
}

.chatText > * + * {
    margin-top: 0.6em;
}

.chatText h3,
.chatText h4,
.chatText h5,
.chatText h6 {
    margin-bottom: 0;
    font-family: 'Source Sans 3';
    color: #004930;
    font-weight: 700;
    line-height: 1.25;
}

.chatText h3 { font-size: 1.2em; }
.chatText h4 { font-size: 1.1em; }
.chatText h5,
.chatText h6 { font-size: 1em; }

.chatText strong {
    font-weight: 700;
}

.chatText ul,
.chatText ol {
    margin-bottom: 0;
    padding-left: 1.3em;
}

.chatText li + li,
.chatText li > ul,
.chatText li > ol,
.chatText li > p {
    margin-top: 0.3em;
}

.chatText a {
    color: #004930;
    text-decoration: underline;
}

.chatText code {
    padding: 1px 5px;
    background-color: rgba(255, 255, 255, 0.55);
    border-radius: 4px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9em;
}

.chatText pre {
    margin-bottom: 0;
    padding: 10px 12px;
    background-color: rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    overflow-x: auto;
}

.chatText pre code {
    padding: 0;
    background: none;
    white-space: pre;
}

.chatText blockquote {
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    padding-left: 12px;
    border-left: 3px solid #004930;
}

.chatText hr {
    margin-bottom: 0;
    border: none;
    border-top: 1px solid rgba(0, 73, 48, 0.3);
}

.chatTable {
    overflow-x: auto;
}

.chatText table {
    border-collapse: collapse;
    font-size: 0.95em;
}

.chatText th,
.chatText td {
    padding: 5px 10px;
    border: 1px solid rgba(0, 73, 48, 0.3);
    text-align: left;
    vertical-align: top;
}

.chatText th {
    font-weight: 700;
    background-color: rgba(255, 255, 255, 0.4);
}

.chatForm {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 10px 30px 24px;
    padding: 6px 6px 6px 22px;
    background-color: #f2f2f2;
    border-radius: 30px;
}

.chatForm textarea {
    flex: 1;
    max-height: 120px;
    box-sizing: border-box;
    padding: 9px 0;
    background-color: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 1.05em;
    color: #004930;
    font-weight: 400;
}

.chatSend {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chatSend:hover {
    transform: scale(1.1);
}

.chatSend svg {
    width: 20px;
    height: 20px;
}

/* Open document */

.documentPanel {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: #f2f2f2;
    border-radius: 16px;
}

.documentScroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 40px 50px;
    box-sizing: border-box;
}

.documentPage {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1.414;
    flex-shrink: 0;
    padding: 60px 55px;
    box-sizing: border-box;
    background-color: #ffffff;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.12);
    cursor: text;
}

/* Editor toolbar */

.editorToolbar {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 14px 14px 0;
    padding: 8px 10px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0px 4px 0px #9dc8aa;
    position: relative;
    z-index: 3;
}

.editorToolbar.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.tbSelect,
.tbFontSize input {
    height: 34px;
    box-sizing: border-box;
    padding: 0 10px;
    background-color: #f2f2f2;
    border: 2px solid #f2f2f2;
    border-radius: 8px;
    outline: none;
    font-family: 'Source Sans 3';
    text-decoration: unset;
    font-size: 0.95em;
    color: #004930;
    font-weight: 600;
    cursor: pointer;
}

.tbSelect:focus,
.tbFontSize input:focus {
    border-color: #004930;
}

.tbBlock {
    width: 128px;
}

.tbFont {
    width: 150px;
}

.tbFontSize {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tbFontSize input {
    width: 42px;
    padding: 0;
    text-align: center;
    cursor: text;
}

.tbButton {
    position: relative;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 1.2em;
    font-weight: 700;
    color: #004930;
    transition: background-color 0.15s ease;
}

.tbButton svg {
    width: 18px;
    height: 18px;
    fill: #004930;
}

.tbButton:hover,
.tbButton.open {
    background-color: #f2f2f2;
}

.tbButton.active {
    background-color: #d9e9de;
}

.tbColorButton svg {
    margin-bottom: 4px;
}

.tbColorBar {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 5px;
    height: 4px;
    border-radius: 2px;
}

.tbColorBar.empty {
    box-shadow: inset 0 0 0 1px #cccccc;
}

.tbSeparator {
    width: 1px;
    height: 22px;
    flex-shrink: 0;
    margin: 0 4px;
    background-color: #cccccc;
}

.saveStatus {
    margin-left: auto;
    padding: 0 6px;
    font-family: 'Source Sans 3';
    font-size: 0.9em;
    color: #004930;
    font-weight: 400;
    opacity: 0.7;
    white-space: nowrap;
}

.saveStatus[data-state="error"] {
    opacity: 1;
    font-weight: 700;
}

/* Popovers (colour, link) */

.tbPopover {
    position: absolute;
    z-index: 10;
    padding: 14px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.18);
    font-family: 'Source Sans 3';
    color: #004930;
}

.colorPopover {
    width: 268px;
}

.colorReset {
    width: 100%;
    padding: 8px 10px;
    background-color: #f2f2f2;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 0.95em;
    font-weight: 600;
    color: #004930;
    text-align: left;
}

.colorReset:hover {
    background-color: #d9e9de;
}

.popoverLabel {
    margin: 12px 0 6px;
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.colorGrid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
}

.colorSwatch {
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.colorSwatch:hover {
    transform: scale(1.2);
}

.colorCustom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
}

.colorCustom input[type="color"] {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    padding: 2px;
    background-color: #f2f2f2;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.colorCustom input[type="text"],
.linkPopover input {
    flex: 1;
    min-width: 0;
    height: 34px;
    box-sizing: border-box;
    padding: 0 10px;
    background-color: #f2f2f2;
    border: 2px solid #f2f2f2;
    border-radius: 8px;
    outline: none;
    font-family: 'Source Sans 3';
    font-size: 0.95em;
    color: #004930;
    font-weight: 600;
}

.colorCustom input[type="text"]:focus,
.linkPopover input:focus {
    border-color: #004930;
}

.colorCustom input.invalid {
    border-color: #cc0000;
}

.colorCustom button,
.linkActions button {
    height: 34px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 0.95em;
    font-weight: 700;
    background-color: #004930;
    color: #ffffff;
    transition: transform 0.15s ease;
}

.colorCustom button:hover,
.linkActions button:hover {
    transform: scale(1.05);
}

.linkPopover {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.linkPopover label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85em;
    font-weight: 700;
}

.linkError {
    margin: 0;
    font-size: 0.85em;
    color: #cc0000;
}

.linkActions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.linkActions .linkRemove {
    background-color: #f2f2f2;
    color: #004930;
}

/* Selection menu (AI actions) and link bubble */

.selectionMenu,
.linkBubble {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0px 6px 18px rgba(0, 0, 0, 0.18);
    font-family: 'Source Sans 3';
}

.selectionMenu button,
.linkBubble button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 0.9em;
    font-weight: 600;
    color: #004930;
    white-space: nowrap;
}

.selectionMenu button:hover,
.linkBubble button:hover {
    background-color: #f2f2f2;
}

.selectionMenu svg {
    width: 16px;
    height: 16px;
    fill: #004930;
}

.selectionMenu .selectionMenuAssistant {
    background-color: #d9e9de;
}

/* Tiptap sets visibility inline on the menus, hence !important */
.selectionMenu.suppressed,
.linkBubble.suppressed {
    visibility: hidden !important;
}

.selectionMenuSeparator {
    width: 1px;
    height: 20px;
    margin: 0 2px;
    background-color: #cccccc;
}

.linkBubbleUrl {
    max-width: 220px;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9em;
    color: #004930;
}

/* Document content (until templates provide their own styles) */

.documentPage .ProseMirror {
    min-height: 100%;
    outline: none;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #000000;
    overflow-wrap: anywhere;
}

.documentPage .ProseMirror > :first-child {
    margin-top: 0;
}

.documentPage .ProseMirror p {
    margin: 0 0 0.6em;
}

.documentPage .ProseMirror h1 { font-size: 20pt; margin: 0.8em 0 0.4em; }
.documentPage .ProseMirror h2 { font-size: 16pt; margin: 0.8em 0 0.4em; }
.documentPage .ProseMirror h3 { font-size: 14pt; margin: 0.8em 0 0.4em; }
.documentPage .ProseMirror h4 { font-size: 12pt; margin: 0.8em 0 0.4em; }
.documentPage .ProseMirror h5 { font-size: 11pt; margin: 0.8em 0 0.4em; }
.documentPage .ProseMirror h6 { font-size: 10pt; margin: 0.8em 0 0.4em; text-transform: uppercase; }

.documentPage .ProseMirror .textSmall {
    font-size: 9pt;
}

.documentPage .ProseMirror a {
    color: #1155cc;
    text-decoration: underline;
    cursor: text;
}

.documentPage .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    height: 0;
    color: #999999;
    pointer-events: none;
}

.chatMessage.failed {
    box-shadow: inset 0 0 0 2px #cc0000;
}

/* Version history */

.tbVersions {
    width: auto;
    gap: 6px;
    padding: 0 10px;
    font-size: 0.95em;
    font-weight: 600;
}

/* Expanded editor (toolbar button): Documentos and Asistente hidden, the document panel fills the screen area */
.tbExpand .iconCollapse,
.editorExpanded .tbExpand .iconExpand {
    display: none;
}

.editorExpanded .tbExpand .iconCollapse {
    display: block;
}

.editScreen.editorExpanded .editSidebar {
    display: none;
}

.editScreen.editorExpanded .documentPanel {
    flex: 1;
    width: 100%;
}

.versionsOpen {
    overflow: hidden;
}

.versionsModal {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background-color: rgba(0, 30, 16, 0.45);
}

.versionsModal[hidden] {
    display: none;
}

.versionsDialog {
    position: relative;
    width: 100%;
    max-width: 860px;
    height: 100%;
    max-height: 880px;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0px 16px 48px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    font-family: 'Source Sans 3';
    color: #004930;
}

.versionsHeader {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 70px;
    padding: 10px 20px 10px 30px;
    box-sizing: border-box;
    background-color: #f2f2f2;
    border-radius: 16px;
    box-shadow: 0px 7px 0px #9dc8aa;
    position: relative;
    z-index: 2;
}

.versionsHeading {
    flex: 1;
    min-width: 0;
}

.versionsHeading h2 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
}

.versionsSubtitle {
    margin: 0;
    font-size: 0.95em;
    opacity: 0.75;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.versionsBack,
.versionsClose {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background-color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.versionsBack:hover,
.versionsClose:hover {
    transform: scale(1.1);
}

.versionsDialog button:focus-visible {
    outline: 2px solid #004930;
    outline-offset: 2px;
}

.versionsBack svg,
.versionsClose svg {
    width: 20px;
    height: 20px;
    fill: #004930;
}

.versionsBody {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 30px;
}

.versionsMessage {
    margin: 30px 0;
    text-align: center;
    font-size: 1.05em;
    opacity: 0.7;
}

.versionsMessage.error,
.versionsError {
    color: #cc0000;
    opacity: 1;
}

.versionsList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.versionItem {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "head view" "excerpt view";
    align-items: center;
    gap: 4px 16px;
    width: 100%;
    padding: 14px 18px;
    background-color: #f2f2f2;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    font-family: 'Source Sans 3';
    color: #004930;
    transition: background-color 0.2s ease;
}

.versionItem:hover {
    background-color: #d9e9de;
}

.versionItemHead {
    grid-area: head;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    font-size: 1.05em;
}

.versionItemHead span {
    font-size: 0.9em;
    opacity: 0.75;
}

.versionItemExcerpt {
    grid-area: excerpt;
    font-size: 0.95em;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.versionItemView {
    grid-area: view;
    padding: 6px 14px;
    background-color: #ffffff;
    border-radius: 16px;
    font-weight: 700;
}

.versionsPreview {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.versionsPage {
    cursor: default;
}

.versionsReadOnly {
    user-select: text;
}

.versionsFooter {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px 16px;
    padding: 16px 30px;
    border-top: 1px solid #f2f2f2;
}

.versionsFooter[hidden],
.versionsError[hidden],
.versionsBack[hidden] {
    display: none;
}

.versionsRestore {
    padding: 10px 22px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 1.05em;
    font-weight: 700;
    transition: transform 0.2s ease;
}

.versionsRestore {
    background-color: #004930;
    color: #ffffff;
}

.versionsRestore:hover {
    transform: scale(1.05);
}

.versionsRestore:disabled {
    opacity: 0.6;
    cursor: progress;
    transform: none;
}

.versionsError {
    margin: 0;
    font-size: 0.95em;
}

/* Linked fields (answers to form questions inside documents) */

.docField {
    padding: 0 3px;
    background-color: #d9e9de;
    border-bottom: 1px dashed #004930;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.docFieldBlock {
    margin: 0 0 0.6em;
    padding: 6px 10px;
    background-color: #eef6f0;
    border-left: 3px solid #009960;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.docFieldBlock p {
    margin: 0 0 0.3em;
}

.docFieldBlock p:last-child {
    margin-bottom: 0;
}

.docField:hover,
.docFieldBlock:hover {
    background-color: #c4e0cc;
}

/* Still to fill in: same cyan the source documents use for "información a rellenar" */
.docField.empty,
.docFieldBlock.empty {
    background-color: #c9f1f7;
    border-color: #0b8ea3;
    color: #0a6575;
    font-style: italic;
}

.docField.empty:hover,
.docFieldBlock.empty:hover {
    background-color: #a8e6f0;
}

.docField.unknown,
.docFieldBlock.unknown {
    background-color: #fde2e2;
    border-color: #cc0000;
}

.ProseMirror-selectednode.docField,
.ProseMirror-selectednode.docFieldBlock {
    outline: 2px solid #004930;
    outline-offset: 1px;
}

/* Previews and exports render fields as plain spans/divs */
.versionsReadOnly .docField,
.versionsReadOnly .docFieldBlock {
    cursor: default;
}

.fieldPopover {
    width: 360px;
    max-width: calc(100% - 16px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fieldPopoverStep {
    margin: 0;
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.7;
}

.fieldPopoverLabel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    font-size: 0.95em;
    font-weight: 700;
}

.fieldPopoverInput {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background-color: #f2f2f2;
    border: 2px solid #f2f2f2;
    border-radius: 8px;
    outline: none;
    font-family: 'Source Sans 3';
    font-size: 1em;
    color: #004930;
    font-weight: 600;
}

textarea.fieldPopoverInput {
    resize: vertical;
    min-height: 110px;
}

.fieldPopoverInput:focus {
    border-color: #004930;
}

.fieldPopoverError {
    margin: 0;
    font-size: 0.85em;
    color: #cc0000;
}

.fieldPopoverActions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.fieldPopoverForm {
    font-size: 0.9em;
    color: #004930;
    font-weight: 600;
}

.fieldPopoverActions button {
    height: 34px;
    padding: 0 16px;
    background-color: #004930;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 0.95em;
    font-weight: 700;
    color: #ffffff;
    transition: transform 0.15s ease;
}

.fieldPopoverActions button:hover {
    transform: scale(1.05);
}

.fieldPopoverActions button:disabled {
    opacity: 0.6;
    cursor: progress;
    transform: none;
}

.editorNotice {
    position: absolute;
    left: 50%;
    bottom: 90px;
    z-index: 6;
    max-width: 80%;
    padding: 10px 16px;
    transform: translateX(-50%);
    background-color: #004930;
    border-radius: 12px;
    box-shadow: 0px 6px 18px rgba(0, 0, 0, 0.2);
    font-family: 'Source Sans 3';
    font-size: 0.95em;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
}

.editorNotice[hidden] {
    display: none;
}

/* Tables in documents */

.documentPage .ProseMirror .tableWrapper {
    overflow-x: auto;
    margin: 0.6em 0 1em;
}

.documentPage .ProseMirror table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0.6em 0 1em;
    font-size: 9.5pt;
}

.documentPage .ProseMirror .tableWrapper table {
    margin: 0;
}

.documentPage .ProseMirror th,
.documentPage .ProseMirror td {
    padding: 4px 6px;
    border: 1px solid #bbbbbb;
    vertical-align: top;
    text-align: left;
    overflow-wrap: anywhere;
}

.documentPage .ProseMirror th {
    background-color: #f2f2f2;
    font-weight: 700;
}

.documentPage .ProseMirror th p,
.documentPage .ProseMirror td p {
    margin: 0;
}

.documentPage .ProseMirror .selectedCell {
    background-color: #d9e9de;
}

/* Confirmation dialog (e.g. downloading with fields still to fill in) */

.confirmModal {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: rgba(0, 30, 16, 0.45);
}

.confirmBox {
    max-width: 420px;
    padding: 26px 28px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0px 16px 48px rgba(0, 0, 0, 0.25);
    font-family: 'Source Sans 3';
    color: #004930;
}

.confirmBox p {
    margin: 0 0 20px;
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.4;
}

.confirmActions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.confirmActions button {
    padding: 10px 20px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 1.05em;
    font-weight: 700;
    transition: transform 0.2s ease;
}

.confirmActions button:hover {
    transform: scale(1.05);
}

.confirmActions button:focus-visible {
    outline: 2px solid #004930;
    outline-offset: 2px;
}

.confirmCancel {
    background-color: #f2f2f2;
    color: #004930;
}

.confirmAccept {
    background-color: #004930;
    color: #ffffff;
}

/* Assistant: typing indicator, highlighted selection, "¿Aplicar?" */

.chatMessage.typing p {
    opacity: 0.6;
    font-style: italic;
    animation: chatTyping 1.2s ease-in-out infinite;
}

@keyframes chatTyping {
    50% { opacity: 0.25; }
}

.chatQuote {
    padding: 12px 16px;
    background-color: #fff2cc;
    border-left: 4px solid #e6b800;
    border-radius: 12px;
}

.chatQuote span {
    display: block;
    margin-bottom: 4px;
    font-family: 'Source Sans 3';
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #004930;
    opacity: 0.75;
}

.chatQuote p {
    margin: 0;
    max-height: 220px;
    overflow-y: auto;
    font-family: 'Source Sans 3';
    font-size: 1em;
    color: #004930;
    white-space: pre-wrap;
}

.chatApply {
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 12px 16px;
    background-color: #ffffff;
    border: 2px solid #004930;
    border-radius: 16px;
    font-family: 'Source Sans 3';
    color: #004930;
}

.chatApply p {
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
}

.chatApply.done {
    border-color: #009960;
}

.chatApplyActions {
    display: flex;
    gap: 8px;
}

.chatApplyActions button {
    padding: 7px 16px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Source Sans 3';
    font-size: 0.95em;
    font-weight: 700;
    transition: transform 0.2s ease;
}

.chatApplyActions button:hover {
    transform: scale(1.05);
}

.chatApplyActions button:disabled {
    opacity: 0.6;
    cursor: progress;
    transform: none;
}

.chatApplyNo {
    background-color: #f2f2f2;
    color: #004930;
}

.chatApplyYes {
    background-color: #004930;
    color: #ffffff;
}

.chatSend:disabled {
    opacity: 0.5;
    cursor: progress;
    transform: none;
}

/* Responsive */

/* Short screens: keep the panels clear of the fixed header */
@media (max-height: 650px) {
    .editScreen {
        top: 110px;
        bottom: 16px;
    }
}

@media (max-width: 1200px) {
    .editScreen {
        gap: 24px;
    }

    .exportProjectButton {
        padding: 8px;
        margin-right: 16px;
    }

    .exportProjectButton span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .panelHeader h2 {
        font-size: 1.3em;
    }

    .documentList.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .documentScroll {
        padding: 24px 24px 40px;
    }

    .documentPage {
        padding: 40px 36px;
    }
}

@media (max-width: 1024px) {
    .editScreen {
        left: 5%;
        width: 90%;
        gap: 16px;
    }

    .editSidebar {
        width: 48%;
        gap: 16px;
    }

    .panelHeader {
        padding: 0 20px;
    }

    .panelHeader h2 {
        font-size: 1.15em;
    }

    .viewToggle {
        gap: 12px;
    }

    .viewButton svg {
        height: 18px;
    }

    .documentList {
        padding: 14px;
    }

    .documentList.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
        gap: 10px;
    }

    .documentItem {
        font-size: 0.95em;
        padding: 8px;
    }

    .chatMessages {
        padding: 24px 16px 10px;
    }

    .chatMessage {
        max-width: 85%;
        padding: 12px 16px;
    }

    .chatForm {
        margin: 10px 16px 16px;
    }

    .documentScroll {
        padding: 20px 16px 30px;
    }

    .tbFont {
        width: 120px;
    }
}

/* Mobile: one scrolling column (documents, open document, assistant) */
@media (max-width: 768px) {
    .editScreen {
        top: 110px;
        bottom: 16px;
        left: 16px;
        width: calc(100% - 32px);
        flex-direction: column;
        gap: 16px;
        overflow-y: auto;
    }

    .editSidebar {
        display: contents;
    }

    .documentsPanel {
        order: 1;
        flex: 0 0 auto;
        height: 300px;
    }

    .documentPanel {
        order: 2;
        flex: 0 0 auto;
    }

    .documentScroll {
        overflow: visible;
    }

    /* Toolbar scrolls sideways instead of wrapping; stays visible while scrolling the page */
    .editorToolbar {
        position: sticky;
        top: 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 10px 10px 0;
    }

    .saveStatus {
        padding-left: 10px;
    }

    .assistantPanel {
        order: 3;
        flex: 0 0 auto;
        height: 440px;
    }

    .panelHeader {
        height: 60px;
        padding: 0 16px;
    }

    .panelHeader h2 {
        font-size: 1.1em;
    }

    .exportDocumentButton {
        position: sticky;
        right: auto;
        bottom: 16px;
        align-self: flex-end;
        margin: -68px 16px 16px 0;
        width: 48px;
        height: 48px;
    }

    .documentPage {
        padding: 30px 24px;
    }
}

@media (max-width: 480px) {
    .versionsModal {
        padding: 0;
    }

    .versionsDialog {
        max-height: none;
        border-radius: 0;
    }

    .versionsHeader {
        padding: 10px 12px 10px 16px;
        border-radius: 0 0 16px 16px;
    }

    .versionsBody {
        padding: 20px 14px;
    }

    .versionsFooter {
        padding: 12px 14px;
    }

    .versionsRestore {
        width: 100%;
    }

    .versionItem {
        grid-template-columns: 1fr;
        grid-template-areas: "head" "excerpt" "view";
    }

    .versionItemView {
        justify-self: start;
    }

    .tbVersions span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .tbVersions {
        width: 34px;
        padding: 0;
    }

    .documentList.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    }

    .documentItem {
        font-size: 0.9em;
    }

    .chatMessage p,
    .chatText,
    .chatForm textarea {
        font-size: 1em;
    }

    .documentPage {
        padding: 24px 18px;
    }
}
