@import "./boxicons-compat.css";

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

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

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

:root {
    --admonition-note-accent-color: #69c7ff;
    --admonition-tip-accent-color: #40c025;
    --admonition-important-accent-color: #9839f7;
    --admonition-caution-accent-color: #ff2e2e;
    --admonition-warning-accent-color: #e2aa03;
    --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;
    --ck-mention-list-max-height: 500px;
    --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: 300ms;
    --launcher-pane-size: 53px;
    --bs-body-color: var(--main-text-color);
}

html {
    /* this fixes FF filter vs. position fixed bug: https://github.com/zadam/trilium/issues/233 */
    height: 100vh;
    overscroll-behavior: none;
}

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: env(safe-area-inset-bottom);
}

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));
}

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: env(safe-area-inset-bottom);
        }
    }

    &.experimental-feature-new-layout #root-widget.horizontal-layout {
        >.status-bar {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }

    &:not(.experimental-feature-new-layout) #root-widget.horizontal-layout {
        #horizontal-main-container {
            padding-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-group.disabled,
.form-checkbox.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.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;
}

label.tn-radio input[type="radio"],
label.tn-checkbox input[type="checkbox"] {
    margin-inline-end: .5em;
}

#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;
}

.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);
}

button.custom-title-bar-button {
    background: transparent;
    border: unset;
}

.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;
}

.icon-action {
    border: 1px solid transparent;
    padding: 5px;
    width: 37px;
    height: 35px;
    cursor: pointer;
    font-size: 1.5em;
    color: var(--button-text-color);
    background: var(--button-background-color);
    border-radius: var(--button-border-radius);
}

.icon-action-always-border {
    border-color: var(--button-border-color);
}

.icon-action:hover:not(.disabled) {
    text-decoration: none;
    border-color: var(--button-border-color);
}

.icon-action.disabled {
    color: var(--muted-text-color) !important;
    cursor: not-allowed;
    pointer-events: none;
}

.icon-action.btn {
    padding: 0 8px;
    min-width: unset !important;
}

.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;
}

/* 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;
}

.dropdown-divider {
    border-color: var(--dropdown-border-color);
}

@keyframes dropdown-menu-opening {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.dropdown-menu,
.tabulator-popup-container,
:root .excalidraw .popover {
    color: var(--menu-text-color) !important;
    font-size: inherit;
    background: var(--menu-background-color) !important;
    user-select: none;
    -webkit-user-select: none;
    --bs-dropdown-zindex: 999;
    --bs-dropdown-link-active-bg: var(--active-item-background-color) !important;
}

body.desktop .dropdown-menu,
body.desktop .tabulator-popup-container,
:root .excalidraw .dropdown-menu .dropdown-menu-container,
:root .excalidraw .popover {
    border: 1px solid var(--dropdown-border-color);
    column-rule: 1px solid var(--dropdown-border-color);
    box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
    animation: dropdown-menu-opening 100ms ease-in;
}

@supports (animation-fill-mode: forwards) {
    /* Delay the opening of submenus */
    body.desktop:not(.motion-disabled) .dropdown-submenu .dropdown-menu {
        opacity: 0;
        animation-fill-mode: forwards;
        animation-delay: var(--submenu-opening-delay);
    }
}

.dropdown-menu.static {
    box-shadow: unset;
    backdrop-filter: unset !important;
}

.dropend .dropdown-toggle::after {
    margin-inline-start: 0.5em;
    color: var(--muted-text-color);
}

.dropdown-menu .disabled {
    color: #888 !important;
    pointer-events: none;
}

.dropdown-menu .disabled .contextual-help {
    pointer-events: all;
    margin-inline-start: 8px;
    font-size: 0.75rem;
    color: var(--contextual-help-icon-color);
    cursor: help;
    opacity: 0.75;
}

.dropdown-menu .disabled .contextual-help:hover {
    opacity: 1;
}

.dropdown-item:hover:not(.disabled, .dropdown-container-item),
.tabulator-menu-item:hover,
:root .excalidraw .context-menu .context-menu-item:hover {
    color: var(--hover-item-text-color) !important;
    background-color: var(--hover-item-background-color) !important;
    border-color: var(--hover-item-border-color) !important;
    cursor: pointer;
}

.dropdown-container-item,
.dropdown-item.dropdown-container-item:hover,
.dropdown-container-item:active {
    background: transparent;
    cursor: default;
}

.dropdown-menu a:not(.selected) .check {
    visibility: hidden;
}

.dropdown-menu:not(#context-menu-container) .dropdown-item,
body.desktop .dropdown-menu .dropdown-toggle,
body #context-menu-container .dropdown-item > span,
body.mobile .dropdown .dropdown-submenu > span {
    display: flex;
    align-items: center;
}


body.mobile .dropdown .dropdown-submenu {
    flex-wrap: wrap;

    & > span {
        flex-grow: 1;
    }
}

.dropdown-item span.keyboard-shortcut,
.dropdown-item *:not(.keyboard-shortcut) > kbd {
    flex-grow: 1;
    text-align: end;
    padding-inline-start: 12px;
}

.dropdown-menu kbd {
    color: var(--muted-text-color);
    border: none;
    background-color: transparent;
    box-shadow: none;
    padding-bottom: 0;
    padding: 0;
}

.dropdown-item,
.dropdown-header,
:root .excalidraw .context-menu .context-menu-item:hover {
    color: var(--menu-text-color) !important;
    border: 1px solid transparent !important;
}

/*  This is a workaround for Firefox not supporting break-before / break-after: avoid on columns.
 *  It usually wraps a menu item followed by a separator / header and another menu item. */
.dropdown-no-break {
    break-inside: avoid;
}

.dropdown-item.disabled,
.dropdown-item.disabled kbd {
    color: #aaa !important;
}

.dropdown-item.active,
.dropdown-item:focus {
    color: var(--active-item-text-color);
    background-color: var(--active-item-background-color);
    border-color: var(--active-item-border-color);
    outline: none;
}

.dropdown-item .destructive-action-icon {
    color: var(--dropdown-item-icon-destructive-color);
}

.dropdown-item > span:not([class]) {
    width: 100%;
}

.dropdown-menu .note-color-picker {
    padding: 4px 12px 8px 12px;
}

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

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

body .cm-editor .cm-placeholder {
    color: #999 !important;
}

#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-block-toolbar-button {
    transform: translateX(7px);
    color: var(--muted-text-color);
    background-color: var(--main-background-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;
}

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

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 {
    color: inherit !important;
    opacity: 1;
}

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

.pointer {
    cursor: pointer;
}

.show-recent-notes-button,
.input-clearer-button,
.go-to-selected-note-button {
    padding-top: 8px;
}

.show-recent-notes-button,
.full-text-search-button {
    cursor: pointer;
    font-size: 1.3em;
    padding-inline-start: 5px;
    padding-inline-end: 5px;
}

.input-clearer-button {
    cursor: pointer;
    font-size: 1.3em;
    background: inherit !important;
    padding-inline-start: 5px;
    padding-inline-end: 5px;
}

.open-external-link-button {
    cursor: pointer;
    font-size: 1.3em;
    padding-inline-start: 5px;
    padding-inline-end: 5px;
    padding-top: 8px;
}

.go-to-selected-note-button {
    cursor: pointer;
    font-size: 1.3em;
    padding-inline-start: 4px;
    padding-inline-end: 3px;
}

.go-to-selected-note-button.disabled,
.go-to-selected-note-button.disabled:hover {
    cursor: inherit;
    color: var(--button-disabled-text-color) !important;
    background-color: var(--button-disabled-background-color) !important;
    text-decoration: none;
}

.note-autocomplete-input {
    /* this is for seamless integration of "input clearer" button */
    border-inline-end: 0;
}

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

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

.tooltip {
    font-size: var(--main-font-size) !important;
    z-index: calc(var(--ck-z-panel) - 1) !important;
}

.tooltip.tooltip-top {
    z-index: 32767 !important;
}

/* Note tooltips are appended to <body> and are frequently triggered from inside modals
   (e.g. links or deleted-note entries in a dialog). The base .tooltip z-index sits below
   Bootstrap's modal, so raise them above it — matching .tooltip-top. */
.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 {
    padding: 15px;
    background-color: var(--tooltip-background-color) !important;
    border: 1px solid var(--main-border-color);
    border-radius: 5px;
    text-align: start;
    color: var(--main-text-color) !important;
    max-width: 500px;
    white-space: pre-line;
    box-shadow: 10px 10px 93px -25px #aaaaaa;
}

.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-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;
}

.tooltip.show {
    opacity: 1;
}

.algolia-autocomplete {
    width: calc(100% - 30px);
    z-index: 2000 !important;
}

.algolia-autocomplete-container .aa-dropdown-menu {
    position: inherit !important;
    overflow: auto;
}

.algolia-autocomplete .aa-input,
.algolia-autocomplete .aa-hint {
    width: 100%;
}

.algolia-autocomplete .aa-dropdown-menu {
    width: 100%;
    background-color: var(--main-background-color);
    border: 1px solid var(--main-border-color);
    border-top: none;
    z-index: 2000 !important;
    max-height: 500px;
    overflow: auto;
    padding: 0;
    margin: 0;
}

.aa-dropdown-menu .aa-suggestion {
    cursor: pointer;
    padding: 6px 16px;
    margin: 0;
}

.aa-dropdown-menu .aa-suggestion .icon {
    display: inline-block;
    line-height: inherit;
    vertical-align: top;
}

.aa-dropdown-menu .aa-suggestion .text {
    display: inline-block;
    width: calc(100% - 20px);
    padding-inline-start: 4px;
}

.aa-dropdown-menu .aa-suggestion .search-result-title {
    display: block;
}

.aa-dropdown-menu .aa-suggestion .search-result-attributes {
    display: block;
    font-size: 0.8em;
    color: var(--muted-text-color);
    opacity: 0.6;
    line-height: 1;
    word-wrap: break-word;
}

.aa-dropdown-menu .aa-suggestion p {
    padding: 0;
    margin: 0;
}

.aa-dropdown-menu .aa-suggestion.aa-cursor {
    color: var(--active-item-text-color);
    background-color: var(--active-item-background-color);
}

.help-button,
.custom-title-bar-button {
    float: inline-end;
    background: none;
    font-weight: 900;
    border: 0;
    cursor: pointer;
}

.help-button {
    color: orange;
}

.multiplicity {
    font-size: 1.3em;
}

/* this is because bootstrap (?) sets code color to red for some reason */
code {
    color: inherit !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) 0;

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

.ck-editor__editable .ck-mermaid__editing-view {
    font-family: var(--monospace-font-family);
}

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);
}

: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;
}

.ck-content a:hover {
    text-decoration: underline;
}

.ck-content .footnote-section {
    border: 1px solid #c4c4c4;
    border-radius: 2px;
    counter-reset: footnote-counter;
    margin: 1em 0;
    padding: 10px;
}

.ck-content .footnote-item {
    counter-increment: footnote-counter;
    display: flex;
    list-style: none;
    margin-inline-start: 0.5em;
}

.ck-content .footnote-item > * {
    vertical-align: text-top;
}

.ck-content .footnote-back-link {
    margin-inline-end: 0.1em;
    position: relative;
    top: -0.2em;
}

.ck-content .footnotes .footnote-back-link > sup {
    margin-inline-end: 0;
}

.ck-content .footnote-item:before {
    content: counter(footnote-counter) ". ";
    display: inline-block;
    min-width: fit-content;
    position: relative;
    inset-inline-end: 0.2em;
    text-align: end;
}

.ck-content .footnote-content {
    border-radius: 2px;
    display: inline-block;
    flex-grow: 1;
    padding: 0 0.3em;
    width: 95%;
}

.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;
}

a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href^="https://"]:not(.no-arrow):after
{
    font-size: smaller;
    content: "\2197";
    vertical-align: top;
}

.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-header .help-button,
.modal-header .custom-title-bar-button {
    padding: 6px;
    margin: 0 12px;
}

.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;
}

.ck-mentions .ck-button {
    font-size: var(--detail-font-size) !important;
    padding: 5px;
}

.ck-mentions .ck-button b {
    font-size: var(--detail-font-size) !important;
}

.ck-mentions {
    --ck-color-list-button-on-background: var(--active-item-background-color);
    --ck-color-list-button-on-background-focus: var(--ck-color-list-button-on-background);
    --ck-color-list-button-on-text: var(--active-item-text-color);
}

.ck-mentions .ck-button b {
    font-weight: bold !important;
    color: inherit !important;
    vertical-align: baseline !important;
}

.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 {
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid var(--card-border-color, var(--main-border-color));
    background-color: var(--card-background-color, var(--accented-background-color));
    display: flex; /* see https://github.com/zadam/trilium/issues/1590 */
    transition: background-color 200ms ease-out;
}

/* 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: 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: 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: 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: 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: 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: 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: 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: 20em;
}

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

/* Header: the standalone title (non-expandable) and the title row (expandable)
   both act as the card header, mirroring the grid/list note-book-card header. */
.include-note-wrapper > .include-note-title,
.include-note-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: .5rem 1rem;
    font-size: 1em;
    font-weight: 500;
    border-bottom: 1px solid var(--card-border-color, var(--main-border-color));
}

/* 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;
}

/* Expandable include note styles */
.include-note-title-row {
    cursor: pointer;
}

/* The title inside the expandable row defers its header styling to the row. */
.include-note-title-row .include-note-title {
    margin: 0;
    padding: 0;
    border-bottom: none;
    font-weight: inherit;
    font-size: inherit;
    min-width: 0;
    flex-grow: 1;
}

.include-note-toggle {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--muted-text-color);
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.include-note-toggle:hover {
    color: var(--main-link-color);
}

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

.include-note-content {
    padding: .75rem 1rem;
}

.include-note-content > .rendered-content > *:last-child {
    margin-bottom: 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-webView,
.include-note-content.type-book:has(.note-list-widget.full-height),
.include-note-content.type-search:has(.note-list-widget.full-height) {
    padding: 0;
}

.include-note[data-box-size="expandable"] .include-note-content {
    padding-top: 0;
}

.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;
}

#context-menu-cover.show {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    bottom: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.1);
}

#context-menu-container {
    max-height: 100vh;
    /* !!! Cannot set overflow: auto, submenus will break !!! */
}

body.mobile #context-menu-container.mobile-bottom-menu {
    position: fixed !important;
    inset-inline-start: 0 !important;
    inset-inline-end: 0 !important;
    bottom: 0 !important;
    top: unset !important;
    max-height: var(--tn-modal-max-height);
    overflow: auto !important;
    user-select: none;
    -webkit-user-select: none;
    padding-bottom: max(env(safe-area-inset-bottom), var(--padding, var(--menu-padding-size))) !important;
}

body.mobile .dropdown-menu {
    position: fixed !important;
    z-index: 3000 !important;
}

body.mobile .dropdown-submenu > .dropdown-menu {
    position: static !important;
    border: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    top: unset !important;
    margin-top: 0 !important;
    width: 100%;
}

#context-menu-container,
#context-menu-container .dropdown-menu,
.tabulator-popup-container {
    padding: 3px 0;
    z-index: 2000;
}

#context-menu-container .dropdown-item,
.tabulator-menu .tabulator-menu-item {
    padding: 0 7px 0 10px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

body.desktop li.dropdown-submenu:hover > ul.dropdown-menu {
    display: block;
}

.dropdown-submenu {
    position: relative;
}

.dropdown-submenu > .dropdown-menu {
    top: 0;
    inset-inline-start: calc(100% - 2px); /* -2px, otherwise there's a small gap between menu and submenu where the hover can disappear */
    margin-top: -10px;
    /* to make submenu scrollable https://github.com/zadam/trilium/issues/3136 */
    max-height: 600px;
    overflow: auto;
}

/* Flipped upward (added by ContextMenu.repositionSubmenu) when the submenu would overflow the bottom of the viewport. */
.dropdown-submenu > .dropdown-menu.submenu-flip-up {
    top: auto;
    bottom: 0;
    margin-top: 0;
    margin-bottom: -10px;
}

body.desktop .dropdown-submenu > .dropdown-menu {
    min-width: max-content;
    max-width: 300px;
}

.dropdown-submenu.dropstart > .dropdown-menu,
body:not(.mobile) #launcher-pane.horizontal .dropdown-submenu > .dropdown-menu {
    inset-inline-start: auto;
    inset-inline-end: calc(100% - 2px);
}

.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);
}

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

::-webkit-scrollbar-thumb {
    border-radius: 5px;
    border: 1px solid var(--scrollbar-border-color);
    background-color: var(--scrollbar-background-color);
}

::-webkit-scrollbar-button {
    display: none;
}

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

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

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

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

.ck.ck-mentions > .ck-list__item {
    max-width: 700px;
}

.ck.ck-mentions > .ck-list__item .ck-button {
    /* wrap text for very long note path title */
    white-space: normal !important;
}

/* Slash commands */

.ck.ck-slash-command-button {
    padding: 0.5em 1em !important;
}

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

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

.ck.ck-slash-command-button__text-part .ck.ck-slash-command-button__description,
.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%;
    display: inline-block;
    padding: 13px 13px;
    cursor: pointer;
    border: none;
    color: var(--launcher-pane-text-color);
    background-color: transparent;
    flex-shrink: 0;
}

#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) {
    body.mobile #launcher-pane .dropdown.global-menu > .dropdown-menu.show,
    body.mobile #launcher-container .dropdown > .dropdown-menu.show,
    body.mobile .dropdown-menu.mobile-bottom-menu.show {
        --dropdown-bottom: calc(var(--mobile-bottom-offset) + 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 #launcher-container .dropdown > .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), env(safe-area-inset-bottom))) !important;
    }

    #mobile-sidebar-container {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        inset-inline-end: 0;
        bottom: 0;
        z-index: 1000;
        transition: background-color 250ms ease-in-out;
        visibility: hidden;
        background: rgba(0, 0, 0, 0.4);
    }

    #mobile-sidebar-container.show {
        visibility: visible;
    }

    #mobile-rest-container > #mobile-sidebar-wrapper {
        position: absolute;
        top: 0;
        inset-inline-start: 0;
        height: 100dvh;
        width: 85vw;
        padding-top: var(--safe-area-inset-top, env(safe-area-inset-top));
        transform: translateX(-100%);
        transition: transform 250ms ease-in-out;
        background: var(--main-background-color);
        z-index: 2000;
    }

    body[dir="rtl"] #mobile-rest-container > #mobile-sidebar-wrapper {
        transform: translateX(100%);
    }

    #detail-container {
        width: 100%;
    }

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

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

    #mobile-sidebar-container.show #mobile-sidebar-wrapper {
        transform: translateX(0);
    }

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

    body.mobile .modal.show {
        background-color: rgba(0, 0, 0, 0.7);
    }

    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: 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-footer {
        padding-top: 12px;
        padding-bottom: calc(max(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 .jump-to-note-dialog {
        .modal-header {
            padding-bottom: 0.75rem !important;
        }

        .modal-content {
            padding-bottom: 0 !important;
        }

        .modal-body {
            overflow-y: auto;
        }

        .aa-dropdown-menu {
            max-height: unset;
            overflow: auto;
        }

        .aa-suggestion {
            padding-inline: 0;
        }
    }

    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);
    }

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

    #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 {
    overflow: auto;
}

#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 {
    padding-inline-start: 25px;
    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;
}

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

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

.reference-link .tn-icon {
    position: relative;
    top: 1px;
    margin-inline-end: 3px;
}

.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;
}

.ck-powered-by-balloon {
    display: none !important;
}

.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 {
    width: env(titlebar-area-x);
    -webkit-app-region: drag;
}

body.electron.platform-darwin:not(.native-titlebar):not(.full-screen) #tab-row-left-spacer {
    width: 80px;
}

body.electron:not(.platform-darwin) .tab-row-container {
    padding-inline-end: calc(100vw - 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);
}

.note-split.type-geoMap .floating-buttons-children {
    background: var(--main-background-color);
    box-shadow: 0px 10px 20px rgba(0, 0, 0, var(--dropdown-shadow-opacity));
    border-radius: 4px;
}

body.zen {
    --tab-bar-height: 0;
}

body.zen .gutter,
body.zen #launcher-container,
body.zen #launcher-pane,
body.zen #left-pane,
body.zen #right-pane,
body.zen .right-pane-peek-button,
body.zen #mobile-sidebar-wrapper,
body.zen .tab-row-container,
body.zen .tab-row-widget,
body.zen .shared-info-widget,
body.zen .ribbon-container:not(:has(.classic-toolbar-widget)),
body.zen .ribbon-container:has(.classic-toolbar-widget) .ribbon-top-row,
body.zen .ribbon-container .ribbon-body:not(:has(.classic-toolbar-widget)),
body.zen .title-row .icon-action,
body.zen .note-badges > *:not(.read-only-badge),
body.zen .ribbon-button-container,
body.zen .inline-title,
body.zen .promoted-attributes-widget,
body.zen .floating-buttons-children > *:not(.bx-edit-alt),
body.zen .action-button,
body.zen .tooltip.content-hint, /* content-area hints (task states, collapsible summaries, drag handles) */
body.zen .note-split:not(.type-book) .note-list-widget {
    display: none !important;
}

body.experimental-feature-new-layout.zen #vertical-main-container {
    /* Remove the placeholder for the right pane peek button */
    --right-pane-peek-button-gutter: 0;
}

body.zen .split-note-container-widget > .gutter {
    display: unset !important;
}

body.zen #launcher-pane {
    position: absolute !important;
    top: 0 !important;
    inset-inline-end: 0 !important;
    width: 64px !important;
    height: 64px !important;
    background: transparent !important;
    border: 0 !important;
}

body.zen .title-row {
    height: unset !important;
    -webkit-app-region: drag;
    padding-inline-start: env(titlebar-area-x);
    padding-inline-end: calc(100vw - env(titlebar-area-width, 100vw) + 2.5em);
    border-bottom: none !important;
}

body.zen .floating-buttons {
    top: -10px;
}

body.zen .floating-buttons-children {
    inset-inline-end: 0;
}

body.zen .floating-buttons-children .button-widget {
    width: var(--zen-button-size);
    height: var(--zen-button-size);
    padding: 0;
}

body.zen .note-title-widget,
body.zen .note-title-widget input {
    font-size: 1rem !important;
}

body.zen #detail-container {
    width: 100%;
}

body.zen .note-split:not(.full-content-width) .scrolling-container {
    display: flex;
    flex-direction: column;
    scroll-behavior: unset !important;
}

body.zen .note-split:not(.full-content-width) .note-detail {
    margin: auto;
    padding-bottom: 25vh;
    max-width: var(--max-content-width);
    width: 100%;
}

body.zen .note-split:not(.full-content-width) .scroll-padding-widget {
    display: none;
}

body.zen .note-split.type-text {
    position: relative;
    font-size: 1.15em;
}

body.zen:not(.backdrop-effects-disabled) .note-split.type-text .title-row {
    --start-color: var(--main-background-color);

    position: absolute;
    width: 100%;
    background: linear-gradient(var(--start-color) 30%, transparent 100%);
    z-index: 1000;
}

@supports (background: color-mix(in srgb, white, transparent)) {
    body.zen .note-split.type-text .title-row {
        --start-color: color-mix(in srgb, var(--main-background-color), transparent 10%);
    }
}

body.zen .note-split.type-text .scrolling-container {
    --padding-bottom: 130px; /* Should be enough to avoid caret being hidden by the formatting toolbar */

    /* (Usually) keeps the caret above the fixed toolbar */
    scroll-padding-bottom: var(--padding-bottom);
}

body.zen:not(.backdrop-effects-disabled) .note-split.type-text .scrolling-container {
    --padding-top: 50px; /* Should be enough to cover the title row */

    padding-top: var(--padding-top);
    scroll-padding-top: var(--padding-top);
}

/* Fixed formatting toolbar */

body.zen:not(.experimental-feature-new-layout) {
    .note-split .ribbon-container {
        position: fixed;
        left: 0;
        bottom: 20px;
        width: 100%;
        z-index: 1000;
        opacity: 0; /* Hidden unless the current note split is focused */
        pointer-events: none;
        transition: opacity 100ms linear;
    }

    .note-split:focus-within .ribbon-container {
        opacity: 1; /* Show when the note split is focused */
    }

    .note-split .ribbon-container .ribbon-body {
        border: 0;
    }

    .note-split .ribbon-container .classic-toolbar-widget {
        margin: auto;
        width: fit-content;
        box-shadow: 0px 10px 20px rgba(0, 0, 0, .1);
        border-radius: 8px;
        border: 1px solid var(--main-border-color);
        padding: 4px;
        background: var(--menu-background-color);
    }

    .note-split .ribbon-container .classic-toolbar-widget:not(:has(> .ck-toolbar)) {
        /* Hide the toolbar wrapper if the toolbar is missing */
        display: none;
    }

    .note-split:focus-within .ribbon-container .classic-toolbar-widget {
        pointer-events: all;
    }

    @media (max-width: 1300px) {
        .note-split .ribbon-container .classic-toolbar-widget {
            /* Set the toolbar to full with */
            width: 100%;
        }

        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_se,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_sw,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_smw,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_sme,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_s {
            /* Force toolbar items overflow dropdowns open upwards */
            top: auto;
            bottom: 100%;
        }
    }
}

body.zen.experimental-feature-new-layout {
    .status-bar {
        display: none;
    }

    .classic-toolbar-widget {
        position: fixed;
        left: 50%;
        bottom: 20px;
        z-index: 1000;
        opacity: 0; /* Hidden unless the current note split is focused */
        pointer-events: none;
        transition: opacity 100ms linear;
        width: fit-content;
        box-shadow: 0px 10px 20px rgba(0, 0, 0, .1);
        border-radius: 8px;
        border: 1px solid var(--main-border-color);
        padding: 4px;
        background: var(--menu-background-color) !important;
        transform: translateX(-50%);
        backdrop-filter: blur(6px);
    }

    #root-widget:has(.note-split.type-text:focus-within) .classic-toolbar-widget,
    .classic-toolbar-widget:focus-within {
        opacity: 1; /* Show when the note split is focused */
        pointer-events: all;
    }

    @media (max-width: 1300px) {
        .classic-toolbar-widget {
            /* Set the toolbar to full with */
            width: 100%;
        }

        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_se,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_sw,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_smw,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_sme,
        .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_s {
            /* Force toolbar items overflow dropdowns open upwards */
            top: auto;
            bottom: 100%;
        }
    }
}

/* 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; }
}

/* Right Pane Tab Styles */
#right-pane-tab-container {
    display: flex;
    gap: 10px;
}

.right-pane-tab {
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s ease;
}

.right-pane-tab:hover {
    background-color: var(--hover-item-background-color);
}

.right-pane-tab.active {
    background-color: var(--primary-color);
    color: white;
}

.right-pane-tab .tab-title {
    display: flex;
    align-items: center;
    gap: 5px;
}

.right-pane-tab .tab-title .tn-icon {
    font-size: 1.1em;
}

.admonition {
    --accent-color: var(--card-border-color);
    background: color-mix(in srgb, var(--accent-color) 15%, transparent);
    border: 1px solid var(--accent-color);
    border-radius: 0.5em;
    padding: 1em;
    margin: 1.25em 0;
    position: relative;
    padding-inline-start: 2.5em;
    overflow: hidden;
}

.admonition p:last-child {
    margin-bottom: 0;
}

.admonition::before {
    color: var(--accent-color);
    font-family: boxicons !important;
    position: absolute;
    top: 1em;
    inset-inline-start: 1em;
}

.admonition.note { --accent-color: var(--admonition-note-accent-color); }
.admonition.tip { --accent-color: var(--admonition-tip-accent-color); }
.admonition.important { --accent-color: var(--admonition-important-accent-color); }
.admonition.caution { --accent-color: var(--admonition-caution-accent-color); }
.admonition.warning { --accent-color: var(--admonition-warning-accent-color); }

.admonition.note::before { content: "\eb21"; }
.admonition.tip::before { content: "\ea0d"; }
.admonition.important::before { content: "\ea7c"; }
.admonition.caution::before { content: "\eac7"; }
.admonition.warning::before { content: "\eac5"; }

.ck-content ul.todo-list li span.todo-list__label__description {
    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;
}

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

.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;
}

iframe.print-iframe {
    position: absolute;
    top: 0;
    left: -600px;
    right: -600px;
    bottom: 0;
    width: 0;
    height: 0;
}

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

/* Scrolling container */

.note-split:not(.type-text.view-mode-normal) > .scrolling-container:has(> :is(.note-detail.full-height, .note-list-widget.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;
}

/* Calendar collection */

.calendar-view a.fc-timegrid-event,
.calendar-view a.fc-daygrid-event {
    /* Workaround: set font weight only if the theme-next is not active */
    font-weight: var(--root-background, 800);
}

@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);
            }
        }

        body: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
 */

:where(:root) {
    --task-checkbox-without-state-background: #d5d5d5;
    --task-checkbox-with-state-background: orange;
    --task-checkbox-done-color: green;
    --task-checkbox-unknown-state-color: orange;
    --task-checkbox-glyph-color: white;

    --task-checkbox-border-radius: 4px;
    --task-checkbox-glyph-ratio: .8;
}

: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;
}

/* Prevent variables from bleeding into nested items */
.ck-content .todo-list .todo-list {
    --task-state-glyph: initial;
    --task-state-glyph-font-family: initial;
    --task-state-color: initial;
    --task-state-adjusted-color: initial;
    --task-state-hue: initial;
    --_task-checkbox-background: initial;
}

/* All tasks with a state */
:where(.ck-content .todo-list li[data-trilium-task-state]:not([data-trilium-task-state="none"])),
.tn-task-checkbox:not([data-trilium-task-state="none"]) {
    --_task-checkbox-background: var(--task-state-adjusted-color, var(--task-state-color, var(--task-checkbox-with-state-background)));
}

/* Default checked state */
:where(.ck-content .todo-list li:where(:not([data-trilium-task-state]), [data-trilium-task-state="done"]):has(> .todo-list__label input[type="checkbox"]:checked)),
.tn-task-checkbox[data-trilium-task-state="done"] {
    --task-state-glyph: "";
    --task-state-glyph-font-family: boxicons;
    --task-state-hue: var(--task-checkbox-done-hue);
    --_task-checkbox-background: var(--task-checkbox-done-color);
}

/* The read-only view renders a real <label>, which Bootstrap's reboot makes
   inline-block — an empty label (its checkbox is absolutely positioned below)
   then produces a full-height line of its own, pushing the item text onto the
   next line. Restore the plain inline display so the empty label collapses. */
:root .ck-content.ck-content ul.todo-list li .todo-list__label {
    display: inline;
}

:root .ck-content.ck-content ul.todo-list li .todo-list__label input[type="checkbox"] {
    --_checkbox-size: var(--ck-content-todo-list-checkmark-size);

    /* Take the checkbox out of the inline flow in every variant and centre it
       geometrically on the first text line (the li is the positioned ancestor,
       `li p` has no margin, and CKEditor's own `left/right: -25px` still places
       it in the gutter). Centering via `vertical-align: middle` depends on font
       metrics and differs from the absolutely-positioned `_without-description`
       variant — this makes both variants share one deterministic geometry. */
    position: absolute;
    top: calc((1lh - var(--_checkbox-size)) / 2);
    /* `1lh` must resolve against the text's line height, not the UA form-control
       font, and the UA's 3px checkbox margins would offset the absolute position.
       (Bootstrap's reboot happens to do both, but don't depend on it.) */
    margin: 0;
    font: inherit;
}

/* CKEditor middle-aligns the inline description span, while a real-<p> description
   (the `_without-description` variant) sits on the plain baseline — so the text
   position depended on which variant rendered. Align both on the baseline. */
:root .ck-content.ck-content ul.todo-list li .todo-list__label .todo-list__label__description {
    vertical-align: baseline;
}

/* Checkbox */
:root .ck-content.ck-content ul.todo-list li .todo-list__label input[type="checkbox"],
.tn-task-checkbox {
    /* Checkbox body */
    &::before {
        all: unset;

        content: "";
        position: absolute;
        inset: 0;
        border-radius: var(--task-checkbox-border-radius);
        background: var(--_task-checkbox-background, var(--task-checkbox-without-state-background));
    }

    /* Checkbox tick */
    &::after {
        all: unset;
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        inset: 0;
        content: var(--task-state-glyph);
        font-family: var(--task-state-glyph-font-family, inherit);
        /* Em box == checkbox box: the flex centering has zero leftover
           space to round, so nothing can snap asymmetrically. */
        font-size: var(--_checkbox-size);
        line-height: 1;
        color: var(--task-checkbox-glyph-color);
        /* The shrink is geometric, not typographic — scale() doesn't snap
           to the device-pixel grid, so the glyph stays centred at any zoom. */
        transform: scale(var(--task-checkbox-glyph-ratio));
    }

    &:disabled {
        opacity: 1;
    }
}

/*
 * Collapsible blocks
 */

 /*
 * Shared styles for collapsible blocks (rendered as native HTML <details>/<summary>).
 * Used in both the editor and the read-only/published view via .ck-content.
 */

.ck-content details.trilium-collapsible {
    --collapsible-block-background: var(--card-background-color);
    --collapsible-block-summary-background: var(--card-background-color);
    --collapsible-block-summary-delimiter-color: var(--main-background-color);
    
    --_border-radius: 8px;
    --_block-padding: .75rem;
    --_inline-padding: 1rem;
    --_margin-between-collapsibles: 3px;
    --_content-indent: 2rem;
    --_arrow-gap: 2rem;

    position: relative;
    overflow: hidden;
    isolation: isolate;
    margin: 1em 0;
    border-radius: var(--_border-radius);
    background: var(--collapsible-block-background);
    padding: var(--_block-padding) var(--_inline-padding) var(--_block-padding) var(--_content-indent);

    &:not(& + &):has(+ details.trilium-collapsible) {
        /* First collapsibile from the series */
        margin-bottom: var(--_margin-between-collapsibles);
        border-end-start-radius: 0;
        border-end-end-radius: 0;
    }

    & + &:has(+ details.trilium-collapsible) {
        /* Middle collapsibile blocks from the series */
        margin-bottom: var(--_margin-between-collapsibles);
        margin-top: 0;
        border-radius: 0;
    }

    & + &:not(:has(+ details.trilium-collapsible)) {
        /* The last collapsibile from the series */
        margin-top: 0;
        border-start-start-radius: 0;
        border-start-end-radius: 0;
    }

    > summary {
        position: relative;
        left: calc(0px - var(--_content-indent ) / 2);
        width: calc(100% + var(--_content-indent));
        padding-left: var(--_arrow-gap);
        cursor: pointer;
        font-weight: 500;
        outline: none;
        list-style: none; /* native marker replaced by the custom arrow below */

        &::-webkit-details-marker {
            display: none;
        }

        &::after {
            display: block;
            content: "";
            z-index: -1;
            position: absolute;
            top: calc(0px - (var(--_block-padding) + 1px));
            left: calc(0px - var(--_content-indent ) / 2);
            width: calc(100% + var(--_inline-padding) * 2 + 1px);
            height: calc(100% + var(--_block-padding) * 2 + 1px);
            background: var(--collapsible-block-summary-background);
        }

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

    &[open] > summary {
        margin-bottom: calc(var(--_block-padding) * 2);
        
        &::after {
            border-bottom: 2px solid var(--collapsible-block-summary-delimiter-color);            
        }
    }

    >*:last-child:not(summary) {
        margin-bottom: 0;
    }
}

/*
 * Custom arrow, shared by every view. In the editor it is a real <span> (inserted by the
 * editing downcast) because it needs click and keyboard handlers; elsewhere that span
 * doesn't exist — the arrow is deliberately not part of the saved HTML — so the data view
 * (read-only text notes, markdown preview) draws it on the summary instead and lets the
 * native <details> toggle do the work. Both share the geometry and the glyph below.
 */
.ck-content details.trilium-collapsible > summary > .trilium-collapsible-arrow,
.ck-content:not(.ck-editor__editable) details.trilium-collapsible > summary::before {
    position: absolute;
    left: 0;
    top: -0.05em;
    width: 1lh;
    height: 1lh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: boxicons;
    cursor: pointer;
    user-select: none;
    /* Scaled rather than sized with font-size, so the box keeps the summary's line metrics
     * and the arrow stays centred on the first line of the title. */
    transform: scale(1.3);
    transition: transform 0.15s ease;
}

.ck-content details.trilium-collapsible > summary > .trilium-collapsible-arrow::before,
.ck-content:not(.ck-editor__editable) details.trilium-collapsible > summary::before {
    content: "\ea50";
}

.ck-content details.trilium-collapsible[open] > summary > .trilium-collapsible-arrow,
.ck-content:not(.ck-editor__editable) details.trilium-collapsible[open] > summary::before {
    transform: scale(1.3) rotate(90deg);
}

/*
 * 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);
}
