/* ============================================================
   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;
    --warning: #f59e0b;

    --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);
    --warning: #fbbf24;

    --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;
}

.undo-send-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 8px 16px;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 600;
}

.undo-send-bar .link-btn {
    color: var(--accent-strong);
    text-decoration: underline;
    font-weight: 700;
}

.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);
}

.snooze-menu {
    position: relative;
}

.snooze-menu__panel:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 50;
}

.snooze-menu__panel button[name="preset"] {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.snooze-menu__panel button[name="preset"]:hover {
    background: var(--surface-hover);
}

.snooze-menu__custom {
    display: flex;
    gap: 6px;
    padding: 6px 4px 2px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.snooze-menu__custom input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 12px;
}

.snooze-menu__custom button {
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.message-labels {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 12px;
}

.label-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--label-color) 16%, var(--surface));
    color: var(--label-color);
    font-size: 12px;
    font-weight: 600;
}

.label-chip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--label-color);
}

.label-menu {
    position: relative;
}

.label-menu__trigger {
    border: 1px dashed var(--border);
    background: none;
    border-radius: 999px;
    padding: 3px 10px;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

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

.label-menu__panel:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 50;
}

.label-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}

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

.label-menu__item svg {
    width: 14px;
    height: 14px;
    margin-left: auto;
    color: var(--accent);
}

/* ---------- 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;
    object-fit: cover;
}

.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);
}

.badge--success {
    background: color-mix(in srgb, var(--success) 16%, transparent);
    color: var(--success);
}

.badge--danger {
    background: color-mix(in srgb, var(--danger) 16%, transparent);
    color: var(--danger);
}

.badge--warning {
    background: color-mix(in srgb, var(--warning) 20%, transparent);
    color: var(--warning);
}

/* ---------- Carte d'invitation (événement iCalendar détecté dans un message) ---------- */

.invite-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.invite-card--cancelled {
    opacity: 0.7;
}

.invite-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    flex-shrink: 0;
}

.invite-card__icon svg {
    width: 20px;
    height: 20px;
}

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

.invite-card__info strong {
    font-size: 15px;
}

.invite-card__conflict {
    color: var(--warning);
    font-weight: 600;
}

.invite-card__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ---------- 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);
}

.search-advanced {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.search-advanced label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11.5px;
    color: var(--text-muted);
}

.search-advanced input {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
}

.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;
}

.bulk-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

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

.bulk-bar__select-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.bulk-bar__actions:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bulk-bar__count {
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    margin-right: 4px;
}

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

.message-item {
    display: flex;
    flex-direction: column;
}

.message-item__row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.thread-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.thread-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
}

.thread-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.thread-toggle .chevron {
    width: 15px;
    height: 15px;
    transition: transform 0.15s;
}

.message-item.is-expanded .thread-toggle .chevron {
    transform: rotate(180deg);
}

.thread-subrows {
    list-style: none;
    margin: 0;
    padding: 2px 0 4px 58px;
}

.message-subrow {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 12.5px;
}

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

.message-subrow.is-unread {
    color: var(--text);
    font-weight: 600;
}

.message-subrow__from {
    flex-shrink: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-subrow__snippet {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-subrow__date {
    flex-shrink: 0;
    font-size: 11.5px;
}

.message-row__select {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    flex-shrink: 0;
    cursor: pointer;
}

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

.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; }
.category-chip--suspect { background: #dc2626; color: #fff; font-weight: 800; }

: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; }
:root[data-theme='dark'] .category-chip--suspect { background: #ef4444; color: #fff; }

.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;
    align-items: flex-start;
    gap: 8px;
    margin-top: 16px;
}

.attachment-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.attachment-thumb {
    display: block;
    width: 96px;
    height: 96px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-thumb--pdf {
    width: 160px;
    height: 210px;
    background: var(--surface-2);
    cursor: pointer;
}

.attachment-thumb--pdf iframe {
    width: 100%;
    height: 100%;
    border: none;
    /* Le clic doit toujours ouvrir l'aperçu plein écran via le <a> englobant,
       pas interagir avec la visionneuse PDF intégrée à cette échelle. */
    pointer-events: none;
}

.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-card__status {
    flex: 1;
    margin-left: 12px;
    color: var(--text-muted);
    font-size: 12px;
}

.compose-card__status--error {
    color: var(--danger);
    font-weight: 600;
}

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

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 22px;
    right: 22px;
    z-index: 60;
    margin: 2px 0 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
}

.autocomplete-list li {
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.autocomplete-list li:hover {
    background: var(--surface-hover);
}

.contact-add-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.contact-add-form input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
}

.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-followup-input {
    flex: 0 0 60px !important;
}

.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;
}

div.compose-body {
    overflow-y: auto;
    max-height: 420px;
}

div.compose-body p {
    margin: 0 0 0.8em;
}

div.compose-body ul,
div.compose-body ol {
    margin: 0 0 0.8em;
    padding-left: 1.4em;
}

.richtext {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.richtext__toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
}

.richtext__toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 7px;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
}

.richtext__toolbar button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.richtext__toolbar button svg {
    width: 16px;
    height: 16px;
}

.richtext__divider {
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: var(--border);
}

.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,
.form-group textarea {
    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 textarea {
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea: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;
}

.rule-form {
    margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.form-group--submit {
    justify-content: flex-end;
}

.account-card--disabled {
    opacity: 0.55;
}

.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;
}

.security-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    margin-bottom: 24px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ---------- Avatar : glisser-déposer sur le profil ---------- */

.avatar-dropzone {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.avatar-dropzone__zone {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    padding: 16px 20px;
    background: var(--surface-2);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.avatar-dropzone__zone:hover,
.avatar-dropzone__zone.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.avatar-dropzone__preview {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    font-size: 18px;
}

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

.calendar-pick-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.calendar-pick-option input {
    width: auto;
}

.totp-steps {
    margin: 0 0 18px;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.6;
}

.totp-secret {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.totp-secret code {
    font-size: 16px;
    letter-spacing: 1px;
}

.totp-confirm-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-width: 420px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
}

.backup-codes li {
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.backup-codes code {
    font-size: 15px;
    letter-spacing: 1px;
}

.totp-confirm-form .form-group {
    margin-bottom: 0;
    max-width: 200px;
}

.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;
    color: inherit;
}

.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;
    }
}

/* ---------- Aide raccourcis clavier ---------- */

.shortcuts-help:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 17, 26, 0.45);
}

.shortcuts-help__panel {
    width: min(420px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 18px 20px;
}

.shortcuts-help__panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.shortcuts-help__panel h2 {
    margin: 0;
    font-size: 16px;
}

.shortcuts-help__panel dl {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcuts-help__panel dl div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.shortcuts-help__panel dt {
    font-family: monospace;
    font-size: 12.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.shortcuts-help__panel dd {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Agenda ---------- */

.calendar-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.calendar-nav__views,
.calendar-nav__dates {
    display: flex;
    align-items: center;
    gap: 6px;
}

.calendar-nav__label {
    font-size: 14px;
}

.calendar-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.calendar-pending {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.calendar-pending__item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
}

.calendar-pending__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warning);
    flex-shrink: 0;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.calendar-week__day {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    min-height: 160px;
}

.calendar-week__day.is-today {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.calendar-week__day-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.calendar-day-add {
    margin-left: auto;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.calendar-week__day:hover .calendar-day-add,
.calendar-month__day:hover .calendar-day-add,
.calendar-day-add:focus-visible {
    opacity: 1;
}

.calendar-day-add:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.calendar-week__events {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calendar-event {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 8px;
    border: none;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--text);
    text-decoration: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    font-size: 12.5px;
    line-height: 1.3;
}

.calendar-event__time {
    font-weight: 700;
    color: var(--accent-strong);
    flex-shrink: 0;
}

.calendar-event__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event--accepted {
    background: color-mix(in srgb, var(--success) 16%, transparent);
}

.calendar-event--declined {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    opacity: 0.6;
}

.calendar-event--tentative {
    background: color-mix(in srgb, var(--warning) 18%, transparent);
}

.calendar-event--cancelled {
    text-decoration: line-through;
    opacity: 0.5;
}

.calendar-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-month__weekday {
    text-align: center;
    padding-bottom: 4px;
}

.calendar-month__day {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 90px;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.calendar-month__day.is-today {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.calendar-month__day.is-outside {
    opacity: 0.45;
}

.calendar-month__day-toprow {
    display: flex;
    align-items: center;
}

.calendar-month__day a {
    text-decoration: none;
}

.calendar-month__day-number {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
}

.calendar-month__chip {
    display: block;
    width: 100%;
    padding: 2px 6px;
    border: none;
    border-radius: 6px;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    color: var(--text);
}

@media (max-width: 900px) {
    .calendar-week,
    .calendar-month {
        grid-template-columns: repeat(7, minmax(80px, 1fr));
        overflow-x: auto;
    }
}

/* ---------- Aujourd'hui (tableau de bord mail + agenda) ---------- */

.today-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.today-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.today-column__title {
    font-size: 14px;
    margin: 0;
}

.today-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.today-message,
.today-event {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
}

.today-message__info,
.today-event__info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.today-message__info strong,
.today-event__info strong {
    font-size: 13.5px;
}

.today-message__info span,
.today-event__info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.today-event__time {
    font-weight: 700;
    color: var(--accent-strong);
    font-size: 12.5px;
    flex-shrink: 0;
    min-width: 44px;
}

@media (max-width: 900px) {
    .today-columns {
        grid-template-columns: 1fr;
    }
}

/* ---------- Nouvel événement (fenêtre modale) ---------- */

.event-modal:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 17, 26, 0.45);
    padding: 20px;
}

.event-modal__panel {
    width: min(480px, 100%);
    max-height: 86vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px 22px;
}

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

.event-modal__panel h2 {
    margin: 0;
    font-size: 17px;
}

.event-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.event-detail__row {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

.event-detail__description {
    margin: 4px 0 0;
    white-space: pre-line;
    font-size: 13.5px;
    line-height: 1.5;
}

.event-detail__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.event-quickadd {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 18px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

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

.event-quickadd input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    outline: none;
}

.event-quickadd input::placeholder {
    color: var(--text-muted);
}

.event-quickadd button {
    flex-shrink: 0;
    white-space: nowrap;
}

.event-form__allday {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    padding-top: 26px;
    white-space: nowrap;
}

.event-form__allday input {
    width: auto;
}
