/* VS Code Markdown Preview styling */
.markdown-rendered .md-hover-target:not(blockquote) {
    position: relative;
    border-left: 3px solid transparent;
    transition: border-color 0.15s ease;
    padding-left: 8px;
}

.markdown-rendered .md-hover-target th,
.markdown-rendered .md-hover-target td {
    border-left: 3px solid var(--color-border-hover);
}

.markdown-rendered .md-hover-target:hover {
    border-left-color: var(--color-accent2);
}

.markdown-rendered td.md-hover-target,
.markdown-rendered th.md-hover-target {
    padding-left: 12px;
    /* more room for border */
}


/* Base container styling */
.markdown-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--color-third);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", system-ui, Ubuntu, "Droid Sans", sans-serif;
    line-height: 1.6;
}

/* Header toolbar styling */
.markdown-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background-color: var(--color-third);
    border-bottom: 1px solid var(--color-border-color);
    height: 34px;
    flex-shrink: 0;
}

.markdown-download-btn,
.markdown-label {
    background: transparent;
    border: none;
    color: var(--color-note-text);
    font-size: 1.0rem;
    padding: var(--spacing-xsm);
    cursor: pointer;
    border-radius: var(--border-radius-button);
    transition: background 0.2s;
    margin-left: auto;
}

.markdown-download-btn {
    margin-right: auto;
    margin-left: 0;
}

.markdown-download-btn:hover,
.markdown-label:hover {
    color: var(--color-text);
}

.markdown-path-input {
    width: 100%;
    padding: 0.15rem var(--spacing-md);
    padding-left: 0.25rem;
    font-size: var(--font-size-xsm);
    font-family: var(--font-family);
    border: 1px solid transparent;
    border-radius: 4px;
    background-color: transparent;
    color: var(--color-text);
    outline: none;
    padding-right: 1.75rem;
    transition: all 0.2s ease;
    max-width: 300px;
}

.markdown-path-input:focus {
    border-color: var(--color-border-hover);
    border-color: var(--color-accent2);
    color: var(--color-text);
}

/* Scrollable content area */
.markdown-scroll-wrapper {
    height: calc(100% - 34px);
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    /* scrollbar-width: thin; */
    scrollbar-color: var(--color-border-hover) var(--color-file-explorer);
    position: relative;
    padding: 16px 24px 24px;
    padding-top: var(--spacing-xsm);
}

.markdown-scroll-wrapper::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.markdown-scroll-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--color-border-hover);
    border-radius: 5px;
    border: 2px solid var(--color-file-explorer);
}

.markdown-scroll-wrapper::-webkit-scrollbar-track {
    background-color: var(--color-file-explorer);
}

/* Markdown content styling */
.markdown-rendered {
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    /* max-width: 980px; */
    margin: 0 auto;
}

/* Headings */
.markdown-rendered h1,
.markdown-rendered h2 {
    border-bottom: 1px solid var(--color-border-hover);
    padding-bottom: 0.3em;
    color: var(--color-textHilight);
    line-height: 1.25;
}

.markdown-rendered h1 {
    font-size: 2em;
    font-weight: 600;
    margin-top: 14px;
    margin-bottom: 1rem;
}

.markdown-rendered h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 1rem;

    padding-bottom: .3em;
    font-size: 1.5em;
    line-height: 1.25
}

.markdown-rendered h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 1rem;
    color: var(--color-textHilight);

    padding-bottom: .3em;
    font-size: 1.25em;
    line-height: 1.25;

}

.markdown-rendered h4 {
    font-size: 1em;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 1rem;
    font-size: 1em;
    line-height: 1.25;
    color: var(--color-textHilight);
}

.markdown-rendered h5 {
    font-size: 0.875em;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 16px;
}

.markdown-rendered h6 {
    font-size: 0.85em;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 16px;
    color: var(--color-note-text);
}

/* Text elements */
.markdown-rendered p {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-rendered a {
    color: var(--color-href);
    /* text-decoration: none; */
    text-decoration: underline;
    text-underline-offset: .2rem;
}

.markdown-rendered a:hover {
    text-decoration: underline;
}

.markdown-rendered strong {
    font-weight: 600;
    color: var(--color-textHilight)
}

.markdown-rendered em {
    font-style: italic;
}

.markdown-rendered del {
    text-decoration: line-through;
}

/* Lists */
.markdown-rendered ul,
.markdown-rendered ol {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 2em;
}

.markdown-rendered ul ul,
.markdown-rendered ul ol,
.markdown-rendered ol ul,
.markdown-rendered ol ol {
    margin-top: 0;
    margin-bottom: 0;
}

.markdown-rendered li {
    margin-bottom: 4px;
}

.markdown-rendered li+li {
    margin-top: 0.25em;
}

/* Blockquotes */
.markdown-rendered blockquote {
    margin: 16px 0;
    padding: 8px 14px;
    color: var(--color-text);
    background-color: var(--color-fourth);
    border-left: 0.25em solid var(--color-border-hover);
    align-content: center;
}

.markdown-rendered blockquote> :first-child {
    margin-top: 0;
}

.markdown-rendered blockquote> :last-child {
    margin-bottom: 0;
}

/* Code */
.markdown-rendered code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    background-color: var(--color-fifth);
    border-radius: 6px;
    line-height: 1.25;
    color: var(--color-textHilight);

}

.markdown-rendered .code-block-container {
    margin-bottom: 16px;
}

.markdown-rendered .code-block-container code {
    color: var(--color-text);
}

.markdown-rendered table code {
    white-space: inherit;
}

.markdown-rendered pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    margin-top: 0;
    margin-bottom: 16px;
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    /* background-color: var(--color-fifth); */
    border-radius: 3px;
}

.code-block-container pre {
    background-color: transparent !important;
}

.markdown-rendered pre code {
    display: inline;
    max-width: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: transparent;
    border: 0;
    font-size: 100%;
}

/* Tables */
/* .markdown-rendered table {
    display: block;
    width: 100%;
    overflow: auto;
    margin-top: 0;
    margin-bottom: 16px;
    border-spacing: 0;
    border-collapse: collapse;
}

.markdown-rendered table th {
    font-weight: 600;
    padding: 6px 13px;
    border: 1px solid var(--color-border-hover);
    background-color: var(--color-third);
    text-align: left;
}

.markdown-rendered table td {
    padding: 6px 13px;
    border: 1px solid var(--color-border-hover);
}

.markdown-rendered table tr {
    background-color: var(--color-secondary);
    border-top: 1px solid var(--color-border-hover);
}

.markdown-rendered table tr:nth-child(2n) {
    background-color: var(--color-third);
} */
.markdown-rendered table {
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
    table-layout: fixed;
    /* ✅ Makes columns equal width */
}

.markdown-rendered thead,
.markdown-rendered tbody {
    width: 100%;
}

.markdown-rendered table th,
.markdown-rendered table td {
    padding: 6px 13px;
    border: 1px solid var(--color-border-hover);
    text-align: left;
    word-wrap: break-word;
    /* ✅ Ensures text wraps inside cells */
}

.markdown-rendered table th {
    font-weight: 600;
    background-color: var(--color-fourth);
}

.markdown-rendered table tr {
    background-color: var(--color-third);
    border-top: 1px solid var(--color-border-hover);
}

.markdown-rendered table tr:nth-child(2n) {
    background-color: var(--color-third);
}

/* Horizontal rules */
.markdown-rendered hr {
    height: 1px;
    height: .25em;
    padding: 0;
    margin: 14px 0;
    background-color: var(--color-border-hover);
    border: 0;
}

/* Images */
.markdown-rendered img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: var(--color-fourth);
    border-radius: 3px;
}

/* Task Lists */
.markdown-rendered input[type="checkbox"] {
    box-sizing: border-box;
    padding: 0;
    margin-right: 8px;
    vertical-align: middle;
}

/* Special elements */
.markdown-rendered kbd {
    display: inline-block;
    padding: 3px 5px;
    font-size: 11px;
    line-height: 10px;
    color: var(--color-accent);
    vertical-align: middle;
    background-color: var(--color-third);
    border: solid 1px var(--color-border-hover);
    border-bottom-color: var(--color-border-hover);
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 var(--color-border-hover);
}

/* Error state */
.markdown-error {
    color: var(--color-error);
    padding: 16px;
    font-style: italic;
    font-weight: 500;
    font-size: var(--font-size-md);
}

.math-block,
.math-inline {
    font-family: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', 'Times New Roman', serif;
    font-style: italic;
    font-size: var(--font-size-lg);
    color: var(--color-textHilight);
    padding: 0 4px;
    border-radius: 6px;
    letter-spacing: 0.03em;
    word-spacing: 0.12em;
    display: inline-block;
    /* width: 100%; */
    margin: 14px 0 14px 0;
    padding: 0.1rem 0.75em;
}

.math-block {
    width: 100%;
    border-radius: 0;
    border-left: 0.25em solid var(--color-border-hover);
    background: var(--color-fourth);

}

/* stacked fraction */
.frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
    vertical-align: middle;
    margin: 0 0.2em;
}

.frac .top,
.frac .bottom {
    padding: 0 0.25em;
}

.frac .top {
    border-bottom: 1px solid currentColor;
}

.frac .bottom {
    margin-top: 0.1em;
}

/* sqrt with overbar */
.sqrt {
    display: inline-flex;
    align-items: flex-end;
    vertical-align: middle;
}

.sqrt::before {
    content: "√";
    margin-right: 0.1em;
}

.sqrt .radicand {
    display: inline-block;
    border-top: 1px solid currentColor;
    padding-top: 0.05em;
}

/* superscripts / subscripts in HTML form */
sup.exp {
    font-size: 0.8em;
    vertical-align: super;
}

sub.sub {
    font-size: 0.8em;
    vertical-align: sub;
}

/* Taller integral, works both inline and block */
.integral {}

/* binomial coefficient ( (n over k) ) */
.binom {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
    vertical-align: middle;
    position: relative;
    padding: 0 0.45em;
    /* room for tall parentheses */
    margin: 0 0.2em;
}

.binom .top,
.binom .bottom {
    padding: 0 0.1em;
}

.binom::before,
.binom::after {
    content: "(";
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    transform: scaleY(1.35);
    transform-origin: center;
    font-style: normal;
    /* keep parens upright even if text is italic */
}

.binom::before {
    left: 0;
    content: "(";
}

.binom::after {
    right: 0;
    content: ")";
}

/* a bit taller in block math */
.math-block .binom::before,
.math-block .binom::after {
    transform: scaleY(1.6);
}

/* math operators with limits */
.mop {
    line-height: 1;
    vertical-align: middle;
}

.mop .symbol {
    font-style: normal;
}

/* Block math: stack over/under */
.math-block .mop {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.math-block .mop .upper {
    font-size: 0.8em;
    margin-bottom: 0.05em;
}

.math-block .mop .lower {
    font-size: 0.8em;
    margin-top: 0.05em;
}

.math-block .mop-sum .symbol,
.math-block .mop-prod .symbol {
    font-size: 1.3em;
}

/* Inline math: show limits to the right, stacked small */
.math-inline .mop {
    display: inline-grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    align-items: baseline;
    column-gap: 0.15em;
}

.math-inline .mop .symbol {
    grid-row: 1 / span 2;
    grid-column: 1;
}

.math-inline .mop .upper {
    grid-row: 1;
    grid-column: 2;
    font-size: 0.65em;
    line-height: 1;
    align-self: start;
}

.math-inline .mop .lower {
    grid-row: 2;
    grid-column: 2;
    font-size: 0.65em;
    line-height: 1;
    align-self: end;
}

/* lim typesets upright and a bit spaced */
.mop-lim .lim-word {
    font-style: normal;
    letter-spacing: 0.02em;
}

.math-block .mop-lim .lim-word {
    font-size: 1.05em;
}

/* Taller integral symbol as before (optional tweak) */
.integral {}

.math-block .integral {
    transform: scaleY(1.8);
    font-size: 1.1em;
}

/* text inside math (upright) */
.mtext {
    font-style: normal;
    font-family: system-ui, ui-sans-serif, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", sans-serif;
    letter-spacing: normal;
}

/* named operators (upright) */
.mopname {
    font-style: normal;
    margin: 0 0.1em;
}

/* font switches */
.mfont-rm {
    font-style: normal;
}

.mfont-bf {
    font-weight: 700;
}

.mfont-it {
    font-style: italic;
}

.mfont-sf {
    font-family: system-ui, ui-sans-serif, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", sans-serif;
}

.mfont-tt {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* very basic fallback for \mathbb non-mapped letters */
.mfont-bb {
    font-style: normal;
    letter-spacing: 0.02em;
}

/* spacing */
.mspace {
    display: inline-block;
}

.mspace-quad {
    width: 1em;
}

.mspace-qquad {
    width: 2em;
}

.mspace-thin {
    width: 0.166em;
}

.mspace-med {
    width: 0.222em;
}

.mspace-thick {
    width: 0.278em;
}

/* negative thin space: pull next token left */
.mspace-negthin {
    width: 0;
    margin-left: -0.166em;
}

/* decorations */
.moverline {
    text-decoration: overline;
    text-decoration-thickness: from-font;
}

.munderline {
    text-decoration: underline;
    text-decoration-thickness: from-font;
}

/* ---------------------
   Callouts / Admonitions
--------------------- */
.callout {
    --co: var(--color-text);
    --bgc: transparent;
    margin: 16px 0;
    padding: 8px 14px;
    border-left: 0.25em solid var(--co);
    background: var(--bgc);
}

.callout__header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--co);
}

.callout__title {
    font-weight: 500;
    line-height: 1.2;
}

.callout__header i {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.15em;
    line-height: 1;
}

.callout__body> :first-child {
    margin-top: 0;
}

.callout__body> :last-child {
    margin-bottom: 0;
}

/* Type colors */
.callout--tip,
.callout--info {
    --co: var(--color-info);
    /* --bgc: rgba(37, 85, 149, 0.05); */
}

.callout--important {
    --co: var(--color-debug);
    /* --bgc: rgba(86, 51, 122, 0.05); */
}

.callout--warning {
    --co: var(--color-warn);
    /* --bgc: rgba(255, 193, 7, 0.05); */
}

.callout--caution {
    --co: var(--color-error);
    /* --bgc: rgba(220, 53, 69, 0.05); */
}

/* red */

blockquote[data-callout] {
    border-left: 6px solid var(--co);
    background: var(--bgc);
    padding: 12px 14px;
    border-radius: 10px;
}