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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    background: #1a1a2e;
    color: #e0e0e0;
    height: 100vh;
}

#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 260px;
    background: #16213e;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    border-right: 1px solid #0f3460;
}

#new-chat {
    padding: 10px;
    background: #0f3460;
    color: #e0e0e0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

#new-chat:hover { background: #533483; }

.conv-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.conv-item:hover { background: #0f3460; }
.conv-item.active { background: #533483; }

.conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-delete {
    background: none;
    border: none;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    display: none;
    line-height: 1;
}

.conv-item:hover .conv-delete { display: block; }
.conv-delete:hover { color: #e74c3c; }

main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.user {
    align-self: flex-end;
    background: #0f3460;
}

.message.assistant {
    align-self: flex-start;
    background: #16213e;
}

.agent-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.agent-planner .agent-label { background: #1a3a5c; color: #5dade2; }
.agent-coder .agent-label { background: #1a3c2a; color: #58d68d; }
.agent-validator .agent-label { background: #3c2a1a; color: #f0b27a; }
.agent-tester .agent-label { background: #2a1a3c; color: #bb8fce; }
.agent-tester_result .agent-label { background: #2a1a3c; color: #bb8fce; }
.agent-result .agent-label { background: #1a3c3c; color: #76d7c4; }
.agent-system .agent-label { background: #2c2c2c; color: #aaa; }

.agent-planner { border-left: 3px solid #5dade2; }
.agent-coder { border-left: 3px solid #58d68d; }
.agent-validator { border-left: 3px solid #f0b27a; }
.agent-tester { border-left: 3px solid #bb8fce; }
.agent-tester_result { border-left: 3px solid #bb8fce; }
.agent-result { border-left: 3px solid #76d7c4; }
.agent-repair .agent-label { background: #3c1a2a; color: #f0a27a; }
.agent-repair { border-left: 3px solid #f0a27a; }

.status-message {
    align-self: flex-start;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    background: #1e1e3a;
    max-width: 85%;
    white-space: pre-wrap;
    word-break: break-word;
}

.status-message.agent-validator { border-left: 3px solid #f0b27a; }
.status-message.agent-tester { border-left: 3px solid #bb8fce; }
.status-message.agent-tester_result { border-left: 3px solid #bb8fce; }
.status-message.agent-system { border-left: 3px solid #aaa; }

.reasoning-toggle {
    font-size: 12px;
    color: #888;
    cursor: pointer;
    margin-bottom: 4px;
    user-select: none;
}

.reasoning-toggle:hover { color: #b0b0b0; }

.reasoning {
    font-size: 12px;
    color: #888;
    border-left: 2px solid #533483;
    padding-left: 8px;
    margin-bottom: 8px;
    white-space: pre-wrap;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.reasoning.expanded { display: block; }

.agent-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.message pre {
    background: #0d1117;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    white-space: pre;
}

.message pre code {
    font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #c9d1d9;
    white-space: pre;
}

#context-panel {
    border-top: 1px solid #0f3460;
    background: #16213e;
}

#context-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 20px;
}

#context-toggle {
    background: none;
    border: none;
    color: #7faacc;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    padding: 4px 0;
}

#context-toggle:hover { color: #a8d0f0; }

#context-status {
    font-size: 12px;
}

.context-ok { color: #58d68d; }
.context-error { color: #e74c3c; }

#context-body {
    padding: 0 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#context-body.collapsed {
    display: none;
}

#context-editor {
    width: 100%;
    padding: 10px;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 8px;
    resize: vertical;
    font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    font-size: 13px;
    min-height: 80px;
    max-height: 300px;
}

#context-actions {
    display: flex;
    gap: 8px;
}

#context-actions button {
    padding: 5px 14px;
    background: #0f3460;
    color: #e0e0e0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

#context-actions button:hover { background: #533483; }

.planner-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #2e476b;
    border-radius: 12px;
    padding: 14px;
    margin-top: 4px;
}

.planner-form-title {
    font-size: 16px;
    font-weight: 700;
    color: #e8f1ff;
}

.planner-form-description {
    font-size: 13px;
    color: #b8c5da;
}

.planner-question {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.planner-question-title {
    font-size: 14px;
    font-weight: 600;
    color: #eef4ff;
}

.planner-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.planner-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #314766;
    background: #1b2943;
    cursor: pointer;
}

.planner-option:hover {
    background: #223252;
}

.planner-option input {
    margin-top: 3px;
}

.planner-option-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.planner-option-main {
    font-size: 14px;
    color: #f0f4fb;
}

.planner-option-description {
    font-size: 12px;
    color: #afbdd3;
}

.planner-badge {
    align-self: flex-start;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #304f22;
    color: #a9e18b;
    border: 1px solid #4d7b37;
}

.planner-text-input {
    width: 100%;
    padding: 10px;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #314766;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
}

.planner-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.planner-form-note {
    font-size: 12px;
    color: #9fb2cc;
}

.planner-submit {
    padding: 10px 16px;
    background: #6da8ff;
    color: #0d1626;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.planner-submit:hover {
    background: #89b9ff;
}

.planner-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#input-area {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #0f3460;
    background: #16213e;
}

#prompt {
    flex: 1;
    padding: 10px;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
}

#send {
    padding: 10px 20px;
    background: #533483;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

#send:hover { background: #0f3460; }
#send:disabled { opacity: 0.5; cursor: not-allowed; }