/* ================================================
   Pollux — Styles globaux
   Design minimaliste inspiré CODEX Light
   ================================================ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 120ms;
}
a:hover {
    color: var(--text);
}

/* ================================================
   Layout
   ================================================ */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* ---- Module Nav (gauche) ---- */

.module-nav {
    display: flex;
    flex-direction: column;
    width: 220px;
    min-width: 220px;
    height: 100%;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: visible;
    z-index: 150;
}

.module-nav[data-collapsed] {
    width: 52px;
    min-width: 52px;
    overflow: visible;
}

/* Logo */
.module-nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 13px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.module-nav-logo-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
    object-fit: cover;
    background: none;
}

.module-nav-logo-text {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    transition: opacity 0.15s;
}

.module-nav[data-collapsed] .module-nav-logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Items */
.module-nav-items {
    flex: 1;
    overflow: visible;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.module-nav-spacer {
    flex: 1;
}

.module-nav-item-bottom {
    opacity: 0.7;
}

.module-nav-item-bottom:hover {
    opacity: 1;
}

.module-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-dim);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    position: relative;
}

.module-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.module-nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.module-nav-item.active svg {
    color: var(--accent);
    transition: color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.module-nav-item:not(.active) {
    opacity: 0.5;
    cursor: pointer;
}

.module-nav-item:not(.active):hover {
    opacity: 0.7;
    background: var(--bg-hover);
}

/* Tooltip JS — positionnée dynamiquement */
.module-tooltip {
    position: fixed;
    background: var(--elevated);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.75em;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
    white-space: nowrap;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
}

.module-tooltip.visible {
    opacity: 1;
}

.module-nav-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.module-nav-item[data-module="cockpit"] svg {
    width: 26px;
    height: 26px;
    margin-left: -3px;
}

.module-nav-label {
    font-family: var(--mono);
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: opacity 0.15s;
}

.module-nav[data-collapsed] .module-nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.module-nav-badge {
    font-family: var(--mono);
    font-size: 0.58em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: auto;
    transition: opacity 0.15s;
}

.module-nav[data-collapsed] .module-nav-badge {
    opacity: 0;
    width: 0;
    overflow: hidden;
    padding: 0;
    border: 0;
    margin: 0;
}

/* Footer toggle */
.module-nav-footer {
    padding: 12.5px 6px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.module-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.module-nav-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.module-nav-chevron {
    transition: transform 0.2s;
}

.module-nav[data-collapsed] .module-nav-chevron {
    transform: rotate(0deg);
}

.module-nav:not([data-collapsed]) .module-nav-chevron {
    transform: rotate(180deg);
}

/* ---- Module Preview Overlay ---- */

.module-preview {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.module-preview.hidden {
    display: none;
}

.module-preview-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.module-preview-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.15s;
}

.module-preview-close:hover {
    color: var(--text);
}

.module-preview-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: 16px;
    margin-bottom: 20px;
    color: var(--accent);
}

.module-preview-icon svg {
    width: 32px;
    height: 32px;
}

.module-preview-name {
    font-family: var(--mono);
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.module-preview-desc {
    font-family: var(--sans);
    font-size: 0.9em;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 24px;
}

.module-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 6px 16px;
}

/* ---- Sidebar ---- */

.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 200ms ease;
    z-index: 100;
}

.sidebar-header {
    height: 59px;
    min-height: 59px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Module identity in sidebar header — matches ck-header pattern */
.sidebar-header-module {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-header-icon {
    flex-shrink: 0;
    color: var(--accent);
    display: flex;
    align-items: center;
}

.sidebar-header-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

.sidebar-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sidebar-header-name {
    font: 600 15px/1 var(--sans);
    color: var(--text);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-header-sub {
    font: 400 11px/1 var(--sans);
    color: var(--text-muted);
    white-space: nowrap;
}

/* Square new-conversation button — adapts to theme */
.btn-new-square {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--text);
    color: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-new-square:hover {
    transform: scale(1.05);
    opacity: 0.85;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 25%, transparent);
}

.btn-new-square:active {
    transform: scale(0.97);
}

.btn-new-square:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hide old btn-new-chat if still referenced */
.btn-new-chat {
    width: 100%;
    display: none;
}

.sidebar-search {
    padding: 8px 16px;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    font: 400 12px/1.4 var(--mono);
    outline: none;
    transition: border-color 150ms;
}
.sidebar-search input:focus {
    border-color: var(--border-focus);
}
.sidebar-search input::placeholder {
    color: var(--text-muted);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.conv-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    min-height: 36px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 120ms;
    margin-bottom: 1px;
    color: var(--text-dim);
    font: 400 12px/1.3 var(--mono);
}
.conv-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.conv-item.active {
    background: var(--bg-active);
    color: var(--text);
}

.conv-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conv-unread .conv-item-title { font-weight: 600; color: var(--text); }
.conv-unread::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent, var(--red));
    flex-shrink: 0;
    margin-right: 6px;
}

/* Actions renommer / supprimer */
.conv-item-actions {
    display: none;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 4px;
}

.conv-item:hover .conv-item-actions {
    display: flex;
}

.conv-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 100ms;
}

.conv-action-btn:hover {
    background: var(--bg-active);
    color: var(--text);
}

.conv-action-danger:hover {
    color: var(--red);
    background: rgba(239, 68, 68, 0.08);
}

/* Favorited star always visible */
.conv-action-fav-active {
    display: flex !important;
    color: var(--accent);
}

.conv-item:has(.conv-action-fav-active) .conv-item-actions {
    display: flex;
}

/* On hover, show all actions but keep fav star prominent */
.conv-item:hover .conv-action-fav-active {
    color: var(--accent);
}

.conv-group-fav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.conv-empty {
    text-align: center;
    padding: 40px 12px;
    font: 400 12px/1.4 var(--mono);
    color: var(--text-muted);
}

.conv-group-label {
    padding: 12px 10px 4px;
    font: 600 9px/1 var(--mono);
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.conv-group-shared {
    display: flex; align-items: center; gap: 6px;
    margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border);
}
.conv-shared-badge {
    display: inline-block; font: 500 9px/1 var(--sans); color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: 2px 6px; border-radius: 3px; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.conv-shared .conv-actions { display: none; }
.conv-unread:not(.conv-shared) { border-left: 2px solid var(--accent); }

.sidebar-footer {
    padding: 21px 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    flex: 1;
    min-width: 0;
}

.user-name {
    font: 500 11px/1 var(--mono);
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-module {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
}

.sidebar-module-icon {
    display: flex;
    align-items: center;
    color: var(--accent);
}

.sidebar-module-name {
    font: 600 9px/1 var(--mono);
    color: var(--accent);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.sidebar-settings-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 120ms;
}

.sidebar-settings-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* ---- Main ---- */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

.main-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 21px 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    z-index: 101;
    width: var(--footer-width, 220px);
}

html[data-module="cockpit"] .main-footer { padding: 16px 14px; }
html[data-module="ecriture"] .main-footer { height: 92px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; }

.main-content-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ---- Artifact panel ---- */

.artifact-panel {
    width: 460px;
    min-width: 360px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 200ms ease;
}

.artifact-panel.hidden {
    display: none;
}

.artifact-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.artifact-panel-header h3 {
    font: 600 11px/1 var(--mono);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.artifact-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
}

.artifact-tab {
    padding: 8px 14px;
    font: 500 10px/1 var(--mono);
    cursor: pointer;
    white-space: nowrap;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-right: 1px solid var(--border);
    transition: all 120ms;
}
.artifact-tab:hover {
    color: var(--text-dim);
}
.artifact-tab.active {
    background: var(--bg);
    color: var(--text);
}

.artifact-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
}

/* ================================================
   Boutons
   ================================================ */

.btn {
    font: 600 12px/1 var(--mono);
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 120ms;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}
.btn-primary:hover {
    background: var(--text);
    color: var(--bg);
    filter: brightness(1.2);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font: 400 11px/1 var(--mono);
    transition: color 120ms;
}
.btn-text:hover {
    color: var(--text);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 120ms;
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.06);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* ================================================
   Formulaires
   ================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font: 600 10px/1 var(--mono);
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    font: 400 14px/1.5 var(--mono);
    transition: border-color 150ms;
    outline: none;
}
.form-input:focus {
    border-color: var(--border-focus);
}
.form-input::placeholder {
    color: var(--text-muted);
}
.form-input.error {
    border-color: var(--red);
}

.form-error {
    color: var(--red);
    font: 400 11px/1.3 var(--mono);
    margin-top: 4px;
}

/* ================================================
   Labels
   ================================================ */

.label {
    font: 600 10px/1 var(--mono);
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* ================================================
   Utilitaires
   ================================================ */

.hidden { display: none !important; }

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

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border);
    border-top-color: var(--text-dim);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeUp 0.25s ease forwards;
}

/* ================================================
   Toast
   ================================================ */

/* ---- Toast Notifications (glassmorphism) ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 14px;
    border-radius: 14px;
    font: 500 13px/1.4 var(--sans);
    color: #fff;
    max-width: 380px;
    pointer-events: auto;
    cursor: pointer;
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 1px 3px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.08);
    animation: toastSlideIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.05);
    transform-origin: bottom right;
    position: relative;
    overflow: hidden;
}

/* Shimmer progress bar at bottom */
.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255,255,255,0.3);
    animation: toastProgress 3s linear forwards;
    border-radius: 0 0 14px 14px;
}

/* Type variants */
.toast-success {
    background: rgba(16, 185, 129, 0.85);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.toast-error {
    background: rgba(239, 68, 68, 0.88);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.toast-info {
    background: rgba(99, 102, 241, 0.82);
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.toast-warning {
    background: rgba(245, 158, 11, 0.85);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Icon */
.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.18);
    flex-shrink: 0;
}
.toast-msg {
    flex: 1;
    min-width: 0;
}

/* Dismiss animation */
.toast.toast-exit {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Hover: pause progress + lift */
.toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.22), 0 2px 6px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.1);
}
.toast:hover::after {
    animation-play-state: paused;
}

/* Light theme adjustments */
[data-theme="light"] .toast-success { background: rgba(16, 185, 129, 0.92); }
[data-theme="light"] .toast-error { background: rgba(239, 68, 68, 0.92); }
[data-theme="light"] .toast-info { background: rgba(99, 102, 241, 0.9); }
[data-theme="light"] .toast-warning { background: rgba(245, 158, 11, 0.92); }
[data-theme="light"] .toast { box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.06); }

@keyframes toastSlideIn {
    0%   { opacity: 0; transform: translateY(20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastSlideOut {
    0%   { opacity: 1; transform: translateX(0) scale(1); }
    100% { opacity: 0; transform: translateX(80px) scale(0.9); }
}

@keyframes toastProgress {
    0%   { width: 100%; }
    100% { width: 0%; }
}

/* ================================================
   Font Size Scaling (Parametres > Apparence)
   Applique un zoom CSS sur tout le contenu principal.
   Le module-nav reste a taille fixe.
   ================================================ */

[data-fontsize="small"] .main-content {
    zoom: 0.88;
    -moz-transform: scale(0.88);
    -moz-transform-origin: 0 0;
}

[data-fontsize="large"] .main-content {
    zoom: 1.12;
    -moz-transform: scale(1.12);
    -moz-transform-origin: 0 0;
}

/* Compenser la hauteur pour Firefox (qui utilise transform au lieu de zoom) */
@-moz-document url-prefix() {
    [data-fontsize="small"] .main-content { height: calc(100% / 0.88); width: calc(100% / 0.88); }
    [data-fontsize="large"] .main-content { height: calc(100% / 1.12); width: calc(100% / 1.12); }
}

/* ================================================
   Responsive
   ================================================ */

/* Mobile overlay backdrop */
/* Hide mobile-only elements by default (shown via mobile.css) */
.mobile-bottom-bar {
    display: none;
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    -webkit-tap-highlight-color: transparent;
}

.mobile-overlay.active {
    display: block;
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 1000;
        width: 280px;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-toggle {
        display: flex !important;
    }
    .artifact-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100vw;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 200ms ease;
    }
    .artifact-panel:not(.hidden) {
        transform: translateX(0);
    }
    .artifact-panel.hidden {
        display: flex;
        transform: translateX(100%);
    }

    /* Prevent iOS zoom on input focus (font-size >= 16px) */
    .chat-input,
    .sidebar-search input,
    .form-input,
    .message-edit-textarea {
        font-size: 16px;
    }
}

@media (max-width: 600px) {
    .chat-header { padding: 10px 12px; }
    .message { padding: 12px; }
    .chat-input-container { padding: 8px 12px 12px; }
}

/* ================================================
   Accessibilite
   ================================================ */

:focus-visible {
    outline: 1px solid var(--border-focus);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================================
   Memory dialog
   ================================================ */

.memory-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.memory-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.memory-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.memory-dialog-header h3 {
    font: 600 11px/1 var(--mono);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.memory-dialog-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.memory-category { margin-bottom: 16px; }

.memory-category-title {
    font: 600 9px/1 var(--mono);
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.memory-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    transition: opacity 200ms;
}

.memory-content {
    flex: 1;
    font: 400 12px/1.4 var(--mono);
    color: var(--text-dim);
}

.memory-confidence {
    font: 400 10px/1 var(--mono);
    color: var(--text-muted);
}

.memory-dialog-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.memory-add-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.memory-add-form .form-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
}

/* ---- Confirm Dialog ---- */

.pollux-confirm-overlay[hidden] { display: none; }

.pollux-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: confirmFadeIn 150ms ease;
}

@keyframes confirmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pollux-confirm-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 100%;
    max-width: 380px;
    padding: 28px 24px 20px;
    text-align: center;
    animation: confirmSlideUp 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-lg);
}

@keyframes confirmSlideUp {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.pollux-confirm-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.pollux-confirm-message {
    font: 400 13px/1.6 var(--sans);
    color: var(--text);
    margin: 0 0 24px;
}

.pollux-confirm-actions {
    display: flex;
    gap: 10px;
}

.pollux-confirm-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font: 500 12px/1 var(--mono);
    cursor: pointer;
    transition: all 150ms;
}

.pollux-confirm-cancel {
    background: var(--elevated);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.pollux-confirm-cancel:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-hover);
}

.pollux-confirm-ok {
    background: var(--accent);
    color: var(--text-inverse);
}

.pollux-confirm-ok:hover {
    filter: brightness(1.15);
}

/* Danger variant for confirm dialog */
.pollux-confirm-dialog.confirm-danger .pollux-confirm-icon {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--red);
    color: var(--red);
}

.pollux-confirm-dialog.confirm-danger .pollux-confirm-ok {
    background: var(--red);
    color: white;
}

.pollux-confirm-dialog.confirm-danger .pollux-confirm-ok:hover {
    filter: brightness(1.1);
}

/* ================================================
   71. Skeleton loading
   ================================================ */

.skeleton {
    background: linear-gradient(90deg, var(--elevated) 25%, var(--surface) 50%, var(--elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-card { height: 80px; margin-bottom: 12px; }

/* ================================================
   73. Etats vides ameliores
   ================================================ */

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { margin-bottom: 16px; color: var(--text-muted); opacity: 0.4; }
.empty-state-title { font: 600 16px/1.3 var(--sans); color: var(--text-dim); margin: 0 0 8px; }
.empty-state-desc { font: 400 13px/1.5 var(--sans); color: var(--text-muted); margin: 0 0 20px; max-width: 400px; margin-left: auto; margin-right: auto; }
.empty-state-action { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 8px; background: var(--accent); color: white; border: none; font: 500 13px/1 var(--sans); cursor: pointer; }

/* ================================================
   74. Etats d'erreur
   ================================================ */

.error-state { text-align: center; padding: 40px 20px; }
.error-state-icon { color: var(--red); margin-bottom: 12px; }
.error-state-msg { font: 400 13px/1.5 var(--sans); color: var(--text-dim); margin: 0 0 16px; }
.error-state-retry { padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 12px/1 var(--sans); cursor: pointer; }
.error-state-retry:hover { border-color: var(--accent); color: var(--accent); }

/* ================================================
   76. Breadcrumbs universels
   ================================================ */

.breadcrumbs { display: flex; align-items: center; gap: 6px; font: 400 12px/1 var(--sans); color: var(--text-muted); padding: 8px 0; }
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .breadcrumb-sep { color: var(--border); }
.breadcrumbs .breadcrumb-current { color: var(--text-dim); font-weight: 500; }

/* ================================================
   80. Onboarding
   ================================================ */

/* ---- Welcome Dashboard ---- */

.welcome-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 10002;
    overflow-y: auto;
}

.welcome-overlay.hidden { display: none; }

/* Ambient glow behind hero */
.wd-glow {
    position: fixed;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.welcome-dashboard {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 52px 32px 48px;
}

/* Stagger animation */
.wd-stagger {
    opacity: 0;
    transform: translateY(16px);
    animation: wdStagger 450ms cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes wdStagger {
    to { opacity: 1; transform: translateY(0); }
}

/* Hero */
.wd-hero {
    text-align: center;
    margin-bottom: 36px;
    opacity: 0;
    animation: wdStagger 500ms 100ms cubic-bezier(.4,0,.2,1) forwards;
}

.wd-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 18px;
    filter: drop-shadow(0 4px 16px color-mix(in srgb, var(--accent) 25%, transparent));
    animation: wdLogoPulse 3s ease-in-out infinite;
}

@keyframes wdLogoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.wd-title {
    font: 700 26px/1.2 var(--sans);
    color: var(--text);
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.wd-baseline {
    font: 400 13px/1.4 var(--sans);
    color: var(--text-muted);
    margin: 0;
}

/* Featured module (ChatSST hero card) */
.wd-featured {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 200ms cubic-bezier(.4,0,.2,1);
    margin-bottom: 24px;
    text-align: left;
}

.wd-featured:hover {
    border-color: var(--wc, var(--accent));
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    transform: translateY(-2px);
}

.wd-featured-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wc, var(--accent));
    background: color-mix(in srgb, var(--wc, var(--accent)) 12%, transparent);
    flex-shrink: 0;
}

.wd-featured-text {
    flex: 1;
    min-width: 0;
}

.wd-featured-name {
    display: block;
    font: 600 15px/1.2 var(--sans);
    color: var(--text);
    margin-bottom: 4px;
}

.wd-featured-desc {
    display: block;
    font: 400 12px/1.5 var(--sans);
    color: var(--text-dim);
}

.wd-featured-cta {
    flex-shrink: 0;
    padding: 8px 18px;
    background: var(--wc, var(--accent));
    color: #fff;
    border-radius: 8px;
    font: 600 12px/1 var(--sans);
    transition: filter 150ms;
}

.wd-featured:hover .wd-featured-cta {
    filter: brightness(1.15);
}

/* Quick actions */
.wd-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}

.wd-action {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 180ms;
    font: 500 12px/1.2 var(--sans);
    color: var(--text-dim);
    text-align: left;
}

.wd-action:hover {
    border-color: var(--wc, var(--accent));
    background: var(--bg-hover);
    color: var(--text);
    transform: translateY(-1px);
}

.wd-action svg {
    flex-shrink: 0;
}

/* Section label */
.wd-section-label {
    font: 600 10px/1 var(--mono);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 12px;
}

/* Module grid */
.wd-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.wd-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 200ms cubic-bezier(.4,0,.2,1);
    text-align: center;
}

.wd-card:hover {
    border-color: var(--wc, var(--accent));
    background: var(--bg-hover);
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
}

.wd-card:active {
    transform: translateY(0);
}

.wd-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wc, var(--accent));
    background: color-mix(in srgb, var(--wc, var(--accent)) 10%, transparent);
    transition: background 200ms;
}

.wd-card:hover .wd-card-icon {
    background: color-mix(in srgb, var(--wc, var(--accent)) 18%, transparent);
}

.wd-card-name {
    font: 600 11px/1 var(--sans);
    color: var(--text);
}

.wd-card-desc {
    font: 400 9.5px/1.2 var(--sans);
    color: var(--text-muted);
}

/* Keyboard tips bar */
.wd-kbd-bar {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    font: 400 11px/1 var(--sans);
    color: var(--text-muted);
}

.wd-kbd-bar kbd {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--elevated);
    font: 500 10px/1.3 var(--mono);
    color: var(--text-dim);
}

/* Footer CTA */
.wd-footer {
    text-align: center;
}

.wd-btn-start {
    padding: 12px 32px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font: 600 13px/1 var(--sans);
    cursor: pointer;
    transition: all 200ms;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 25%, transparent);
}

.wd-btn-start:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}

@media (max-width: 640px) {
    .wd-grid { grid-template-columns: repeat(3, 1fr); }
    .wd-actions { flex-direction: column; }
    .wd-featured { flex-direction: column; text-align: center; }
    .wd-featured-cta { width: 100%; text-align: center; }
    .welcome-dashboard { padding: 32px 16px; }
}

/* ================================================
   82. Module notification badge
   ================================================ */

/* Badge: deployed menu — inline after label, vertically centered */
.module-badge {
    position: static;
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--red);
    color: white;
    font: 600 9px/18px var(--mono);
    text-align: center;
    flex-shrink: 0;
    animation: badge-bounce 300ms ease-out;
}

/* Badge: collapsed menu — absolute dot on top-right of icon */
.module-nav[data-collapsed] .module-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    margin-left: 0;
    min-width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    border: 2px solid var(--surface, #12121a);
}

/* ================================================
   83. Module access popup (shared: admin + settings)
   ================================================ */
.omod-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; padding-top:3px; }
.omod-item { display:flex; flex-direction:column; align-items:center; gap:8px; padding:14px 8px; background:var(--bg); border:1.5px solid var(--border); border-radius:12px; cursor:pointer; position:relative; transition:all 250ms cubic-bezier(0.4,0,0.2,1); user-select:none; }
.omod-item:hover { border-color:var(--text-muted); background:var(--surface); }
.omod-item.omod-active { border-color:var(--mod-color,var(--accent)); background:var(--surface); box-shadow:0 0 0 1px var(--mod-color,var(--accent)); }
.omod-icon { width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; background:var(--surface); border:1px solid var(--border); color:var(--text-muted); transition:all 250ms ease; }
.omod-active .omod-icon { background:color-mix(in srgb,var(--mod-color,var(--accent)) 15%,var(--surface)); border-color:var(--mod-color,var(--accent)); color:var(--mod-color,var(--accent)); }
.omod-active .omod-icon svg { stroke:var(--mod-color,var(--accent)); fill:var(--mod-color,var(--accent)); }
.omod-label { font:500 11px/1 var(--sans); color:var(--text-muted); text-align:center; transition:color 200ms; }
.omod-active .omod-label { color:var(--text); font-weight:600; }
.omod-check { position:absolute; top:6px; right:6px; width:20px; height:20px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:var(--border); color:transparent; transition:all 250ms cubic-bezier(0.4,0,0.2,1); transform:scale(0.8); opacity:0; }
.omod-active .omod-check { background:var(--mod-color,var(--accent)); color:#fff; transform:scale(1); opacity:1; }
.omod-active .omod-check svg { stroke:#fff; }
@media (max-width:500px) { .omod-grid { grid-template-columns:repeat(2,1fr); } }

/* ================================================
   84. Mode compact
   ================================================ */

[data-density="compact"] .card, [data-density="compact"] .admin-card { padding: 10px; }
[data-density="compact"] .message { padding: 8px 16px; }
[data-density="compact"] .module-nav-item { padding: 6px 8px; }
[data-density="compact"] .sidebar-header { padding: 10px; }

/* ================================================
   84-91. Animations
   ================================================ */

/* 84. Module transition */
.module-transition-enter { opacity: 0; transform: translateY(8px); }
.module-transition-active { opacity: 1; transform: translateY(0); transition: opacity 150ms ease-out, transform 150ms ease-out; }

/* 85. Hover scale on cards */
.card-hover { transition: transform 150ms ease, box-shadow 150ms ease; }
.card-hover:hover { transform: scale(1.015); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* 86. Active press on buttons */
.btn-press:active { transform: scale(0.97); transition: transform 60ms; }

/* 87. Scroll reveal */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 300ms ease-out, transform 300ms ease-out; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* 88. Send button pulse */
@keyframes send-pulse { 0% { box-shadow: 0 0 0 0 var(--accent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.btn-send.pulse { animation: send-pulse 400ms ease-out; }

/* 91. Badge bounce */
@keyframes badge-bounce { 0% { transform: scale(0.5); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.badge-bounce { animation: badge-bounce 300ms ease-out; }

/* ================================================
   95. Connection indicator
   ================================================ */

.connection-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green, #22c55e);
    margin-right: 4px;
    vertical-align: middle;
    transition: background 300ms;
}

.connection-dot.offline {
    background: var(--red, #ef4444);
}

/* ============================================================
   Unified Module Sidebar Styles
   Overrides per-module sidebar CSS to match wiki sidebar pattern.
   Applies to: cockpit, sentinel, sentinel-cert, scribe/reunions,
   praedict, minerva, studio, ecriture/scribe
   ============================================================ */

.ck-sidebar,
.sentinel-sidebar,
.cert-sidebar,
.scribe-sidebar,
.pr-sidebar,
.mv-sidebar,
.st-sidebar {
    width: 200px;
    min-width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 8px;
}

.ck-sidebar-item,
.sentinel-sidebar-item,
.cert-sidebar-item,
.scribe-sidebar-item,
.pr-sidebar-item,
.mv-sidebar-item,
.st-sidebar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font: 400 12px/1.3 var(--sans);
    color: var(--text-dim);
    cursor: pointer;
    transition: all 120ms;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.ck-sidebar-item:hover,
.sentinel-sidebar-item:hover,
.cert-sidebar-item:hover,
.scribe-sidebar-item:hover,
.pr-sidebar-item:hover,
.mv-sidebar-item:hover,
.st-sidebar-item:hover {
    background: var(--bg-hover, color-mix(in srgb, var(--text) 5%, transparent));
    color: var(--text);
}

.ck-sidebar-item.active,
.sentinel-sidebar-item.active,
.cert-sidebar-item.active,
.scribe-sidebar-item.active,
.pr-sidebar-item.active,
.mv-sidebar-item.active,
.st-sidebar-item.active {
    background: var(--accent-glow, color-mix(in srgb, var(--accent) 12%, transparent));
    color: var(--accent);
}

.ck-sidebar-item svg,
.sentinel-sidebar-item svg,
.cert-sidebar-item svg,
.scribe-sidebar-item svg,
.pr-sidebar-item svg,
.mv-sidebar-item svg,
.st-sidebar-item svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    opacity: 0.6;
    transition: opacity 120ms;
}

.ck-sidebar-item:hover svg,
.sentinel-sidebar-item:hover svg,
.cert-sidebar-item:hover svg,
.scribe-sidebar-item:hover svg,
.pr-sidebar-item:hover svg,
.mv-sidebar-item:hover svg,
.st-sidebar-item:hover svg {
    opacity: 0.85;
}

.ck-sidebar-item.active svg,
.sentinel-sidebar-item.active svg,
.cert-sidebar-item.active svg,
.scribe-sidebar-item.active svg,
.pr-sidebar-item.active svg,
.mv-sidebar-item.active svg,
.st-sidebar-item.active svg {
    opacity: 1;
    color: var(--accent);
}

/* Sidebar badges (notification counts) */
.ck-sidebar-badge,
.sentinel-sidebar-badge,
.st-sidebar-badge {
    margin-left: auto;
    font: 500 10px/1 var(--mono);
    padding: 2px 6px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}

/* Remove ::before accent bars from studio sidebar items (use wiki style instead) */
.st-sidebar-item::before {
    display: none !important;
}

/* ================================================
   App Launcher — Menu applications Pollux
   ================================================ */

.app-launcher-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.25s;
}

.app-launcher-backdrop.open {
    opacity: 1;
    visibility: visible;
}

[data-theme="light"] .app-launcher-backdrop {
    background: rgba(255, 255, 255, 0.5);
}

.app-launcher {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 9001;
    width: 720px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 80px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.2s;
}

.app-launcher-backdrop.open .app-launcher {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

[data-theme="light"] .app-launcher {
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.12),
                0 0 0 1px rgba(0, 0, 0, 0.04) inset;
}

/* Header */
.app-launcher-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.app-launcher-header-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}

.app-launcher-header-title {
    font: 600 14px/1 var(--sans);
    color: var(--text);
    flex: 1;
}

.app-launcher-header-sub {
    font: 400 11px/1 var(--mono);
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.app-launcher-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.12s;
}

.app-launcher-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Search */
.app-launcher-search {
    padding: 12px 24px;
}

.app-launcher-search input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    font: 400 13px/1.4 var(--sans);
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s;
}

.app-launcher-search input::placeholder {
    color: var(--text-muted);
}

.app-launcher-search input:focus {
    border-color: var(--border-focus);
}

.app-launcher-search-wrap {
    position: relative;
}

.app-launcher-search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Category labels */
.app-launcher-category {
    font: 600 10px/1 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 24px 6px;
}

/* Grid */
.app-launcher-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 6px 18px 18px;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
}

.app-launcher-grid::-webkit-scrollbar {
    width: 4px;
}

.app-launcher-grid::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border-radius: 4px;
}

.app-launcher-grid::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

/* Card */
.app-launcher-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    position: relative;
    border: 1px solid transparent;
}

.app-launcher-card:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.app-launcher-card:active {
    transform: scale(0.98);
}

.app-launcher-card.active {
    background: var(--accent-glow);
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Icon container */
.app-launcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    transition: all 0.2s;
}

.app-launcher-icon svg {
    width: 18px;
    height: 18px;
}

/* Per-module icon colors */
.app-launcher-card[data-app="codex"] .app-launcher-icon       { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.app-launcher-card[data-app="synapse"] .app-launcher-icon     { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.app-launcher-card[data-app="doc"] .app-launcher-icon          { background: rgba(13, 148, 136, 0.12); color: #0d9488; }
.app-launcher-card[data-app="cockpit"] .app-launcher-icon     { background: rgba(249, 115, 22, 0.12); color: #f97316; }
.app-launcher-card[data-app="sentinel"] .app-launcher-icon    { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
.app-launcher-card[data-app="sentinel-cert"] .app-launcher-icon { background: rgba(217, 119, 6, 0.12); color: #d97706; }
.app-launcher-card[data-app="scribe"] .app-launcher-icon      { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.app-launcher-card[data-app="praedict"] .app-launcher-icon    { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }
.app-launcher-card[data-app="minerva"] .app-launcher-icon     { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.app-launcher-card[data-app="wiki"] .app-launcher-icon         { background: rgba(200, 164, 21, 0.12); color: #c8a415; }
.app-launcher-card[data-app="studio"] .app-launcher-icon      { background: rgba(192, 38, 211, 0.12); color: #c026d3; }
.app-launcher-card[data-app="ecriture"] .app-launcher-icon    { background: rgba(244, 63, 94, 0.12); color: #f43f5e; }

/* Light theme — slightly stronger icon backgrounds */
[data-theme="light"] .app-launcher-card[data-app="codex"] .app-launcher-icon       { background: rgba(59, 130, 246, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="synapse"] .app-launcher-icon     { background: rgba(99, 102, 241, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="doc"] .app-launcher-icon          { background: rgba(13, 148, 136, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="cockpit"] .app-launcher-icon     { background: rgba(249, 115, 22, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="sentinel"] .app-launcher-icon    { background: rgba(220, 38, 38, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="sentinel-cert"] .app-launcher-icon { background: rgba(217, 119, 6, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="scribe"] .app-launcher-icon      { background: rgba(16, 185, 129, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="praedict"] .app-launcher-icon    { background: rgba(6, 182, 212, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="minerva"] .app-launcher-icon     { background: rgba(139, 92, 246, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="wiki"] .app-launcher-icon         { background: rgba(200, 164, 21, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="studio"] .app-launcher-icon      { background: rgba(192, 38, 211, 0.09); }
[data-theme="light"] .app-launcher-card[data-app="ecriture"] .app-launcher-icon    { background: rgba(244, 63, 94, 0.09); }

/* Text */
.app-launcher-info {
    flex: 1;
    min-width: 0;
}

.app-launcher-name {
    font: 600 12px/1.2 var(--mono);
    color: var(--text);
    letter-spacing: 0.02em;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-launcher-desc {
    font: 400 11px/1.4 var(--sans);
    color: var(--text-dim);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Active indicator dot */
.app-launcher-card.active .app-launcher-name::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    background: var(--accent);
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}

/* Keyboard shortcut badge */
.app-launcher-kbd {
    font: 500 9px/1 var(--mono);
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 5px;
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}

.app-launcher-card:hover .app-launcher-kbd {
    opacity: 1;
}

/* No results */
.app-launcher-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font: 400 13px/1.5 var(--sans);
}

/* Hover glow effect on icon */
.app-launcher-card:hover .app-launcher-icon {
    transform: scale(1.05);
}

/* Footer */
.app-launcher-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-top: 1px solid var(--border);
    font: 400 10.5px/1 var(--mono);
    color: var(--text-muted);
}

.app-launcher-footer-keys {
    display: flex;
    gap: 12px;
}

.app-launcher-footer-keys span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-launcher-footer-keys kbd {
    font: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 4px;
}

.app-launcher-welcome-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font: 400 10.5px/1 var(--mono);
    cursor: pointer;
    transition: all 150ms;
}

.app-launcher-welcome-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
