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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0f1117;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

main {
    height: 100vh;
}

/* Chat layout */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #1e2030;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #c0c0c0;
    letter-spacing: 0.5px;
}

.environment-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    background: #1a3a2a;
    color: #4ade80;
    border: 1px solid #2a4a3a;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 15px;
}

/* Message bubbles */
.message {
    display: flex;
    max-width: 90%;
}

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

.message-assistant {
    align-self: flex-start;
}

.message-tool {
    align-self: flex-start;
    max-width: 100%;
}

.message-tool .message-content {
    padding: 0;
    background: none;
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-user .message-content {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-assistant .message-content {
    background: #1e2030;
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
}

.message-assistant .message-content h1,
.message-assistant .message-content h2,
.message-assistant .message-content h3 {
    color: #f0f0f0;
    margin: 16px 0 8px 0;
    line-height: 1.3;
}

.message-assistant .message-content h2 { font-size: 16px; }
.message-assistant .message-content h3 { font-size: 14px; }

.message-assistant .message-content p {
    margin: 6px 0;
}

.message-assistant .message-content ul,
.message-assistant .message-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.message-assistant .message-content hr {
    border: none;
    border-top: 1px solid #2a2d3e;
    margin: 12px 0;
}

.message-assistant .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 13px;
}

.message-assistant .message-content th,
.message-assistant .message-content td {
    border: 1px solid #2a2d3e;
    padding: 6px 10px;
    text-align: left;
}

.message-assistant .message-content th {
    background: #161822;
    color: #c0c0c0;
    font-weight: 600;
}

.message-assistant .message-content td {
    background: #1a1d2e;
}

.message-assistant .message-content strong {
    color: #f0f0f0;
}

.message-error {
    align-self: flex-start;
}

.message-error .message-content {
    background: #2a1520;
    border: 1px solid #4a2030;
    border-bottom-left-radius: 4px;
}

.error-block {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f0a0a0;
    font-size: 14px;
}

.error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #6b2030;
    color: #f0a0a0;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.message-assistant .message-content code {
    background: #161822;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

.message-assistant .message-content pre {
    background: #161822;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-assistant .message-content pre code {
    background: none;
    padding: 0;
}

/* Tool cards */
.tool-card {
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    background: #131622;
    border: 1px solid #1e2235;
    border-left: 2px solid #3b82f6;
}

.tool-card-name {
    color: #93c5fd;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-weight: 500;
    font-size: 11px;
}

.tool-card-args {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #1e2235;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tool-arg {
    display: flex;
    gap: 0;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.6;
}

.tool-arg-key {
    color: #6b7280;
    flex-shrink: 0;
    min-width: 0;
}

.tool-arg-key::after {
    content: ":\00a0";
}

.tool-arg-value {
    color: #d1d5db;
    word-break: break-all;
}

/* Tool indicators (activity) */
.tool-active {
    color: #60a5fa;
    background: #172040;
}

.tool-error {
    color: #f87171;
    background: #2a1520;
}

/* Activity indicator (pulsing dot + label) */
.activity-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #8b8fa3;
    margin-top: 4px;
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #60a5fa;
    animation: pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Token info */
.token-info {
    align-self: center;
    font-size: 11px;
    color: #555;
    padding: 4px 0;
}

/* Input area */
.chat-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #1e2030;
    background: #0f1117;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #2a2d3e;
    border-radius: 12px;
    background: #161822;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
}

.chat-input-area textarea:focus {
    border-color: #2563eb;
}

.chat-input-area textarea:disabled {
    opacity: 0.5;
}

.chat-input-area button {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.chat-input-area button:hover:not(:disabled) {
    background: #1d4ed8;
}

.chat-input-area button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #2a2d3e;
    border-radius: 3px;
}
