* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #1a1a1a;
    color: #ffffff;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Prevent scrolling during initial view */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* Scrollable body in chat mode */
body.chat-mode {
    align-items: flex-start;
    overflow-y: auto;
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 20px;
    /* Transition for layout changes */
    transition: all 0.5s ease;
    height: 100%;
    justify-content: center;
}

body.chat-mode .container {
    justify-content: flex-start;
    padding-bottom: 220px;
    /* Increased space for input */
    padding-top: 40px;
}

h1 {
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.5px;
    color: #f4f4f5;
    text-align: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body.chat-mode h1 {
    opacity: 0;
    transform: translateY(-20px);
    display: none;
    /* remove from flow layout after transition? for now just hide */
    height: 0;
    margin: 0;
    overflow: hidden;
}

/* Animation for falling characters */
.falling-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(-20px);
    animation: dropIn 0.5s ease forwards;
}

@keyframes dropIn {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-container {
    background-color: #262626;
    width: 100%;
    max-width: 720px;
    min-height: 160px;
    border-radius: 20px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid #333;
    transition: border-color 0.2s ease, all 0.5s ease;
    z-index: 10;
}

/* Move input to bottom in chat mode */
body.chat-mode .input-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}

.input-container:focus-within {
    border-color: #404040;
}

textarea {
    width: 100%;
    flex-grow: 1;
    background: transparent;
    border: none;
    color: #e4e4e7;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
    min-height: 80px;
}

textarea::placeholder {
    color: #52525b;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.icon-btn {
    background: #3f3f46;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    /* Rounded rectangle */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #a1a1aa;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: #52525b;
    color: #fff;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.right-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.run-btn {
    background-color: #3f3f46;
    color: #a1a1aa;
    border: none;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: not-allowed;
    /* Default disabled cursor */
    transition: all 0.2s ease;
}

.run-btn.active {
    background-color: #e4e4e7;
    color: #18181b;
    cursor: pointer;
}

.run-btn:not(.active):hover {
    background-color: #3f3f46;
    /* No change on hover if disabled */
}

/* Chat History Styling */
.chat-history {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 20px;
    opacity: 0;
    /* Initially hidden */
    transition: opacity 0.5s ease;
}

body.chat-mode .chat-history {
    opacity: 1;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.user-message {
    align-self: flex-end;
    background-color: #3f3f46;
    color: #fff;
    padding: 10px 16px;
    border-radius: 18px;
    /* Bubble shape */
    max-width: 80%;
    margin-left: auto;
    font-size: 16px;
}

.ai-message-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Collapsible Thinking Process */
details.thinking-details {
    margin-bottom: 8px;
}

summary.thinking-summary {
    font-size: 13px;
    color: #71717a;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    list-style: none;
    /* Remove default triangle */
    user-select: none;
    transition: color 0.2s;
}

summary.thinking-summary:hover {
    color: #a1a1aa;
}

summary.thinking-summary::after {
    content: '›';
    display: inline-block;
    transition: transform 0.2s;
    margin-left: 4px;
}

details[open] summary.thinking-summary::after {
    transform: rotate(90deg);
}

.thinking-content {
    font-size: 13px;
    color: #52525b;
    margin-top: 6px;
    padding-left: 10px;
    border-left: 2px solid #333;
    font-family: monospace;
    white-space: pre-wrap;
}

.ai-message {
    font-size: 16px;
    line-height: 1.6;
    color: #e4e4e7;
    white-space: pre-wrap;
    /* Preserve formatting */
}

/* Markdown-like simple styling for AI response */
.ai-message h1,
.ai-message h2,
.ai-message h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    color: #fff;
}

.ai-message ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.ai-message li {
    margin-bottom: 4px;
}

/* Markdown Code Blocks */
.code-block {
    background-color: #212121;
    border-radius: 12px;
    margin: 24px 0;
    overflow: hidden;
    border: none;
    font-family: 'Inter', sans-serif;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 0 20px;
    background-color: transparent;
    font-size: 11px;
    font-weight: 500;
    color: #8e8e8e;
    text-transform: lowercase;
}

.copy-code-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8e8e8e;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 400;
    transition: color 0.1s ease;
}

.copy-code-btn:hover {
    color: #fff;
}

.code-block pre {
    padding: 32px 20px 20px 20px;
    overflow-x: auto;
    margin: 0;
}

.code-block code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre;
    background: transparent !important;
}

/* Ensure PrismJS doesn't add its own background or weird margins */
pre[class*="language-"] {
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
}

code[class*="language-"] {
    background: transparent !important;
    text-shadow: none !important;
}

/* PrismJS Syntax Highlighting Overrides for intensity */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #5c6370;
}

.token.punctuation {
    color: #abb2bf;
}

.token.namespace {
    opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #d19a66;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #98c379;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #56b6c2;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #c678dd;
}

.token.function,
.token.class-name {
    color: #61afef;
}

.token.regex,
.token.important,
.token.variable {
    color: #e06c75;
}

/* Inline code */
.ai-message :not(pre)>code {
    background-color: #2b2d31;
    padding: 3px 6px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9em;
    color: #f4f4f5;
}

.message-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    opacity: 0.6;
}

.action-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #a1a1aa;
    padding: 4px;
}

.action-icon:hover {
    color: #fff;
}

/* Share Button */
.share-btn {
    position: fixed;
    top: 24px;
    right: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #262626;
    border: 1px solid #333;
    border-radius: 99px;
    /* Pill shape */
    color: #e4e4e7;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1000;
}

.share-btn:hover {
    background-color: #3f3f46;
}

.share-btn svg {
    stroke: #a1a1aa;
}