/* Styles for Edit Online, Edit Locally, and Edit (GitHub) buttons */
.md-content .md-typeset .md-button,
.md-content .md-typeset a.md-button.tenx-edit-online-button,
.md-content .md-typeset .edit-options a.tenx-edit-online-button,
.md-content .md-typeset [class*="tenx-"][class*="-edit-button"],
.md-content .md-typeset .tenx-github-button,
.md-content .md-typeset .tenx-edit-online-button,
.md-typeset .md-button,
.md-typeset a.md-button.tenx-edit-online-button,
.md-typeset .edit-options a.tenx-edit-online-button,
.md-typeset [class*="tenx-"][class*="-edit-button"],
.md-typeset .tenx-github-button,
.md-typeset .tenx-edit-online-button,
.md-button,
a.md-button.tenx-edit-online-button,
.edit-options a.tenx-edit-online-button,
[class*="tenx-"][class*="-edit-button"],
.tenx-github-button,
.tenx-edit-online-button {
    padding: 0.2rem 0.6rem !important;
    font-size: 0.7rem !important;
    line-height: 1.5 !important;
    min-height: 1.5rem !important;
    min-width: 3.5rem !important;
    background: transparent !important;
    color: #5e8bde !important;
    border: 2px solid #5e8bde !important;
    border-radius: 0.2rem !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: var(--md-text-font, "Roboto") !important;
    text-decoration: none !important; /* Ensure <a> tags don't have underlines */
}

.md-content .md-typeset .md-button:not(:hover):not(:focus):not(:active),
.md-content .md-typeset a.md-button.tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.md-content .md-typeset .edit-options a.tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.md-content .md-typeset [class*="tenx-"][class*="-edit-button"]:not(:hover):not(:focus):not(:active),
.md-content .md-typeset .tenx-github-button:not(:hover):not(:focus):not(:active),
.md-content .md-typeset .tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.md-typeset .md-button:not(:hover):not(:focus):not(:active),
.md-typeset a.md-button.tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.md-typeset .edit-options a.tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.md-typeset [class*="tenx-"][class*="-edit-button"]:not(:hover):not(:focus):not(:active),
.md-typeset .tenx-github-button:not(:hover):not(:focus):not(:active),
.md-typeset .tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.md-button:not(:hover):not(:focus):not(:active),
a.md-button.tenx-edit-online-button:not(:hover):not(:focus):not(:active),
.edit-options a.tenx-edit-online-button:not(:hover):not(:focus):not(:active),
[class*="tenx-"][class*="-edit-button"]:not(:hover):not(:focus):not(:active),
.tenx-github-button:not(:hover):not(:focus):not(:active),
.tenx-edit-online-button:not(:hover):not(:focus):not(:active) {
    background: transparent !important;
    color: #5e8bde !important;
    border: 2px solid #5e8bde !important;
}

.md-content .md-typeset .md-button:hover,
.md-content .md-typeset .md-button:focus,
.md-content .md-typeset .md-button:active,
.md-content .md-typeset a.md-button.tenx-edit-online-button:hover,
.md-content .md-typeset a.md-button.tenx-edit-online-button:focus,
.md-content .md-typeset a.md-button.tenx-edit-online-button:active,
.md-content .md-typeset .edit-options a.tenx-edit-online-button:hover,
.md-content .md-typeset .edit-options a.tenx-edit-online-button:focus,
.md-content .md-typeset .edit-options a.tenx-edit-online-button:active,
.md-content .md-typeset [class*="tenx-"][class*="-edit-button"]:hover,
.md-content .md-typeset [class*="tenx-"][class*="-edit-button"]:focus,
.md-content .md-typeset [class*="tenx-"][class*="-edit-button"]:active,
.md-content .md-typeset .tenx-github-button:hover,
.md-content .md-typeset .tenx-github-button:focus,
.md-content .md-typeset .tenx-github-button:active,
.md-content .md-typeset .tenx-edit-online-button:hover,
.md-content .md-typeset .tenx-edit-online-button:focus,
.md-content .md-typeset .tenx-edit-online-button:active,
.md-typeset .md-button:hover,
.md-typeset .md-button:focus,
.md-typeset .md-button:active,
.md-typeset a.md-button.tenx-edit-online-button:hover,
.md-typeset a.md-button.tenx-edit-online-button:focus,
.md-typeset a.md-button.tenx-edit-online-button:active,
.md-typeset .edit-options a.tenx-edit-online-button:hover,
.md-typeset .edit-options a.tenx-edit-online-button:focus,
.md-typeset .edit-options a.tenx-edit-online-button:active,
.md-typeset [class*="tenx-"][class*="-edit-button"]:hover,
.md-typeset [class*="tenx-"][class*="-edit-button"]:focus,
.md-typeset [class*="tenx-"][class*="-edit-button"]:active,
.md-typeset .tenx-github-button:hover,
.md-typeset .tenx-github-button:focus,
.md-typeset .tenx-github-button:active,
.md-typeset .tenx-edit-online-button:hover,
.md-typeset .tenx-edit-online-button:focus,
.md-typeset .tenx-edit-online-button:active,
.md-button:hover,
.md-button:focus,
.md-button:active,
a.md-button.tenx-edit-online-button:hover,
a.md-button.tenx-edit-online-button:focus,
a.md-button.tenx-edit-online-button:active,
.edit-options a.tenx-edit-online-button:hover,
.edit-options a.tenx-edit-online-button:focus,
.edit-options a.tenx-edit-online-button:active,
[class*="tenx-"][class*="-edit-button"]:hover,
[class*="tenx-"][class*="-edit-button"]:focus,
[class*="tenx-"][class*="-edit-button"]:active,
.tenx-github-button:hover,
.tenx-github-button:focus,
.tenx-github-button:active,
.tenx-edit-online-button:hover,
.tenx-edit-online-button:focus,
.tenx-edit-online-button:active {
    background: #5e8bde !important;
    color: #ffffff !important;
    border: 2px solid #5e8bde !important;
    outline: none !important;
}

/* Ensure icons inside buttons align properly */
.md-content .md-typeset .md-button > span,
.md-content .md-typeset a.md-button.tenx-edit-online-button > span,
.md-content .md-typeset .edit-options a.tenx-edit-online-button > span,
.md-content .md-typeset [class*="tenx-"][class*="-edit-button"] > span,
.md-content .md-typeset .tenx-edit-online-button > span,
.md-typeset .md-button > span,
.md-typeset a.md-button.tenx-edit-online-button > span,
.md-typeset .edit-options a.tenx-edit-online-button > span,
.md-typeset [class*="tenx-"][class*="-edit-button"] > span,
.md-typeset .tenx-edit-online-button > span,
.md-button > span,
a.md-button.tenx-edit-online-button > span,
.edit-options a.tenx-edit-online-button > span,
[class*="tenx-"][class*="-edit-button"] > span,
.tenx-edit-online-button > span {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Tooltip styles for buttons like Edit Online/Edit Locally */
[data-tooltip]:not(.md-button--small) {
    position: relative;
}

[data-tooltip]:not(.md-button--small):hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--md-default-bg-color);
    color: var(--md-default-fg-color);
    padding: 0.3rem 0.5rem;
    border-radius: 0.2rem;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1001;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Disable CSS tooltips inside editor dialogs (they use JS-based tooltips) */
.md-dialog--editor [data-tooltip]:hover::after,
.md-dialog--editor [data-tooltip]:hover::before {
    content: none !important;
    display: none !important;
}

/* Tooltip styles for copy buttons in dialogs */
.md-dialog-content button.md-button--small:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--md-default-bg-color);
    color: var(--md-default-fg-color);
    padding: 0.3rem 0.5rem;
    border-radius: 0.2rem;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1001;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Ensure code elements are hoverable */
.md-dialog-content code[data-tooltip] {
    position: relative;
    pointer-events: auto !important;
    user-select: auto !important;
    cursor: default;
}

/* Styles for JavaScript-created tooltips */
.custom-tooltip {
    position: absolute; /* Use absolute positioning within the dialog */
    background: var(--md-default-bg-color);
    color: var(--md-default-fg-color);
    padding: 0.3rem 0.5rem;
    border-radius: 0.2rem;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 100000; /* Already set high to be above dialog */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Tooltip arrow when positioned above */
.custom-tooltip.above::after {
    content: '';
    position: absolute;
    top: 100%; /* Arrow at the bottom of the tooltip */
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--md-default-bg-color);
}

/* Tooltip arrow when positioned below */
.custom-tooltip.below::after {
    content: '';
    position: absolute;
    bottom: 100%; /* Arrow at the top of the tooltip */
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--md-default-bg-color);
}

/* Styles for the dialog */
html dialog.md-dialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: none;
    border-radius: 0.5rem;
    background: var(--md-default-bg-color) !important;
    color: var(--md-default-fg-color) !important;
    padding: 1.5rem;
    max-width: 700px;
    width: 90%;
    min-width: 500px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    pointer-events: auto;
    overflow: visible; /* Ensure tooltips can extend outside the dialog */
}

html dialog.md-dialog[open] {
    display: block;
    opacity: 1;
    visibility: visible;
}

html dialog.md-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    pointer-events: auto;
}

/* Ensure the dialog content area doesn't clip tooltips */
.md-dialog-content {
    position: relative; /* Establish a positioning context for absolute-positioned tooltips */
    overflow: visible !important; /* Prevent clipping of tooltips */
}

/* Scoped styles for dialog/modal content */
.md-dialog-content h3 {
    margin-top: 0;
    color: var(--md-default-fg-color) !important;
    font-size: 0.95rem !important;
}

.md-dialog-content p {
    font-size: 0.8rem !important;
}

.md-dialog-content ul {
    list-style: none;
    padding: 0;
}

.md-dialog-content li {
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    flex-wrap: nowrap;
    min-width: 0;
    font-size: 0.8rem !important;
}

.md-dialog-content .code-button-pair {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-width: 0;
}

.md-dialog-content code {
    background: var(--md-code-bg-color) !important;
    padding: 0.2rem 0.4rem;
    border-radius: 0.2rem;
    white-space: nowrap;
    display: inline-block;
    line-height: 1.2;
    font-size: 0.7rem !important;
    vertical-align: middle;
    color: var(--md-code-fg-color) !important;
    box-sizing: border-box;
    max-width: calc(100% - 2rem);
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-dialog-content button.md-button--small {
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.2;
    height: 1.5rem;
    width: 1.5rem;
    min-height: auto;
    min-width: 1.5rem;
    background: transparent !important;
    color: var(--md-default-fg-color) !important;
    border: none;
    border-radius: 0.2rem;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    pointer-events: auto;
}

.md-dialog-content button.md-button--small svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.md-dialog-content button.md-button--small:hover {
    color: var(--md-accent-fg-color) !important;
    background: rgba(0, 0, 0, 0.1) !important;
}

.md-dialog-content button.md-button--small:focus,
.md-dialog-content button.md-button--small:active {
    background: transparent !important;
    color: var(--md-default-fg-color) !important;
    outline: none !important;
}

.md-dialog-content .md-button {
    padding: 0.2rem 0.8rem;
    font-size: 0.8rem;
    font-weight: normal;
    line-height: 1.5;
    min-height: 1.5rem;
    min-width: 4rem;
    background: transparent !important;
    color: #ffffff !important;
    border: 2px solid #526cfe !important;
    border-radius: 0.2rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    box-sizing: border-box;
}

.md-dialog-content .md-button:hover,
.md-dialog-content .md-button:focus,
.md-dialog-content .md-button:active {
    background: #526cfe !important;
    color: #ffffff !important;
    border: 2px solid #526cfe !important;
    outline: none;
}

.md-overlay, dialog:not([id$="-dialog"]) {
    display: none;
    z-index: -1;
}

/* Admonition rules */
.md-typeset .admonition[class*="tenx-"],
.md-typeset details[class*="tenx-"] {
    border-color: rgb(185, 185, 187) !important;
    font-size: 15px;
}

.md-typeset .admonition[class*="tenx-"] > .admonition-title,
.md-typeset details[class*="tenx-"] > summary {
    background-color: rgba(95, 111, 131, 0.1) !important;
    font-size: 15px;
}

.md-typeset .admonition[class*="tenx-"] > .admonition-title::before,
.md-typeset details[class*="tenx-"] > summary::before {
    background-color: rgb(185, 185, 187) !important;
    font-size: 15px;
}

.md-typeset .admonition:not([class*="tenx-"]),
.md-typeset details:not([class*="tenx-"]) {
    border-color: rgb(185, 185, 187) !important;
    font-size: 15px;
}

.md-typeset .admonition:not([class*="tenx-"]) > .admonition-title,
.md-typeset details:not([class*="tenx-"]) > summary {
    background-color: rgba(95, 111, 131, 0.1) !important;
    font-size: 15px;
}

.md-typeset .admonition:not([class*="tenx-"]) > .admonition-title::before,
.md-typeset details:not([class*="tenx-"]) > summary::before {
    background-color: rgb(185, 185, 187) !important;
    font-size: 15px;
}

.tenx-tooltip {
    border-bottom: 1px dotted var(--md-default-fg-color, #000000);
}