body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden; /* Защита от горизонтального скролла */
}

/* --- СИСТЕМА ЭКРАНОВ (Именно она у тебя сломалась) --- */
.screen {
    display: none !important; /* Строго скрываем все экраны */
    width: 100%;
    max-width: 450px;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.screen.active {
    display: flex !important; /* Строго показываем только активный */
    animation: fadeInStandard 0.4s ease-in-out;
}

/* --- ВХОД И РЕГИСТРАЦИЯ --- */
.auth-box {
    background: white; padding: 30px; border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); width: 100%; text-align: center;
    box-sizing: border-box;
}
.auth-box h2 { margin-top: 0; color: #333; }
.auth-box input { margin-bottom: 15px; }

/* --- ДАШБОРД И ПЛИТКИ --- */
.dashboard-header {
    background: white; padding: 20px; border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); width: 100%;
    margin-bottom: 20px; display: flex; justify-content: space-between;
    align-items: center; box-sizing: border-box;
}
.logout-btn { background: #e74c3c; color: white; border: none; padding: 8px 15px; border-radius: 10px; cursor: pointer; }

.themes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; }
.theme-tile {
    height: 120px; border-radius: 20px; border: none;
    color: white; font-size: 16px; font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5); cursor: pointer; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); transition: transform 0.2s; 
    display: flex; justify-content: center; align-items: center; text-align: center; padding: 10px;
}
.theme-tile:hover { transform: scale(1.05); }

/* --- СОХРАНЕННЫЕ ОТКРЫТКИ --- */
.saved-cards-section { width: 100%; margin-top: 30px; text-align: left; }
.saved-card-item {
    background: white; padding: 15px; border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); display: flex; 
    justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.saved-card-info h4 { margin: 0 0 5px 0; color: #333; }
.saved-card-info p { margin: 0; font-size: 12px; color: #888; }
.download-mini-btn {
    background: #3498db; color: white; border: none;
    padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: bold;
}

/* --- БИЛДЕР (ОТКРЫТКА) --- */
.builder-container {
    background: white; padding: 20px; border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); width: 100%; box-sizing: border-box; position: relative;
}

.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
#slideCounter {
    font-size: 13px; /* Делаем шрифт меньше (стандартный около 16px) */
    color: #666; /* Чуть приглушаем цвет, чтобы не отвлекал от кнопок */
    text-align: center;
    flex-grow: 1; /* Чтобы счетчик ровно стоял по центру между кнопками */
}
.nav-btn, .add-btn { color: white; border: none; padding: 6px 12px; border-radius: 10px; cursor: pointer; font-weight: bold; }
.nav-btn { background: #bdc3c7; }
.nav-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.add-btn { 
    background: #2ecc71; 
    padding: 6px 10px; /* Уменьшаем отступы внутри кнопки (было 8px 15px) */
    font-size: 13px;   /* Уменьшаем размер самого текста */
    margin-left: 5px;  /* Небольшой отступ слева, чтобы не прилипала к стрелочке */
}
.delete-btn {
    background: #e74c3c; color: white; border: none; padding: 12px; border-radius: 10px;
    font-size: 16px; font-weight: bold; cursor: pointer; width: 100%; margin-top: 5px; transition: 0.2s;
}
.delete-btn:disabled { background: #f5b7b1; cursor: not-allowed; }

.card-editor { display: flex; flex-direction: column; gap: 15px; }
input[type="text"], textarea {
    width: 100%; padding: 12px; border: 1px solid #ddd;
    border-radius: 10px; font-size: 16px; box-sizing: border-box; font-family: inherit;
}
textarea { resize: vertical; min-height: 120px; }

.image-selector {
    border: 2px dashed #ff69b4; border-radius: 15px; height: 200px;
    display: flex; justify-content: center; align-items: center; cursor: pointer;
    background-color: #fff0f5; color: #ff69b4; font-weight: bold; overflow: hidden; position: relative;
}
.image-selector img {
    width: 100%; height: 100%; object-fit: contain; position: absolute; top: 0; left: 0; background: white;
}

/* --- ОКНА (МОДАЛКИ) И ТЕГИ --- */
.gif-modal {
    display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: white; border-radius: 20px; z-index: 100; flex-direction: column;
    padding: 20px; box-sizing: border-box; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.close-modal { align-self: flex-end; cursor: pointer; color: #888; font-weight: bold; margin-bottom: 10px; }

.tags-container {
    display: flex; gap: 10px; overflow-x: auto; white-space: nowrap; flex-wrap: nowrap;
    padding-bottom: 10px; -ms-overflow-style: none; scrollbar-width: none;
}
.tags-container::-webkit-scrollbar { display: none; }
.tags-container button { flex-shrink: 0; }

.custom-url-box { display: flex; gap: 10px; margin-bottom: 15px; }
.custom-url-box button { padding: 10px; background: #2ecc71; color: white; border: none; border-radius: 8px; cursor: pointer; }

.gif-grid { display: flex; flex-wrap: wrap; gap: 10px; overflow-y: auto; }
.gif-grid img { width: calc(50% - 5px); height: 120px; object-fit: cover; border-radius: 10px; cursor: pointer; }

.generate-btn {
    width: 100%; margin-top: 20px; padding: 15px; background: #ff69b4; color: white; border: none;
    border-radius: 15px; font-size: 16px; font-weight: bold; cursor: pointer;
}

.fade-transition { animation: fadeInStandard 0.4s ease-in-out; }
@keyframes fadeInStandard {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* --- НОВЫЕ КНОПКИ ДЛЯ СОХРАНЕННЫХ ОТКРЫТОК --- */
.saved-card-actions {
    display: flex; gap: 8px; align-items: center;
}
.icon-btn {
    background: #f0f2f5; border: none; padding: 8px 12px;
    border-radius: 10px; cursor: pointer; font-size: 16px;
    transition: 0.2s; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #e4e6e9; transform: scale(1.05); }
.delete-icon { background: #fceceb; }
.delete-icon:hover { background: #fadbd8; }

/* --- ДИЗАЙН СОХРАНЕННЫХ ОТКРЫТОК В ДАШБОРДЕ --- */
.saved-card-item {
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 15px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #f0f0f0;
}

.saved-card-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.saved-card-preview {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    flex-shrink: 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

.saved-card-info {
    flex-grow: 1;
    padding: 0 15px;
    overflow: hidden;
}

.saved-card-name {
    font-weight: bold;
    color: #2c3e50;
    font-size: 16px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.saved-card-actions {
    display: flex;
    gap: 8px;
}

.saved-btn {
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: opacity 0.2s, transform 0.1s;
}

.saved-btn:active { transform: scale(0.95); }
.saved-btn:hover { opacity: 0.85; }

.share-btn { 
    background: #3498db; 
    color: white; 
}

.delete-btn { 
    background: #ff4757; 
    color: white; 
    padding: 8px 12px; 
}

/* --- СИСТЕМА УВЕДОМЛЕНИЙ (TOASTS) --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999; /* Поверх всего */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #fff;
    color: #333;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    min-width: 250px;
    max-width: 350px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 5px solid gray; /* Дефолтный цвет */
    cursor: pointer;
    
    /* Анимации появления и исчезновения */
    animation: toastFadeIn 0.4s ease forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Цвета по типам */
.toast.success { border-left-color: #2ecc71; color: #155724; background-color: #d4edda; }
.toast.error   { border-left-color: #e74c3c; color: #721c24; background-color: #f8d7da; }

/* Анимация появления */
@keyframes toastFadeIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Класс для исчезновения */
.toast.fade-out {
    opacity: 0;
    transform: translateX(100px);
}

/* --- МОБИЛЬНЫЙ ФОРМАТ ПРИЛОЖЕНИЯ --- */
body {
    background-color: #dcdde1; /* Темный фон по бокам на ПК */
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

/* Ограничиваем главные экраны */
.screen {
    max-width: 480px !important;
    width: 100%;
    min-height: 100vh;
    background: #f0f2f5;
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
    position: relative;
    box-sizing: border-box;
    margin: 0 auto;
}

/* Ограничиваем все всплывающие окна (Модалки) */
.gif-modal {
    max-width: 480px !important;
    width: 100%;
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Ограничиваем окно подтверждения (Confirm) */
#confirmModal {
    max-width: 350px !important;
    width: 90% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* Уведомления (тосты) тоже сдвигаем в пределы мобильного экрана */
.toast-container {
    max-width: 480px;
    width: 100%;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
    padding: 0 15px;
    align-items: flex-end; /* Чтобы тосты прижимались к правому краю самого телефона */
}
.toast {
    width: auto;
    max-width: 100%;
}