/* CSS переменные для темизации */
:root {
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --bg-header: rgba(249, 250, 251, 0.6);
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-color: rgba(0, 0, 0, 0.08);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.05);
    --card-shadow: rgba(99, 102, 241, 0.1);
    --card-glow-color: rgba(167, 139, 250, 0.1);
    --hover-border-color: rgba(99, 102, 241, 0.5);
    --hero-overlay: rgba(255, 255, 255, 0.1);
    --input-bg: #f3f4f6;
    --modal-bg: rgba(0, 0, 0, 0.5);
    --float-btn-bg: #ffffff;
    --float-btn-text: #1f2937;
}

.dark {
    --bg-primary: #050714;
    --bg-secondary: #11182B;
    --bg-header: rgba(5, 7, 20, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #e5e7eb;
    --text-tertiary: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(23, 26, 48, 0.6);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-shadow: rgba(167, 139, 250, 0.15);
    --card-glow-color: rgba(167, 139, 250, 0.1);
    --hover-border-color: rgba(167, 139, 250, 0.7);
    --hero-overlay: rgba(0, 0, 0, 0.5);
    --input-bg: #1f2937;
    --modal-bg: rgba(0, 0, 0, 0.7);
    --float-btn-bg: #1f2937;
    --float-btn-text: #e5e7eb;
}

/* Глобальная анимация смены темы */

html { scroll-behavior: smooth; }
body {
    font-family: 'Manrope', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}
h1, h2, h3, h4, p, a, span, div { transition: color 0.2s ease, background-color 0.2s ease; }
.gradient-text { background: linear-gradient(90deg, #60A5FA, #A78BFA, #F472B6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-fill-color: transparent; }
.hero-bg { background-image: url('images/aiuse.jpg?q=80&w=1974&auto=format&fit=crop'); background-size: cover; background-position: center center; background-attachment: scroll; }
@media (min-width: 1024px) { .hero-bg { background-attachment: fixed; } }
.hero-text-shadow { text-shadow: 0px 2px 5px rgba(0,0,0,0.5); }
.header-bg { background-color: var(--bg-header); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

header nav a {
    position: relative;
    padding: 8px 6px;
    transition: transform 0.2s ease-out, color 0.2s ease-out;
    will-change: transform; 
}
header nav a:hover { transform: translateY(-2px); color: var(--text-primary); }
header nav a::after { content: ''; position: absolute; width: 0; height: 2px; bottom: 4px; left: 50%; transform: translateX(-50%); background-color: var(--hover-border-color); transition: width 0.3s ease; }
header nav a:hover::after { width: 100%; }

h1, h2, h3, h4 { color: var(--text-primary); }

.card-bg { background: var(--card-bg); backdrop-filter: blur(8px); border: 1px solid var(--card-border); transition: all 0.3s ease; position: relative; overflow: hidden; }
.card-bg:hover { transform: translateY(-8px); border-color: var(--hover-border-color); box-shadow: 0 10px 40px -15px var(--card-shadow); }
.card-bg::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: radial-gradient(800px circle at var(--mouse-x) var(--mouse-y), var(--card-glow-color), transparent 40%); z-index: 0; opacity: 0; transition: opacity 0.3s ease; }
.card-bg:hover::before { opacity: 1; }
.card-bg > * { position: relative; z-index: 1; }

.btn-gradient { background-image: linear-gradient(to right, #4F46E5 0%, #A78BFA 51%, #4F46E5 100%); transition: all 0.5s ease; background-size: 200% auto; color: white; box-shadow: 0 4px 15px 0 rgba(129, 140, 248, 0.4); }
.btn-gradient:hover:not(:disabled) { background-position: right center; box-shadow: 0 6px 20px 0 rgba(129, 140, 248, 0.5); transform: translateY(-2px); }
.btn-gradient:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background-color: rgba(255, 255, 255, 0.2); border: 2px solid white; color: white; transition: all 0.3s ease; backdrop-filter: blur(5px); }
.btn-secondary:hover { background-color: white; color: #111827; }

.floating-btn-container { position: fixed; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 0.75rem; }
.floating-btn-container.left { left: 20px; }
.floating-btn-container.right { right: 20px; }
.floating-btn { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background-color: var(--float-btn-bg); color: var(--float-btn-text); box-shadow: 0 5px 15px rgba(0,0,0,0.2); transition: all 0.3s ease; border: 1px solid var(--border-color); }
.floating-btn:hover { transform: translateY(-4px) scale(1.05); }
#back-to-top-btn { opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
#back-to-top-btn.visible { opacity: 1; visibility: visible; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--modal-bg); display: flex; align-items: center; justify-content: center; z-index: 5000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { background-color: var(--bg-secondary); padding: 2rem; border-radius: 1rem; max-width: 90%; width: 500px; max-height: 90vh; overflow-y: auto; position: relative; transform: scale(0.95); transition: transform 0.3s ease; }
.modal-overlay.active .modal-content { transform: scale(1); }
.modal-close-btn { position: absolute; top: 1rem; right: 1rem; background: none; border: none; cursor: pointer; color: var(--text-tertiary); }
.modal-close-btn:hover { color: var(--text-primary); }

.quiz-step { display: none; }
.quiz-step.active { display: block; }
.quiz-option { display: block; width: 100%; text-align: left; padding: 0.75rem 1rem; margin-bottom: 0.5rem; border: 1px solid var(--border-color); border-radius: 0.5rem; cursor: pointer; transition: all 0.2s ease; }
.quiz-option:hover { border-color: var(--hover-border-color); background-color: rgba(99, 102, 241, 0.1); }

#gemini-chat-output { height: 250px; overflow-y: auto; }
.gemini-message { margin-bottom: 0.75rem; }
.gemini-message.user { text-align: right; }
.gemini-message .bubble { display: inline-block; padding: 0.5rem 1rem; border-radius: 1rem; max-width: 80%; }
.gemini-message.user .bubble { background-color: #4F46E5; color: white; }
.gemini-message.assistant .bubble { background-color: var(--input-bg); }
.loader { border: 4px solid var(--border-color); border-top: 4px solid #818CF8; border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.sticker { position: absolute; top: 15px; right: -30px; transform: rotate(45deg); padding: 4px 30px; font-size: 12px; font-weight: bold; color: white; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.sticker-bestseller { background-color: #ef4444; }
.sticker-discount { background-color: #f59e0b; }

#promo-banner { background: linear-gradient(90deg, #60A5FA, #A78BFA, #F472B6); color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }

.rating-stars { display: flex; gap: 2px; }
.rating-stars i { opacity: 0; transform: translateY(5px); transition: opacity 0.3s ease, transform 0.3s ease; }
.rating-stars.animate-in i { opacity: 1; transform: translateY(0); }
.rating-stars.animate-in i:nth-child(1) { transition-delay: 0.1s; }
.rating-stars.animate-in i:nth-child(2) { transition-delay: 0.2s; }
.rating-stars.animate-in i:nth-child(3) { transition-delay: 0.3s; }
.rating-stars.animate-in i:nth-child(4) { transition-delay: 0.4s; }
.rating-stars.animate-in i:nth-child(5) { transition-delay: 0.5s; }
.rating-stars .filled { color: #f59e0b; }

#copy-notification { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background-color: #28a745; color: white; padding: 10px 20px; border-radius: 8px; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
#copy-notification.show { opacity: 1; visibility: visible; }

#preloader { transition: opacity 0.5s ease-out, visibility 0.5s ease-out; }
#preloader.preloader-hidden { opacity: 0; visibility: hidden; }

/* Стилизация вывода Markdown */
.prose-service p { margin-bottom: 0.5rem; }
.prose-course ul { list-style-type: disc; padding-left: 1.5rem; margin-top: 0.5rem; }
.prose-course li { margin-bottom: 0.25rem; }
#task-output p, #quiz-gemini-result p { margin-bottom: 1rem; }
#task-output h1, #task-output h2, #task-output h3, #quiz-gemini-result h1, #quiz-gemini-result h2, #quiz-gemini-result h3 { font-weight: bold; margin-top: 1.5rem; margin-bottom: 0.5rem; }
#task-output ul, #quiz-gemini-result ul { list-style-type: disc; padding-left: 1.5rem; margin-bottom: 1rem; }
#task-output ol, #quiz-gemini-result ol { list-style-type: decimal; padding-left: 1.5rem; margin-bottom: 1rem; }
#task-output li, #quiz-gemini-result li { margin-bottom: 0.5rem; }
