:root {
    color-scheme: light dark;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    background: radial-gradient(circle at top, #f5f7ff 0%, #eef2ff 45%, #dfe7ff 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.app {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(32, 54, 96, 0.2);
    max-width: 1000px;
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    color: #1f3c88;
}

header p {
    margin: 0.5rem 0 0;
    color: #4a4a68;
}

.output-layout {
    display: flex;
    gap: 1.5rem;
}

.chat-window {
    flex: 1 1 0;
    min-height: 320px;
    max-height: 480px;
    overflow-y: auto;
    padding: 1rem;
    border-radius: 12px;
    background: #f8f9ff;
    border: 1px solid rgba(31, 60, 136, 0.15);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    box-shadow: 0 6px 15px rgba(36, 64, 122, 0.08);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #4f86f7, #6d5dfc);
    color: white;
}

.message.assistant {
    align-self: flex-start;
    background: white;
    color: black;
    border: 1px solid rgba(31, 60, 136, 0.1);
}

.tool-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(31, 60, 136, 0.15);
}

.tool-chips-prefix {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4a4a68;
    opacity: 0.75;
    margin-right: 0.15rem;
}

.tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(31, 60, 136, 0.08);
    border: 1px solid rgba(31, 60, 136, 0.18);
    color: #1f3c88;
    font-size: 0.8rem;
    line-height: 1.2;
    white-space: nowrap;
}

.tool-chip-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.tool-chip-label {
    font-weight: 500;
}

.message.status {
    align-self: center;
    background: rgba(31, 60, 136, 0.08);
    border: none;
    box-shadow: none;
    font-style: italic;
}

#chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: #1f3c88;
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.input-row {
    display: flex;
    gap: 0.75rem;
}

textarea {
    flex: 1;
    resize: vertical;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(31, 60, 136, 0.2);
    font-size: 1rem;
    font-family: inherit;
    min-height: 70px;
}

button {
    background: linear-gradient(135deg, #1f3c88, #274690);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(31, 60, 136, 0.25);
}

.chart-panel {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(31, 60, 136, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    min-height: 320px;
    max-height: 480px;
}

.chart-panel h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #1f3c88;
    flex-shrink: 0;
}

.chart-placeholder {
    flex: 1;
    min-height: 220px;
    max-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    border-radius: 10px;
    border: 1px dashed rgba(31, 60, 136, 0.25);
    color: #4a4a68;
    background: rgba(248, 249, 255, 0.7);
}

#chartCanvas {
    flex: 1;
    min-height: 220px;
    max-height: 420px;
    display: none;
}

.chart-panel canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 420px !important;
}

@media (max-width: 720px) {
    body {
        padding: 1rem;
    }

    .app {
        padding: 1.5rem;
    }

    .output-layout {
        flex-direction: column;
    }

    .chart-panel {
        flex: 1 1 auto;
    }

    .input-row {
        flex-direction: column;
    }

    button {
        width: 100%;
    }
}
