:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f6fa;
    --text-color: #2c3e50;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

/* Thème Sombre */
body.dark-theme {
    --primary-color: #64b5f6;
    --secondary-color: #34495e;
    --text-color: #ecf0f1;
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Optimisation du rendu */
img, video {
    max-width: 100%;
    height: auto;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    padding: clamp(10px, 2vw, 24px);
    /* Améliorer le rendu des polices */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: min(1400px, 100%);
}

/* Styles communs */
.card {
    background-color: var(--card-bg);
    padding: clamp(1rem, 2.5vw, 2rem);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.hidden {
    display: none !important;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
    width: 100%;
}

.btn-primary:hover {
    background-color: #357abd;
}

.btn-secondary {
    background-color: var(--error-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
}

/* Login Section */
#login-section {
    max-width: 440px;
    margin: 0 auto;
}

#login-section h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input:not([type="checkbox"]) {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    font-size: 1rem;
}

.form-group input:disabled,
.form-group select:disabled {
    background: #eef2f7;
    color: #7a8391;
    border-color: #cfd7e3;
    cursor: not-allowed;
}

.smtp-disabled-group label {
    opacity: 0.65;
}

.smtp-disabled-label {
    opacity: 0.6;
    cursor: not-allowed;
}

.password-toggle.smtp-disabled-toggle {
    opacity: 0.35;
    cursor: not-allowed;
}

body.dark-theme .form-group input:disabled,
body.dark-theme .form-group select:disabled {
    background: #3a4655;
    color: #a9b6c8;
    border-color: #506177;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.35rem;
    line-height: 1;
    opacity: 0.75;
}

.password-toggle:hover {
    opacity: 1;
}

.notify-down-row {
    margin-top: -0.3rem;
}

.notify-down-label {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid #d8dee6;
    border-radius: 12px;
    background: rgba(74, 144, 226, 0.05);
    cursor: pointer;
}

.notify-down-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    pointer-events: none;
}

.notify-down-slider {
    display: inline-block;
    width: 44px;
    height: 24px;
    min-width: 44px;
    border-radius: 999px;
    background: linear-gradient(180deg, #cbd3df 0%, #b7bfcd 100%);
    position: relative;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.notify-down-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease;
}

.notify-down-input:checked + .notify-down-slider {
    background: linear-gradient(180deg, #39d27d 0%, #22b865 100%);
    box-shadow: inset 0 0 0 1px rgba(13, 122, 65, 0.35);
}

.notify-down-input:checked + .notify-down-slider::after {
    transform: translateX(20px);
}

.notify-down-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.notify-down-title {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text-color);
    line-height: 1.25;
}

.notify-down-subtitle {
    margin-top: 2px;
    color: #6b7483;
    font-size: 0.82rem;
    line-height: 1.3;
}

.notify-down-input:focus-visible + .notify-down-slider {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.ui-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.ui-dialog-card {
    width: min(100%, 420px);
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
    padding: 1rem 1rem 0.9rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    animation: dialogIn 0.18s ease-out;
}

@keyframes dialogIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ui-dialog-title {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
}

.ui-dialog-message {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-line;
}

.ui-dialog-input {
    width: 100%;
    margin-top: 0.85rem;
    padding: 10px 12px;
    border: 1px solid #d3d8df;
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--card-bg);
    color: var(--text-color);
}

.ui-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
    margin-top: 0.95rem;
}

.ui-dialog-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 600;
}

.ui-dialog-btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.ui-dialog-btn-secondary {
    background: var(--secondary-color);
    color: var(--text-color);
}

.error-message {
    color: var(--error-color);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Links Section */
#links-section header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

#links-section header h1 {
    font-size: clamp(1.2rem, 2.2vw, 2rem);
    line-height: 1.2;
}

.search-bar {
    margin-bottom: 2rem;
}

.search-bar input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    font-size: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: clamp(0.9rem, 1.6vw, 1.5rem);
}

.link-card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    /* Optimisation GPU pour les animations */
    will-change: transform;
}

.link-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.link-card i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.link-icon-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 1rem;
}

.link-card span {
    font-weight: bold;
    font-size: 1.1rem;
}

.link-card .desc {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 0.5rem;
}

/* Wrapper pour la carte et le bouton supprimer */
.link-card-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    cursor: move;
    cursor: grab;
    transition: opacity 0.2s, transform 0.2s;
    user-select: none;
}

.link-card-wrapper:active {
    cursor: grabbing;
}

.link-card-wrapper.dragging {
    opacity: 0.4;
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.link-card-wrapper.drag-over {
    border: 3px dashed var(--primary-color);
    border-radius: var(--radius);
    background-color: rgba(52, 152, 219, 0.2);
    transform: scale(1.02);
}

.link-card-wrapper.drag-over::before {
    content: "Déposer ici";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    z-index: 1000;
    pointer-events: none;
}

.link-card-wrapper .link-card {
    height: 100%;
    width: 100%;
    position: relative;
}

.link-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.link-card-wrapper:hover .link-actions {
    opacity: 1;
}

.delete-btn,
.edit-btn,
.move-btn {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.move-btn {
    background: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
}

.move-btn:hover {
    background: rgba(52, 152, 219, 0.3);
}

.move-spacer {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.edit-btn {
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary-color);
}

.delete-btn:hover {
    background: var(--error-color);
    color: white;
}

.edit-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Statut des liens */
.link-status-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.2rem;
    z-index: 10;
}

/* Vert pour site qui fonctionne */
.status-online .link-status-badge {
    color: #2ecc71;
}

/* Rouge pour erreurs et offline */
.status-offline .link-status-badge,
.status-error .link-status-badge,
.status-maintenance .link-status-badge,
.status-timeout .link-status-badge {
    color: #e74c3c;
}

/* Bleu pour redirection */
.status-redirect .link-status-badge {
    color: #3498db;
}

.status-checking .link-status-badge {
    color: #95a5a6;
}

.status-unknown .link-status-badge {
    color: #95a5a6;
}

.status-text {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 0.3rem;
    font-style: italic;
}

/* Vert pour site qui fonctionne */
.status-online .status-text {
    color: #2ecc71;
}

/* Rouge pour erreurs */
.status-offline .status-text,
.status-error .status-text,
.status-maintenance .status-text,
.status-timeout .status-text {
    color: #e74c3c;
}

/* Bleu pour redirection */
.status-redirect .status-text {
    color: #3498db;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.header-actions button {
    width: auto;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.modal-content {
    background-color: var(--card-bg);
    padding: clamp(1rem, 2.2vw, 2rem);
    border-radius: var(--radius);
    width: 100%;
    max-width: min(560px, 96vw);
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
    max-height: 92vh;            /* Limite la hauteur pour petit écran */
    max-height: 92dvh;
    overflow-y: auto;            /* Active le scroll interne si nécessaire */
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color-secondary, #aaa);
    transition: transform 0.15s ease, color 0.15s ease;
}

.close-modal:hover {
    transform: scale(1.1);
    color: var(--text-color);
}

.close-modal:active {
    transform: scale(0.95);
}

.close-edit-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color-secondary, #aaa);
    transition: transform 0.15s ease, color 0.15s ease;
}

.close-edit-modal:hover {
    transform: scale(1.1);
    color: var(--text-color);
}

.close-edit-modal:active {
    transform: scale(0.95);
}

/* Bouton de fermeture (paramètres) plus visible et élégant */
.close-settings-modal {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-color);
    background: linear-gradient(135deg, rgba(0,0,0,0.06), rgba(0,0,0,0));
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    cursor: pointer;
}

.close-settings-modal:hover {
    transform: scale(1.07);
    background: linear-gradient(135deg, rgba(0,0,0,0.08), rgba(0,0,0,0.02));
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}

.close-settings-modal:active {
    transform: scale(0.95);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Styles du sélecteur de thème */
.theme-switch {
    position: fixed;
    top: clamp(8px, 2vw, 20px);
    left: clamp(8px, 2vw, 20px);
    z-index: 1000;
    display: flex;
    gap: 5px;
    background: var(--card-bg);
    padding: 5px;
    border-radius: 30px;
    box-shadow: var(--shadow);
}

.theme-switch button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    color: var(--text-color);
    transition: all 0.3s;
    font-size: 1rem;
}

.theme-switch button:hover {
    background-color: var(--secondary-color);
}

.theme-switch button.active {
    background-color: var(--primary-color);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        max-width: 100%;
    }

    /* Header responsive */
    #links-section header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .header-actions {
        flex-direction: column;
        width: 100%;
    }

    .header-actions button,
    .header-actions a {
        width: 100% !important;
    }

    /* Grille responsive */
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    /* Cartes de liens */
    .link-card {
        padding: 1rem;
    }

    .link-card i {
        font-size: 2rem;
    }

    .link-card span {
        font-size: 1rem;
    }

    .link-icon-img {
        width: 40px;
        height: 40px;
    }

    /* Modal responsive */
    .modal-content {
        margin: 0;
        max-width: 100%;
        border-radius: 12px;
    }

    /* Formulaires */
    .form-group input {
        font-size: 16px; /* Éviter le zoom sur iOS */
    }

    /* Thème switch */
    .theme-switch {
        top: 10px;
        left: 10px;
        padding: 3px;
    }

    .theme-switch button {
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    /* Actions des liens toujours visibles sur mobile */
    .link-actions {
        opacity: 1;
    }

    .link-status-badge {
        font-size: 1rem;
    }
}

/* Tablettes */
@media (min-width: 769px) and (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .container {
        max-width: 90%;
    }
}

/* Très petits écrans */
@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr;
    }

    #links-section header h1 {
        font-size: 1.5rem;
    }

    .link-card {
        padding: 1.5rem;
    }

    .search-bar input {
        padding: 10px;
        font-size: 16px;
    }
}

/* Mode paysage mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        min-height: auto;
        padding: 10px;
    }

    .theme-switch {
        position: absolute;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Amélioration tactile */
@media (hover: none) and (pointer: coarse) {
    .link-card:active {
        transform: scale(0.95);
    }

    button:active {
        opacity: 0.7;
    }

    /* Actions toujours visibles sur tactile */
    .link-actions {
        opacity: 1;
    }
}

/* Modale de confirmation de suppression */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.delete-confirmation {
    max-width: 400px;
    text-align: center;
    border-radius: 12px;
    position: relative;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirmation-icon {
    font-size: 64px;
    color: var(--error-color);
    margin-bottom: 20px;
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

.delete-confirmation h2 {
    margin-bottom: 12px;
    color: var(--text-color);
    font-size: 20px;
}

.delete-confirmation p {
    color: var(--text-color);
    margin-bottom: 24px;
    font-size: 14px;
    opacity: 0.8;
}

.confirmation-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-cancel, .btn-delete {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 2px solid transparent;
}

.btn-cancel:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-delete {
    background-color: var(--error-color);
    color: white;
}

.btn-delete:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-delete:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 600px) {
    .delete-confirmation {
        max-width: calc(100vw - 40px);
        margin: 20px;
    }

    .confirmation-icon {
        font-size: 48px;
    }

    .delete-confirmation h2 {
        font-size: 18px;
    }
}

/* Styles pour l'onglet Export/Import */
.backup-tab {
    padding: 20px 0;
}

.backup-section {
    padding: 20px;
    background-color: var(--secondary-color);
    border-radius: 8px;
    margin-bottom: 20px;
}

.backup-section h3 {
    margin-bottom: 10px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}

.backup-section p {
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 15px;
    font-size: 13px;
}

.backup-section small {
    display: block;
    color: var(--error-color);
    margin-top: 10px;
    font-size: 12px;
}

.backup-divider {
    border: none;
    border-top: 1px solid var(--bg-color);
    margin: 20px 0;
}

.icons-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--bg-color);
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 6px;
    background-color: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.icon-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.icon-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 4px;
}

.icon-item-name {
    font-size: 11px;
    color: var(--text-color);
    text-align: center;
    word-break: break-all;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.icon-item-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 12px;
}

.icon-item:hover .icon-item-delete {
    opacity: 1;
}

.icon-item-delete:hover {
    background-color: #c0392b;
}

/* === GALERIE D'ICÔNES === */
.icon-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
    background-color: var(--card-background);
    padding: 8px;
}

.icon-preview img {
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
}

.icon-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-background);
    max-height: 300px;
    overflow-y: auto;
    margin-top: 12px;
}

.icon-gallery.hidden {
    display: none;
}

.icon-gallery-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--background);
}

.icon-gallery-item:hover {
    border-color: var(--primary-color);
    background-color: var(--card-background);
    transform: scale(1.05);
}

.icon-gallery-item.selected {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

.icon-gallery-item.selected img {
    filter: brightness(1.5);
}

.icon-gallery-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin-bottom: 4px;
}

.icon-gallery-item-name {
    font-size: 10px;
    color: var(--text-color);
    text-align: center;
    word-break: break-all;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Scrollbar personnalisée pour la galerie */
.icon-gallery::-webkit-scrollbar {
    width: 6px;
}

.icon-gallery::-webkit-scrollbar-track {
    background: transparent;
}

.icon-gallery::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.icon-gallery::-webkit-scrollbar-thumb:hover {
    background: var(--text-color-secondary);
}

/* Très grands écrans */
@media (min-width: 1440px) {
    .container {
        max-width: 1600px;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

/* Pixel-perfect ciblé */
@media (max-width: 320px) {
    body {
        padding: 6px;
    }

    .card {
        padding: 0.85rem;
    }

    #login-section h2 {
        font-size: 1.2rem;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 40px;
        font-size: 0.92rem;
    }

    .theme-switch {
        transform: scale(0.92);
        transform-origin: top left;
    }

    .modal-content {
        padding: 0.9rem;
    }
}

@media (min-width: 321px) and (max-width: 375px) {
    .card {
        padding: 1rem;
    }

    #links-section header h1 {
        font-size: 1.4rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 1rem;
    }
}

@media (min-width: 376px) and (max-width: 390px) {
    .card {
        padding: 1.05rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    }

    .link-card {
        padding: 1.1rem;
    }
}

@media (min-width: 391px) and (max-width: 768px) {
    .container {
        max-width: 720px;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 980px;
    }

    #links-section header {
        align-items: center;
    }

    .header-actions {
        justify-content: flex-end;
    }
}

@media (min-width: 1025px) and (max-width: 1439px) {
    .container {
        max-width: 1240px;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (min-width: 1440px) {
    #links-section header h1 {
        font-size: 2.1rem;
    }

    .link-card {
        padding: 1.7rem;
    }
}

@media (max-width: 640px) {
    .notify-down-label {
        grid-template-columns: auto 1fr;
        align-items: start;
    }

    .notify-down-text {
        grid-column: 2;
    }
}