/* ============================================================
   Courrier — design system
   ============================================================ */

:root {
    --font: 'Inter', 'SF Pro Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --accent: #6366f1;
    --accent-strong: #4f46e5;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --danger: #ef4444;
    --success: #10b981;

    --bg: #eef0f8;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-hover: #f1f2f9;
    --border: #e3e5f0;
    --text: #171a26;
    --text-muted: #6b7085;
    --shadow-sm: 0 1px 2px rgba(23, 26, 38, 0.06);
    --shadow-md: 0 8px 24px rgba(23, 26, 38, 0.09);
    --radius: 12px;
    --radius-lg: 18px;
}

:root[data-theme='dark'] {
    --accent: #818cf8;
    --accent-strong: #6366f1;
    --accent-soft: rgba(129, 140, 248, 0.16);

    --bg: #0e1017;
    --surface: #171a24;
    --surface-2: #1d212e;
    --surface-hover: #232838;
    --border: #2a2f40;
    --text: #e7e9f2;
    --text-muted: #8f95ab;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ---------- Structure générale ---------- */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    padding: 0 16px 16px 0;
}

/* ---------- Barre supérieure ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    background: transparent;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 16px;
}

.brand__logo {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.brand__logo--lg {
    width: 52px;
    height: 52px;
    border-radius: 15px;
}

.brand__logo--lg svg {
    width: 26px;
    height: 26px;
}

.topbar__brand {
    width: 236px;
    flex-shrink: 0;
}

.topbar__search {
    flex: 1;
    max-width: 640px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.topbar__search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar__search input {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    color: var(--text);
    font: inherit;
    outline: none;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Icônes thème : n'afficher que l'icône opposée au thème courant */
:root[data-theme='light'] .icon-moon { display: none; }
:root[data-theme='dark'] .icon-sun { display: none; }

/* ---------- Menu utilisateur ---------- */

.user-menu {
    position: relative;
}

.user-menu__trigger {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 230px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 50;
}

.user-menu__identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.user-menu__identity span {
    color: var(--text-muted);
    font-size: 12px;
}

.user-menu__panel a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
}

.user-menu__panel a:hover {
    background: var(--surface-hover);
}

/* ---------- Avatars ---------- */

.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--account-color, var(--accent));
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.avatar--user {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    width: 36px;
    height: 36px;
    cursor: pointer;
}

.avatar--lg {
    width: 46px;
    height: 46px;
    font-size: 15px;
}

/* ---------- Barre latérale ---------- */

.sidebar {
    width: 252px;
    flex-shrink: 0;
    padding: 4px 12px 16px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--accent-strong);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s, background 0.15s;
}

.compose-btn:hover {
    background: var(--accent);
}

.compose-btn:active {
    transform: scale(0.98);
}

.sidebar__section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--text);
    font-weight: 500;
    transition: background 0.12s;
}

.sidebar__item svg {
    width: 17px;
    height: 17px;
    color: var(--text-muted);
}

.sidebar__item:hover {
    background: var(--surface-hover);
}

.sidebar__item.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

:root[data-theme='dark'] .sidebar__item.is-active {
    color: var(--accent);
}

.sidebar__item.is-active svg {
    color: inherit;
}

.sidebar__item span:first-of-type {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__item--folder {
    padding-left: 14px;
    font-weight: 450;
}

.sidebar__item--add {
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar__account-header {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 12px 5px;
    border: none;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    border-radius: 8px;
}

.sidebar__account-header .chevron {
    width: 14px;
    height: 14px;
    margin-left: auto;
    transition: transform 0.15s;
}

.sidebar__account-header[aria-expanded='false'] .chevron {
    transform: rotate(-90deg);
}

.sidebar__account-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--account-color, var(--accent));
    flex-shrink: 0;
}

.account-dot--sm {
    width: 7px;
    height: 7px;
}

.sync-error-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.badge {
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

:root[data-theme='dark'] .badge {
    color: var(--accent);
}

/* ---------- Panneaux liste + lecture ---------- */

.mail-panes {
    display: flex;
    flex: 1;
    gap: 14px;
    min-width: 0;
    min-height: 0;
}

.message-list-pane {
    width: 390px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 18px 10px;
}

.pane-header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pane-header__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--border);
}

.filter-bar__chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chip {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.chip:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.chip.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

:root[data-theme='dark'] .chip.is-active {
    color: var(--accent);
}

.filter-bar__sort {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.filter-bar__sort svg {
    width: 15px;
    height: 15px;
}

.filter-bar__sort select {
    border: none;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    max-width: 130px;
}

.filter-bar__sort select:hover {
    color: var(--text);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.message-list {
    list-style: none;
    margin: 0;
    padding: 4px 8px 12px;
    overflow-y: auto;
    flex: 1;
}

.message-row {
    display: flex;
    gap: 12px;
    padding: 11px 10px;
    border-radius: var(--radius);
    color: var(--text);
    transition: background 0.12s;
}

.message-row:hover {
    background: var(--surface-hover);
}

.message-row.is-selected {
    background: var(--accent-soft);
}

.message-row__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-row__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.message-row__from {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-row__date {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

.message-row__subject {
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-row__snippet {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-row__snippet .clip {
    width: 13px;
    height: 13px;
}

.message-row.is-unread .message-row__from,
.message-row.is-unread .message-row__subject {
    font-weight: 700;
}

.message-row.is-unread .avatar {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.star--on {
    color: #f59e0b;
    margin-right: 3px;
}

/* ---------- Panneau de lecture ---------- */

.reading-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.reading-pane turbo-frame {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.message-view {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.message-view__header {
    padding: 22px 26px 16px;
    border-bottom: 1px solid var(--border);
}

.message-view__subject {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.message-view__meta {
    display: flex;
    gap: 13px;
    align-items: flex-start;
}

.message-view__addresses {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-view__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.message-view__actions .divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 5px;
}

.message-view__body {
    padding: 22px 26px;
    flex: 1;
}

.email-body {
    line-height: 1.55;
    word-wrap: break-word;
    overflow-x: auto;
}

.email-body img {
    max-width: 100%;
    height: auto;
}

.email-body--text {
    font-family: inherit;
    white-space: pre-wrap;
    margin: 0;
}

:root[data-theme='dark'] .email-body {
    /* La plupart des mails HTML supposent un fond clair */
    background: #fff;
    color: #171a26;
    padding: 18px;
    border-radius: var(--radius);
}

.is-starred {
    color: #f59e0b;
}

/* ---------- IA : catégories, résumé ---------- */

.category-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    vertical-align: 1px;
    margin-right: 4px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    white-space: nowrap;
}

:root[data-theme='dark'] .category-chip {
    color: var(--accent);
}

.category-chip--important { background: rgba(239, 68, 68, 0.14); color: #dc2626; }
.category-chip--travail { background: rgba(14, 165, 233, 0.14); color: #0284c7; }
.category-chip--personnel { background: rgba(16, 185, 129, 0.14); color: #059669; }
.category-chip--finance { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.category-chip--newsletter { background: rgba(139, 92, 246, 0.14); color: #7c3aed; }
.category-chip--publicité { background: rgba(236, 72, 153, 0.14); color: #db2777; }
.category-chip--notification { background: rgba(107, 112, 133, 0.16); color: #6b7085; }

:root[data-theme='dark'] .category-chip--important { color: #f87171; }
:root[data-theme='dark'] .category-chip--travail { color: #38bdf8; }
:root[data-theme='dark'] .category-chip--personnel { color: #34d399; }
:root[data-theme='dark'] .category-chip--finance { color: #fbbf24; }
:root[data-theme='dark'] .category-chip--newsletter { color: #a78bfa; }
:root[data-theme='dark'] .category-chip--publicité { color: #f472b6; }
:root[data-theme='dark'] .category-chip--notification { color: #9ca3af; }

.ai-summary {
    margin: 0 0 20px;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.ai-summary__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--accent-strong);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

:root[data-theme='dark'] .ai-summary__title {
    color: var(--accent);
}

.ai-summary__title svg {
    width: 14px;
    height: 14px;
}

.ai-summary p {
    margin: 0;
    line-height: 1.55;
}

.settings-subtitle {
    margin: 28px 0 12px;
    font-size: 15px;
}

.ai-features {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-muted);
    line-height: 1.5;
}

.account-card--active {
    border-color: var(--accent);
}

[aria-busy='true'] {
    opacity: 0.5;
    pointer-events: none;
    animation: busy-pulse 1s ease infinite;
}

@keyframes busy-pulse {
    50% {
        opacity: 0.25;
    }
}

/* ---------- Pièces jointes ---------- */

.attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 13px;
    max-width: 280px;
    transition: border-color 0.12s;
}

.attachment-chip:hover {
    border-color: var(--accent);
}

.attachment-chip svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.attachment-chip__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip__size {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

/* ---------- États vides ---------- */

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    padding: 40px 24px;
    text-align: center;
}

.empty-state svg {
    width: 52px;
    height: 52px;
    opacity: 0.45;
}

.empty-state--list {
    min-height: 220px;
}

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn--primary {
    background: var(--accent-strong);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent);
}

.btn--ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn--ghost:hover {
    background: var(--surface-hover);
}

.btn--block {
    width: 100%;
    justify-content: center;
}

.btn--google {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 100%;
    justify-content: center;
    padding: 12px 18px;
    margin-top: 14px;
    box-shadow: var(--shadow-sm);
}

.btn--google:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
}

.btn--sm {
    padding: 7px 12px;
    font-size: 12.5px;
    white-space: nowrap;
}

.oauth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

.oauth-divider::before,
.oauth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.oauth-hint {
    margin: 16px 0;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 13px;
    line-height: 1.6;
}

.oauth-hint code {
    background: var(--surface-hover);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 12px;
    word-break: break-all;
}

.provider-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1.5px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 700;
    vertical-align: 1px;
}

:root[data-theme='dark'] .provider-badge {
    color: var(--accent);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.icon-btn--danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.icon-btn svg {
    width: 17px;
    height: 17px;
}

.link-btn {
    border: none;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    padding: 0;
}

.inline-form {
    display: inline-flex;
}

/* ---------- Composition ---------- */

.compose-wrap {
    flex: 1;
    display: flex;
    min-width: 0;
}

.compose-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-width: 860px;
    margin: 0 auto;
}

.compose-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px 8px;
}

.compose-card__header h1 {
    margin: 0;
    font-size: 17px;
}

.compose-field {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 22px;
    border-bottom: 1px solid var(--border);
}

.compose-field label {
    width: 34px;
    color: var(--text-muted);
    font-size: 13px;
    flex-shrink: 0;
}

.compose-field input,
.compose-field select {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    color: var(--text);
    font: inherit;
    outline: none;
    min-width: 0;
}

.compose-field__extra {
    flex-shrink: 0;
}

.compose-body {
    flex: 1;
    padding: 18px 22px;
    border: none;
    background: none;
    color: var(--text);
    font: inherit;
    line-height: 1.55;
    resize: none;
    outline: none;
    min-height: 220px;
}

.compose-card__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
}

.compose-attachments {
    color: var(--text-muted);
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Pages d'authentification ---------- */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 500px at 15% -10%, var(--accent-soft), transparent),
        radial-gradient(900px 500px at 110% 110%, rgba(139, 92, 246, 0.1), transparent),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 34px;
}

.auth-card__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    margin-bottom: 26px;
}

.auth-card__brand h1 {
    margin: 6px 0 0;
    font-size: 21px;
}

.auth-card__brand p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

.auth-card__alt {
    text-align: center;
    color: var(--text-muted);
    margin: 18px 0 0;
    font-size: 13.5px;
}

/* ---------- Formulaires ---------- */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
    flex: 1;
    min-width: 0;
}

.form-group label {
    font-weight: 600;
    font-size: 13px;
}

.form-group input,
.form-group select {
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color 0.12s, box-shadow 0.12s;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-row--3 .form-group:first-child {
    flex: 2;
}

.form-error,
.form-group ul {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    color: var(--danger);
    font-size: 12.5px;
}

.form-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.form-hint,
.form-group .help-text {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.advanced-settings {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 15px;
    background: var(--surface-2);
}

.advanced-settings summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
}

.advanced-settings[open] summary {
    margin-bottom: 14px;
}

.color-picker {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
}

.color-swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.color-swatch span {
    display: block;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--swatch);
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.1s;
}

.color-swatch input:checked + span {
    border-color: var(--text);
    transform: scale(1.15);
}

/* ---------- Pages paramètres / comptes ---------- */

.settings-wrap {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px 30px;
    overflow-y: auto;
}

.settings-wrap--narrow {
    max-width: 760px;
    margin: 0 auto;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 8px;
}

.settings-header h1 {
    margin: 0;
    font-size: 20px;
}

.account-cards {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.account-card__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.account-card__actions {
    display: flex;
    gap: 4px;
}

/* ---------- Toasts ---------- */

.toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    animation: toast-in 0.25s ease;
    font-size: 13.5px;
}

.toast--success {
    border-left: 3px solid var(--success);
}

.toast--error {
    border-left: 3px solid var(--danger);
}

.toast--closing {
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.25s, transform 0.25s;
}

.toast button {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 17px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* ---------- Utilitaires ---------- */

.muted {
    color: var(--text-muted);
}

.small {
    font-size: 12.5px;
}

.text-danger {
    color: var(--danger);
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .message-list-pane {
        width: 330px;
    }
}

@media (max-width: 900px) {
    .topbar__brand {
        width: auto;
    }

    .brand__name {
        display: none;
    }

    .sidebar {
        width: 64px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .sidebar__item span,
    .sidebar__account-label,
    .sidebar__account-header .chevron,
    .compose-btn span,
    .badge {
        display: none;
    }

    .compose-btn {
        padding: 12px;
    }

    .sidebar__item {
        justify-content: center;
        padding: 10px;
    }

    .sidebar__account-header {
        justify-content: center;
    }

    .mail-panes:not(.mail-panes--single) .reading-pane {
        display: none;
    }

    .message-list-pane {
        width: 100%;
    }

    .content {
        padding: 0 10px 10px;
    }
}
