Skip to content

Build your personal knowledge base with Trilium Notes

89.0 KB
Raw Blame
@import "./boxicons-compat.css";
@import "./adaptive-colors.css";
@import "./menus.css";
@import "./buttons.css";
@import "./zen.css";

@font-face {
    font-family: Montserrat;
    src: url(../fonts/Montserrat-Light.woff2) format("woff2");
    font-weight: normal;
}

@font-face {
    font-family: Montserrat;
    src: url(../fonts/Montserrat-SemiBold.woff2) format("woff2");
    font-weight: bold;
}

@font-face {
    font-family: JetBrainsLight;
    src: url(../fonts/JetBrainsMono-Light.woff2) format("woff");
}

:root {
    --bs-body-font-family: var(--main-font-family) !important;
    --bs-body-font-weight: var(--main-font-weight) !important;
    --bs-body-color: var(--main-text-color) !important;
    --bs-body-bg: var(--main-background-color) !important;
    --tn-modal-max-height: 90svh;

    --tree-item-light-theme-max-color-lightness: 50;
    --tree-item-dark-theme-min-color-lightness: 75;
}

body#trilium-app.motion-disabled *,
body#trilium-app.motion-disabled *::before,
body#trilium-app.motion-disabled *::after {
    /* Disable transitions and animations */
    transition: none !important;
    animation: none !important;
}

body#trilium-app.shadows-disabled *,
body#trilium-app.shadows-disabled *::before,
body#trilium-app.shadows-disabled *::after {
    /* Disable shadows */
    box-shadow: none !important;
}

body#trilium-app.backdrop-effects-disabled *,
body#trilium-app.backdrop-effects-disabled *::before,
body#trilium-app.backdrop-effects-disabled *::after {
    /* Disable backdrop effects */
    backdrop-filter: none !important;
}

.table {
    --bs-table-bg: transparent !important;
    --bs-table-border-color: var(--main-border-color);
    --bs-table-striped-bg: color-mix(in srgb, var(--main-text-color) 5%, transparent);
    --bs-table-striped-color: var(--main-text-color);
}

:root {
    --submenu-opening-delay: 250ms;
    --modal-control-button-size: 22px;
    --launcher-pane-size: 53px;
    --bs-body-color: var(--main-text-color);
    /* What a menu, the sidebar or a dialog dims the page behind it with in the phone layout. */
    --mobile-backdrop-color: rgba(0, 0, 0, 0.5);
    --mobile-modal-backdrop-color: var(--mobile-backdrop-color);
}

html {
    /* this fixes FF filter vs. position fixed bug: https://github.com/zadam/trilium/issues/233 */
    height: 100vh;
    /* Chrome on Android sizes `vh` without its toolbar, which leaves the page that much to scroll. */
    height: 100dvh;
    overscroll-behavior: none;
}

/* iOS 26 gives a web app added to the home screen a dynamic viewport short by the status bar until
   the first rotation (WebKit bug 301108); the large viewport is the screen's height from the start.
   `bootstrap()` sets the class only when the page runs under the status bar. */
html.ios-web-app,
html.ios-web-app body,
html.ios-web-app #root-widget {
    height: 100lvh !important;
}

body {
    /* Fix for CKEditor block gutter icon "stretching" body and causing scrollbar to appear after pressing enter
        on the last line of the editor. */
    position: fixed;
    width: 100vw;
    height: 100vh;
    background-color: var(--main-background-color);
    color: var(--main-text-color);
    font-family: var(--main-font-family);
    font-size: var(--main-font-size);

    --native-titlebar-foreground: var(--main-text-color);
    --native-titlebar-darwin-x-offset: 10;
    --native-titlebar-darwin-y-offset: 12;
    --launcher-pane-height: 53px;
    --tab-bar-height: 40px;
    --mobile-bottom-offset: var(--safe-area-inset-bottom, env(safe-area-inset-bottom));
}

/*
 * Height of the Window Controls Overlay. Chromium centres the caption buttons within it, so this
 * is the only way to shift them vertically -- there is no x/y equivalent to macOS'
 * setWindowButtonPosition(). Set it to twice the centre line of the tab bar's own buttons so the
 * two line up; themes that place those buttons differently (see theme-next) need their own value.
 *
 * Scoped to Linux on purpose. Windows also supports the overlay, but leaving the variable unset
 * there keeps Chromium's system caption height, whose taller hover fills would otherwise spill
 * past the tab bar. Dropping the scope is fine once the result has actually been looked at on
 * Windows.
 */
body.platform-linux {
    --native-titlebar-height: 40;
}

body.ios {
    --mobile-bottom-offset: calc(env(safe-area-inset-bottom) * 0.25);
}

body.desktop .mobile-only,
body.mobile .desktop-only,
body:not(.electron) .electron-only {
    display: none !important;
}

body.mobile.context-menu-shown * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

body.mobile #root-widget {
    padding-top: var(--safe-area-inset-top, env(safe-area-inset-top));
    padding-left: var(--safe-area-inset-left, env(safe-area-inset-left));
    padding-right: var(--safe-area-inset-right, env(safe-area-inset-right));
}

body.mobile #root-widget.virtual-keyboard-opened #mobile-bottom-bar {
    display: none !important;
}

#mobile-bottom-bar {
    border-top: 1px solid var(--main-border-color);
    padding-bottom: var(--mobile-bottom-offset);
}

body.desktop #root-widget.horizontal-layout {
    padding-top: var(--safe-area-inset-top, env(safe-area-inset-top));
    background-color: var(--launcher-pane-background-color);
}

body.desktop {
    #root-widget.vertical-layout {
        #launcher-pane,
        #left-pane,
        #rest-pane {
            padding-top: var(--safe-area-inset-top, env(safe-area-inset-top));
            padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom));
        }
    }

    #root-widget.horizontal-layout {
        >.status-bar {
            padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom));
        }
    }

    .modal .modal-dialog {
        margin-top: calc(var(--safe-area-inset-top, env(safe-area-inset-top)) + var(--bs-modal-margin));
    }
}

a {
    text-decoration: none;
}

a,
a:visited,
a:hover {
    color: var(--link-color);
}

.note-list-widget a {
    text-decoration: none;
}

.note-list-widget a:hover {
    text-decoration: underline;
}

input,
select,
textarea,
.form-control,
.form-select {
    color: var(--input-text-color);
    background: var(--input-background-color);
}

.form-control:disabled {
    background-color: var(--input-background-color);
    opacity: 0.6;
}

.form-control:focus {
    color: var(--input-text-color);
    background: var(--input-background-color);
}

.form-select {
    background: var(--input-background-color)
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%23ffffff' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/></svg>")
        right 0.75rem center/15px 20px no-repeat;
}

.form-text {
    color: var(--muted-text-color);
}

.form-field-error {
    color: var(--dropdown-item-icon-destructive-color);
    font-size: 0.7em;
}

.form-group.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.form-checkbox.disabled {
    opacity: 0.5;
}

.form-group {
    margin-bottom: 15px;
}

/* Add a gap between consecutive radios / check boxes */
label.tn-radio + label.tn-radio,
label.tn-checkbox + label.tn-checkbox {
    margin-inline-start: 12px;
}

/* Check boxes and radio buttons */

@supports selector(label:has(*)) {
    /* Check box & radio button commons */

    /* The parent label */
    label.tn-radio,
    label.tn-checkbox {
        --box-size: 1em;
        --box-label-gap: 0.5em;

        position: relative;
        padding-inline-start: calc(var(--box-size) + var(--box-label-gap)) !important;
        user-select: none;
    }

    /* The original input */
    label.tn-radio > input[type="radio"],
    label.tn-checkbox > input[type="checkbox"] {
        position: absolute;
        top: 0;
        inset-inline-start: 0;
        width: var(--box-size);
        height: 100%;
        margin: unset;
        opacity: 0 !important;
    }

    label.tn-radio::before,
    label.tn-radio::after,
    label.tn-checkbox::before,
    label.tn-checkbox::after {
        content: "";
        position: absolute;
        top: 50%;
        inset-inline-start: 0;
        translate: 0 -50%;
        width: var(--box-size);
        height: var(--box-size);
    }

    label.tn-radio:has(> input[type="radio"]:focus-visible)::before,
    label.tn-checkbox:has(> input[type="checkbox"]:focus-visible)::before {
        outline: 2px solid var(--input-focus-outline-color);
    }

    /* Check boxes */

    /* The check box background */
    label.tn-checkbox::before {
        border-radius: 3px;
        background: var(--radio-checkbox-background);
    }

    label.tn-checkbox:has(> input[type="checkbox"]:not(:disabled)):hover:before {
        background: var(--radio-checkbox-hover-background);
    }

    @keyframes checkbox-checked {
        from {
            transform: scale(2);
        }
        to {
            transform: scale(1);
        }
    }

    /* The tick mark */
    label.tn-checkbox::after {
        mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3ctitle%3echeck-bold%3c/title%3e%3cpath d='M9%2c20.42L2.79%2c14.21L5.62%2c11.38L9%2c14.77L18.88%2c4.88L21.71%2c7.71L9%2c20.42Z' /%3e%3c/svg%3e");
        mask-position: center center;
        mask-size: 0.95em;
        background-color: var(--radio-checkbox-indicator-color);
        transform: scale(0);
        opacity: 0;
        transition:
            transform 300ms ease-out,
            opacity 300ms linear;
    }

    label.tn-checkbox:has(> input[type="checkbox"]:checked)::after {
        opacity: 1;
        transform: scale(1);
        transition: opacity 100ms ease-in-out;
        animation: checkbox-checked 150ms ease-out;
    }

    /* The mixed state of a box whose items are partly checked, such as a select-all box. */
    label.tn-checkbox:has(> input[type="checkbox"]:indeterminate)::after {
        mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M4 10.5h16v3H4z' /%3e%3c/svg%3e");
        opacity: 1;
        transform: scale(1);
    }

    /* Radio buttons */

    label.tn-radio::before,
    label.tn-radio::after {
        border-radius: 50%;
    }

    /* The outer circle */
    label.tn-radio::before {
        background: var(--radio-checkbox-background);
    }

    label.tn-radio:has(> input[type="radio"]:not(:disabled)):hover::before {
        background: var(--radio-checkbox-hover-background);
    }

    @keyframes radio-checked {
        from {
            transform: scale(1.5);
        }
        to {
            transform: scale(0.5);
        }
    }

    /* The inner circle */
    label.tn-radio::after {
        background: var(--radio-checkbox-indicator-color);
        transform: scale(0);
        opacity: 0;
        transition:
            opacity 300ms linear,
            transform 300ms ease-in;
    }

    label.tn-radio:has(> input[type="radio"]:checked)::after {
        transform: scale(0.5);
        opacity: 1;
        transition: opacity 150ms linear;
        animation: radio-checked 200ms ease-out;
    }

    /* Disabled check boxes and radio buttons */

    label.tn-radio:has(> input[type="radio"]:disabled)::before,
    label.tn-radio:has(> input[type="radio"]:disabled)::after,
    label.tn-checkbox:has(> input[type="checkbox"]:disabled)::before,
    label.tn-checkbox:has(> input[type="checkbox"]:disabled)::after {
        opacity: 0.5;
    }
}

#left-pane input,
#left-pane select,
#left-pane textarea {
    color: var(--left-pane-text-color);
    background: var(--left-pane-background-color);
}

input::placeholder,
.form-control::placeholder,
#left-pane input::placeholder {
    color: var(--muted-text-color);
}

.table thead th,
.table td,
.table th {
    /* Fix center vertical alignment of table cells */
    vertical-align: middle;
    color: var(--main-text-color);
    background: transparent;
}

.ck .todo-list__checkmark {
    top: 10px !important;
}

.modal-backdrop {
    background-color: var(--modal-backdrop-color) !important;
}

body.mobile .modal .modal-dialog {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
}

.component {
    contain: size;
}

code,
kbd,
pre,
samp {
    font-family: var(--monospace-font-family) !important;
}

/*
 * Programming ligatures: the bundled JetBrains Mono renders `!=` as `≠`, `->` as `→` and so on,
 * which reads as the characters having been silently replaced (see #2851). The `monospaceLigatures-
 * Enabled` option gates this; the class is applied by RootContainer.
 *
 * Scoped to the monospace surfaces rather than set on `body`: `font-variant-ligatures` is inherited,
 * so a blanket rule would also disable `fi`/`fl` in prose, which is a typographic regression in note
 * content and not what anyone is asking for. Inheritance is what makes `.cm-editor` enough to cover
 * CodeMirror's internals.
 */
body.monospace-ligatures-disabled :is(code, kbd, pre, samp, .cm-editor) {
    font-variant-ligatures: none;
}

.badge {
    --bs-badge-color: var(--muted-text-color);

    margin-inline-start: 8px;
    background: var(--accented-background-color);
}

.input-group-text {
    background-color: var(--accented-background-color) !important;
    color: var(--muted-text-color) !important;
}

button.close {
    color: var(--main-text-color);
}

button.close:hover {
    color: var(--hover-item-text-color);
}

.modal-content {
    background-color: var(--modal-background-color) !important;
}

.nav-link.active {
    background-color: inherit !important;
    color: var(--main-text-color) !important;
}

.tdialog {
    display: none;
}

.ui-autocomplete {
    max-height: 300px;
    overflow-y: auto;
    /* prevent horizontal scrollbar */
    overflow-x: hidden;
}

.ui-widget-content a:not(.ui-tabs-anchor) {
    color: #337ab7 !important;
}

div.ui-tooltip {
    max-width: 600px;
    max-height: 600px;
    overflow: auto;
}

/*
* .search-inactive is added to search window <webview> when the window
* is inactive.
*/
.search-inactive {
    visibility: hidden;
}

/*
* .search-inactive is added to search window <webview> when the window
* is active.
*/
.search-active {
    visibility: visible;
}

.electronSearchText-box {
    display: none;
}
.electronSearchText-visible {
    display: block;
}

/* The search terms `useImperativeSearchHighlighlighting()` finds in titles, cards and previews. */
[data-highlight-root]::highlight(search-match),
[data-highlight-root] *::highlight(search-match) {
    color: var(--note-list-view-search-result-highlight-color, var(--admonition-warning-accent-color));
    text-decoration: underline;
}

/* The highlights of `FindInHtml`, in the colors CKEditor gives .ck-find-result and
   .ck-find-result_selected in an editable text note. */
[data-highlight-root]::highlight(find-result),
[data-highlight-root] *::highlight(find-result) {
    background-color: var(--ck-color-highlight-background);
    color: var(--ck-color-text);
}

[data-highlight-root]::highlight(find-result-selected),
[data-highlight-root] *::highlight(find-result-selected) {
    background-color: var(--ck-color-find-result-selected);
}

[data-highlight-root]::highlight(find-result-secondary),
[data-highlight-root] *::highlight(find-result-secondary) {
    background-color: color-mix(in srgb, var(--ck-color-find-result-background, #66ff99) 40%, transparent);
}

/* Allow to use <kbd> elements inside the title to define shortcut hints. */
.ui-menu kbd,
button kbd {
    color: var(--muted-text-color);
    border: none;
    background-color: transparent;
    box-shadow: none;
}

.ui-menu kbd {
    margin-inline-start: 30px;
    float: inline-end;
}

.suppressed {
    display: none;
}

.cm-editor {
    height: 100%;
    outline: none !important;
    overflow: hidden;
    font-size: var(--monospace-font-size);
}

.cm-scroller {
    font-family: var(--monospace-font-family) !important;
}

:root pre.code-preview > .code-preview-content {
    font-family: var(--monospace-font-family);
    font-size: var(--monospace-font-size);
}

.cm-editor .cm-placeholder {
    color: inherit;
    opacity: 0.5;
    /* Out of flow, so the caret takes its height from the line rather than from the hint. */
    position: absolute;
}

/* Firefox draws the caret against the spacer CodeMirror puts before the placeholder widget,
   short (https://bugzilla.mozilla.org/show_bug.cgi?id=904846). The spacer must stay in layout:
   CodeMirror measures a position next to a widget from its rect, and a hidden one reads as
   zeros, which places a completion list at the caret off-screen. */
@supports (-moz-appearance: none) {
    .cm-editor .cm-widgetBuffer:has(+ .cm-placeholder) {
        vertical-align: baseline;
    }
}

/* `getTooltipHost()` renders CodeMirror tooltips here, outside the clipping `.cm-editor`.
   Must stay above dialogs (1101) and below the context menu (2500). */
.cm-tooltip-host {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
    font-size: var(--monospace-font-size);
}

/* CodeMirror's hover and lint tooltips in the app's tooltip style: a code note renders them in
   `.cm-tooltip-host`, the search field (`search_field_editor.css`) inside its own editor. */
:is(.cm-tooltip-host, .search-string-editor .cm-editor) {
    .cm-tooltip:is(.cm-tooltip-hover, .cm-tooltip-lint) {
        --cm-tooltip-background: var(--tooltip-background-color, transparent);

        max-width: 500px;
        padding: 0;
        border: 0;
        border-radius: var(--tooltip-border-radius, 5px);
        background:
            linear-gradient(var(--cm-tooltip-background), var(--cm-tooltip-background)),
            var(--main-background-color);
        color: var(--tooltip-foreground-color, var(--main-text-color));
        box-shadow: var(--tooltip-box-shadow, 0 5px 10px rgba(0, 0, 0, 0.2));
        font-family: var(--main-font-family);
        font-size: var(--tooltip-font-size, 0.9em);
        line-height: 1.5;
        overflow: hidden;
    }

    .cm-diagnostic {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
        margin: 0;
        padding: var(--tooltip-padding, 4px 8px);
        padding-inline-start: 16px;
        border: 0;

        &::before {
            content: "";
            position: absolute;
            inset-block: 6px;
            inset-inline-start: 6px;
            width: 3px;
            border-radius: 3px;
            background: var(--cm-diagnostic-color, transparent);
        }
    }

    .cm-diagnostic-error {
        --cm-diagnostic-color: var(--admonition-caution-accent-color);
    }

    .cm-diagnostic-warning {
        --cm-diagnostic-color: var(--admonition-warning-accent-color);
    }

    .cm-diagnostic-info {
        --cm-diagnostic-color: var(--admonition-note-accent-color);
    }

    .cm-diagnosticAction {
        margin: 0;
        padding: 2px 8px;
        border-radius: 4px;
        background: color-mix(in srgb, currentColor 15%, transparent);
        color: inherit;

        &:hover {
            background: color-mix(in srgb, currentColor 25%, transparent);
        }
    }

    .cm-ts-hover {
        padding: var(--tooltip-padding, 4px 8px);
    }

    .cm-ts-hover-signature {
        font-family: var(--monospace-font-family);
    }

    .cm-tooltip-section:not(:first-child) {
        border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    }
}

#sql-console-query {
    height: 150px;
    width: 100%;
    border: 1px solid #ccc;
    margin-bottom: 10px;
}

#sql-console-query .cm-editor {
    height: 150px;
}

#sql-console-query .cm-editor .cm-scroller {
    min-height: inherit !important;
}

.btn {
    border-radius: var(--button-border-radius);
    border-color: var(--button-border-color);
}

.btn:hover {
    border-color: var(--hover-item-border-color);
}

button.btn,
button.btn-sm {
    font-size: inherit;
}

.btn-micro {
    padding: 0 10px 0 10px;
}

.btn.btn-primary {
    border-color: var(--primary-button-border-color);
    background-color: var(--primary-button-background-color);
    color: var(--primary-button-text-color);
}

.btn:not(:disabled):not(.disabled):active,
.btn:not(:disabled):not(.disabled).active {
    border-color: var(--primary-button-text-color);
    background-color: var(--active-item-background-color);
    color: var(--active-item-text-color);
}

.btn.btn-primary kbd {
    color: var(--primary-button-text-color);
}

.btn:not(.btn-primary) {
    background-color: var(--button-background-color);
    color: var(--button-text-color);
}

#left-pane .btn:not(.btn-primary) {
    background-color: var(--button-background-color);
    color: var(--left-pane-text-color);
}

.ck.ck-button.ck-block-toolbar-button {
    transform: translateX(10px);
    --ck-color-button-default-background: transparent;
    color: var(--muted-text-color);
    /* Making this narrower because https://github.com/zadam/trilium/issues/502 (problem only in smaller font sizes) */
    min-width: 0;
    padding: 0;
    z-index: 1000;
    translate: -40% 0;
    padding: 0;
}

body[dir=rtl] .ck.ck-block-toolbar-button {
    transform: translateX(-10px);
}

pre:not(.hljs) {
    color: var(--main-text-color) !important;
    white-space: pre-wrap;
    font-size: 100%;
}

:root pre {
    --padding-size: 1em;
    --copy-button-margin-size: .35em;
    --copy-button-width: 37px;

    position: relative;
    padding: var(--padding-size);
}

pre:has(> .cm-editor) {
    padding: 0;
    margin: 0;
}

pre > button.copy-button {
    position: absolute;
    top: var(--copy-button-margin-size);
    inset-inline-end: var(--copy-button-margin-size);
}

:root pre:has(> button.copy-button) {
    padding-inline-end: calc(var(--copy-button-width) + (var(--copy-button-margin-size) * 2));
}

pre > button.copy-button:hover,
.code-embed-content > button.copy-button:hover {
    color: inherit !important;
    opacity: 1;
}

pre > button.copy-button:active,
.code-embed-content > button.copy-button:active {
    background-color: unset !important;
}

.pointer {
    cursor: pointer;
}

table.promoted-attributes-in-tooltip {
    margin: auto;
}

table.promoted-attributes-in-tooltip td,
table.promoted-attributes-in-tooltip th {
    padding: 10px;
}

/* Note tooltips are appended to <body> and are frequently triggered from inside a dialog (a link,
   a deleted-note entry), including the few that lift themselves above the base tooltip layer — the
   content manager's active-content overlay among them. Held at the same "above everything" layer
   .tooltip-top names, so they clear those too. */
.tooltip.note-tooltip {
    z-index: 32767 !important;
}


/* Tooltip for text editor content, placed at the bottom of the screen to be less intruive when editing */
.tooltip.text-editor-content-tooltip {
    position: fixed !important;
    inset: auto auto 1rem 1rem !important;
    transform: none !important;
    margin: 0 !important;
}

.tooltip.text-editor-content-tooltip .tooltip-arrow {
    display: none;
}

.pre-wrap-text {
    white-space: pre-wrap;
}

.bs-tooltip-bottom .tooltip-arrow::before {
    border-bottom-color: var(--main-border-color) !important;
}
.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: var(--main-border-color) !important;
}
.bs-tooltip-left .tooltip-arrow::before {
    border-inline-start-color: var(--main-border-color) !important;
}
.bs-tooltip-right .tooltip-arrow::before {
    border-inline-end-color: var(--main-border-color) !important;
}

.bs-tooltip-bottom .tooltip-arrow::after {
    border-bottom-color: var(--tooltip-background-color) !important;
}
.bs-tooltip-top .tooltip-arrow::after {
    border-top-color: var(--tooltip-background-color) !important;
}
.bs-tooltip-left .tooltip-arrow::after {
    border-inline-start-color: var(--tooltip-background-color) !important;
}
.bs-tooltip-right .tooltip-arrow::after {
    border-inline-end-color: var(--tooltip-background-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before,
.bs-tooltip-left .tooltip-arrow::before {
    inset-inline-start: -1px;
    border-width: 0.4rem 0 0.4rem 0.4rem;
    border-inline-start-color: var(--main-border-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before,
.bs-tooltip-bottom .tooltip-arrow::before {
    bottom: -1px;
    border-width: 0 0.4rem 0.4rem;
    border-bottom-color: var(--main-border-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before,
.bs-tooltip-right .tooltip-arrow::before {
    inset-inline-end: -1px;
    border-width: 0.4rem 0.4rem 0.4rem 0;
    border-inline-end-color: var(--main-border-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before,
.bs-tooltip-top .tooltip-arrow::before {
    top: -1px;
    border-width: 0.4rem 0.4rem 0;
    border-top-color: var(--main-border-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::after,
.bs-tooltip-left .tooltip-arrow::after {
    inset-inline-start: -1px;
    border-width: 0.4rem 0 0.4rem 0.4rem;
    border-inline-start-color: var(--tooltip-background-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::after,
.bs-tooltip-bottom .tooltip-arrow::after {
    bottom: -1px;
    border-width: 0 0.4rem 0.4rem;
    border-bottom-color: var(--tooltip-background-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::after,
.bs-tooltip-right .tooltip-arrow::after {
    inset-inline-end: -1px;
    border-width: 0.4rem 0.4rem 0.4rem 0;
    border-inline-end-color: var(--tooltip-background-color) !important;
}

.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::after,
.bs-tooltip-top .tooltip-arrow::after {
    top: -1px;
    border-width: 0.4rem 0.4rem 0;
    border-top-color: var(--tooltip-background-color) !important;
}

.note-tooltip.tooltip .tooltip-arrow {
    display: none;
}

.tooltip-inner p:last-of-type {
    margin-bottom: 0;
}

.rendered-note-attributes {
    color: var(--muted-text-color);
    margin-bottom: 7px;
}

.note-tooltip-title {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.note-tooltip-detail {
    margin-top: -5px;
    margin-bottom: 5px;
    color: var(--muted-text-color);
    font-size: small;
}

.note-tooltip-content {
    /* height needs to stay small because tooltip has problem when it can't fit to either top or bottom of the cursor */
    max-height: 300px;
    overflow: auto;
}

.note-tooltip-content .note-title-with-path .note-path {
    font-size: small;
}

.note-tooltip-content .open-popup-button {
    position: absolute;
    inset-inline-end: 15px;
    bottom: 8px;
    font-size: 1.2em;
    color: inherit;
}

.note-tooltip-attributes {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tooltip-inner img {
    max-width: 250px;
    max-height: 250px;
}

.tooltip-inner figure.image-style-side {
    float: inline-end;
}

/* this is because bootstrap (?) sets code color to red for some reason */
code {
    color: inherit !important;
}

/*
 * Inline code — a `code` that is not the body of a code block.
 *
 * CKEditor ships its own `.ck-content code` rule with a hardcoded grey, which ignores the theme
 * entirely. The rule below overrides it (one class more specific) for every surface that renders
 * note content: the editable and read-only text notes, doc notes and the print sheet.
 *
 * The values are theme-tunable; the defaults here are a translucent neutral grey so they hold up
 * on a light and a dark background alike, which is what the legacy themes fall back to.
 */
:where(:root) {
    --inline-code-background-color: rgba(128, 128, 128, 0.18);
    --inline-code-border-color: rgba(128, 128, 128, 0.28);
    --inline-code-hover-background-color: rgba(128, 128, 128, 0.3);
}

.ck-content code:not(pre code) {
    padding: 0.1em 0.35em;
    border-radius: 5px;
    background-color: var(--inline-code-background-color);
    /* Monospace runs visually larger than the surrounding prose at the same nominal size. */
    font-size: 0.8em;
    /* A long path or identifier must wrap rather than push the paragraph past the note width. */
    overflow-wrap: break-word;

    &.ck-code_selected {
        background-color: var(--inline-code-hover-background-color) !important;
    }
}

.animated {
    animation-duration: 1s;
    animation-fill-mode: both;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.fadeInDown {
    animation-name: fadeInDown;
}

@keyframes fadeOutUp {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        -webkit-transform: translate3d(0, -100%, 0);
        transform: translate3d(0, -100%, 0);
    }
}

.fadeOutUp {
    animation-name: fadeOutUp;
}

div[data-notify="container"] {
    text-align: center;
}

.saved-indicator {
    font-size: 150%;
}

.ck-editor__is-empty.ck-content.ck-editor__editable::before {
    content: "You can start writing note here ...";
    position: absolute;
    display: block;

    margin: var(--ck-spacing-large, var(--ck-spacing-lg)) 0;

    color: var(--muted-text-color);
}

svg.ck-icon.note-icon {
    color: var(--main-text-color);
    font-size: 20px;
}

.ck-content {
    --ck-content-font-family: var(--detail-font-family);
    --ck-content-font-size: 1.1em;
    --ck-content-font-color: var(--main-text-color);
    --ck-content-line-height: var(--bs-body-line-height);
}

/*
 * Table borders in text notes. `ckeditor5-content.css` hardcodes a light grey, which glares on a
 * dark background. The default mixes the text color into transparency, which matches that grey
 * on a light theme. A border set through the table or cell properties is inline and still wins.
 */
:where(:root) {
    --text-note-table-border-color: color-mix(in srgb, var(--main-text-color) 25%, transparent);
}

:root .ck-content .table table:not(.layout-table) {
    border-color: var(--text-note-table-border-color);

    & > :is(thead, tbody, tfoot) > tr > :is(td, th) {
        border-color: var(--text-note-table-border-color);
    }
}

:root .ck-content .table table:not(.layout-table) th {
    background-color: var(--accented-background-color);
}

.ck-content .image > figcaption {
    color: var(--main-text-color) !important;
    background-color: var(--accented-background-color) !important;
}

.ck-content li p {
    margin: 0 !important;
}

/* `:where(:not(.excalidraw *))` leaves out the menus of an embedded canvas drawing. */
.ck-content a:hover:where(:not(.excalidraw *)) {
    text-decoration: underline;
}

.ck-content .footnote-section {
    border: 1px solid #c4c4c4;
}

.ck-content .ck-content-widget.footnote-section .ck-content-widget__type-around__button_after {
    display: none;
}

#options-dialog input[type="number"] {
    text-align: end;
}

.help-cards ul {
    padding-inline-start: 20px;
}

.help-cards kbd {
    color: var(--main-text-color);
    background-color: var(--accented-background-color);
    border: 1px solid var(--main-border-color);
    padding: 2px;
}

.card {
    color: inherit !important;
    border-color: var(--main-border-color) !important;
}

.modal-header {
    padding: 0.5rem 1rem 0.5rem 1rem !important; /* make modal header padding slightly smaller */
}

/* Modal and toast control buttons (close and help) */

.modal .modal-header .btn-close,
.modal .modal-header .help-button,
.modal .modal-header .custom-title-bar-button,
#toast-container .toast .toast-header .btn-close,
#toast-container .toast .toast-close .btn-close {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-inline-start: 8px;
    border: 0;
    border-radius: 50%;
    padding: 0;
    width: var(--modal-control-button-size);
    height: var(--modal-control-button-size);
    background: var(--modal-control-button-background);
    font-size: var(--modal-control-button-size);
    line-height: normal;
    font-weight: normal;
    color: var(--modal-control-button-color);
    opacity: 1;
    cursor: default;
}

.modal .modal-header .btn-close,
#toast-container .toast .toast-header .btn-close,
#toast-container .toast .toast-close .btn-close {
    --modal-control-button-hover-background: var(--modal-close-button-hover-background);
}

.modal .modal-header .btn-close::after,
#toast-container .toast .toast-header .btn-close::after,
#toast-container .toast .toast-close .btn-close::after {
    content: "\ec8d";
    font-family: boxicons;
}

.modal .modal-header .help-button,
.modal .modal-header .custom-title-bar-button {
    margin-inline-end: 0;
    font-size: calc(var(--modal-control-button-size) * .70);
    font-family: unset;
    font-weight: bold;
}

.modal .modal-header .btn-close:hover,
.modal .modal-header .help-button:hover,
.modal .modal-header .custom-title-bar-button:hover,
#toast-container .toast .toast-header .btn-close:hover,
#toast-container .toast .toast-close .btn-close:hover {
    background: var(--modal-control-button-hover-background);
    color: var(--modal-control-button-hover-color);
}

.modal .modal-header .btn-close:active,
.modal .modal-header .help-button:active,
.modal .modal-header .custom-title-bar-button:active,
#toast-container .toast .toast-header .btn-close:active,
#toast-container .toast .toast-close .btn-close:active {
    transform: scale(.85);
}

.modal .modal-header .btn-close:focus,
.modal .modal-header .help-button:focus,
#toast-container .toast .toast-header .btn-close:focus,
#toast-container .toast .toast-close .btn-close:focus {
    box-shadow: none !important;
}

.modal .modal-header .btn-close:focus-visible,
.modal .modal-header .help-button:focus-visible,
#toast-container .toast .toast-header .btn-close:focus-visible,
#toast-container .toast .toast-close .btn-close:focus-visible {
    outline: 2px solid var(--input-focus-outline-color);
    outline-offset: 2px;
}

.modal-content-with-sidebar {
    flex-direction: row !important;
}

.modal-content-with-sidebar > .modal-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--main-border-color);
    flex-shrink: 0;
    min-height: 0;
}

.modal-content-with-sidebar .modal-sidebar-header {
    padding: 0.75rem 1rem;
    flex-shrink: 0;
    text-align: center;
    border-bottom: 1px solid var(--main-border-color);
}

.modal-content-with-sidebar .modal-sidebar-header h5 {
    margin: 0;
    font-size: 1em;
}

.modal-content-with-sidebar > .modal-main > .modal-header > .modal-title {
    visibility: hidden;
    flex-grow: 1;
    width: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.modal-content-with-sidebar > .modal-main > .modal-header {
    flex-wrap: nowrap;
}

.modal-content-with-sidebar > .modal-main {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.modal-content-with-sidebar > .modal-main > .modal-body {
    overflow: auto;
    flex-grow: 1;
    min-height: 0;
}

body.mobile .modal-content-with-sidebar {
    flex-direction: column !important;
}

body.mobile .modal-content-with-sidebar > .modal-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--main-border-color);
    height: 30vh;
    flex-shrink: 0;
    overflow: hidden;
    order: 1;
}

body.mobile .modal-content-with-sidebar > .modal-main {
    order: 0;
}

body.mobile .modal-content-with-sidebar .modal-sidebar-header {
    display: none;
}

body.mobile .modal-content-with-sidebar > .modal-main > .modal-header > .modal-title {
    visibility: visible;
    width: auto;
}

.side-checkbox {
    display: flex;
    align-items: end;
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
    line-height: 1.5;
}

.ck-link-actions .ck-tooltip {
    /* force hide the tooltip since it shows misleading "open link in new tab */
    display: none !important;
}

.include-note {
    --ck-color-focus-border: var(--link-color);

    margin: 0 0 10px;
    border-radius: var(--_include-note-top-border-radius, 8px)
                   var(--_include-note-top-border-radius, 8px)
                   var(--_include-note-bottom-border-radius, 8px)
                   var(--_include-note-bottom-border-radius, 8px);
    background-color: var(--card-background-color, var(--accented-background-color));
    display: flex; /* see https://github.com/zadam/trilium/issues/1590 */
    flex-direction: column;
    transition: background-color 200ms ease-out;
}

.include-note > .ck-widget__selection-handle {
    margin-inline-start: var(--_include-note-top-border-radius, 8px);
}

/* On the wrapper: the editor gives the caption a border of its own for the focus ring. */
.include-note-wrapper:has(+ figcaption) {
    border-bottom: 2px solid var(--main-background-color);
}

figure.captioned-content-embed {
    margin: 0;
}

:is(.include-note, .captioned-content-embed) > figcaption {
    padding: 6px 1rem;
    font-size: .8em;
    text-align: center;
}

/* Includes in a series share flush edges, as link previews and collapsible blocks do. */
.include-note:not([data-position^="wrap-"]) + .include-note:not([data-position^="wrap-"]) {
    --_include-note-top-border-radius: 0px;
}

.include-note:not([data-position^="wrap-"]):has(+ .include-note:not([data-position^="wrap-"])) {
    --_include-note-bottom-border-radius: 0px;
    margin-bottom: 3px;
}

.include-note {
    /* The corners of the embed box that its content touches, as lengths for `calc()`. */
    --_include-note-content-top-radius: 0px;
    --_include-note-content-bottom-radius: var(--_include-note-bottom-border-radius, 8px);
    /* The frame around content that fills the box. Below a title and above a caption, the 2px
       border between them and the content is the frame on that side. */
    --_include-note-content-inset: 2px;
    --_include-note-content-top-inset: 0px;
    --_include-note-content-bottom-inset: var(--_include-note-content-inset);
    --_include-note-framed-top-radius:
        max(0px, var(--_include-note-content-top-radius) - var(--_include-note-content-top-inset));
    --_include-note-framed-bottom-radius: max(0px,
        var(--_include-note-content-bottom-radius) - var(--_include-note-content-bottom-inset));
    /* What the frame takes from `.include-note-box-height`, set by content that draws it. */
    --_include-note-frame-height: 0px;

    &[data-hide-title="true"]:not([data-box-size="tiny"], [data-box-size="expandable"]) {
        --_include-note-content-top-radius: var(--_include-note-top-border-radius, 8px);
        --_include-note-content-top-inset: var(--_include-note-content-inset);
    }

    &:has(> figcaption) {
        --_include-note-content-bottom-radius: 0px;
        --_include-note-content-bottom-inset: 0px;
    }
}

/* CKEditor counts only non-UIElements as content (see `hasContent` in the
   engine), so a widget rendered entirely from UIElements — an include note, a
   Mermaid diagram, etc. — looks "empty" to it. When such a widget is the first
   block, it can wrongly become the editor's placeholder host, overlaying the
   placeholder text on top of the widget. Suppress it for any widget. */
.ck-widget.ck-placeholder::before {
    content: "" !important;
}

/* Using data- attribute to support both CKEditor and readonly view */
.include-note[data-box-size="small"] .include-note-content {
    max-height: var(--include-note-height, 10em);
    overflow: auto;
}

/* PDFs and web views render in an (absolutely positioned) iframe, so they need an explicit
   height per box size instead of an intrinsic, content-driven one. */
.include-note[data-box-size="small"] .include-note-content.type-pdf,
.include-note[data-box-size="small"] .include-note-content.type-webView {
    height: var(--include-note-height, 10em);
}

/* The small box has room for the compact audio player's visualizer band (which carries a floor of its own) or
   for its controls row and the file footer below it — not for all three. Drop the band, and release the floor
   so the box shrinks to what is left instead of overflowing onto the Download / Open buttons. */
.include-note[data-box-size="small"] .include-note-content.type-audio .audio-preview-visualization-wrapper {
    display: none;
}

.include-note[data-box-size="small"] .include-note-content.type-audio .rendered-media {
    min-height: 0;
}

.include-note[data-box-size="medium"] .include-note-content {
    max-height: var(--include-note-height, 20em);
    overflow: auto;
}

.include-note[data-box-size="medium"] .include-note-content.type-pdf .rendered-content,
.include-note[data-box-size="medium"] .include-note-content.type-webView .rendered-content {
    height: var(--include-note-height, 20em);
}

.include-note[data-box-size="full"] .include-note-content.type-pdf .rendered-content,
.include-note[data-box-size="full"] .include-note-content.type-webView .rendered-content {
    height: 50em; /* an iframe can't take a percentage full height, so fall back to a large fixed one */
}

.include-note[data-box-size="expandable"] .include-note-content.type-webView .rendered-content {
    height: var(--include-note-height, 20em);
}

/* Full-height collection views (table, board, calendar, geo map, presentation) render their own
   scroll region with no intrinsic height, so — like PDFs and web views — they need an explicit
   height per box size. The inner widget fills it via its existing height:100% chain. List/grid
   collections are content-driven and keep the generic max-height above. */
.include-note[data-box-size="small"] .include-note-content.type-book:has(.note-list-widget.full-height),
.include-note[data-box-size="small"] .include-note-content.type-search:has(.note-list-widget.full-height) {
    height: var(--include-note-height, 10em);
}

.include-note[data-box-size="medium"] .include-note-content.type-book:has(.note-list-widget.full-height),
.include-note[data-box-size="medium"] .include-note-content.type-search:has(.note-list-widget.full-height) {
    height: var(--include-note-height, 20em);
}

.include-note[data-box-size="full"] .include-note-content.type-book:has(.note-list-widget.full-height),
.include-note[data-box-size="full"] .include-note-content.type-search:has(.note-list-widget.full-height) {
    height: 50em; /* a full-height view can't take a percentage full height, so fall back to a large fixed one */
}

.include-note[data-box-size="expandable"] .include-note-content.type-book:has(.note-list-widget.full-height),
.include-note[data-box-size="expandable"] .include-note-content.type-search:has(.note-list-widget.full-height) {
    height: var(--include-note-height, 20em);
}

/* Pictures, diagrams and players fit the box height, where text scrolls in it. */
.include-note[data-box-size="small"] {
    --include-note-media-max-height: var(--include-note-height, 10em);
}

.include-note[data-box-size="medium"] {
    --include-note-media-max-height: var(--include-note-height, 20em);
}

.include-note[data-box-size="expandable"] {
    --include-note-media-max-height: var(--include-note-height);
}

/* Media takes a resized height inside the border and padding, as with the edge-to-edge types. */
.include-note[data-box-size] .include-note-content:is(
    .type-image, .type-canvas, .type-canvasDrawing, .type-mermaidDiagram, .type-mindMap,
    .type-spreadsheet, .type-mermaid,
    .type-video
) {
    box-sizing: content-box;
    max-height: none;
}

.include-note-box-height {
    height: calc(var(--include-note-height, 20em) - var(--_include-note-frame-height, 0px));
}

.include-note[data-box-size="small"] .include-note-box-height {
    height: calc(var(--include-note-height, 10em) - var(--_include-note-frame-height, 0px));
}

.include-note[data-box-size="full"] .include-note-box-height {
    height: calc(50em - var(--_include-note-frame-height, 0px));
}

.include-note-content:fullscreen .include-note-box-height {
    height: 100%;
}

/* Tiny and Full fit their content: only these box sizes take a resized size. */
.include-note:is([data-box-size="small"], [data-box-size="medium"], [data-box-size="expandable"]) {
    margin-inline: auto;
    max-width: 100%;
    width: var(--include-note-width, auto);

    .include-note-content {
        height: var(--include-note-height, auto);
        overflow: auto;
    }

    &.include-note_collapsed {
        --ck-resize-corner-radius: var(--_include-note-bottom-border-radius, 8px);

        > .ck-widget__resize-handles
            > .ck-widget__resize-handle:not(.ck-widget__resize-handle_width) {
            display: none;
        }
    }
}

.link-embed:where([data-embed-type="youtube"]) {
    margin-inline: auto;
    max-width: 100%;
    width: var(--include-note-width, auto);
}

.include-note,
.link-embed:where([data-embed-type="youtube"]) {
    clear: both;

    &[data-position="left"] {
        margin-right: auto;
        margin-left: 0;
    }

    &[data-position="right"] {
        margin-right: 0;
        margin-left: auto;
    }

    &:is([data-position="wrap-left"], [data-position="wrap-right"]) {
        --_include-note-wrap-gap: clamp(0px, 100% - var(--include-note-width, 100%),
            var(--ck-content-image-style-spacing, 1.5em));

        clear: none;
        max-width: 100%;
        width: var(--include-note-width, 100%);
    }

    &[data-position="wrap-left"] {
        float: left;
        margin-right: var(--_include-note-wrap-gap);
    }

    &[data-position="wrap-right"] {
        float: right;
        margin-left: var(--_include-note-wrap-gap);
    }
}

body.mobile :is(.include-note, .link-embed)[data-position] {
    --ck-resize-corner-radius: var(--_include-note-bottom-border-radius, 8px);

    float: none;
    clear: both;
    margin-inline: 0;
    width: auto;

    > .ck-widget__resize-handles > :is(
        .ck-widget__resize-handle_width, .ck-widget__resize-handle_corner
    ) {
        display: none;
    }
}

.include-note-content:not(:fullscreen) :is(
    .rendered-content > img, .rendered-content > svg, .image-viewer-content > img,
    .video-preview-wrapper:not(:fullscreen) > .video-preview
) {
    max-height: var(--include-note-media-max-height, none);
}

.include-note-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* The header: the title row, or the bare title of an embed whose upload is under way. */
.include-note-wrapper > .include-note-title,
.include-note-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: .75rem 1rem;
    font-size: 1em;
    font-weight: 500;
}

/* createLink wraps the icon and anchor in a single <span>; lay it out as a flex
   row so the (larger) note icon lines up vertically with the title text instead
   of sitting on the text baseline. */
.include-note-title > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.include-note-title .bx {
    flex-shrink: 0;
    font-size: 1.2em;
    color: var(--note-list-view-icon-color, var(--muted-text-color));
}

/* Neutralize the default link color and pill hover so the title reads as a
   plain card header (matching .note-book-title in the grid/list view). */
.include-note-title a {
    --link-hover-background: transparent;
    --link-hover-color: currentColor;
    color: inherit;
    font-weight: 500;
    text-decoration: none;
}

.include-note[data-box-size="expandable"] > .include-note-wrapper > .include-note-title-row {
    border-start-start-radius: var(--_include-note-top-border-radius, 8px);
    border-start-end-radius: var(--_include-note-top-border-radius, 8px);

    &:hover {
        background: var(--card-background-hover-color);
    }
}

.include-note[data-box-size="expandable"]:not(.ck-widget)
    > .include-note-wrapper > .include-note-title-row {
    cursor: pointer;
}

.include-note[data-box-size="expandable"]:not(:has(> figcaption))
    > .include-note-wrapper:has(> .include-note-body > .include-note-content[hidden])
    > .include-note-title-row {
    border-end-start-radius: var(--_include-note-bottom-border-radius, 8px);
    border-end-end-radius: var(--_include-note-bottom-border-radius, 8px);
}

/* The title inside the expandable row defers its header styling to the row. */
.include-note-title-row .include-note-title {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    border-bottom: none;
    width: max-content;
    font-weight: inherit;
    font-size: inherit;
}

.include-note-title-row > .include-note-title-label {
    flex-grow: 1;
}

.include-note-title-row > .icon-action {
    flex-shrink: 0;
}

.include-note-title-row > .include-note-display-modes {
    flex-shrink: 0;
}

/* Outranks `:root div.btn-group .icon-action`, so the group is as tall as the other buttons. */
:root .include-note-title-row > .include-note-display-modes .icon-action {
    --icon-button-size: 24px;
}

/* Browsers drop a click on a disabled button, which then toggles no expandable embed. */
.include-note-title-row > .icon-action.disabled {
    pointer-events: auto;
}

.include-note-title-row > .include-note-badges:empty {
    display: none;
}

.include-note-badges > .excerpt-badge {
    order: 1;
}

.include-note-toggle {
    --icon-button-hover-background: transparent;

    transition: transform 0.2s ease;
}

.include-note-toggle.expanded {
    transform: rotate(90deg);
}

/* The selector must outrank the `display` that the icon pack sets on its own class. */
.include-note-title-row > .include-note-icon {
    --size: calc(1em + 12px);

    display: flex;
    flex-shrink: 0;
    justify-content: center;
    align-items: center;
    margin-inline-end: 4px;
    border-radius: 50%;
    width: var(--size);
    height: var(--size);
    background: var(--note-list-view-large-icon-background, var(--main-background-color));
    font-size: 1.2em;
    color: var(--note-list-view-large-icon-color, var(--muted-text-color));
}

/* The glyph and its circle differ by a whole, even number of pixels. */
@supports (width: round(1px, 1px)) {
    .include-note-title-row > .include-note-icon {
        font-size: round(1.2em, 1px);
    }
}

.include-note-heading {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;

    /* The note path from createLink() goes above the title. */
    .include-note-title > span {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 0;
    }

    small {
        font-size: .7em;
        font-weight: 500;
        line-height: 1;
        letter-spacing: .5pt;
        opacity: .5;
    }

    .include-note-description {
        margin-top: 4px;
    }
}

.include-note-body {
    position: relative;
}

.include-note-content {
    /* Keeps the z-indexes inside the content, such as those of map panes, under the backdrop. */
    isolation: isolate;
    border-top: 2px solid var(--main-background-color);
    padding: .75rem 1rem;
}

/* Keeps the z-indexes of the content, such as those of a drawing's canvases, under the controls
   of the embed, such as "Exit fullscreen". */
.include-note-content > .rendered-content {
    isolation: isolate;
}

/* Outranks the margin that the editor themes give the last block, so that a text embed and its
   editor end alike. */
.include-note-content > .rendered-content > *:last-child,
:root .include-note-content > .rendered-content .ck-content > :last-child {
    margin-bottom: 0;
}

/* Outranks the margin, shadow and corners that the themes give `.ck-content pre`, the first two
   with `!important`. */
:root .include-note-content pre.code-embed-editor,
:root .include-note-content.type-code pre {
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0;
}

.include-note-content pre.code-embed-editor {
    padding: 0;
}

pre.code-embed-editor.read-only,
pre.code-embed-editor > .cm-editor:not(.cm-focused) {
    .cm-activeLine {
        background-color: transparent;
    }

    .cm-activeLineGutter {
        background-color: transparent;
        color: inherit;
        font-weight: inherit;
    }
}

.include-note-content.type-code {
    padding: var(--_include-note-content-top-inset) var(--_include-note-content-inset)
             var(--_include-note-content-bottom-inset);
}

:root .include-note-content.type-code pre {
    border-radius: var(--_include-note-framed-top-radius) var(--_include-note-framed-top-radius)
                   var(--_include-note-framed-bottom-radius)
                   var(--_include-note-framed-bottom-radius);

    &.code-embed-editor {
        overflow: hidden;
    }
}

:root .include-note-content.type-extendedCodeBlock pre.code-embed-editor {
    border-radius: var(--_include-note-content-top-radius) var(--_include-note-content-top-radius)
                   var(--_include-note-content-bottom-radius)
                   var(--_include-note-content-bottom-radius);
    overflow: hidden;

    .cm-gutters {
        padding-inline: 4px;
    }

    /* `.cm-line` adds 6px before each line. */
    .cm-content {
        padding-block: var(--padding-size, 1em);
        padding-inline-start: calc(var(--padding-size, 1em) - 6px);
    }

    .cm-editor[data-theme-name="vs-code-light"] {
        background-color: #f6f6f6;
    }

    .cm-editor[data-theme-name="vs-code-dark"] {
        background-color: #1c1b1b;
    }
}

.include-note-content.type-extendedCodeBlock {
    display: flex;
    flex-direction: column;

    > .rendered-content,
    > .rendered-content > .source-embed,
    .code-embed-content,
    pre.code-embed-editor,
    .cm-editor {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }
}

.include-note-content.type-extendedCodeBlock .code-embed-content {
    --_copy-button-size: 37px;
    --_copy-button-inset: .35em;

    position: relative;

    > button.copy-button {
        position: absolute;
        top: var(--_copy-button-inset);
        inset-inline-end: var(--_copy-button-inset);
    }

    &:has(> button.copy-button) .cm-content {
        padding-inline-end: calc(var(--_copy-button-size) + var(--_copy-button-inset) * 2);
    }
}

/* Takes the wheel and the touch gestures for the page until the content has the focus. */
.include-note-backdrop {
    position: absolute;
    inset: 0;
}

.include-note-content:focus {
    outline: none;
}

/* Outlined as a selected widget in the editor. */
.include-note:has(> .include-note-wrapper > .include-note-body.active) {
    /* With the focus in its content, the widget is either selected in a blurred editor or not
       selected at all. */
    --ck-color-widget-blurred-border: var(--ck-color-focus-border);
    --ck-color-widget-type-around-button-hover: var(--ck-color-focus-border);
    --ck-color-widget-type-around-button-active: var(--ck-color-focus-border);
    --ck-color-widget-type-around-button-blurred-editable: var(--ck-color-focus-border);
    --ck-color-widget-type-around-button-icon: var(--main-background-color);

    outline: var(--ck-widget-outline-thickness, 3px) solid var(--ck-color-focus-border);
}

/* Hides what a larger box size drew, until the Tiny row replaces it. */
.include-note[data-box-size="tiny"] > .include-note-wrapper > .include-note-body {
    display: none;
}

.include-note[data-box-size="tiny"] > .include-note-wrapper > .include-note-title-row {
    user-select: none;
    -webkit-user-select: none;
}

.include-note[data-hide-title="true"]:not([data-box-size="tiny"], [data-box-size="expandable"]) {
    > .include-note-wrapper > :is(.include-note-title-row, .include-note-title) {
        display: none;
    }

    > .include-note-wrapper > .include-note-body > .include-note-content:not(:fullscreen) {
        border-top: none;
        border-radius: var(--_include-note-top-border-radius, 8px)
                       var(--_include-note-top-border-radius, 8px) 0 0;
    }
}

/* Media that renders edge-to-edge (iframes, images, video, full-height collection views) shouldn't
   be inset. List/grid collections keep their padding (they are content-driven, not full-height). */
.include-note-content.type-pdf,
.include-note-content.type-image,
.include-note-content.type-video,
.include-note-content.type-canvas,
.include-note-content.type-canvasDrawing,
.include-note-content.type-mermaidDiagram,
.include-note-content.type-extendedCodeBlock,
.include-note-content.type-webView,
.include-note-content.type-book:has(.note-list-widget.full-height),
.include-note-content.type-search:has(.note-list-widget.full-height) {
    box-sizing: content-box;
    padding: 0;
}

.include-note-content:fullscreen {
    display: flex;
    flex-direction: column;
    background-color: var(--main-background-color);
}

/* Scrolls in place of the fullscreen box, so that the exit button stays put. */
.include-note-content:fullscreen > .rendered-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.include-note-content:fullscreen > .rendered-content > .source-embed {
    height: 100%;
}

.include-note-content.type-text:fullscreen > .rendered-content:not(.full-content-width) > * {
    max-width: var(--preferred-max-content-width);
    margin-inline: auto;
}

.include-note-content:not(:fullscreen) > .include-note-fullscreen-controls {
    display: none;
}

.include-note-exit-fullscreen {
    --overlay-group-inset-top:
        calc(var(--safe-area-inset-top, env(safe-area-inset-top)) + var(--overlay-group-inset));
    --overlay-group-inset-end:
        calc(var(--safe-area-inset-right, env(safe-area-inset-right)) + var(--overlay-group-inset));
    /* Above the 10 of `.note-detail-error-card` in SplitEditor.css. */
    z-index: 11;
}

.include-note-exit-fullscreen > button {
    gap: 8px;
}

.alert {
    padding: 8px 14px;
    width: auto;
}

.alert-warning,
.alert-info {
    color: var(--main-text-color) !important;
    background-color: transparent !important;
    border-color: var(--main-border-color) !important;
}

.gutter {
    background: linear-gradient(to bottom, transparent, var(--accented-background-color), transparent);
}

.gutter:hover {
    background: linear-gradient(to bottom, transparent, var(--main-border-color), transparent);
}

.gutter.gutter-horizontal {
    cursor: col-resize;
}

.gutter.gutter-vertical {
    cursor: row-resize;
}

.hidden-ext.note-split + .gutter {
    display: none;
}

/* Keeps the style and layout of hidden tabs, so showing one again needs no full relayout. */
@supports (content-visibility: hidden) {
    #center-pane > .split-note-container-widget > .note-split.hidden-ext {
        display: flex !important;
        flex: 0 0 100% !important;
        margin-inline: -100% 0;
        content-visibility: hidden;
        clip-path: inset(50%);
        animation: none;
    }
}

.caret-stop {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    user-select: text;
}

.right-dropdown-widget {
    flex-shrink: 0;
}

.right-dropdown-widget .right-dropdown-button {
    position: relative;
}

.tooltip-trigger {
    background: transparent;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#launcher-pane.horizontal .right-dropdown-widget {
    width: 53px;
}

#launcher-pane.vertical .right-dropdown-widget {
    height: 53px;
}

/* rotate caret on hover */
.dropdown-menu > li > a:hover:after {
    text-decoration: underline;
    transform: rotate(-90deg);
}

/*
 * WebKit scrollbars
 */

:root {
    --scrollbar-thickness: 10px;
    --scrollbar-thumb-thickness: 3px;
    --scrollbar-thumb-hover-thickness: 6px;
    --scrollbar-start-end-gap: 8px;
}

/* Scrollbar's body */

@supports (-webkit-box-reflect: below) {
    ::-webkit-scrollbar {
        width: 12px;
    }
}

::-webkit-scrollbar-track {
    background-color: var(--scrollbar-background-color);
}

::-webkit-scrollbar:vertical {
    width: var(--scrollbar-thickness) !important;
}

::-webkit-scrollbar:horizontal {
    height: var(--scrollbar-thickness) !important;
}

/* Scrollbar's thumb */

::-webkit-scrollbar-thumb {
    --s-thumb-thickness: var(--scrollbar-thumb-thickness);
    --s-thumb-color: var(--scrollbar-thumb-color);

    --s-gradient-angle: 90deg;
    --s-gradient-p1: calc((var(--scrollbar-thickness) - var(--s-thumb-thickness)) / 2);
    --s-gradient-p2: calc(var(--s-gradient-p1) + var(--s-thumb-thickness));

    border: none !important;
    background: linear-gradient(var(--s-gradient-angle),
                                transparent, transparent var(--s-gradient-p1),
                                var(--s-thumb-color) 0px, var(--s-thumb-color) var(--s-gradient-p2),
                                transparent 0) !important;

    border-radius: calc(var(--scrollbar-thickness) / 2) !important;
}

::-webkit-scrollbar-thumb:horizontal {
    --s-gradient-angle: 0deg;
}

::-webkit-scrollbar-thumb:hover {
    --s-thumb-thickness: var(--scrollbar-thumb-hover-thickness);
    --s-thumb-color: var(--scrollbar-thumb-hover-color);
}

/* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap).
 * This gap is useful also to avoid breaking the rounded corners of a container when a
 * custom scrollbar background color is used. */

::-webkit-scrollbar-button:vertical {
    height: var(--scrollbar-start-end-gap);
}

::-webkit-scrollbar-button:horizontal {
    width: var(--scrollbar-start-end-gap);
}

/*
 * Firefox scrollbars
 *
 * Unsupported features: --scrollbar-thumb-thickness, --scrollbar-thumb-hover-thickness,
 *                       --scrollbar-start-end-gap, --scrollbar-thumb-hover-color.
 */

:root {
    scrollbar-color: var(--scrollbar-thumb-color) transparent;
    scrollbar-width: var(--scrollbar-thickness);
}

@supports (-webkit-box-reflect: below) {
    /* Prevent the scrollbar-color and scrollbar-width properties to override the custom styles
     * defined using ::-webkit-scrollbar. */
    :root {
        scrollbar-color: unset;
        scrollbar-width: unset;
    }
}

::-webkit-scrollbar-corner {
    background-color: inherit;
}

::selection {
    background-color: var(--selection-background-color);
}

/*
 * Fades a scroll container's content out at its edges instead of hard-clipping it, so text
 * dissolves toward whatever chrome sits past the edge (a section title bar, a composer).
 * A mask rather than an overlay gradient because the content becomes genuinely transparent:
 * this holds up when the pane background is a semi-transparent tint over a window material
 * (Mica/vibrancy), which no painted gradient color could match. Opt in per edge by setting
 * `--scroll-fade-top` / `--scroll-fade-bottom` on the scroll container (or an ancestor);
 * each edge defaults to a hard clip. The defaults are `var()` fallbacks rather than custom
 * property declarations here, so a widget's knobs win regardless of stylesheet bundling
 * order. The overlay scrollbar fades over the same distance — the cost of masking the
 * scroll container itself, accepted wherever this is used.
 */
.scroll-edge-fade {
    mask-image: linear-gradient(
        to bottom,
        transparent,
        black var(--scroll-fade-top, 0px),
        black calc(100% - var(--scroll-fade-bottom, 0px)),
        transparent
    );
}

[data-bs-toggle="tooltip"]:not(.button-widget) span {
    padding-bottom: 0;
    border-bottom: 1px dotted;
}

.hidden-int,
.hidden-ext {
    display: none !important;
}

/* Snippet form */

.ck.ck-template-form__text-part {
    margin-inline-start: 0.5em;
    line-height: 1.2em !important;
}

.ck.ck-template-form__text-part > span {
    line-height: inherit !important;
}

.ck.ck-template-form__text-part .ck-template-form__description {
    display: block;
    opacity: 0.8;
}

.area-expander {
    display: flex;
    flex-direction: row;
    color: var(--muted-text-color);
    font-size: 90%;
}

.area-expander hr {
    height: 1px;
    border-color: var(--main-border-color);
    position: relative;
    top: 4px;
    margin-top: 5px;
}

.area-expander-text {
    padding-inline-start: 20px;
    padding-inline-end: 20px;
    white-space: nowrap;
}

.area-expander:hover {
    cursor: pointer;
}

.area-expander:hover hr {
    border-color: var(--main-text-color);
}

.area-expander:hover .area-expander-text {
    color: var(--main-text-color);
}

.help-dropdown {
    display: inline-block;
}

.help-dropdown .dropdown-menu {
    border-radius: 10px;
    border-width: 2px;
    box-shadow: 10px 10px 93px -25px black;
    padding: 10px 15px 10px 15px !important;
    width: 600px;
    white-space: normal;
}

.help-dropdown .dropdown-menu pre {
    background-color: var(--accented-background-color);
    padding: 10px;
    margin: 10px;
}

.help-dropdown code {
    font-variant-ligatures: none;
}

#launcher-pane .launcher-button {
    font-size: 150%;
    /* Matches the `line-height: 1` boxicons gives an icon-only launcher, so an icon in a child
       span, as in a dropdown launcher, centers the same way. */
    line-height: 1;
    display: inline-block;
    padding: 0;
    cursor: pointer;
    border: none;
    color: var(--launcher-pane-text-color);
    background-color: transparent;
    flex-shrink: 0;
}

#launcher-pane div.launcher-button {
    display: flex;
    justify-content: center;
    align-items: center;
}

#launcher-pane.vertical .launcher-button {
    width: 100%;
    height: 53px;
}

#launcher-pane.horizontal .launcher-button {
    width: 53px;
    height: 100%;
}

#launcher-pane.horizontal .quick-search {
    width: 350px;
    min-width: 150px;
}

#launcher-pane .icon-action:hover {
    background-color: var(--hover-item-background-color);
}

#left-pane {
    color: var(--left-pane-text-color);
    background-color: var(--left-pane-background-color);
}

/* Mobile, phone mode */

#detail-container {
    max-height: 100%;
    position: relative;
}

@media (max-width: 991px) {
    /* The launcher bar's menus stand in the page's body, in a wrapper with their dropdown's class,
       outside the bar whose `--launcher-pane-size` the theme sets, so its horizontal size is read
       where the theme defines it. */
    body.mobile .tn-dropdown-portal:is(.global-menu, .right-dropdown-widget) > .dropdown-menu.show,
    body.mobile .dropdown-menu.mobile-bottom-menu.show {
        --dropdown-bottom: calc(var(--mobile-bottom-offset) + var(--launcher-pane-horiz-size, var(--launcher-pane-size)));
        position: fixed !important;
        bottom: var(--dropdown-bottom) !important;
        top: unset !important;
        inset-inline-start: 0 !important;
        inset-inline-end: 0 !important;
        transform: unset !important;
        overflow-y: auto;
        max-height: calc(var(--tn-modal-max-height) - var(--dropdown-bottom));
    }

    body.mobile .tn-dropdown-portal.right-dropdown-widget > .dropdown-menu.show {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    body.mobile .dropdown-menu.mobile-bottom-menu.show {
        --dropdown-bottom: 0px;
        padding-bottom: calc(max(var(--menu-padding-size), var(--safe-area-inset-bottom, env(safe-area-inset-bottom)))) !important;
    }

    #mobile-rest-container {
        overflow: clip;
        position: relative;
    }

    #mobile-rest-container > #mobile-sidebar-wrapper {
        position: absolute;
        top: 0;
        inset-inline-start: 0;
        height: 100%;
        width: 100%;
        transition: transform 250ms ease-in-out;
        background: var(--main-background-color);

        &:not(.show, .dragging) {
            visibility: hidden;
            transition: transform 250ms ease-in-out, visibility 0s 250ms;
        }
    }

    #detail-container {
        position: relative;
        width: 100%;
        background: var(--main-background-color);
        transition: transform 250ms ease-in-out;

        &::before {
            content: "";
            position: absolute;
            inset-block: 0;
            inset-inline-end: 100%;
            width: 24px;
            background: linear-gradient(to left, rgba(0, 0, 0, 0.12), transparent);
            pointer-events: none;
            transition: opacity 250ms ease-in-out;
        }
    }

    body.mobile-sidebar-open #detail-container::before {
        opacity: 0;
    }

    #mobile-rest-container.instant-screen-change {
        > #mobile-sidebar-wrapper,
        > #detail-container,
        > #detail-container::before {
            transition: none !important;
        }
    }

    body[dir="rtl"] #detail-container::before {
        background: linear-gradient(to right, rgba(0, 0, 0, 0.12), transparent);
    }

    .note-split.empty-note {
        --max-content-width: var(--preferred-max-content-width);
    }

    .note-detail-empty {
        margin: 15px;
    }

    body.mobile #launcher-container {
        justify-content: space-evenly;
    }

    body.mobile .modal.show {
        background-color: var(--mobile-modal-backdrop-color);
    }

    body.mobile .modal-backdrop {
        background-color: transparent !important;
    }

    body.mobile > .tn-dropdown-portal > .tn-dropdown-backdrop,
    body.mobile .tn-popover-backdrop {
        background-color: var(--mobile-backdrop-color);
        opacity: 1;
    }

    body.mobile .modal-dialog {
        position: fixed;
        bottom: 0;
        inset-inline-start: 0;
        inset-inline-end: 0;
        margin: 0 !important;
        max-height: 85vh;
        display: flex;
    }

    body.mobile .modal-dialog.modal-dialog-full-page-on-mobile {
        width: 100%;
        height: 100%;
        max-height: unset;
        max-width: unset;

        .modal-header {
            margin-top: var(--safe-area-inset-top, env(safe-area-inset-top));
        }

        .modal-content {
            border-radius: 0;
            border: 0;

            .modal-body {
                overflow: scroll;
            }
        }
    }

    body.mobile .modal-content {
        overflow-y: auto;
        border-radius: var(--bs-modal-border-radius) var(--bs-modal-border-radius) 0 0;
    }

    body.mobile .modal:not(.options-dialog) .modal-content {
        padding-left: var(--safe-area-inset-left, env(safe-area-inset-left));
        padding-right: var(--safe-area-inset-right, env(safe-area-inset-right));
    }

    body.mobile .modal-footer {
        padding-top: 12px;
        padding-bottom: calc(max(var(--safe-area-inset-bottom, env(safe-area-inset-bottom)), 12px));
    }

    body.mobile .help-dialog kbd {
        display: inline !important;
    }

    body.mobile .options-section-card table {
        word-break: break-all;
    }

    body.mobile .modal-dialog .dropdown-menu {
        position: static !important;
        border: 0 !important;
        border-radius: 0 !important;
        font-size: 1rem !important;
    }

    body.mobile .modal-dialog.modal-dialog-scrollable {
        height: unset;
    }
}

/* Mobile, tablet mode */
@media (min-width: 992px) {
    body.mobile #root-widget {
        flex-direction: column-reverse !important;
        background-color: var(--launcher-pane-background-color);
    }

    /* `column-reverse` puts `#mobile-bottom-bar` at the top, so the panes clear the navigation bar
       instead. The open keyboard covers the navigation bar, as in phone mode. */
    body.mobile #mobile-bottom-bar {
        padding-bottom: 0;
    }

    body.mobile #root-widget:not(.virtual-keyboard-opened) {
        #mobile-rest-container > #mobile-sidebar-wrapper,
        #detail-container {
            padding-bottom: var(--mobile-bottom-offset);
        }
    }

    #mobile-sidebar-wrapper {
        --navigator-backdrop: var(--left-pane-background-color);
        transform: none !important;
        background-color: var(--navigator-backdrop) !important;
    }

    #mobile-rest-container > #mobile-sidebar-wrapper.left-pane-hidden {
        display: none !important;
    }

    #mobile-rest-container > #mobile-sidebar-wrapper.left-pane-hidden ~ #detail-container {
        width: 100%;
    }

    #mobile-rest-container {
        background-color: var(--root-background);
    }

    #detail-container {
        background: var(--main-background-color);
    }

    body.mobile {
        .modal-dialog {
            margin: var(--bs-modal-margin);
            max-width: 80%;
        }

        .modal-content {
            height: 100%;
        }
    }
}

#launcher-pane {
    color: var(--launcher-pane-text-color);
    background-color: var(--launcher-pane-background-color);
    position: relative;
}

#launcher-pane .right-dropdown-widget {
    position: static;
}

#right-pane .card {
    border: 0;
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    margin-inline-start: 10px;
    margin-inline-end: 5px;
    background: transparent;
}

#right-pane .card-header {
    padding: 6px 0 3px 0;
    width: 99%; /* to give minimal right margin */
    background-color: var(--button-background-color);
    border-color: var(--button-border-color);
    border-width: 0 0 1px 0;
    border-radius: 4px;
    border-style: solid;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: bold;
    color: var(--muted-text-color) !important;
}

#right-pane .card-header-title {
    text-transform: uppercase;
}

#right-pane .card-header-buttons {
    display: flex;
    transform: scale(0.9);
    position: relative;
    top: 2px;
}

#right-pane .body-wrapper {
    overflow: auto;
}

#right-pane .card-body {
    width: 100%;
    padding: 8px;
    border: 0;
    height: 100%;
    overflow: auto;
}

#right-pane .card-body ul {
    margin-bottom: 5px;
}

.text-with-ellipsis {
    overflow-x: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.note-split {
    /* Limits the maximum width of the note */
    --max-content-width: var(--preferred-max-content-width);

    margin-inline-start: auto;
    margin-inline-end: auto;
}

.note-split.full-content-width {
    --max-content-width: unset;
}

body.mobile {
    /* The full width of a text note table, read by `TriliumTableScroll` and `table_scroll.css`. */
    --table-reference-width: var(--preferred-max-content-width);
}

button.close:hover {
    text-shadow: none;
    color: currentColor;
}

.hidden-no-content {
    display: none;
}

.reference-link small {
    display: inline-block;
}

:root a.reference-link.reference-link-missing,
.ck-content a.reference-link > span.reference-link-missing {
    color: var(--bs-danger);
}

/* The board column a reference points at. `--custom-color` is set by the theme on
   `.use-note-color`. */
.reference-link small.use-note-color {
    color: var(--custom-color, inherit);
}

.options-section:first-of-type h4 {
    margin-top: 0;
}

.options-section h4 {
    margin-top: 25px;
    margin-bottom: 15px;
}

.options-section-card h5 {
    margin-top: 10px;
    margin-bottom: 10px;
}

.options-section-card input[type="number"] {
    /* overriding settings from .form-control */
    width: 10em !important;
    flex-grow: 0 !important;
}

textarea {
    cursor: auto;
}

.attachment-actions-toolbar {
    display: flex;
    align-items: center;
}

.attachment-help-button {
    display: inline-block;
    margin-inline-start: 10px;
    vertical-align: middle;
    font-size: 1em;
}

.empty-table-placeholder {
    text-align: center;
    color: var(--muted-text-color);
}

body.electron.platform-darwin:not(.native-titlebar) .tab-row-container {
    padding-inline-start: 1em;
}

.tab-row-widget {
    contain: inline-size;
}

#tab-row-left-spacer {
    -webkit-app-region: drag;
}

/*
 * Only macOS reserves the traffic lights' room with this spacer; every other platform uses the
 * container padding below, which handles controls on either side. Keeping the spacer at zero
 * elsewhere avoids reserving `titlebar-area-x` twice on a Linux desktop with left-hand controls.
 *
 * `titlebar-area-x` is where the traffic lights actually end, as the platform measures it, and it
 * is reported in CSS pixels — so it already accounts both for the width the running macOS gives
 * the cluster and for the page zoom, which the system-drawn buttons do not follow. A fixed reserve
 * cannot do either: it shrinks with the page while the buttons stay put, so zooming out slid them
 * over whatever the tab bar puts first (the pane toggle). It resolves to zero when there are no
 * controls to clear, i.e. with a native title bar or in full screen.
 */
body.electron.platform-darwin #tab-row-left-spacer {
    width: env(titlebar-area-x);
}

/*
 * Keep the tab bar clear of the Window Controls Overlay. Its side follows the UI direction on
 * Windows and the desktop's decoration layout (GNOME's `button-layout`) on Linux, so reserve space
 * on whichever side(s) Chromium actually took. `titlebar-area-*` are physical coordinates, so the
 * padding is physical too; logical padding swaps sides in a right-to-left locale.
 */
body.electron:not(.platform-darwin) .tab-row-container {
    padding-left: env(titlebar-area-x, 0px);
    padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));
}

@media (display-mode: window-controls-overlay) {
    body:not(.electron) .tab-row-container {
        padding-left: env(titlebar-area-x, 0px);
        padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));
    }
}

.tab-row-container .toggle-button {
    background: transparent;
    appearance: none;
    border: 0;
    width: 24px;
    height: 24px;
    color: var(--launcher-pane-text-color);
    margin: 8px 10px;
    font-size: 18px;
}

.recent-changes-content li > span:first-child::after {
    content: " - ";
}

.recent-changes-content li {
    border: 1px solid transparent;
}

.recent-changes-content li:not(.deleted-note):hover {
    border-color: var(--hover-item-border-color);
    background: var(--hover-item-background-color);
    color: var(--hover-item-text-color);
}

/* Content renderer */

footer.file-footer,
footer.webview-footer {
    display: flex;
    justify-content: center;
}

footer.file-footer button,
footer.webview-footer button {
    margin: 5px;
}

/* AI Chat Widget Styles */
.chat-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--main-border-color);
    background-color: var(--accented-background-color);
}

.chat-title {
    font-weight: bold;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-actions {
    display: flex;
    gap: 5px;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.chat-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-assistant {
    align-self: flex-start;
}

.chat-message-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--accented-background-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-message-user .chat-message-avatar {
    background-color: var(--primary-color);
    color: white;
}

.chat-message-assistant .chat-message-avatar {
    background-color: var(--muted-text-color);
    color: white;
}

.chat-message-content {
    flex-grow: 1;
    padding: 10px 15px;
    border-radius: 12px;
    background-color: var(--accented-background-color);
    overflow-wrap: break-word;
    word-break: break-word;
}

.chat-message-user .chat-message-content {
    background-color: var(--primary-color);
    color: white;
}

.chat-message-content pre {
    background-color: var(--main-background-color);
    border-radius: 5px;
    padding: 10px;
    overflow-x: auto;
    margin: 10px 0;
}

.chat-message-user .chat-message-content pre {
    background-color: rgba(255, 255, 255, 0.2);
}

.chat-message-content code {
    font-family: monospace;
    background-color: var(--main-background-color);
    padding: 2px 4px;
    border-radius: 3px;
}

.chat-message-user .chat-message-content code {
    background-color: rgba(255, 255, 255, 0.2);
}

.chat-controls {
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 10px;
    border-top: 1px solid var(--main-border-color);
}

.chat-input-container {
    position: relative;
}

.chat-input {
    width: 100%;
    resize: none;
    padding-inline-end: 40px;
}

.chat-buttons {
    display: flex;
    justify-content: space-between;
}

.chat-loading {
    animation: chat-loading 1s infinite;
    letter-spacing: 3px;
}

@keyframes chat-loading {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* Reset on every item, so the nested items of a checked item are not struck through. */
.ck-content ul.todo-list li {
    --todo-description-decoration: none;
    --todo-description-opacity: 1;
}

.ck-content ul.todo-list li:has(> span.todo-list__label input[type="checkbox"]:checked) {
    --todo-description-decoration: line-through;
    --todo-description-opacity: 0.6;
}

.ck-content ul.todo-list li span.todo-list__label__description {
    text-decoration: var(--todo-description-decoration);
    opacity: var(--todo-description-opacity);
    transition: opacity 200ms ease;
}

/*
 * Empty to-do item caret fix.
 *
 * CKEditor's default to-do list theme spaces the checkbox from the text using a
 * negative `margin-right: -15px` on the checkbox, which leaves the (still empty)
 * description as a zero-width inline box. Some engines (notably Electron/Chromium,
 * see upstream https://github.com/ckeditor/ckeditor5/issues/9141) cannot place the
 * caret inside such an empty inline box, so it collapses onto the checkbox with
 * no leading margin. Giving the empty description a real inline-block box lets the
 * caret land at the normal text offset. The filler <br> is only present while the
 * item is empty, so this reverts automatically as soon as the user types.
 */
.ck-editor__editable.ck-content ul.todo-list li span.todo-list__label__description:has(> br[data-cke-filler="true"]) {
    display: inline-block;
    min-width: 1px;
}

.chat-options-container {
    display: flex;
    margin: 5px 0;
    align-items: center;
    padding: 0 10px;
}

.chat-option {
    display: flex;
    align-items: center;
    font-size: 0.9em;
    margin-inline-end: 15px;
    cursor: pointer;
}

.chat-option input[type="checkbox"] {
    margin-inline-end: 5px;
}

/* Style for thinking process in chat responses */
.thinking-process {
    background-color: rgba(0, 0, 0, 0.05);
    border-inline-start: 3px solid var(--main-text-color);
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.thinking-step {
    margin-bottom: 8px;
    padding-inline-start: 10px;
}

.thinking-step.observation {
    border-inline-start: 2px solid #69c7ff;
}

.thinking-step.hypothesis {
    border-inline-start: 2px solid #9839f7;
}

.thinking-step.evidence {
    border-inline-start: 2px solid #40c025;
}

.thinking-step.conclusion {
    border-inline-start: 2px solid #e2aa03;
    font-weight: bold;
}

/*
 * In-content floating buttons
 */

.content-floating-buttons {
    position: absolute;
    z-index: 10; /* should be below dropdown (note actions) */
}

.content-floating-buttons.top-left {
    top: 10px;
    inset-inline-start: 10px;
}

.content-floating-buttons.top-right {
    top: 10px;
    inset-inline-end: 10px;
}

.content-floating-buttons.bottom-left {
    bottom: 10px;
    inset-inline-start: 10px;
}

.content-floating-buttons.bottom-right {
    bottom: 10px;
    inset-inline-end: 10px;
}

.content-floating-buttons button.tn-icon {
    font-size: 130%;
    padding: 1px 10px 1px 10px;
}

/* CK Editor */

/* Insert text snippet: limit the width of the listed items to avoid overly long names */
:root body.desktop div.ck-template-form li.ck-list__item .ck-template-form__text-part > span {
    max-width: 25vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.revision-diff-added {
    background: rgba(100, 200, 100, 0.5);
}

.revision-diff-removed {
    background: rgba(255, 100, 100, 0.5);
    text-decoration: line-through;
}

/* Content that sizes itself from its container while rendering (a Mermaid gantt chart) needs a
   real width: A4 minus the 2cm `@page` margins that `print.tsx` sets for the browser. */
iframe.print-iframe {
    position: absolute;
    top: 0;
    left: -10000px;
    width: 170mm;
    height: 0;
    border: 0;
}

.excalidraw.theme--dark canvas {
    --theme-filter: invert(100%) hue-rotate(180deg);
}

/* Scrolling container */

.note-split > .scrolling-container:is(.detail-full-height, .list-full-height) {
    display: flex;
    flex-direction: column;
}

.note-detail.full-height,
.scrolling-container > .note-list-widget.full-height {
    position: relative;
    flex-grow: 1;
    width: 100%;
    overflow: hidden;
}

/* Fills what the content above leaves, but never less than half the container, so content taller
   than the container pushes the collection below it instead of squeezing it to nothing. */
.scrolling-container > .note-list-widget.full-height {
    flex: 1 0 0;
    min-height: 50%;
}

/* A full-height note fills the container instead of scrolling it, so the padding that lets
   flowing content scroll past its end would only take height away from the note. */
.scrolling-container.detail-full-height > .scroll-padding-widget {
    display: none;
}

@media (max-width: 991px) {
    body.mobile {
        .split-note-container-widget {
            flex-direction: column !important;

            .note-split {
                width: 100%;
            }

            .note-split.visible + .note-split.visible {
                border-top: 1px solid var(--main-border-color);
            }
        }

        &:not(.ios) #root-widget.virtual-keyboard-opened .note-split:not(.active) {
            max-height: 80px;
            opacity: 0.4;
        }
    }
}

.title-row {
    height: 50px;
    min-height: 50px;
    align-items: center;
}

.ocr-text-section {
    padding: 10px;
    background: var(--accented-background-color);
    border-left: 3px solid var(--main-border-color);
    text-align: left;
    width: 100%;
}

.ocr-header {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--muted-text-color);
}

.ocr-content {
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap;
}

.ck-content pre code {
    tab-size: var(--code-block-tab-width, 4);
}

/*
 * COLLAPSIBLE LIST ITEMS
 */

:where(:root) {
    --text-editor-collapsible-list-arrow-color: var(--muted-text-color);
    /* Neutral by design: a translucent grey reads on both light and dark backgrounds. */
    --text-editor-collapsible-list-arrow-hover-background: rgba(128, 128, 128, 0.25);
    --text-editor-collapsible-list-arrow-hover-color: var(--main-text-color);
}

/*
 * TASK STATES
 */

:root .tn-task-checkbox {
    --_checkbox-size: 18px;

    position: relative;
    width: var(--_checkbox-size);
    height: var(--_checkbox-size);
}

/* Inline-block slot for using .tn-task-checkbox inside flowing text (e.g. the
   task-state line in the checkbox tooltip). Without a block-formatting
   ancestor the inner span is inline and its ::before / ::after collapse to
   zero size, showing only the glyph. */
.tn-task-checkbox-inline {
    display: inline-block;
    margin-inline-start: 8px;
    vertical-align: middle;
    line-height: 0;
}

.tn-task-checkbox-inline > .tn-task-checkbox {
    /* Scale the checkbox (and, via `calc(var(--_checkbox-size) * ratio)`,
       its glyph) to the surrounding text size so it fits the tooltip line
       instead of forcing the default 18px. */
    --_checkbox-size: 1.1em;
    display: block;
    transform: translateY(-0.05em);
}

/* Status line block above the checkbox tooltip's body. The 8px bottom margin
   separates it from the "Right click…" hint when the line is present; when
   the state is an anchor (unchecked/checked) the line is omitted entirely,
   so no spacing is added. */
.tn-task-tooltip-state {
    margin-bottom: 8px;
}

/*
 * Editor-only tweaks: summary acts like a regular editable text block, and the arrow is the
 * only collapse affordance (clicking the summary text places a caret instead of toggling).
 */

.ck-editor__editable details.trilium-collapsible {

    .ck-placeholder::before {
        opacity: 0.5;
    }

    /* Body-paragraph placeholder ("Content") is registered on the first body
     * block. Hide it whenever the body has more than one block — the hint is
     * only useful when the body is a single empty <p>. The body blocks live in
     * the editing-only `.trilium-collapsible-content` wrapper, so `:has(> :nth-child(2))`
     * matches a wrapper with 2+ body children; `:not(:last-child)` would only hide
     * the placeholder on non-last paragraphs, leaving the last one (e.g. the
     * original empty body after Enter-in-summary) still visible. */
    .trilium-collapsible-content:has(> :nth-child(2)) > p.ck-placeholder::before {
        display: none;
    }

    /* The shared `> *:last-child:not(summary)` rule now lands on the content
     * wrapper (which has no margin of its own); zero the wrapper's last body
     * block instead so the collapsible keeps its tight bottom padding. */
    .trilium-collapsible-content > *:last-child {
        margin-bottom: 0;
    }

    > summary {
        cursor: text;
        padding-right: calc(var(--_inline-padding) + 1lh); /* extra space for the handle on the right */

        /* Block selection handle (mirror of the table widget's drag handle).
         * Click selects the whole <details>; movement uses Alt+↑/↓ from there.
         * Sits in the details' top-left padding area, visible on hover. */
        > .trilium-collapsible-handle {
            position: absolute;
            top: 0;
            bottom: 0;
            right: var(--_inline-padding);
            z-index: 1000;
            width: 1lh;
            height: 1lh;
            cursor: default;
            opacity: 0;
            transition: opacity 0.15s ease;

            &::before {
                position: absolute;
                inset: 0;
                content: "\ec6c";
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 1em;
                font-family: boxicons;
                color: var(--muted-text-color, currentColor);
            }
        }
    }

    &:hover > summary > .trilium-collapsible-handle,
    &:focus-within > summary > .trilium-collapsible-handle {
        opacity: 1;
    }
}

/* Unknown state: orange outline */
.tn-unknown-task-state .todo-list__label input[type="checkbox"] {
    outline: 3px solid var(--task-checkbox-unknown-state-color);
}