/* Chainlit loads its bundled stylesheet after this file. */
html:root {
    --primary: 215 11% 89%;
    --primary-foreground: 220 10% 16%;
    --accent: 215 13% 95%;
    --accent-foreground: 220 10% 16%;
    --ring: 215 9% 43%;
    --sidebar-ring: var(--ring);
    --tif-primary-hover: 215 11% 83%;
    --tif-primary-text: 215 12% 30%;
}

html:root.dark {
    --primary: 215 11% 85%;
    --accent: 215 8% 24%;
    --accent-foreground: 215 10% 94%;
    --ring: 215 12% 76%;
    --tif-primary-hover: 215 11% 78%;
    --tif-primary-text: 215 12% 82%;
}

/* Links and status icons need contrast on the page background. */
html:root .text-primary,
html:root .hover\:text-primary:hover {
    color: hsl(var(--tif-primary-text));
}

html:root .fill-primary {
    fill: hsl(var(--tif-primary-text));
}

html:root [role="checkbox"].border-primary,
html:root [role="radio"].border-primary {
    border-color: hsl(var(--ring));
}

html:root .hover\:bg-primary\/80:hover,
html:root .hover\:bg-primary\/90:hover {
    background-color: hsl(var(--tif-primary-hover));
}

img.logo[src$="/tif-logo.png"] {
    height: auto;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background-color: hsl(220 10% 16%);
}

.dark img.logo[src$="/tif-logo.png"] {
    background-color: transparent;
}

img[src$="/tif-logo.png"]:not(.logo) {
    object-fit: contain;
    padding: 0.125rem;
    background-color: hsl(220 10% 16%);
}

/* Keep Chainlit's login form and replace only its surrounding branding. */
.grid.min-h-svh:has(> div > div > img.logo) {
    grid-template-columns: minmax(0, 1fr);

    & > :first-child > :first-child {
        justify-content: flex-start;
    }

    img.logo {
        /* Use the TIF asset directly so a cached Chainlit /logo cannot show. */
        content: url("/public/tif-logo.png") / "TIF";
        width: 7rem;
        height: auto;
        padding: 0.625rem 0.75rem;
        border-radius: 0.625rem;
        background-color: hsl(220 10% 16%);
    }

    & > :nth-child(2),
    form > :first-child:has(> h1) {
        display: none;
    }
}

.dark .grid.min-h-svh:has(> div > div > img.logo) img.logo {
    background-color: transparent;
}

/* Chainlit sets the chat disclaimer's display property inline. */
.watermark {
    display: none !important;
}

#theme-toggle {
    display: none;
}

.message-content .tif-usage-footer {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    line-height: 1.5;
}

.message-content .tif-answer-notes {
    font-size: 0.875rem;
    line-height: 1.5;
}

.tif-mermaid-renderer {
    position: fixed;
    inset: 0 auto auto -10000px;
    width: 56rem;
    height: 20rem;
    border: 0;
    pointer-events: none;
}

pre:has(+ .tif-mermaid-preview) {
    display: none;
}

.tif-mermaid-preview {
    padding: 0.75rem 1rem;
}

.tif-mermaid-preview img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-inline: auto;
}

.tif-mermaid-preview details {
    margin-block-start: 0.75rem;
    font-size: 0.875rem;
}

.tif-mermaid-preview summary {
    cursor: pointer;
}

.tif-mermaid-preview pre {
    overflow-x: auto;
    padding: 0.75rem;
    background: hsl(var(--muted));
}

.tif-mermaid-error {
    margin: 0;
    padding: 0.5rem 1rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
}

/* Chainlit's feature list is the full-screen readme dialog. */
[role="dialog"].h-screen.w-screen.max-h-screen {
    width: min(54rem, calc(100% - 2rem));
    max-width: none;
    height: auto;
    max-height: min(82dvh, 46rem);
    padding: clamp(1rem, 3vw, 1.75rem);
    border: 1px solid hsl(var(--border));
    border-radius: 1rem !important;
    overflow: hidden;

    & > div:first-child {
        width: 100%;
        min-height: 0;
    }

    & > div:first-child > .overflow-y-auto {
        min-height: 0;
        overscroll-behavior: contain;
    }

    & > div:first-child > .overflow-y-auto > * {
        flex-shrink: 0;
    }
}
