:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e1e4e8;
    --text: #1c2128;
    --muted: #6a737d;
    --primary: #2f6fed;
    --primary-text: #ffffff;
    --bubble-mine: #2f6fed;
    --bubble-mine-text: #ffffff;
    --bubble-theirs: #eceff3;
    --bubble-theirs-text: #1c2128;
    --danger: #d1242f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar .brand { font-weight: 600; text-decoration: none; color: var(--text); }

.topbar nav { display: flex; align-items: center; gap: 1rem; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.topbar nav a:hover { color: var(--text); }
.lang-switch {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-size: 0.8rem !important;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}
.link-button:hover { color: var(--text); }
.inline-form { display: inline; }

main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 420px;
    margin: 2rem auto;
}

.panel h1 { margin-top: 0; font-size: 1.4rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.field input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

button.primary, .btn.primary {
    background: var(--primary);
    color: var(--primary-text);
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.1rem;
    font-size: 1rem;
    cursor: pointer;
}
button.primary:hover, .btn.primary:hover { opacity: 0.92; }

.alert {
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert.error { background: #ffeef0; color: var(--danger); border: 1px solid #ffc1c9; }
.alert.success { background: #ecfdf3; color: #146c43; border: 1px solid #b8f0cf; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* Chat layout: sidebar + message pane */
.chat-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    height: 70vh;
    min-height: 420px;
}

.chat-sidebar {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.chat-sidebar .new-conversation { padding: 0.75rem; border-bottom: 1px solid var(--border); }
.chat-sidebar .new-conversation input { width: 100%; margin-bottom: 0.4rem; }
.conversation-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.conversation-list li {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.9rem;
}
.conversation-list li:hover { background: var(--bg); }
.conversation-list li.active { background: #eaf1ff; }
.conversation-list .badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--bubble-theirs);
    color: var(--muted);
    margin-left: 0.4rem;
}

.chat-main { display: flex; flex-direction: column; min-width: 0; }
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.bubble {
    max-width: 70%;
    padding: 0.5rem 0.8rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}
.bubble.mine { align-self: flex-end; background: var(--bubble-mine); color: var(--bubble-mine-text); }
.bubble.theirs { align-self: flex-start; background: var(--bubble-theirs); color: var(--bubble-theirs-text); }
.bubble .meta { display: block; font-size: 0.7rem; opacity: 0.7; margin-top: 0.2rem; }

.composer {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}
.composer input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 1rem;
}
.composer button {
    border: none;
    border-radius: 20px;
    background: var(--primary);
    color: var(--primary-text);
    padding: 0 1.2rem;
    cursor: pointer;
}

.support-widget { max-width: 480px; margin: 0 auto; }

.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.7rem;
}
.queue-item .actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.queue-item .actions button {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    font-size: 0.85rem;
}
