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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
}

h1 {
    font-size: 2em;
}

.status {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.status.connected {
    background: #4caf50;
    color: white;
}

.status.disconnected {
    background: #f44336;
    color: white;
}

nav {
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.3s;
}

.tab.active {
    background: #2196f3;
    color: white;
    border-color: #2196f3;
}

.tab:hover {
    background: #e3f2fd;
}

.tab.active:hover {
    background: #1976d2;
}

.panel {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.panel.active {
    display: block;
}

.chat-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    height: 600px;
}

.sidebar {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    overflow-y: auto;
}

.sidebar h3 {
    margin-bottom: 15px;
}

.group-item {
    padding: 10px;
    margin-bottom: 5px;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.group-item:hover {
    background: #e3f2fd;
}

.group-item.active {
    background: #2196f3;
    color: white;
}

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

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 10px;
}

.message {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.sender {
    font-weight: 600;
    color: #2196f3;
    display: block;
    margin-bottom: 5px;
}

.content {
    display: block;
    margin-bottom: 5px;
}

.timestamp {
    font-size: 0.85em;
    color: #666;
}

.input-area {
    display: flex;
    gap: 10px;
}

input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #2196f3;
}

button {
    padding: 10px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

button:hover {
    background: #1976d2;
}

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

#group-list {
    margin-bottom: 10px;
}

#create-group-btn {
    width: 100%;
    margin-top: 10px;
}

.session-item, .status-item {
    padding: 10px;
    background: #f9f9f9;
    margin-bottom: 10px;
    border-radius: 4px;
}

/* ==========================================================================
   Settings Drawer
   ==========================================================================
   Note: Add the Instrument Sans font in the HTML <head>:
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600&display=swap" rel="stylesheet">
   ========================================================================== */

/* -- Drawer ---------------------------------------------------------------- */

#settings-drawer {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 420px;
    background: #fff;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#settings-drawer.open {
    transform: translateX(0);
}

/* -- Backdrop -------------------------------------------------------------- */

#settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(2px);
    transition: opacity 200ms;
}

#settings-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* -- Header ---------------------------------------------------------------- */

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.settings-header .settings-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-title-icon {
    color: #666;
}

.settings-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    border-radius: 6px;
    transition: color 150ms, background 150ms;
}

.settings-close-btn:hover {
    color: #333;
    background: #f0f0f0;
}

/* -- Body (scrollable) ----------------------------------------------------- */

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.settings-body::-webkit-scrollbar {
    width: 6px;
}

.settings-body::-webkit-scrollbar-track {
    background: transparent;
}

.settings-body::-webkit-scrollbar-thumb {
    background: #d4d4d4;
    border-radius: 3px;
}

.settings-body::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* Firefox scrollbar */
.settings-body {
    scrollbar-width: thin;
    scrollbar-color: #d4d4d4 transparent;
}

/* -- Sections -------------------------------------------------------------- */

.settings-section {
    margin-bottom: 28px;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
    margin-bottom: 14px;
}

/* -- Form Fields ----------------------------------------------------------- */

.setting-field {
    margin-bottom: 18px;
}

.setting-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
}

.setting-help {
    font-size: 0.75rem;
    color: #999;
    margin-top: 4px;
}

.setting-input {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 150ms;
    font-family: inherit;
}

.setting-input:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.setting-textarea {
    width: 100%;
    height: auto;
    min-height: 80px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    outline: none;
    resize: vertical;
    transition: border-color 150ms;
    font-family: inherit;
}

.setting-textarea:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.setting-select {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 150ms;
    font-family: inherit;
    background: #fff;
    cursor: pointer;
    appearance: auto;
}

.setting-select:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.setting-number {
    width: 80px;
    height: 40px;
    text-align: center;
    display: inline-block;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 150ms;
    font-family: inherit;
}

.setting-number:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* -- Toggle Switch --------------------------------------------------------- */

.setting-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: #ddd;
    transition: background 200ms;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.toggle-track.on {
    background: #4361ee;
}

.toggle-knob {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-track.on .toggle-knob {
    transform: translateX(20px);
}

/* -- Segmented Control ----------------------------------------------------- */

.setting-segmented {
    display: flex;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.segment-btn {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 150ms;
    border: none;
    background: transparent;
    font-family: inherit;
}

.segment-btn.active {
    background: #fff;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* -- Skill Checkboxes ------------------------------------------------------ */

.skill-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.skill-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 100ms;
}

.skill-item:hover {
    background: #f5f5f5;
}

.skill-item input[type="checkbox"] {
    accent-color: #4361ee;
}

.skill-name {
    font-size: 0.85rem;
}

/* -- Footer ---------------------------------------------------------------- */

.settings-footer {
    padding: 16px 24px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.settings-save-btn {
    flex: 1;
    height: 42px;
    background: #4361ee;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 150ms;
    font-family: inherit;
}

.settings-save-btn:hover {
    background: #3a56d4;
}

.settings-saved {
    font-size: 0.8rem;
    color: #2ec4b6;
    opacity: 0;
    transition: opacity 300ms;
}

.settings-saved.visible {
    opacity: 1;
}

/* -- Mobile ---------------------------------------------------------------- */

@media (max-width: 640px) {
    #settings-drawer {
        width: 100%;
        border-radius: 0;
    }
}

/* Typing indicator */
.typing-indicator .content {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.dot-pulse {
    display: inline-flex;
    gap: 4px;
}

.dot-pulse::before,
.dot-pulse::after,
.dot-pulse {
    content: '';
}

.dot-pulse,
.dot-pulse::before,
.dot-pulse::after {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: dot-pulse 1.4s infinite ease-in-out both;
}

.dot-pulse::before {
    content: '';
    position: relative;
    left: -10px;
    animation-delay: -0.32s;
}

.dot-pulse::after {
    content: '';
    position: relative;
    left: 10px;
    animation-delay: 0.16s;
}

@keyframes dot-pulse {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
