@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@300;400;600;700&display=swap');

* {
    box-sizing: border-box;
    scrollbar-width: none;
}
/* Global input theming using CSS variables for easy color customization */
:root {
    --input-bg: #1e1e1e;            /* background color of input controls */
    --input-text: #f5f5f5;          /* text color inside inputs */
    --input-border: #454545;        /* border color for inputs */
    --input-border-focus: #777;       /* border color on focus */
    --input-placeholder: #8c8c8c;   /* placeholder text color */
    --input-radius: 6px;             /* border radius for inputs */
    --input-shadow-focus: 0 0 0 3px rgba(255,255,255,0.04);
}

/* Apply global styling to inputs, textareas, and selects
     while keeping the existing shell/input structure intact. */
input, textarea, select {
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--input-border);
    border-radius: var(--input-radius);
    outline: none;
}
input::placeholder, textarea::placeholder {
    color: var(--input-placeholder);
}

/* Preserve existing behavior for the main input inside the chat shell */
#input {
    background: transparent;
    border: 0;
    color: var(--input-text);
}
/* Inner input inside the shell container (the visual input field in the chat) */
#input-shell input {
    background: transparent;
    border: none;
    color: var(--input-text);
}
/* Focus styling for consistency across inputs */
input:focus, textarea:focus, select:focus {
    border-color: var(--input-border-focus);
}

:root {
--input-bg: #1e1e1e;
--input-text: #f5f5f5;
--input-border: #454545;
--input-placeholder: #8c8c8c;
--input-radius: 6px;
}

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

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    width: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #181818;
    color: #f5f5f5;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.hidden { display: none !important; }

.edit-prompt-button {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 4;
    width: 60px;
    padding: 8px;
    background: rgba(39, 39, 39, 0);
}

.edit-prompt-button:hover:not(:disabled) { background: #35353500; }
.edit-prompt-button[hidden] { display: none; }
.edit-prompt-button img { width: 100%; height: 100%; object-fit: contain; }

.prompt-editor {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(6px);
}

.prompt-editor[hidden] { display: none; }

.prompt-editor-card {
    display: flex;
    flex-direction: column;
    width: min(820px, 100%);
    height: min(650px, 85vh);
    padding: 20px;
    border: 1px solid #454545;
    border-radius: 16px;
    background: #202020;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}

.prompt-editor-header,
.prompt-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.prompt-editor-header h2 { margin: 0 0 16px; font-size: 18px; font-weight: 500; }
.close-prompt-editor { width: 32px; height: 32px; margin-top: -10px; background: transparent; color: #aaa; font-size: 24px; }
.close-prompt-editor:hover:not(:disabled) { background: #353535; color: #fff; }

#system-prompt {
    flex: 1;
    width: 100%;
    min-height: 0;
    resize: none;
    padding: 16px;
    background: #202020;
    color: #e8e8e8;
    font: sans-serif;
    border: 0;
}

.prompt-editor-footer { margin-top: 16px; }
.prompt-editor-footer > div { display: flex; gap: 8px; }
.prompt-editor-footer button { width: auto; height: 36px; padding: 0 15px; border-radius: 8px; font-size: 13px; }
.prompt-secondary-button { background: #343434; color: #ccc; }
.prompt-save-button { background: #f1f1f1; color: #181818; }
#prompt-editor-status { color: #d79763; font-size: 12px; }

.welcome-screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 24px clamp(32px, 10vw, 160px) 24px 24px;
    overflow: hidden;
    isolation: isolate;
    background: #181818;
}

.welcome-screen::before {
    position: absolute;
    inset: -24px;
    z-index: -1;
    content: "";
    background: linear-gradient(rgba(24, 24, 24, 0), rgba(24, 24, 24, 0)), url("auth_bg.jpg") center / cover no-repeat;
    filter: blur(8px);
    transform: scale(1.06);
}

.github-link {
    position: absolute;
    top: 22px;
    right: clamp(24px, 5vw, 72px);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 9px;
    color: rgba(245, 245, 245, .72);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    transition: color 180ms ease, opacity 180ms ease;
}

.github-link img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.github-link:hover {
    color: #fff;
    opacity: .9;
}



.welcome-promo {
    position: absolute;
    top: 50%;
    left: clamp(32px, 10vw, 160px);
    z-index: 1;
    width: min(900px, 34vw);
    transform: translateY(-50%);
}

.welcome-promo h1 {
    margin: 0;
    color: #f5f5f5;
    font-size: clamp(64px, 6vw, 108px);
    font-weight: 700;
    letter-spacing: 0.01em;
    font-family: 'Oxanium', sans-serif;
}

.welcome-promo p {
    max-width: 900px;
    margin: 18px 0 0;
    color: rgba(245, 245, 245, 0.899);
    font-size: 18px;
    line-height: 1.6;
}

.quick-demo-button {
    justify-content: center;
    width: 160px;
    height: 50px;
    margin-top: 24px;
    border-radius: 20px;
    background: rgba(131, 131, 131, 0.384);
    color: #f5f5f5;
    font-size: 18px;
    font-weight: 500;

    /* Slight animated glow */
    animation: subtle-glow 2.5s ease-in-out infinite;
}

@keyframes subtle-glow {
    0%, 100% {
        box-shadow: 0 0 4px rgba(180, 180, 180, 0.12);
    }

    50% {
        box-shadow: 0 0 6px rgba(180, 180, 180, 0.28);
    }
}



#chat {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    margin: 0 auto;
    padding: 34px max(24px, calc((100% - 1040px) / 2)) 130px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 1;
    scrollbar-width: thin;
    scrollbar-color: #424242 transparent;
}

#chat::-webkit-scrollbar {
    display: block;
    width: 6px;
}

#chat::-webkit-scrollbar-thumb {
    border: 1px solid transparent;
    border-radius: 999px;
    background: #424242;
    background-clip: content-box;
}

.tool-run {
    align-self: center;
    width: min(82%, 840px);
    max-width: 100%;
    margin-top: -10px;
    color: #8d8d8d;
    font-size: 12px;
}

.tool-run summary {
    width: fit-content;
    cursor: pointer;
    list-style-position: inside;
    user-select: none;
    font-size: 13px;
}

.tool-run summary::marker {
    color: #777777;
}

.tool-count {
    color: #666666;
}

.tool-log {
    max-height: 220px;
    overflow-y: auto;
    margin-top: 7px;
    padding-left: 18px;
    scrollbar-width: thin;
    scrollbar-color: #454545 transparent;
}

.tool-empty {
    padding: 4px 0 8px;
    color: #777777;
    line-height: 1.45;
}

.tool-entry {
    padding: 5px 0 8px;
}

.tool-entry-meta {
    margin-bottom: 3px;
    color: #858585;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
}

.tool-entry-content {
    display: -webkit-box;
    overflow: hidden;
    color: #c8c8c8;
    font-size: 15px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

/* Keep tool calls visually lightweight and part of the chat flow. */
.tool-run,
.tool-log,
.tool-entry {
    background: transparent;
    border: 0;
}

#idle-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding-bottom: 188px;
    color: #bffafa;
    pointer-events: none;
    transition: opacity 360ms ease-out, transform 360ms ease-out;
}

#idle-state img {
    width: min(245px, 42vw);
    height: auto;
    opacity: 0.92;
    filter: grayscale(1) brightness(1.35);
    mask-image: none;
}

/* Sitter: half-overlaps the idle title on the left.
   Tweak --sitter-x / --sitter-y to fine-tune position (percentages). */
#idle-state #sitter {
    position: absolute;
    left: var(--sitter-x, 65.5%);
    top: var(--sitter-y, 42.5%);
    width: min(100px, 15vw);
    height: auto;
    transform: translate(-50%, -50%);
    opacity: 1;
    z-index: 99;
    pointer-events: none;
}

/* Let the empty-state controls receive clicks through the blank chat layer. */
body:not(.has-messages) #chat {
    pointer-events: none;
}

.idle-title {
    margin-top: -8px;
    color: #bffafa;
    font-family: 'Oxanium', sans-serif;
    font-size: clamp(28px, 3vw, 38px);
    font-weight: 400;
    letter-spacing: -0.03em;
}

.suggested-prompts {
    display: flex;
    gap: 10px;
    margin-top: 112px;
    pointer-events: auto;
}

.suggested-prompts[hidden] { display: none; }

.suggested-prompt {
    width: auto;
    height: 34px;
    padding: 0 14px;
    border: 1px solid #585858;
    border-radius: 8px;
    background: #222222;
    color: #a9a9a9;
    font-size: 12px;
    white-space: nowrap;
}

.suggested-prompt:hover:not(:disabled) {
    background: #2c2c2c;
    color: #d5ffff;
    transform: translateY(-1px);
}

.time-selector {
    display: flex;
    gap: 10px;
    margin-top: 112px;
    pointer-events: auto;
}

.time-selector[hidden] { display: none; }

.time-button {
    width: auto;
    height: 34px;
    padding: 0 14px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;

    border: 1px solid #585858;
    border-radius: 8px;
    background: #222222;
    color: #a9a9a9;

    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.time-button img {
    width: 2.5em !important;
    height: 2.5em !important;
    max-width: 2.5em !important;
    max-height: 2.5em !important;
    object-fit: contain;
    flex: 0 0 auto;
}

.time-button:hover {
    background: #2c2c2c;
    color: #d5ffff;
    transform: translateY(-1px);
}

.time-button.is-selected {
    border-color: #36d6e7;
    background: rgba(54, 214, 231, 0.12);
    color: #bffafa;
}

body.has-messages #idle-state {
    opacity: 0;
    transform: translateY(-10px) scale(.98);
}

/* Remove scattered stars once a conversation starts */
body.has-messages #stars-bg {
    display: none;
}

/* Subtle drift for scattered stars */
@keyframes star-drift {
    from { transform: translate(0, 0) rotate(var(--r)); }
    to   { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); }
}

/* Twinkle (opacity + scale pulse) for single stars */
@keyframes twinkle {
    0%, 100% { opacity: .12; transform: translate(0, 0) rotate(var(--r)) scale(1); }
    50%      { opacity: .7;  transform: translate(0, 0) rotate(var(--r)) scale(1.3); }
}

/* Gentle drift for the corner floater */
@keyframes floater {
    from { transform: translate(-50%, -50%) translate(0, 0) rotate(-4deg); }
    to   { transform: translate(-50%, -50%) translate(var(--fdx), var(--fdy)) rotate(4deg); }
}

.message {
    max-width: min(75%, 760px);
    padding: 13px 17px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 15px;
    animation: message-in 220ms ease-out both;
}

.user-message-entering {
    animation-delay: 360ms;
}

.message-time {
    display: block;
    margin-top: 7px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    line-height: 1;
    text-align: right;
}

.message-row.user {
    align-self: flex-end;
    background: #181818;
}

.message.user {
    background: #34343422;
    border-bottom-right-radius: 6px;
}

.agent {
    max-width: 100%;
    align-self: flex-start;
    background: #181818;
    border-bottom-left-radius: 6px;
}

/* Message rows with avatars */
.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: min(85%, 800px);
}

.message-row .message {
    max-width: 100%;
}

.message-row.agent {
    align-self: flex-start;
}

.message-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-row .avatar {
    flex: 0 0 auto;
    width: 45px;
    margin-top: 2px;
    border-radius: 50%;
    background: #181818;
    object-fit: contain;
}

.message-row .user-avatar {
    padding: 0;
    object-fit: cover;
}

/* Full-width HTML responses: avatar on top */
.message-row.html-row {
    align-self: center;
    width: min(100%, 900px);
    max-width: 100%;
    flex-direction: column;
    gap: 8px;
}

.message-row.html-row .avatar {
    margin-top: 0;
}

.html-loading-message {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    padding: 13px 17px;
    color: rgba(255, 255, 255, 0.62);
}

.loading-dots {
    display: inline-flex;
    gap: 2px;
}

.loading-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: loading-dot 1.1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 140ms; }
.loading-dots span:nth-child(3) { animation-delay: 280ms; }

.html-message {
    flex: 0 0 auto;
    align-self: center;
    width: min(100%, 900px);
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 14px;
    background: #181818;
}

.html-response-frame {
    display: block;
    width: 100%;

    border: 0;

    background: transparent;
}

.html-message .message-time {
    padding: 0 14px 10px;
    background: #181818;
}

/* Markdown styling */
.agent pre {
    background: #181818;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
}

.agent code {
    font-family: monospace;
}

.agent p:first-child {
    margin-top: 0;
}

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

#input-area {
    position: fixed;
    z-index: 2;
    bottom: 22px;
    left: 50%;
    width: min(920px, calc(100% - 32px));
    transform: translateX(-50%);
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: bottom 1000ms cubic-bezier(.22, .8, .25, 1);
    will-change: bottom;
}

.response-timer {
    display: block;
    margin-top: 7px;
    color: #888;
    font: 11px/1.2 Consolas, "Courier New", monospace;
    text-align: right;
}

.response-timer[hidden] { display: none; }

body:not(.has-messages) #input-area {
    bottom: calc(50% - 6px);
}

.connection-indicator {
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #e05252;
    transform: translateY(-50%);
    box-shadow: 0 0 0 3px rgba(224, 82, 82, 0.12);
    transition: background 180ms ease, box-shadow 180ms ease;
}

.connection-indicator.connected {
    background: #55bd72;
    box-shadow: 0 0 0 3px rgba(85, 189, 114, 0.12);
}

#input-shell {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px 7px 20px;
    border: 1px solid #3b3b3b;
    border-radius: 999px;
    background: rgba(39, 39, 39, 0.94);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    backdrop-filter: blur(18px);
    transition: border-color 180ms ease, box-shadow 180ms ease;
    flex: 1 1 auto;
    min-width: 0;
}

.model-picker {
    position: relative;
    flex: 0 0 auto;
    min-width: 0;
    margin-left: -100px;
    
}

.model-picker-button {
    display: flex;
    align-items: center;
    gap: 7px;
    width: auto;
    max-width: 260px;
    height: 54px;
    padding: 0 9px;
    border: 1px solid #3b3b3b;
    border-radius: 200px;
    background: rgb(39, 39, 39);
    color: #262626;
    font: inherit;
    font-size: 12px;
    text-align: left;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.42), 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.model-picker-button:hover {
    background: #313131;

}
.model-picker-button[aria-expanded="true"] {
    border-color: #454545;
    background: #2b2b2b;
}

.model-picker-button span {
    color: #cfcfcf;
    transform: none;
}

#model-provider-logo,
.model-option img {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    object-fit: contain;
}

#model-picker-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #d4d4d4;
}

.model-picker-chevron {
    color: #888;
    font-size: 16px;
    line-height: 1;
}

.model-options {
    position: absolute;
    left: -23px;
    bottom: calc(100% + 10px);
    z-index: 5;
    display: grid;
    width: min(360px, calc(100vw - 32px));
    max-width: 115%;
    /* Height scales with the viewport so it fits any screen; scrolls when it overflows */
    max-height: 25vh;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #454545 transparent;
    border: 1px solid #454545;
    border-radius: 12px;
    background: rgba(31, 31, 31, .98);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
}

/* Visible scrollbar for the model list (the global *::-webkit-scrollbar rule hides it) */
.model-options::-webkit-scrollbar {
    display: block;
    width: 6px;
}

.model-options::-webkit-scrollbar-thumb {
    border: 1px solid transparent;
    border-radius: 999px;
    background: #454545;
    background-clip: content-box;
}

.model-options[hidden] { display: none; }

.model-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 6px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #ddd;
    font: inherit;
    text-align: left;
}

.model-option:hover { background: #353535; color: #fff; }
.model-option span { min-width: 0; }
.model-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; color: #d4d4d4; /* light grey model name */ }


#send img {
    width: 45px;
}
#input-shell:focus-within {
    border-color: #5a5a5a;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.42), 0 0 0 3px rgba(255, 255, 255, 0.04);
}

#input {
    flex: 1;
    min-width: 0;
    padding: 10px 0;
    border: 0;
    background: transparent;
    color: #f5f5f5;
    outline: none;
    font: inherit;
    font-size: 15px;
}

#input::placeholder {
    color: #8c8c8c;
}

button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: none;
    border-radius: 50%;
    background: #f1f1f1;
    color: #181818;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
    transition: transform 180ms ease, background 180ms ease;
}

button span {
    color: #181818;
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* Quick Demo hover customization — keep this after the global button rules. */
.quick-demo-button:hover:not(:disabled) {
    background: rgba(109, 112, 128, 0.686);
    color: #f5f5f5;
    transform: none;

    /* Slight glow */
    box-shadow: 0 0 8px rgba(109, 112, 128, 0.25);
    transform: scale(1.02);
}



#send { 
    background: transparent;    
}
#send:hover:not(:disabled) { background: transparent; }
/* Move the send button left and rotate by 45 degrees */ 
#send { transform: translateX(-17px) translateY(6px) rotate(-45deg); transform-origin: center; }


@keyframes message-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes loading-dot {
    0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}


@media (max-width: 600px) {
    .edit-prompt-button { top: 12px; right: 12px; }
    .prompt-editor { padding: 12px; }
    .prompt-editor-card { height: 90vh; padding: 14px; }
    .welcome-screen {
        align-items: center;
        justify-content: flex-start;
        flex-direction: column;
        padding: 32px 20px 48px;
        overflow-x: hidden;
        overflow-y: auto;
    }
    .welcome-promo {
        position: relative;
        top: auto;
        left: auto;
        width: min(100%, 500px);
        margin: 8px auto 0;
        transform: none;
    }
    #chat { padding: 24px 16px 120px; }
    .message { max-width: 88%; }
    .html-message { width: 100%; }
    #input-area { bottom: 14px; width: calc(100% - 22px); }
    .model-picker-button { max-width: 42px; padding: 0 8px; }
    .model-options { left: 0; } /* keep the dropdown on-screen on small screens */
    #model-picker-label, .model-picker-chevron { display: none; }
    body:not(.has-messages) #input-area { bottom: calc(50% - 6px); }
    #idle-state { padding-bottom: 190px; }
    #idle-state img { width: min(210px, 54vw); }
    .idle-title { font-size: clamp(24px, 7vw, 32px); text-align: center; }
    .suggested-prompts { flex-wrap: wrap; justify-content: center; width: min(100%, 330px); margin-top: 105px; }
    .time-selector { flex-wrap: wrap; justify-content: center; width: min(100%, 330px); margin-top: 105px; }
    .connection-indicator { left: auto; right: 13px; top: -13px; }
}

