* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #475569;
    --success: #10b981;
    --error: #ef4444;
    --code-bg: #0d1117;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

main {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.api-key-section {
    margin-bottom: 30px;
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.api-key-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.api-key-wrapper label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.api-key-input {
    width: 100%;
    padding: 12px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.api-key-help {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.api-key-help a {
    color: var(--primary-color);
    text-decoration: none;
}

.api-key-help a:hover {
    text-decoration: underline;
}

.context-section {
    margin-bottom: 30px;
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.context-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.context-wrapper label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.context-select {
    width: 100%;
    padding: 12px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.context-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.context-select option {
    background: var(--background);
    color: var(--text-primary);
}

.context-help {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.context-options {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.context-option-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.context-option-wrapper label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.input-section {
    margin-bottom: 30px;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#promptInput {
    width: 100%;
    padding: 16px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#promptInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

#promptInput::placeholder {
    color: var(--text-secondary);
}

.submit-btn {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    align-self: flex-start;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.response-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.response-header {
    margin-bottom: 20px;
}

.response-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.user-prompt-section {
    background: var(--background);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--secondary-color);
    margin-bottom: 20px;
}

.user-prompt-section h3 {
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

.user-prompt-section p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-style: italic;
}

.structured-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-block {
    background: var(--background);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
}

.section-block h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

.section-block p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.code-block {
    background: var(--code-bg);
    padding: 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    font-size: 0.95em;
    display: block;
    overflow-x: auto;
    margin: 0;
    border: 1px solid var(--border-color);
}

.section-block code.code-block {
    padding: 12px;
    font-size: 0.95em;
}

.section-block pre.code-block {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.expression-view-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.expression-view-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.expression-tree {
    background: var(--background);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.tree-node {
    padding: 8px 0;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tree-node:last-child {
    border-bottom: none;
}

.tree-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.tree-label {
    color: var(--text-primary);
    font-weight: 600;
}

.tree-value {
    color: var(--primary-color);
}

.tree-type {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-left: auto;
}

.raw-response-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.raw-response-section details {
    background: var(--background);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.raw-response-section summary {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.raw-response-section summary:hover {
    color: var(--text-primary);
}

.raw-response-section pre {
    margin-top: 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.error-section {
    margin-top: 20px;
    padding: 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--error);
}

.error-icon {
    font-size: 1.2rem;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.btn-loader {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 20px;
    }

    .response-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

