/* Optional Night appearance. Screen UI only; documents, images and PDF pixels
   retain their own colors. No filters, layout replacement or editor remount. */
body .latexdesk-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 8px 12px; border: 1px solid #889c91; border-radius: 4px;
  background: #fff; color: #124c3d; font: 600 13px/1.2 "Segoe UI", sans-serif;
  white-space: nowrap; cursor: pointer;
}
body .latexdesk-theme-toggle[hidden] { display: none !important; }
body .latexdesk-theme-toggle [data-latexdesk-theme-icon] { font: 22px/1 sans-serif; }
body .latexdesk-theme-toggle:focus-visible { outline: 3px solid #207b58; outline-offset: 3px; }
body .latexdesk-theme-toggle--login { margin: 0 0 20px auto; display: flex; width: fit-content; }
.latexdesk-workspace[data-workspace-focus-ready="true"] .latexdesk-toolbar {
  grid-template-columns: minmax(0, 1fr) 44px auto auto auto;
  grid-template-areas: "file appearance compile ai more";
}
.latexdesk-workspace[data-workspace-focus-ready="true"][data-files-collapsed="1"] .latexdesk-toolbar {
  grid-template-columns: auto minmax(0, 1fr) 44px auto auto auto;
  grid-template-areas: "navigation file appearance compile ai more";
}
body .latexdesk-workspace .latexdesk-theme-toggle--editor,
body .latexdesk-workspace .latexdesk-theme-toggle--tabs {
  grid-area: appearance; flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0;
}
.latexdesk-theme-toggle--editor .latexdesk-theme-toggle__label,
.latexdesk-theme-toggle--tabs .latexdesk-theme-toggle__label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
body .latexdesk-workspace .latexdesk-theme-toggle--tabs { display: none; }
@media (max-width: 960px) {
  body .latexdesk-workspace[data-workspace-focus-ready="true"] .latexdesk-theme-toggle--editor { display: none; }
  body .latexdesk-workspace[data-workspace-focus-ready="true"] .latexdesk-theme-toggle--tabs { display: inline-flex; }
  .latexdesk-workspace[data-workspace-focus-ready="true"] .latexdesk-mobile-workspace-tabs {
    grid-template-columns: 44px repeat(3, minmax(0, 1fr)) 44px;
    grid-template-areas: "menu files editor pdf appearance";
  }
  .latexdesk-workspace[data-workspace-focus-ready="true"] .latexdesk-mobile-workspace-tabs--home {
    grid-template-columns: 44px 44px repeat(3, minmax(0, 1fr)) 44px;
    grid-template-areas: "menu home files editor pdf appearance";
  }
}
@media screen {
  html[data-latexdesk-theme="dark"] { color-scheme: dark; background: #080b09; }
  html[data-latexdesk-theme="dark"] body:is(.ldj-stage--folio,.login) {
    --folio-green: #8be0b6; --folio-deep: #10281f; --folio-mint: #193629;
    --folio-paper: #111713; --folio-gray: #080b09; --folio-rule: #36463d;
    --folio-ink: #e5eee8; --folio-muted: #b0c0b6;
    --ldj-ink: var(--folio-ink); --ldj-muted: var(--folio-muted); --ldj-line: var(--folio-rule);
    --ldj-blue: var(--folio-green); --ldj-bg: var(--folio-gray); --ldj-surface: var(--folio-paper);
    --ldj-soft: #19231d; --ldj-control-line: #617b6b; --ldj-primary-dark: #216a4e;
    --appearance-action: #185b41; --appearance-hover: #236f51;
    --ld-login-blue: var(--folio-green); --ld-login-navy: var(--folio-deep);
    --ld-login-line: var(--folio-rule); --ld-login-muted: var(--folio-muted);
    background: var(--folio-gray); color: var(--folio-ink);
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.ldj-stage__main,.ldj-stage__header,.ldj-stage__footer,.ldj-stage__skip,.ldj-stage__editor-toolbar,.ldj-stage__overview-summary,.folio-workflow-links) {
    background: var(--folio-paper); color: var(--folio-ink); border-color: var(--folio-rule); box-shadow: none;
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--desk .ldj-stage__main { background: transparent; }
  html[data-latexdesk-theme="dark"] body.ldj-stage.ldj-stage--folio .ldj-stage__content > .latexdesk-journals { background: var(--folio-paper); color: var(--folio-ink); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-projects { --ldp-surface: var(--folio-paper); --ldp-primary: var(--folio-green); --ldp-primary-dark: var(--folio-green); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-projects__notice { background: #162b1e; color: #bbeacb; border-color: #548367; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.latexdesk-projects__notice.is-error,.latexdesk-plan-limit) { background: #351b1d; color: #ffc2c2; border-color: #bb7074; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-application {
    --ldj-app-ink: var(--folio-ink); --ldj-app-muted: var(--folio-muted); --ldj-app-green: var(--folio-green);
    --ldj-app-paper: var(--folio-paper); --ldj-app-soft: var(--ldj-soft); --ldj-app-line: var(--folio-rule); --ldj-app-danger: #ffc2c2;
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content .latexdesk-journals__submission-card { background: var(--folio-paper); color: var(--folio-ink); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-membership-request__status { background: var(--ldj-soft); color: var(--folio-ink); border-color: var(--ldj-control-line); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-team-inbox__link { background: var(--appearance-action); color: white; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-library { --ld-library-muted: var(--folio-muted); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.latexdesk-policy__content,.latexdesk-contact-card,.latexdesk-docs__toc a,.latexdesk-library__collections a,.latexdesk-library__preview,.latexdesk-library-card__link:hover) { background: var(--ldj-soft); color: var(--folio-ink); border-color: var(--folio-rule); box-shadow: none; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-library__collections span { color: var(--folio-muted); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-library__count { background: var(--ldj-soft); color: var(--folio-muted); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content section.latexdesk-journals.ldj-application .ldj-app-field :is(input,textarea,select) { background: #0b110d; color: var(--folio-ink); border-color: var(--ldj-control-line); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.ldj-submit-step-number,.ldj-app-step-number) { background: var(--ldj-soft); color: var(--folio-ink); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.ldj-submit-step,.ldj-app-progress-step):is(.is-current,.is-complete) :is(.ldj-submit-step-number,.ldj-app-step-number) { background: var(--appearance-action); color: white; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__notice { background: #16241c; color: #bed9c8; border-color: var(--folio-rule); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(h1,h2,h3,h4,h5,h6,legend,label) { color: var(--folio-ink); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.ldj-stage__role,.latexdesk-journals__status-badge,.ldj-board-journal__badge) { background: var(--ldj-soft); color: var(--folio-green); border-color: var(--ldj-control-line); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__mark { background: var(--appearance-action); color: white; box-shadow: 4px 4px 0 #264435; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__mark::after { border-top-color: var(--folio-paper); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__nav a[aria-current="page"] { background: #224533; color: #d2f7e1; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content :is(section,article,fieldset,details,.latexdesk-account-card,.latexdesk-team-panel,.latexdesk-team-inbox__card,.latexdesk-join-choice,.ldj-app-card,.latexdesk-project-card,.latexdesk-project-create,.latexdesk-plan-summary,.ldj-stage__plan-card,.latexdesk-journals__workflow-form,.latexdesk-journals__manuscript-information,.latexdesk-journals__status-card,.latexdesk-journals__section-card,.ldj-board-journal__identity,.ldj-board-journal__responsibilities,.latexdesk-template-card,.latexdesk-templates,.latexdesk-transfer,.latexdesk-docs__content,.latexdesk-policy,.latexdesk-public__page-header,.latexdesk-library-card,.folio-workflow-links,.folio-pricing-navigation a) {
    background: var(--folio-paper); color: var(--folio-ink); border-color: var(--folio-rule); box-shadow: none;
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content :is(.latexdesk-account-current-role,.latexdesk-workspace-selected,.latexdesk-join-current-account,.folio-service-note,.latexdesk-library__note,.latexdesk-template-feedback,.latexdesk-template-create,.latexdesk-ai-unavailable,.ldj-stage__plan-notice,.latexdesk-project-card__submission-note) { background: var(--ldj-soft); color: var(--folio-ink); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content :is(p,dt,dd,small,summary,th,td) { color: inherit; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(input,textarea,select,option,pre,code) { background: #0b110d; color: var(--folio-ink); border-color: var(--ldj-control-line); caret-color: #b4f2d0; }
  /* Journal desk field rules are more specific than the generic appearance rule. */
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content .latexdesk-journals :is(input,textarea,select,option) { background: #0b110d; color: var(--folio-ink); border-color: var(--ldj-control-line); caret-color: #b4f2d0; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content .latexdesk-journals :is(input[readonly],input:disabled,textarea[readonly]) { background: var(--ldj-soft); color: var(--folio-muted); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-setup-nav a { background: var(--ldj-soft); color: var(--folio-green); border-color: var(--folio-rule); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-setup-nav a[aria-current="page"] { background: var(--appearance-action); color: #f4fff7; border-color: #4d9c71; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(input,textarea)::placeholder { color: #a0b0a5; opacity: 1; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(input[readonly],input:disabled,textarea[readonly]) { background: var(--ldj-soft); color: var(--folio-muted); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio input::file-selector-button { background: #24372a; color: var(--folio-ink); border: 1px solid var(--ldj-control-line); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.ldj-stage__button,.latexdesk-join-button,.latexdesk-projects__primary-button,.latexdesk-projects__restore-button,.latexdesk-projects__download-button,.latexdesk-project-create__toggle,.latexdesk-journals__open-submission,.latexdesk-library__button,.folio-pricing-navigation a[aria-current="page"]) {
    background: var(--appearance-action); color: #f4fff7 !important; border-color: #4d9c71;
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage.ldj-stage--folio .ldj-stage__content button:not(:disabled):not([data-latexdesk-theme-toggle]) {
    background: var(--appearance-action); color: #f4fff7; border-color: #4d9c71;
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content button:not(:disabled):hover { background: var(--appearance-hover); color: white; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.latexdesk-projects__delete-warning,.latexdesk-projects__error,.latexdesk-journals__error,.ldj-error,.latexdesk-template-feedback--error) { background: #351b1d; color: #ffc2c2; border-color: #bb7074; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .ldj-stage__content .latexdesk-projects__delete-button { background: #8b3038; color: #fff; border-color: #df959c; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio .latexdesk-delete-project form { background: #351b1d; color: #ffc2c2; border-color: #bb7074; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(.latexdesk-project-card__icon,.latexdesk-project-card__engine,.latexdesk-archived-projects__count) { background: var(--ldj-soft); color: var(--folio-green); border-color: var(--folio-rule); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--folio :is(a:focus-visible,button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,summary:focus-visible) { outline-color: #a5ecc5; }

  /* Editor, including portaled menus, fallback textarea and optional AI drawer. */
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-workspace,dialog.latexdesk-workspace-menu,.latexdesk-ai-panel) {
    --ld-border: var(--folio-rule); --ld-muted: var(--folio-muted); --ld-primary: var(--folio-green);
    --ld-panel-bg: #080c09; --ld-toolbar-bg: #19231d; --ld-danger: #ffa9ab;
    --ld-ink: var(--folio-ink); --ld-text: var(--folio-ink); color: var(--folio-ink);
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-preview-panel__viewport,.latexdesk-preview-placeholder,.latexdesk-mobile-pdf) { background: #080b09; color: var(--folio-muted); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-errors { background: #311a1c; color: #ffc2c2; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-errors h3 { color: #ffc2c2; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-errors[data-severity="warning"] { background: #302818; color: #f5d799; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-errors[data-severity="warning"] h3 { color: #f5d799; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-compile-log,.latexdesk-compilation-problem) { background: #311a1c; color: #ffc2c2; border-color: #bb7074; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-compilation-problem h3 { color: #ffc2c2; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-compile-warning,.latexdesk-engine-recommendation) { background: #302818; color: #f5d799; border-color: #b49c61; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-editing-notice,.latexdesk-workspace-menu__ai-notice,.latexdesk-add-dialog,.latexdesk-mobile-editor-tools) { background: var(--ldj-soft); color: var(--folio-ink); border-color: var(--folio-rule); }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] :is(button,input,select,textarea),
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace-menu :is(button,a.latexdesk-workspace__back) {
    background: #17251c; color: #d6f3e0; border-color: #617b6b;
  }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] :is(button,a)[aria-current="true"],
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] .latexdesk-mobile-workspace-tabs button[aria-pressed="true"],
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] .latexdesk-add-choices button[aria-pressed="true"],
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] button[aria-selected="true"] { background: #274835; color: #e5ffee; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] :is([data-latexdesk-compile],.latexdesk-workspace-home),
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace-menu .latexdesk-workspace-menu__main-page { background: var(--appearance-action); color: white; border-color: #4d9c71; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] button:not(:disabled):hover { background: #274835; color: #e5ffee; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-workspace[data-workspace-endpoint] button:disabled { background: #1e2521; color: #94a499; border-color: #36463d; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-file-kind,.latexdesk-current-file__kind) { background: #20392b; color: #b5efcc; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-save-state[data-state="saved"],.latexdesk-compile-status.is-success) { color: #95e6b5; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-ai-diff pre,.latexdesk-ai-state.is-error,.latexdesk-ai-balance.is-exhausted) { background: #301c20; color: #f8c4cd; border-color: #a36976; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-ai-diff > div:last-child pre { background: #162b1e; color: #bbeacb; border-color: #548367; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-ai-panel__header,
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-ai-panel .is-primary,
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor .latexdesk-ai-proposal [data-latexdesk-ai-accept] { background: var(--appearance-action) !important; color: #fff !important; border-color: #4d9c71 !important; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(dialog,.latexdesk-ai-panel)::backdrop { background: #0009; }

  /* Original CodeMirror light palette remains the fallback in the bundle. */
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor {
    --ld-cm-keyword: #cfb5f5; --ld-cm-atom: #aaccff; --ld-cm-literal: #94e3b4;
    --ld-cm-string: #f4c18b; --ld-cm-escape: #f0c697; --ld-cm-definition: #aaccff;
    --ld-cm-local: #cdb8f3; --ld-cm-type: #91dfb8; --ld-cm-class: #91dbdf;
    --ld-cm-macro: #a6d9eb; --ld-cm-property: #aaccff; --ld-cm-comment: #a8b3ac; --ld-cm-invalid: #ffa9ab;
    background: #080c09; color: #e5eee8;
  }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor :is(.cm-editor,.cm-scroller,.cm-content) { background: #080c09; color: #e5eee8; caret-color: #bcf4d4; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-gutters { background: #101a14; color: #a7b7ad; border-color: #36463d; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor :is(.cm-activeLine,.cm-activeLineGutter) { background: #1b2b20; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-cursor { border-left-color: #bcf4d4; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-selectionBackground { background: #2c5740; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor ::selection { background: #2c5740; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor :is(.cm-panels,.cm-panel,.cm-tooltip,.cm-tooltip-autocomplete) { background: #19231d; color: #e5eee8; border-color: #617b6b; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor :is(.cm-textfield,.cm-button) { background: #0c140f; color: #e5eee8; border-color: #617b6b; background-image: none; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-searchMatch { background: #6b511e; outline: 1px solid #eac979; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-searchMatch-selected { background: #775525; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-matchingBracket { background: #2b5840; outline: 1px solid #8be0b6; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-nonmatchingBracket { background: #642e38; }
  html[data-latexdesk-theme="dark"] .latexdesk-smart-editor .cm-editor.cm-focused { outline-color: #8be0b6; }
  html[data-latexdesk-theme="dark"] body.ldj-stage--editor :is(.latexdesk-pdf-frame,.latexdesk-preview-panel iframe,.latexdesk-pdf-canvas) { color-scheme: light; background: white; }

  html[data-latexdesk-theme="dark"] body.login :is(#loginform,#registerform,#lostpasswordform,.message,#login_error,.success) { background: #111713; color: #e5eee8; border-color: #617b6b; box-shadow: none; }
  html[data-latexdesk-theme="dark"] body.login.latexdesk-login #login :is(#loginform,#registerform,#lostpasswordform) { border-color: #617b6b; box-shadow: 6px 6px 0 #264435; }
  html[data-latexdesk-theme="dark"] body.login :is(h1 a,#nav a,#backtoblog a,.privacy-policy-link,label,.dashicons) { color: #8be0b6 !important; }
  html[data-latexdesk-theme="dark"] body.login #login :is(input.input,input[type=password]) { background: #0b110d; color: #e5eee8; border-color: #617b6b; }
  html[data-latexdesk-theme="dark"] body.login.latexdesk-login #login .button-primary { background: #185b41 !important; color: white !important; border-color: #4d9c71 !important; }
  html[data-latexdesk-theme="dark"] body.login.latexdesk-login .latexdesk-login-intro strong { color: #e5eee8; }
  html[data-latexdesk-theme="dark"] body.login.latexdesk-login .latexdesk-login-intro span { color: #b0c0b6; }
  html[data-latexdesk-theme="dark"] body .latexdesk-theme-toggle,
  html[data-latexdesk-theme="dark"] body .latexdesk-workspace-menu .latexdesk-theme-toggle { background: #193629; color: #c1f4d7; border-color: #719880; }
  html[data-latexdesk-theme="dark"] body .latexdesk-theme-toggle:focus-visible { outline-color: #a5ecc5; }
}
@media print { body .latexdesk-theme-toggle { display: none !important; } }
