:root {
    --bg: #f7f7f8;
    --panel: #ffffff;
    --accent: #0e7aef;
    --text: #232529;
    --muted: #787a80;
    --border: #e1e1e4;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
}

.topics-panel {
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px;
    z-index: 1000;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-header h1 {
    font-size: 18px;
    margin: 0;
}

button.ghost {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}

#topics-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
}

#topics-list li {
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
}

#topics-list li.active {
    background: rgba(14, 122, 239, 0.13);
}

.chat-area {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.chat-desc {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
    align-self: flex-start;
}

.status-dot.online {
    background: #2bc866;
}

.toggle-topics {
    display: none;
    border: 1px solid var(--border);
    background: var(--panel);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--accent);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 0;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.icon-button.danger {
    background: #f83b3b;
}

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

.message {
    border-radius: 12px;
    padding: 12px 14px;
    max-width: 70%;
    line-height: 1.5;
}

.message.temporary {
    opacity: 0.7;
    font-style: italic;
}

.message.user {
    align-self: flex-end;
    background: #0e7aef;
    color: white;
}

.message.assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border);
}

.composer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--panel);
}

.composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    font-size: 16px;
}

.composer button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 24px;
    font-size: 16px;
    cursor: pointer;
}

.topics-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 900;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .topics-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 320px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
        border-right: none;
    }
    body.topics-open .topics-panel {
        transform: translateX(0);
    }
    body.topics-open .topics-overlay {
        opacity: 1;
        pointer-events: auto;
    }
    .toggle-topics,
    .icon-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
