/* =========================
   Base / Reset
   ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    /* background-image:
        linear-gradient(rgba(200, 200, 200, 0.05) 3px, transparent 3px),
        linear-gradient(90deg, rgba(200, 200, 200, 0.05) 3px, transparent 3px);
    background-size: 30px 30px; */
    min-height: 100vh;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* centered before chat starts */
}

/* =========================
   Greeting / Header
   ========================= */
.greeting {
    font-size: 48px;
    color: #333;
    margin-bottom: 40px;
    text-align: center;
}

.star {
    color: #ff6b35;
    margin-right: 15px;
}



.greeting,
.greeting .star {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans", Inter, sans-serif;

}




.fa-paper-plane {

    color: #ff6b35;
    cursor: pointer;
    font-size: 20px;
}

/* =========================
   Chat column
   ========================= */
.chat-container {
    width: 100%;
    max-width: 700px;
    position: relative;
}

/* Model info chip */
.model-info {
    position: absolute;
    right: 0;
    top: -40px;
    color: #666;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Suggestions row */
.suggestions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.suggestion {
    background: white;
    border: none;
    padding: 12px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;

}

.suggestion:hover {
    transform: translateY(-2px);
}

/* =========================
   Composer (input area)
   ========================= */
.input-wrapper {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    padding: 18px 60px 18px 24px;
    border: 1px solid lightgray;
}

textarea {
    width: 100%;
    height: 60px;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    background: transparent;
    overflow: hidden;

    /* no tiny scrollbar */
}

textarea::placeholder {
    color: #666;
}

.input-icons {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 12px;
}

.icon {
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.icon:hover {
    opacity: 1;
}

/* =========================
   Conversation (messages list)
   ========================= */
.conversation {
    /* Use browser/page scroll — no inner scrollbars */
    overflow: visible;
    max-height: none;

    /* margin-bottom: 50px; */
    border-radius: 12px;

    /* Ensure last message isn’t hidden behind fixed composer */
    /* padding-bottom: 132px; */
    /* ≈ composer height + air */
}

body.chat-started .conversation {
    margin-bottom: 50px;
}

/* =========================
   Messages / Bubbles
   ========================= */
.user-message,
.ai-response {
    margin: 10px 0;
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 85%;
}

.user-message {
    background: #dbeafe;
    /* light blue */
    margin-left: auto;
    /* right align */
}

.ai-response {
    background: #f3f4f6;
    /* light gray */
    margin-right: auto;
    /* left align */
    max-width: 100%;
    /* fill the column like the input */
    white-space: pre-wrap;
    /* <-- critical */
    line-height: 1.6;
}

.bubble {
    display: block;
    width: 100%;
    white-space: pre-line;
    /* preserve \n from JSON as real line breaks */
    line-height: 1.6;
    /* readability */
    font-size: 16px;
}

.message-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

/* Paragraph / block spacing (avoid span to not affect KaTeX) */
.bubble p+p,
.bubble ul,
.bubble ol,
.bubble pre,
.bubble blockquote {
    margin-top: 0.5em;
}

/* =========================
   Chat-started state
   ========================= */
body.chat-started {
    justify-content: flex-start;
    /* push layout to top once chat begins */
}

/* Hide header extras (no gap left) */
body.chat-started .greeting,
body.chat-started .suggestions,
body.chat-started .model-info {
    display: none !important;
}

/* Use page (browser) scroll, not a 100vh flex column */
body.chat-started .chat-container {
    display: block !important;
    height: auto !important;
}

/* Center the card itself + center its inner content */
#composer #addImage {
    /* your existing styles ... */
    width: 80%;
    margin: 0 auto;
    /* horizontally center the box */
    min-height: 50px;
    /* give it height so vertical centering is visible */

    display: flex;
    /* center the contents */
    align-items: center;
    /* vertical */
    justify-content: center;
    /* horizontal */
    text-align: center;
    /* inline text/icons */

    border: 1px dashed #c9c9c9;
    border-bottom: 0;
    border-radius: 12px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 14px;
    background: #fafafa;
    width: 90%;


}



/* Pin composer to viewport bottom, centered to the 700px column */
body.chat-started #composer-stack {
    position: fixed !important;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    width: calc(100% - 40px);
    /* match body side padding (20px each) */
    max-width: 700px;
    /* align with .chat-container width */
    z-index: 100;
    /* background: #fff; */
    /* border-radius: 24px; */
    /* box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06); */
}

.conversation.has-messages {
    padding-bottom: 185px;
    /* composer height + breathing room */
}

body>header {
    position: fixed;
    top: 12px;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 20px;
    pointer-events: none;
    /* let clicks pass except on links */
}

body>header nav {
    display: flex;
    gap: 12px;
    align-items: center;
    font-family: inherit;
    pointer-events: auto;
    /* re-enable on the nav itself */
}

body>header nav a {
    text-decoration: none;
    color: #333;
    font-weight: 600;
    padding: 8px 12px;
    /* border-radius: 999px; */
    /* border: 1px solid #ff6b35; */
    /* background: #fff; */
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); */
}

body>header nav a:last-child {
    border: 1px solid #ff6b35;
    /* background-color: #ff6b35; */
    color: #ff6b35;
    border-radius: 10px;
    font-weight: 700;
}

body.chat-started>header {
    /* keep header visible after chat starts */
    top: 8px;
}

summary {

    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    /* background: #fff; */
    border: 1px solid lightgray;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 600;
    color: #333;
}

/* Make the math pill span the input width (leaving room for send icons) */
#math-input {
    position: absolute;
    left: 24px;
    right: 24px;
    /* keep clear of the send button/icons on the right */
    bottom: 12px;
    margin: 0 !important;
    z-index: 1300;
}

#math-input>summary {
    display: inline-flex;
    /* shrink to content */
    align-items: center;
    gap: 6px;
    padding: 4px 8px !important;
    /* ↓ smaller */
    font-size: 12px !important;
    /* ↓ smaller text */
    line-height: 1.1;
    border-radius: 8px !important;
    /* ↓ smaller corners */
    white-space: nowrap;
    /* keep on one line */
}

/* Open the keypad DOWNWARD and match the input width */
#math-input .kb-panel {
    position: absolute;
    top: calc(60%);
    /* ⬅️ below the pill */
    left: 0;
    right: 0;
    /* stretch to the same width as #math-input */
    /* bottom: auto; */
    /* no upward anchoring */

    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 10px;

    min-width: 260px;
    width: 100% !important;
    /* your requested min width */
    max-width: none;
    /* cap at input width */
    /* width: auto; */
    /* fill available space */
}

/* Only show when open (keep your existing rule) */
#math-input:not([open]) .kb-panel {
    display: none;
}

/* (Optional) ensure the wrapper doesn't clip the popover */
.input-wrapper {
    overflow: visible;
}


/* nicer key buttons (if you didn't inline styles) */
#math-input .keys button {
    border: 1px solid #eee;
    background: #fff;
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
}

/* When the composer stack is fixed at the bottom, open UP instead */
body.chat-started #composer-stack #math-input .kb-panel {
    top: auto;
    bottom: calc(100% + 70px);

    /* pop above the pill */
    max-height: 40vh;
    /* avoid overflowing the viewport */
    overflow: auto;
    z-index: 999;
    /* stay above the input wrapper */
}

.input-wrapper textarea {

    /* send icon space */
    margin-bottom: 20px;
    /* f(x) pill space */
    box-sizing: border-box;
}

/* Pin ONLY the Models <select> to the top-left of the page */
/* Top-left floating model picker */
.model-picker {
    position: fixed;
    top: 20px;
    left: 12px;
    z-index: 220;
    /* above page chrome, below modals */
    font-family: inherit;
}

/* Summary “button” */
.model-picker>summary {
    list-style: none;
    user-select: none;
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    cursor: pointer;
}

.model-picker>summary::-webkit-details-marker {
    display: none;
}

.model-picker .mp-title {
    font-weight: 700;
    color: #374151;
}

.model-picker .mp-current {
    color: #6b7280;
    font-weight: 600;
}

/* Dropdown card */
.model-picker[open] .mp-menu {
    margin-top: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    padding: 8px;
    min-width: 260px;
}

/* Items */
.mp-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    /* radio, texts, check */
    align-items: start;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    cursor: pointer;
}

.mp-item:hover {
    background: #f9fafb;
}

.mp-item+.mp-item {
    margin-top: 2px;
}

/* Hide native radio visually, keep accessible */
.mp-item>input {
    margin-top: 2px;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    position: relative;
}

.mp-item>input:checked {
    border-color: #111827;
}

.mp-item>input:checked::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: #111827;
}

/* Two-line text */
.mp-texts {
    line-height: 1.25;
}

.mp-line1 {
    font-weight: 600;
    color: #111827;
}

.mp-line2 {
    font-size: 12px;
    color: #6b7280;
}

/* Checkmark on selected */
.mp-check {
    visibility: hidden;
    color: #111827;
    font-weight: 700;
}

.mp-item>input:checked~.mp-check {
    visibility: visible;
}

/* Upgrade pill */
.mp-pill {
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #e5e7eb;
    color: #111827;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
}

.signOut {


    color: #111827 !important;
    border: 1px solid rgb(229, 231, 235);
    border-radius: 10px;
}

:root {
    --panel: #fff;
    --text: #111;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #ef4444;
    --primary-600: #1d4ed8;
    --danger: #ef4444;
    --sidebar: #f8fafc;
    --footer-h: 44px;
    /* footer height (tweak if your footer is taller/shorter) */
    --composer-gap: 12px;
}

/* Modal root */
#settings-modal[hidden] {
    display: none;
}

#settings-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    /* covers whole screen */
}

/* Close button fixed to screen corner */
#settings-modal .close-global {
    position: fixed;
    top: 10px;
    right: 20px;
    z-index: 10001;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 0;
    background: #fff;
    color: #111;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    /* box-shadow: 0 6px 18px rgba(0, 0, 0, .12); */
}

#settings-modal .close-global:hover {
    background: #f9fafb;
}

/* Panel spans entire viewport */
.settings-panel {
    position: fixed;
    inset: 0;
    background: var(--panel);
    color: var(--text);
    display: grid;
    grid-template-columns: 280px 1px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Left sidebar + divider + content */
.settings-sidebar {
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
}

.settings-divider {
    background: var(--border);
}

.settings-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: auto;
}

/* Sidebar header */
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    /* border-bottom: 1px solid var(--border); */
}

/* Vertical tabs */
.tabs--vertical {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
}

.tabs--vertical [role="tab"] {
    text-align: left;
    /* background: #fff; */
    border: 0;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: #374151;
}

.tabs--vertical [role="tab"][aria-selected="true"] {
    background: #e8f0ff;
    border-color: #c7d2fe;
    color: #111;
}

/* Panels/content */
[role="tabpanel"] {
    padding: 18px 20px;
    outline: none;
}

/* Inputs */
.form-row {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.form-row label {
    font-weight: 600;
    color: #111;
}

.form-row input,
.form-row select {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
}

.form-row input:focus,
.form-row select:focus {
    border-color: #93c5fd;
    outline: none;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, .35);
}

.choice {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: #111;
}

.hint {
    color: var(--muted);
    margin: 6px 0 16px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.primary,
.secondary,
.danger {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
}

.primary {
    background: var(--primary);
    color: #fff;
}

/* .primary:hover {
            background: var(--primary-600);
        } */

.secondary {
    background: #fff;
    color: #111;
    border-color: var(--border);
}

.secondary:hover {
    background: #f9fafb;
}

.danger {
    background: #fff;
    color: #ef4444;
    border-color: #fecaca;
}

.danger:hover {
    background: #fff1f2;
}

/* Plans */
.billing-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 14px;
    background: #fff;
}

.toggle-btn {
    padding: 8px 14px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
}

.toggle-btn.is-active {
    background: #111;
    color: #fff;
}

.save-pill {
    background: #dcfce7;
    color: #166534;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: .75rem;
    margin-left: 6px;
}

.plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.plan-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 5px;
    background: #fff;
}

.plan-card--highlight {
    border-color: #c7d2fe;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .12);
}

.plan-card header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.plan-card h3 {
    margin: 0;
    font-size: 1.1rem;
}

.price {
    margin: 0;
    font-weight: 700;
}

.price .amount {
    font-size: 1.25rem;
    margin-right: 4px;
}

.price .per {
    color: #6b7280;
}

.features {
    margin: 0 0 12px;
    padding-left: 18px;
    list-style: none;
}

.features li {
    margin: 4px 0;
}

.stack {
    margin-top: 8px;
    padding-top: 12px;
    /* border-top: 1px dashed var(--border); */
}

#conversation.has-messages {
    margin-top: 40px;
}

@media (max-width: 1154px) {



    #app-settings {
        /* position: fixed !important; */
        top: 19px !important;
        right: 355px !important;
        left: auto !important;
        /* <-- UNSET the inline left:16px */
        bottom: auto !important;

        display: block !important;

    }

    #app-settings.has-messages {

        top: 15px !important;
    }


    /* keep textarea stable */
    #userInput {
        resize: none !important;
        overflow: hidden;
        /* no extra bottom padding here—reserve space on the wrapper instead */
    }

    @supports (-webkit-touch-callout: none) {
        .model-picker.floating {
            left: 100px;
            bottom: 8px;
        }

    }

    /* 2) Pin the picker inside the wrapper */
    .model-picker.floating {
        position: absolute !important;
        left: 60px;
        /* just to the right of the keyboard button */
        bottom: 12px;
        top: auto !important;
        /* ← IMPORTANT: cancel any earlier 'top' */
        margin: 0 !important;
        z-index: 1900 !important;
    }

    /* tiny, button-like summary */
    .model-picker.floating>summary {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 8px;
        border: 1px solid var(--border, #e5e7eb);
        border-radius: 10px;
        background: var(--panel, #fff);
        cursor: pointer;
        list-style: none;
        white-space: nowrap;
        font-size: 12px;
    }

    /* menu overlays upward so the button doesn't move */
    .model-picker.floating .mp-menu {
        position: absolute !important;
        bottom: 100%;
        left: 0;
        margin-bottom: 6px !important;
        z-index: 2000;
    }



}

/* Responsive settings modal */
@media (max-width: 1155px) {

    .signOut {

        border: 0;
        border-radius: 0;
    }

    #app-settings {

        right: 120px !important;
        top: 22.2px !important;

    }

    #app-settings.has-messages {


        top: 17px !important;

    }

    .settings-sidebar {
        padding-bottom: 0;
        /* remove space reserved for the footer p */
    }

    .settings-sidebar>p {
        display: none !important;
        /* hide it on small screens */
        position: static;
        /* undo absolute positioning */
        left: auto;
        right: auto;
        bottom: auto;
        margin: 0;
    }

    .settings-panel {
        grid-template-columns: 1fr;
        /* stack */
    }

    .settings-sidebar {
        position: sticky;
        top: 0;
        z-index: 1;
        border-bottom: 1px solid var(--border);
    }

    .settings-divider {
        display: none;
    }

    /* Tabs become horizontal pills */
    .tabs--vertical {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
        background: var(--sidebar);
        border-top: 1px solid var(--border);
    }

    .tabs--vertical [role="tab"] {
        border-radius: 999px;
        padding: 8px 12px;
    }

    /* Content gets comfy padding */
    [role="tabpanel"] {
        padding: 16px;
    }

    /* Plan cards: single column on very narrow screens */
    .plans {
        grid-template-columns: 1fr;
    }

    /* Close button smaller */
    #settings-modal .close-global {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 22px;
    }

    .settings-panel {
        /* keep it a grid, but define rows */
        grid-template-columns: 1fr;
        /* already there */
        grid-template-rows: auto 1fr;
        /* <-- sidebar fits content, content fills remainder */
        align-content: start;
        /* no vertical stretching of rows */
    }

    .settings-sidebar {
        position: sticky;
        /* you already set this */
        top: 0;
        align-self: start;
        /* don't stretch to 100vh */
    }

    /* Optional: trim extra spacing so the panel content hugs the tabs */
    .settings-header {
        margin: 0;
    }

    .tabs--vertical {
        margin: 0;
    }

    .settings-content {
        padding-top: 0;
    }

    [role="tabpanel"] {
        margin-top: 0;
    }

}


.footer-smallscreen {

    display: none;
}

@media (max-width: 657px) {


    .site-footer span {

        font-size: 11px;
    }

}


@media (max-width: 589px) {

    .site-footer span {

        font-size: 10px;
    }
}

@media (max-width: 550px) {

    .site-footer span {

        font-size: 12px;
    }

    .footer-items {

        display: none;
    }

    .footer-smallscreen {

        display: block;
    }
}

@media (max-width: 520px) {

    /* Trim paddings further */
    .settings-header {
        padding: 12px;
    }

    .tabs--vertical {
        padding: 10px 12px;
    }

    [role="tabpanel"] {
        padding: 12px;
    }

    .plan-card {
        padding: 12px;
    }


}

@media(max-width: 492px) {



    .model-picker {

        top: 70px !important;

    }
}

/* Dark theme is applied when <html class="dark"> is present */
html.dark body {
    color: #e5e7eb;
    background-color: #0b1220;
    /* background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 3px, transparent 3px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 3px, transparent 3px); */
}

/* Practice card picks up theme colors */
.practice-card {
    background: var(--panel) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Choices readable in both themes */
.practice-card button[type="button"] {
    background: var(--panel) !important;
    color: var(--text) !important;
    /* border-color: var(--border) !important; */
}

/* Make steps/explanations + KaTeX inherit theme text color */
/* Steps container picks up theme */
.practice-steps {
    background: var(--panel) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Each <details> card */
.practice-steps details {
    background: var(--panel) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 8px 12px !important;
    margin: 10px 0 !important;
}

/* Summary/title + all text (including KaTeX) use theme color */
.practice-steps summary,
.practice-steps *,
.practice-steps .katex {
    color: var(--text) !important;
}

/* Tidy summary marker + hover (optional) */
.practice-steps summary::-webkit-details-marker {
    display: none;
}

.practice-steps summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.practice-steps details:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}

/* Keep disabled options fully visible */
.practice-card button[disabled] {
    opacity: 1 !important;
}

html.dark .greeting {
    color: #e5e7eb;
}

html.dark .model-info {
    color: #9ca3af;
}

html.dark .suggestion {
    background: #0f172a;
    color: #e5e7eb;
    border: 1px solid #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

html.dark .user-message {
    background: #1f2937;
    color: #e5e7eb;
}

html.dark .ai-response {
    background: #0f172a;
    color: #e5e7eb;
}

html.dark .input-wrapper {
    background: #0b1220;
    border-color: #374151;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .6);
}

html.dark textarea {
    color: #e5e7eb;
}

html.dark textarea::placeholder {
    color: #9ca3af;
}

html.dark body>header nav a {
    color: #e5e7eb;
}

html.dark .signOut {
    color: #e5e7eb !important;
}

html.dark summary {
    background: #0f172a;
    border-color: #374151;
    color: #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}

/* Model picker */
html.dark .model-picker>summary {
    background: #0f172a;
    border-color: #374151;
    color: #e5e7eb;
}

html.dark .model-picker[open] .mp-menu {
    background: #0f172a;
    border-color: #374151;
}

html.dark .mp-item:hover {
    background: #111827;
}

html.dark .mp-item>input {
    border-color: #475569;
}

html.dark .mp-line1 {
    color: #e5e7eb;
}

html.dark .mp-line2 {
    color: #9ca3af;
}

/* Settings modal: flip its CSS variables + pieces that used hard colors */
html.dark {
    --panel: #0b1220;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #374151;
    --sidebar: #0a0f1a;
}

html.dark #settings-modal .close-global {
    background: transparent;
    color: #e5e7eb;
    /* border: 1px solid #374151; */
}

html.dark .tabs--vertical [role="tab"] {
    background: #0f172a;
    border-color: #374151;
    color: #cbd5e1;
}

html.dark .tabs--vertical [role="tab"][aria-selected="true"] {
    background: #1f2937;
    border-color: #4f46e5;
    color: #fff;
}

html.dark .billing-toggle {
    background: #0f172a;
    border-color: #374151;
    color: white !important;
}

html.dark .toggle-btn.is-active {
    background: #2563eb;
    color: #fff;
}

html.dark .toggle-btn {

    color: white !important;
}

html.dark .plan-card {
    background: #0f172a;
}

html.dark .price .per {
    color: #9ca3af;
}

html.dark .form-row input,
html.dark .form-row select {
    background: #0f172a;
    border-color: #374151;
    color: #e5e7eb;
}

html.dark .form-row input:focus,
html.dark .form-row select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .35);
}

/* Math keypad (overrides inline light styles) */
html.dark #math-input>summary {
    background: #0f172a !important;
    border-color: #374151 !important;
    color: #e5e7eb !important;
}

html.dark #math-input .kb-panel {
    background: #0f172a !important;
    border-color: #374151 !important;
}

html.dark #math-input .keys button {
    background: #111827 !important;
    border-color: #374151 !important;
    color: #e5e7eb !important;
}

html.dark .upgrade-link {

    color: #969faf !important;
}

/* Theme toggle button itself */
html.dark #theme-toggle {
    background: #0f172a;
    border-color: #374151;
    color: #e5e7eb;
}

.discord {

    text-decoration: none;
    color: #374151;
    border: 1px solid rgb(229, 231, 235);
    border-radius: 10px;
}

.r-toast-root {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 10050;
    display: grid;
    gap: 8px;
    width: min(92vw, 560px);
    pointer-events: none;
}

.r-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #111;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
    animation: toast-in .25s ease;
}

.r-toast--success {
    border-left: 4px solid #16a34a;
}

.r-toast--error {
    border-left: 4px solid #ef4444;
}

.r-toast--info {
    border-left: 4px solid #2563eb;
}

.r-toast__msg {
    flex: 1;
    line-height: 1.4;
}

.r-toast__action {
    background: #111;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.r-toast__close {
    background: transparent;
    border: 0;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: inherit;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }
}

/* Dark mode (compatible with your html.dark toggler) */
html.dark .r-toast {
    background: #0f172a;
    color: #e5e7eb;
    border-color: #374151;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

.monthly-sub,
.changePassword {
    opacity: .5;
    /* fade it */
    cursor: not-allowed;
    /* show disabled cursor */
    filter: saturate(.8);
    /* optional: slightly desaturate */
}

.plan_name_container {

    border-top: 1px dashed #e4e6e9;
    border-bottom: 1px dashed #e4e6e9;
    padding-top: 20px;
    padding-bottom: 20px;

}

.trail-period {


    border-bottom: 1px dashed #e4e6e9;
    padding-top: 20px;
    padding-bottom: 20px;

}

.settings-sidebar {
    position: relative;
    /* establish containing block */
    padding-bottom: 56px;
    /* space so content doesn't hide behind the footer p */
}

.settings-sidebar>p {
    position: absolute;
    left: 16px;
    /* tweak to your padding */
    right: 16px;
    bottom: 16px;
    /* distance from bottom */
    margin: 0;
}


/* Sticky footer note */
.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* default when chat not started */
    /* below your composer (z=100) */
    text-align: center;
    padding: 8px 12px;
    font-size: 12px;
    color: #6b7280;
    pointer-events: auto;
    /* keeps clicks going to page */
    background: transparent;
    height: var(--footer-h);
    line-height: var(--footer-h);
    z-index: 120;
}

body.chat-started .site-footer {
    bottom: 0 !important;
}

.site-footer a,
.site-footer a:link,
.site-footer a:visited {
    color: inherit !important;
    /* or set a hex color you want */
    text-decoration: none !important;
    /* keeps underline off */
}

.site-footer a:hover,
.site-footer a:focus {
    text-decoration: underline;
    /* optional hover style */
}

/* Dark theme color */
html.dark .site-footer {
    color: #9ca3af;

}


/* No bubble chrome for notices */
.bubble-plain,
.notice-row .bubble {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Center the notice row and hide any label just in case */
.notice-row {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.notice-row .message-label {
    display: none !important;
}

/* Optional: constrain width so your inline <small> looks tidy */
.notice-row .bubble-plain {
    max-width: 820px;
    width: 100%;
}



/* optional: nicer ordered lists from markdown */
.ai-response .bubble ol {
    padding-left: 1.25rem;
}

.ai-response .bubble ul {
    padding-left: 1.25rem;
}

/* B) Hide iOS Safari disclosure arrow on all relevant <summary> */
.model-picker>summary::-webkit-details-marker,
#math-input>summary::-webkit-details-marker,
summary::-webkit-details-marker {
    display: none !important;
}

/* also suppress list-style bullets some browsers show */
.model-picker>summary,
#math-input>summary,
summary {
    list-style: none;
}

/* Safari-only override: avoid fixed+transform glitch */
@supports (-webkit-hyphens: none) {
    body.chat-started #composer-stack {
        left: 0;
        right: 0;
        transform: none;
        /* <-- key fix */
        margin-left: auto;
        margin-right: auto;
    }
}



/* nuke all shadows on the component */
.upgrading-msg,
.upgrading-msg *,
.upgrading-msg::before,
.upgrading-msg::after {
    box-shadow: none !important;
    /* replaces 0 */
    text-align: center !important;
    text-shadow: none !important;
    /* if text looks glowy */
    filter: none !important;
    /* kills drop-shadow() */
    outline: none !important;
    /* focus outline */
    text-align: center;
    --tw-shadow: 0 0 #0000 !important;
    /* Tailwind shadow var */
    --tw-ring-shadow: 0 0 #0000 !important;
    /* Tailwind ring var */
    --tw-ring-offset-shadow: 0 0 #0000 !important;

}

/* placement + look */
.suggestion.upgrading-msg {
    margin-top: 10px;
    text-align: right;
}

/* link styling */
.upgrade-link {
    font-size: 13.5px;
    font-weight: 500;
    color: #4B5563;
    /* slate-600 */
    text-decoration: none;
}

.upgrade-link:hover {
    /* color: #111827; */
    text-decoration: underline;
}

/* Default: center above the trigger */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    /* center horizontally */
    bottom: 140%;
    /* place above */
    transform: translateX(-50%) translateY(6px);
    background: #111827;
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
    z-index: 50;
    font-size: 12.5px;
    line-height: 1.25;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;

    /* keep within viewport */
    max-width: min(320px, calc(100vw - 24px));
    white-space: normal;
    /* allow wrapping */
    text-align: center;
}

.tooltip::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(140% - 6px);
    transform: translateX(-50%) translateY(6px);
    border: 6px solid transparent;
    border-top-color: #111827;
    opacity: 0;
    transition: opacity .15s ease, transform .15s ease;
}

.tooltip:hover::after,
.tooltip:hover::before,
.tooltip:focus-within::after,
.tooltip:focus-within::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Small screens: if space is tight above, show BELOW, centered full-width-ish */
@media (max-width: 480px) {
    .tooltip::after {
        bottom: auto;
        top: 120%;
        left: 50%;
        transform: translateX(-50%) translateY(-6px);
        max-width: calc(100vw - 24px);
    }

    .tooltip::before {
        bottom: auto;
        top: calc(120% - 6px);
        left: 50%;
        transform: translateX(-50%) translateY(-6px);
        border-top-color: transparent;
        border-bottom-color: #111827;
        /* arrow points up when tooltip is below */
    }
}


/* Ultra-small screens: show ABOVE again */
@media (max-width: 348px) {
    .tooltip::after {
        top: auto;
        /* undo 480px rule */
        bottom: 140%;
        /* place above */
        left: 50%;
        transform: translateX(-50%) translateY(6px);
        max-width: calc(100vw - 16px);
        /* a bit tighter padding on tiny screens */
    }

    .tooltip::before {
        top: auto;
        /* undo 480px rule */
        bottom: calc(100% - 6px);
        left: 50%;
        transform: translateX(-50%) translateY(6px);
        border-bottom-color: transparent;
        /* arrow points down when above */
        border-top-color: #111827;
    }

    /* optional: shrink font slightly on very small screens */
    .tooltip::after {
        font-size: 12px;
    }
}

/* Short landscape: remove giant top gap */
@media (orientation: landscape) and (max-height: 603px) {
    body {
        /* kill the 40px top padding in this mode */
        padding: 12px 12px 20px 12px !important;
        justify-content: flex-start;
        /* keep content visible */
    }

    .greeting {
        margin-top: 0 !important;
        padding-top: clamp(4px, env(safe-area-inset-top, 0px), 10px) !important;
    }
}

/* Dock summary near the send icon */
.tool-menu {
    position: absolute;
    right: 56px;
    /* just left of the send icon */
    bottom: 12px;
    z-index: 1300;
}

/* Summary button */
.tool-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px;
    padding-left: 8px;
    font-size: 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

/* ↓ OPEN DOWNWARD (below the summary) */
.tool-panel {
    position: absolute;
    top: 120%;
    /* ⬅️ open below */
    right: 0;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: 8px;
    min-width: 180px;
    max-height: 40vh;
    /* avoid overflow if near viewport bottom */
    overflow: auto;
}

.tool-menu:not([open]) .tool-panel {
    display: none;
}

/* Items */
.tool-item {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font: inherit;
}

.tool-item:hover {
    background: #f9fafb;
}

/* Selected state */
.tool-item[aria-checked="true"] {
    border-color: #c7d2fe;
    background: #eef2ff;
    font-weight: 600;
}

/* Dark theme mirrors */
html.dark .tool-summary {
    background: #0f172a;
    color: #e5e7eb;
    border-color: #374151;
}

html.dark .tool-panel {
    background: #0f172a;
    color: #e5e7eb;
    border-color: #374151;
}

html.dark .tool-item {
    background: transparent;
    color: #e5e7eb;
}

html.dark .tool-item:hover {
    background: #111827;
}

html.dark .tool-item[aria-checked="true"] {
    background: #1f2937;
    border-color: #4f46e5;
}

/* Keep it sensible on small screens */
@media (max-width:520px) {
    .tool-menu {
        right: 48px;
    }

    .greeting {

        margin-top: 70px !important;
        /* or whatever spacing you want */

    }
}

/* Default: open downward */
.tool-panel {
    position: absolute;
    top: 120%;
    bottom: auto;
    /* <— important */
    right: 0;
}

/* When conversation has messages → open upward */
.conversation.has-messages~#composer .tool-menu .tool-panel {
    top: auto;
    bottom: 120%;
}

#log {
    white-space: pre-wrap;
    font: 12px ui-monospace, monospace;
    color: #a6b2d1;
    background: #0f0f23;
    border: 1px solid #2b2b40;
    border-radius: 8px;
    padding: 10px;
    max-height: 260px;
    overflow: auto
}

a[download] {
    display: none
}

.progress {
    height: 10px;
    background: #2b2b40;
    border-radius: 999px;
    overflow: hidden
}

.progress .bar {
    height: 100%;
    width: 0%;
    background: #00d9ff;
    transition: width .2s ease
}

#player {
    width: 100%;
    max-width: 960px;
    border-radius: 10px;
    display: none
}

.row {
    display: flex;
    gap: 10px;
    align-items: center
}

/* Offscreen one-time line renderer */
#lineRenderStage {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: var(--w);
    padding: 0;
    margin: 0
}

/* Force light text for offscreen snapshots so html2canvas captures visible glyphs */
#lineRenderStage,
#lineRenderStage .katex,
#lineRenderStage .katex * {
    color: #eaeaf0 !important;
}

/* Video-only sizing: make rendered math/text larger inside the snapshot stage */
#lineRenderStage .katex {
    font-size: 2.6em !important;
    /* try 2.4–2.8em to taste */
}

#lineRenderStage .katex * {
    font-size: inherit !important;
    /* prevent KaTeX children from double-scaling */
}

#lineRenderStage .text {
    font-size: 26px !important;
    /* was ~22px in your demo */
    line-height: 1.5 !important;
}


/* Inline content for rasterization (no inline numbers) */
.line {
    width: calc(var(--w) - 40px);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 0;
    margin: 0;
    background: transparent;
}

.katex {
    font-size: 2.2em
}

.text {
    font-size: 22px;
    line-height: 1.4;
    white-space: pre-wrap
}

.card {
    background: #1a1a2e;
    border: 1px solid #24324d;
    border-radius: 10px;
    padding: 16px
}

.parents-cta {
    margin-top: 12px;
    padding: 10px;
    background: #fff7ed;
    /* light orange */
    border: 1px solid #fed7aa;
    border-radius: 8px;
    /* font-size: 13px; */
    text-align: center;
    color: #9a3412;
}

.parents-link {
    font-weight: 600;
    color: #c2410c;
    text-decoration: underline;
    cursor: pointer;
}

.parents-link:hover {
    color: #9a3412;
}

/* ================
   Parents CTA – Dark Mode
   ================ */
html.dark .parents-cta {
    background: #1e293b;
    /* slate-800 */
    border: 1px solid #334155;
    /* slate-700 */
    color: #f8fafc;
    /* near-white */
}

html.dark .parents-link {
    color: #f97316;
    /* orange-500 */
}

html.dark .parents-link:hover {
    color: #fb923c;
    /* orange-400 */
}