:root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-2: #22262f;
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --text: #f0f0f5;
    --text-muted: #9a9ea8;
    --success: #00b894;
    --error: #ff6b6b;
    --radius: 14px;
    --mine-bubble: #6c5ce7;
    --theirs-bubble: #22262f;
}

* { box-sizing: border-box; }

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

/* ---- Auth ---- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-card h1 { margin: 0 0 8px; font-size: 28px; }
.subtitle { color: var(--text-muted); margin-bottom: 24px; }

.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-form label { font-size: 14px; color: var(--text-muted); }

input, select {
    background: var(--surface-2);
    border: 1px solid #33384a;
    color: var(--text);
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 16px;
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 13px 20px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

button:hover { background: var(--primary-light); }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    text-align: left;
}
.alert-error { background: rgba(255,107,107,0.15); color: var(--error); }
.alert-info { background: rgba(108,92,231,0.15); color: var(--primary-light); }

/* ---- Topbar ---- */

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.back { color: var(--text); font-size: 22px; text-decoration: none; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
    text-decoration: none;
    font-size: 20px;
    background: var(--surface-2);
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}

.container { max-width: 600px; margin: 0 auto; padding: 20px; }
.container-alert { max-width: 600px; margin: 12px auto 0; }

/* ---- Recherche utilisateur ---- */

.search-user { margin-bottom: 24px; }
.search-user label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 14px; }
.search-row { position: relative; }

#search-feedback { margin-top: 8px; }
.search-result {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    text-align: left;
    background: var(--surface-2);
    border: 1px solid transparent;
}
.search-found { border-color: var(--success); cursor: pointer; }
.search-found span { color: var(--success); font-size: 13px; }
.search-error { color: var(--error); background: rgba(255,107,107,0.1); }

/* ---- Liste conversations ---- */

.conversation-list { display: flex; flex-direction: column; gap: 8px; }

.conv-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
}

.conv-avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.conv-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.conv-info strong { font-size: 15px; }
.conv-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-empty { font-style: italic; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 15px;
}

/* ---- Chat / conversation ---- */

.chat-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 16px 100px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.track-bubble {
    display: flex;
    gap: 12px;
    max-width: 85%;
    padding: 12px;
    border-radius: var(--radius);
    align-items: center;
}

.track-bubble img {
    width: 56px; height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.track-bubble.mine {
    align-self: flex-end;
    background: var(--mine-bubble);
    color: white;
}

.track-bubble.theirs {
    align-self: flex-start;
    background: var(--theirs-bubble);
}

.track-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.track-info strong { font-size: 14px; }
.track-info span { font-size: 13px; opacity: 0.8; }
.track-link {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: inherit;
    text-decoration: underline;
}

.composer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 16px;
    background: var(--surface);
    display: flex;
    justify-content: center;
}

.send-btn {
    width: 100%;
    max-width: 600px;
}

.waiting-turn {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    margin: 0;
}

/* ---- Modal recherche morceau ---- */

dialog {
    background: var(--surface);
    color: var(--text);
    border: none;
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 480px;
}

dialog::backdrop {
    background: rgba(0,0,0,0.6);
}

dialog h2 { margin: 0 0 16px; font-size: 18px; }

.track-results {
    max-height: 320px;
    overflow-y: auto;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    background: var(--surface-2);
}

.result:hover { background: #2a2f3a; }

.result img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.result strong { display: block; font-size: 14px; }
.result span { font-size: 12px; color: var(--text-muted); }

.close-btn {
    background: transparent;
    border: 1px solid #444;
    width: 100%;
    margin-top: 16px;
}

/* ---- Réglages ---- */

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-form label {
    font-size: 14px;
    color: var(--text-muted);
}