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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #333;
    background: #f5f5f5;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* === Sidebar === */

.sidebar {
    width: 52px;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.sidebar button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar button.active {
    background: #4a90d9;
}

.sidebar button svg {
    width: 20px;
    height: 20px;
    fill: rgba(255, 255, 255, 0.7);
}

.sidebar button.active svg {
    fill: #fff;
}

/* === Main content === */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.view {
    display: none;
    flex: 1;
    flex-direction: column;
}

.view.active {
    display: flex;
}

/* === Chat view === */

.chat-header {
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-toggle {
    display: flex;
    background: #eee;
    border-radius: 6px;
    overflow: hidden;
}

.model-toggle button {
    padding: 6px 14px;
    border: none;
    background: transparent;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
}

.model-toggle button.active {
    background: #4a90d9;
    color: #fff;
}

.chat-header .status {
    margin-left: auto;
    font-size: 12px;
    color: #999;
}

.btn-reset {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 12px;
    color: #888;
    cursor: pointer;
}

.btn-reset:hover {
    background: #f0f0f0;
    color: #555;
}

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

.message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

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

.message .role {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.user .role {
    text-align: right;
}

.message .bubble {
    padding: 10px 14px;
    border-radius: 10px;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .bubble {
    background: #4a90d9;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.message.assistant .bubble {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 2px;
}

.message .meta {
    font-size: 11px;
    color: #aaa;
}

.chat-input {
    padding: 12px 20px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}

.chat-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    line-height: 1.4;
    min-height: 42px;
    max-height: 120px;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #4a90d9;
}

.chat-input button {
    padding: 0 16px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-input button:hover {
    background: #3a7bc8;
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* === System prompt view === */

.prompt-view {
    padding: 20px;
    gap: 12px;
}

.prompt-view h2 {
    font-size: 16px;
    font-weight: 600;
    color: #555;
}

.prompt-view p {
    font-size: 13px;
    color: #888;
}

.prompt-view textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
}

.prompt-view textarea:focus {
    outline: none;
    border-color: #4a90d9;
}

/* === Settings view === */

.settings-view {
    padding: 20px;
    gap: 20px;
}

.settings-view h2 {
    font-size: 16px;
    font-weight: 600;
    color: #555;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-group label {
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.setting-group input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    max-width: 500px;
}

.setting-group input:focus {
    outline: none;
    border-color: #4a90d9;
}

.setting-group .row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary {
    padding: 6px 14px;
    background: #eee;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    color: #555;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    display: inline-block;
}

.status-dot.ok {
    background: #4caf50;
}

.status-dot.error {
    background: #f44336;
}

/* === Loading indicator === */

.loading {
    display: inline-flex;
    gap: 4px;
    padding: 10px 14px;
}

.loading span {
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.loading span:nth-child(2) { animation-delay: 0.2s; }
.loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}
