/* Mobile header micro-adjustments: shift logo right, burger left */
@media (max-width: 768px) {
    .logo-link {
        margin-left: 6px;
    }

    .header-right {
        right: 22px;
        /* move burger a bit left from the edge */
    }
}

@media (max-width: 480px) {
    .logo-link {
        margin-left: 8px;
    }

    .header-right {
        right: 24px;
        /* slightly more left on very small screens */
    }
}

:root {
    --primary-color: #1a1a1a;
    --primary-color-rgb: 26, 26, 26;
    --secondary-color: #fff;
    --secondary-color-rgb: 255, 255, 255;
    --border-color: #d0d0d0;
    --border-color-rgb: 208, 208, 208;
    --hover-color: #f5f5f5;
    --abswhite-color: #ffffff;
    --ekinshi-color: #fff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;

    /* Subject colors with light background variants */
    --biology-color: #34C759;
    --biology-bg: rgba(52, 199, 89, 0.02);
    --biology-color-rgb: 52, 199, 89;

    --physics-color: #8A2BE2;
    --physics-bg: rgba(138, 43, 226, 0.02);
    --physics-color-rgb: 138, 43, 226;

    --history-color: #A52A2A;
    --history-bg: rgba(165, 42, 42, 0.02);
    --history-color-rgb: 165, 42, 42;

    --informatics-color: #4682B4;
    --informatics-bg: rgba(70, 130, 180, 0.02);
    --informatics-color-rgb: 70, 130, 180;

    --chemistry-color: #00B7EB;
    --chemistry-bg: rgba(0, 183, 235, 0.02);
    --chemistry-color-rgb: 0, 183, 235;

    --world-history-color: #FF4500;
    --world-history-bg: rgba(255, 69, 0, 0.02);
    --world-history-color-rgb: 255, 69, 0;

    --geography-color: #2E8B57;
    --geography-bg: rgba(46, 139, 87, 0.02);
    --geography-color-rgb: 46, 139, 87;

    --english-color: #FF69B4;
    --english-bg: rgba(255, 105, 180, 0.02);
    --english-color-rgb: 255, 105, 180;

    --kazakh-language-color: #b64861;
    --kazakh-language-bg: rgba(182, 72, 97, 0.02);
    --kazakh-language-color-rgb: 182, 72, 97;

    --kazakh-literature-color: #bb8f53;
    --kazakh-literature-bg: rgba(187, 143, 83, 0.02);
    --kazakh-literature-color-rgb: 187, 143, 83;

    --law-basics-color: #1fcbcb;
    --law-basics-bg: rgba(31, 203, 203, 0.02);
    --law-basics-color-rgb: 31, 203, 203;

    --russian-language-and-literature-color: #5164ae;
    --russian-language-and-literature-bg: rgba(81, 100, 174, 0.02);
    --russian-language-and-literature-color-rgb: 81, 100, 174;


    /* Current subject background - default to history */
    --current-subject-bg: var(--history-bg);
    --current-subject-color-rgb: var(--history-color-rgb);
}

/* Theme transitions тек theme toggle жағдайында ғана */
html.theme-transitioning {
    transition: background-color 0.4s ease, color 0.4s ease;
}

html.theme-transitioning * {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

[data-theme="dark"] {
    --primary-color: #fff;
    --primary-color-rgb: 255, 255, 255;
    --secondary-color: #1a1a1a;
    --secondary-color-rgb: 26, 26, 26;
    --border-color: #404040;
    --border-color-rgb: 64, 64, 64;
    --hover-color: #2a2a2a;
    --ekinshi-color: #2a2a2a;
    --shadow: 0 2px 8px rgba(255, 255, 255, 0.1);

    /* Dark theme subject colors with darker background variants */
    --history-bg: rgba(165, 42, 42, 0.05);
    --world-history-bg: rgba(255, 69, 0, 0.05);
    --informatics-bg: rgba(70, 130, 180, 0.05);
    --physics-bg: rgba(175, 82, 222, 0.05);
    --chemistry-bg: rgba(0, 183, 235, 0.05);
    --law-basics-bg: rgba(47, 79, 79, 0.05);
    --biology-bg: rgba(52, 199, 89, 0.05);
    --geography-bg: rgba(46, 139, 87, 0.05);
    --english-bg: rgba(255, 105, 180, 0.05);
    --kazakh-language-bg: rgba(139, 69, 19, 0.05);
    --kazakh-literature-bg: rgba(92, 64, 51, 0.05);
}

/* Dark theme үшін main content көлеңке стилін алып тастау */

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

/* Google Fonts import with preconnect for better performance */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

/* Custom text selection colors */
::selection {
    background-color: #fff59d;
    color: #333333;
}

::-moz-selection {
    background-color: #fff59d;
    color: #333333;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--secondary-color);
    /* Біртұтас secondary color фон */
    color: var(--primary-color);
    transition: var(--transition);
    overflow-x: hidden;
    overflow-y: auto;
    /* Мобильде глобал scroll болсын */
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Fix unwanted line in JUZ40 footer */
.juz40-footer,
.juz40-footer-inner {
    border: none !important;
    border-top: none !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
}

/* Header - көрсетілген */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--secondary-color);
    /* Біртұтас фон */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* Жұмсақ анимация */
    /* border-bottom линиясын алып тастау */
}

/* Scroll кезінде header стилі */
.header.scrolled {
    background: var(--secondary-color);
    /* Біртұтас фон сақталады */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    /* Жұмсақ көлеңке */
    /* border-bottom линиясын алып тастау */
}

/* Mobile menu ашылған кезде header көлеңкесін жасыру */
.header.mobile-menu-open {
    box-shadow: none !important;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Header navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 30px;
    position: relative;
}

.header-nav-item {
    text-decoration: none;
    color: var(--primary-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    font-weight: 400;
    /* Inter Regular қалыңдық */
    padding: 8px 16px;
    border-radius: 0;
    /* Дөңгелек жиектерді алып тастау */
    transition: all 0.3s ease;
    position: relative;
    letter-spacing: 0.2px;
    /* Inter Regular үшін жұмсақ әрiптер арасындағы кеңістік */
    /* Астыңғы сызықты алып тастаймыз */
}

.header-nav-item:hover {
    color: rgba(var(--current-subject-color-rgb), 1);
}

.header-nav-item.active {
    background-color: transparent;
    /* Қара фонды алып тастау */
    color: var(--primary-color);
    font-weight: 400;
    /* Inter Regular қалыңдық - біріңғай стиль */
    /* Актив күйдегі астыңғы сызықты алып тастаймыз */
}

.header-nav-item.active:hover {
    color: var(--primary-color);
}

/* Анимациялы навигация индикаторы */
.nav-indicator {
    position: absolute;
    bottom: -2px;
    height: 2px;
    background: linear-gradient(90deg,
            rgba(var(--current-subject-color-rgb), 1),
            rgba(var(--current-subject-color-rgb), 0.8));
    border-radius: 1px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
    width: 0;
    opacity: 0;
}

.nav-indicator.active {
    opacity: 1;
}

/* Header right section */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 0;
    overflow: hidden;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo-icon {
    color: var(--primary-color);
    width: 28px;
    height: 28px;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.logo {
    font-family: 'Outfit', 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 36px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.4px;
    color: var(--primary-color);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    line-height: 1;
}

.top-nav {
    display: none;
    gap: 10px;
    align-items: center;
}

.top-nav.show {
    display: flex;
}

.nav-select {
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    min-width: 140px;
}

.nav-select:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.nav-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

/* Custom Select Styles */
.custom-select {
    position: relative;
    display: inline-block;
    min-width: auto;
    /* Минималды кеністі алып тастау */
    width: auto;
    /* Кеністі мазмұнға бейімдеу */
}

.select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    /* Padding кішірейту */
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    gap: 6px;
    /* Gap кішірейту */
    white-space: nowrap;
    /* Мәтін жолына түсірмеу */
    width: auto;
    /* Кеністі мазмұнға бейімдеу */
    min-width: auto;
    /* Минималды кеністі алып тастау */
}

.select-trigger:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.select-trigger.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

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

.select-arrow {
    color: var(--primary-color);
    transition: var(--transition);
    flex-shrink: 0;
}

.select-trigger.active .select-arrow {
    transform: rotate(180deg);
}

.select-dropdown {
    position: absolute;
    /* fixed-тан қайтадан absolute-ке өзгерту */
    top: 100%;
    /* Бастапқы күйде төменге ашылу */
    left: 0;
    right: auto;
    width: max-content;
    /* Мазмұнға сай кеністі */
    min-width: 100%;
    /* Минимум триггер кеністігі */
    max-width: 300px;
    /* Максимум кеністі шектеу */
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    margin-top: 4px;
    /* Бастапқы күйде margin-top */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    /* Тек opacity анимациясы */
    max-height: 160px;
    overflow-y: scroll;
}

/* Іздеу кезінде менюлер жоғарыға ашылу */
.search-container.searching .select-dropdown {
    top: auto;
    bottom: 100%;
    /* Іздеу кезінде жоғарыға ашылу */
    margin-top: 0;
    margin-bottom: 4px;
}

.search-container.searching .custom-select.active .select-dropdown {
    opacity: 1;
    visibility: visible;
}

/* Іздеу кезінде менюлер жоғарыға ашылу */

.select-dropdown::-webkit-scrollbar {
    width: 7px;
    border-radius: 16px;
    /* Container-дің border-radius-ымен сәйкес */
}

.select-dropdown::-webkit-scrollbar-track {
    background: var(--hover-color);
    border-radius: 16px;
    /* Container-дің border-radius-ымен сәйкес */
    margin: 8px 0;
    /* Жоғары және төменгі жиектерден отступ */
}

.select-dropdown::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 16px;
    /* Container-дің border-radius-ымен сәйкес */
    opacity: 0.6;
    border: 1px solid var(--secondary-color);
    /* Жиектен аздап алыстату */
}

.custom-select.active .select-dropdown {
    opacity: 1;
    visibility: visible;
}

.select-option {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 14px;
    margin: 4px 8px;
    white-space: nowrap;
    /* Мәтін жолына түсірмеу */
    text-overflow: ellipsis;
    /* Ұзын мәтін үшін ... */
    overflow: hidden;
    /* Артық мәтін жасыру */
}

.select-option:hover {
    background-color: var(--hover-color);
}

.select-option.selected {
    background-color: var(--primary-color);
    color: var(--secondary-color);
}

/* Loading state for dropdown options */
.select-option.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.select-option.loading::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border: 2px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Автор(лар) атауы – базовый размер */
.book-author {
    font-size: 16px;
    line-height: 20px;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background-color: var(--hover-color);
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
}

/* Theme toggle icons */
.theme-toggle .sun-icon {
    display: block;
    opacity: 0;
    transform: rotate(180deg) scale(0.8);
}

.theme-toggle .moon-icon {
    display: block;
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Dark theme - swap icons with smooth transitions */
[data-theme="dark"] .theme-toggle .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="dark"] .theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0.8);
}

/* Enhanced hover effects for dark theme */
[data-theme="dark"] .theme-toggle:hover {
    box-shadow: 0 2px 12px rgba(255, 255, 255, 0.08);
}

/* Subtle glow effect on hover */
.theme-toggle:hover .moon-icon {
    filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.3));
}

[data-theme="dark"] .theme-toggle:hover .sun-icon {
    filter: drop-shadow(0 0 6px rgba(255, 184, 0, 0.3));
}

.hidden {
    display: none;
}

/* Мобильная компоновка одиночного результата: кнопки сверху над фигурой */
@media (max-width: 768px) {
    .single-result-layout {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    /* Скрываем левый балансир на мобильном */
    .single-result-layout .result-left-spacer {
        display: none !important;
    }

    /* Кнопки в один ряд сверху, по центру */
    .single-result-layout .result-buttons {
        flex-direction: row !important;
        gap: 12px !important;
        flex: none !important;
    }

    /* Центральный блок занимает ширину search-box */
    #mainResultWrapper {
        max-width: min(700px, 90vw) !important;
        width: 100% !important;
    }
}

/* Main Content */
.main-content {
    margin-top: 60px;
    /* Header биіктігі */
    min-height: calc(var(--app-height, 100vh) - 60px);
    /* динамикалық биіктік */
    transition: var(--transition);
    padding: 0;
    background: var(--secondary-color);
    overflow: visible;
    /* Ішкі контейнерлер өздері scroll жасайды қажет болса */
    position: relative;
    padding-bottom: 0 !important;
    /* Ensure no bottom padding */
    margin-bottom: 0 !important;
}

.page {
    display: none;
    min-height: calc(var(--app-height, 100vh) - 60px);
    background: var(--secondary-color);
    position: relative;
    z-index: 1;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.page.active {
    display: block;
}

/* Search Page */
.search-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 10px 20px 40px 20px;
    text-align: center;
    position: relative;
    transition: var(--transition);
}

/* Grid background for search page */
.search-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(var(--primary-color-rgb), 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--primary-color-rgb), 0.04) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 0;
    pointer-events: none;
    transition: var(--transition);
    /* Top fade for the grid: reduce opacity near the very top */
    -webkit-mask-image: linear-gradient(to bottom,
            rgba(0, 0, 0, 0) 0px,
            rgba(0, 0, 0, 0.35) 40px,
            rgba(0, 0, 0, 0.7) 120px,
            rgba(0, 0, 0, 1) 200px);
    mask-image: linear-gradient(to bottom,
            rgba(0, 0, 0, 0) 0px,
            rgba(0, 0, 0, 0.35) 40px,
            rgba(0, 0, 0, 0.7) 120px,
            rgba(0, 0, 0, 1) 200px);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
}

/* Center fade gradient overlay for grid */
.search-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center,
            rgba(var(--secondary-color-rgb), 0.0) 0%,
            rgba(var(--secondary-color-rgb), 0.3) 40%,
            rgba(var(--secondary-color-rgb), 0.6) 60%,
            rgba(var(--secondary-color-rgb), 0.8) 80%,
            rgba(var(--secondary-color-rgb), 1.0) 100%);
    z-index: 1;
    pointer-events: none;
    transition: var(--transition);
}

/* Search container контентін z-index жоғарылату */
.search-container>* {
    position: relative;
    z-index: 2;
}

/* Survey Banner */
/* Survey Banner */
.survey-banner {
    position: fixed;
    bottom: 50px;
    left: 8px;
    right: 8px;
    max-width: 420px;
    background: #ffffff;
    /* Жай ақ түс */
    border-radius: 22px;
    /* 20->22px */
    padding: 14px 20px;
    /* Көлеңке: жұмсақ бірақ айқын қара түсті */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
    z-index: 998;
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
    /* Жұқа шеткі линия */
    border: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    /* Фондық иконка сыртқа шықпауы үшін */
}

/* Variants - Background енді бәрінде ақ, тек кнопка түсі өзгереді. Сондықтан variant background-тарды алып тастаймыз немесе override жасаймыз */
.survey-banner.variant-1,
.survey-banner.variant-2,
.survey-banner.variant-3,
.survey-banner.variant-4,
.survey-banner.variant-5 {
    background: #ffffff;
}

.survey-banner.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.survey-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    z-index: 1;
    /* Фондық иконка үстінде болуы үшін */
}

.survey-text {
    flex: 1;
    color: #1a1a1a;
    /* Мәтін қара түсті */
    font-family: 'Inter', sans-serif;
    /* Inter font */
    /* Font өзгерту */
    font-size: 14px;
    /* Өлшемін азайту 15->14px */
    font-weight: 500;
    /* Medium weight */
    line-height: 1.35;
    text-shadow: none;
    /* Shadow керек емес ақ фонда */
}

.survey-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    /* Default button style */
    background: #000;
    color: #fff;
    font-family: 'Inter', sans-serif;
    /* Inter font */
    /* Font өзгерту */
    font-size: 14px;
    font-weight: 500;
    /* Medium weight */
    border-radius: 19px;
    /* 14->17->19px */
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

/* Button colors per variant */
/* 1. Қателік (variant-1) - Қызыл */
.survey-banner.variant-1 .survey-button {
    background-color: #FF3B30;
    /* System Red */
    color: #fff;
}

/* 2. Telegram (variant-2) - #0088CC */
.survey-banner.variant-2 .survey-button {
    background-color: #0088CC;
    color: #fff;
}

/* 3. Instagram (variant-3) - Black */
.survey-banner.variant-3 .survey-button {
    background: #000000;
    color: #fff;
}

/* 4. JUZ40 (variant-4) - #2e768f */
.survey-banner.variant-4 .survey-button {
    background-color: #2e768f;
    color: #fff;
}

/* 5. Ұсыныс (variant-5) - Күлгін */
.survey-banner.variant-5 .survey-button {
    background-color: #8A2BE2;
    color: #fff;
}

.survey-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    /* Hover-де color өзгертпейміз, тек shadow/transform */
}


.survey-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: #ffffff;
}

.survey-button:active {
    transform: translateY(0) scale(0.98);
}

/* Social media icons for search page */
.social-icons {
    position: fixed;
    bottom: 8px;
    left: 8px;
    display: flex;
    flex-direction: row;
    gap: 6px;
    z-index: 999;
    transition: var(--transition);
}

.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: var(--primary-color);
    text-decoration: none;
    transition: transform 0.15s ease;
    opacity: 0.5;
}

.social-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.social-icon:hover {
    transform: scale(1.08);
    opacity: 1;
    transition: transform 0.15s ease, opacity 0.15s ease;
    /* Only transform and opacity transition */
}

.social-icon.instagram:hover {
    color: #e4405f !important;
    transition: none;
    /* Instant color change */
}

.social-icon.telegram:hover {
    color: #0088cc !important;
    transition: none;
    /* Instant color change */
}

.social-icon.tiktok:hover {
    color: #fe2c55 !important;
    transition: none;
    /* Instant color change */
}

.social-icon.threads:hover {
    color: #000000 !important;
    transition: none;
    /* Instant color change */
}

/* Dark theme hover colors */
[data-theme="dark"] .social-icon.instagram:hover {
    color: #fd5949 !important;
    transition: none;
    /* Instant color change */
}

[data-theme="dark"] .social-icon.telegram:hover {
    color: #229ed9 !important;
    transition: none;
    /* Instant color change */
}

[data-theme="dark"] .social-icon.tiktok:hover {
    color: #ff0050 !important;
    transition: none;
    /* Instant color change */
}

[data-theme="dark"] .social-icon.threads:hover {
    color: #ffffff !important;
    transition: none;
    /* Instant color change */
}

/* Hide social icons when searching to avoid blocking content */
.search-container.searching~.social-icons {
    opacity: 0;
    visibility: hidden;
}

/* Hide survey banner when searching */
.search-container.searching~.survey-banner {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Legal links for search page */
.legal-links {
    position: fixed;
    bottom: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 999;
    font-size: 12px;
    line-height: 14px;
    transition: var(--transition);
}

/* JUZ40 стильдері juz40.css файлына көшірілді */

.legal-link {
    color: var(--primary-color);
    text-decoration: none;
    opacity: 0.5;
    transition: opacity 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.legal-link:hover {
    opacity: 1;
    color: rgba(var(--current-subject-color-rgb), 1);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

.legal-separator {
    color: var(--primary-color);
    opacity: 0.3;
    font-weight: 300;
    user-select: none;
}

/* Hide legal links when searching to avoid blocking content */
.search-container.searching~.legal-links {
    opacity: 0;
    visibility: hidden;
}

/* Promotional message for search */
.search-promo-message {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    font-size: 14px;
    color: var(--primary-color);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.search-container.searching .search-promo-message {
    opacity: 1;
    visibility: visible;
}

.promo-link {
    color: rgba(var(--current-subject-color-rgb), 1);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.promo-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
    color: rgba(var(--current-subject-color-rgb), 0.8);
}

/* Mobile responsive legal links */
@media (max-width: 768px) {

    /* Автор(лар) атауы – мобильде сәл кіші */
    .book-author {
        font-size: 14px;
        line-height: 18px;
    }

    /* Subject (Пән) dropdown: на мобильном открывать вправо, левый край = левому краю кнопки */
    .search-filters-row .custom-select[data-type="subject"] .select-dropdown {
        left: 0 !important;
        right: auto !important;
        transform: none !important;
        /* Сохраняем ширину по содержимому, но не меньше ширины триггера */
        min-width: 100%;
        max-width: calc(100vw - 40px);
    }

    /* Уменьшенный dropdown для круглых кнопок С / Б */
    .search-filters-row .custom-select[data-type="grade"] .select-dropdown,
    .search-filters-row .custom-select[data-type="publisher"] .select-dropdown {
        border-radius: 14px;
        padding: 4px 0;
        min-width: 170px !important;
        max-width: 220px !important;
        max-height: 150px;
        font-size: 14px;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    }

    .search-filters-row .custom-select[data-type="grade"] .select-dropdown .select-option,
    .search-filters-row .custom-select[data-type="publisher"] .select-dropdown .select-option {
        padding: 10px 14px;
        font-size: 14px;
    }

    .search-filters-row .custom-select[data-type="grade"] .select-dropdown .select-option.selected,
    .search-filters-row .custom-select[data-type="publisher"] .select-dropdown .select-option.selected {
        border-radius: 10px;
    }

    .legal-links {
        bottom: 6px;
        right: 6px;
        font-size: 11px;
        gap: 4px;
    }

    /* Move legal links up when search is active on mobile */
    .search-container.searching~.legal-links {
        opacity: 0;
        visibility: hidden;
    }

    /* Survey Banner Mobile */
    .survey-banner {
        bottom: 40px;
        left: 8px;
        right: 8px;
        max-width: calc(100vw - 16px);
        padding: 14px 16px;
        border-radius: 20px;
    }

    .survey-content {
        gap: 12px;
    }

    .survey-text {
        font-size: 13px;
    }

    .survey-button {
        padding: 9px 20px;
        font-size: 14px;
        border-radius: 16px;
    }

    .search-container.searching~.survey-banner {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    /* Mobile promotional message */
    .search-promo-message {
        bottom: 2px;
        font-size: 11px;
        padding: 8px 12px;
        margin: 0 8px;
        white-space: nowrap;
        text-align: center;
        max-width: calc(100vw - 20px);
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .search-container.searching~.social-icons {
        opacity: 0;
        visibility: hidden;
    }

    .social-icon {
        width: 20px;
        height: 20px;
    }

    .social-icon svg {
        width: 14px;
        height: 14px;
    }
}



/* Search filters енді жасырылған */
.search-filters {
    display: none;
}

.search-container.searching {
    justify-content: flex-start;
    padding: 20px 20px 120px 20px;
    /* Bottom padding for fixed search box */
}

.search-title {
    font-size: clamp(28px, 5vw, 36px);
    font-weight: 700;
    /* Жирный шрифт */
    margin-bottom: 30px;
    margin-top: 0;
    color: var(--primary-color);
    max-width: 600px;
    transition: var(--transition);
    line-height: 1.2;
    letter-spacing: -0.02em;
    /* Заманауи letter spacing */
}

/* "мәлімет" сөзі үшін арнайы стиль */
.search-title .highlight-word {
    color: rgba(var(--current-subject-color-rgb), 1);
    transition: color 0.4s ease;
}

.search-container.searching .search-title {
    display: none;
}

.search-box {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    /* Тіктөртбұрыш форма - border radius арттыру */
    max-width: min(700px, 90vw);
    /* Кенірек ету */
    width: 100%;
    margin-bottom: 30px;
    transition: var(--transition);
    background: var(--secondary-color);
    padding: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Іздеу жолағы контейнері */
.search-input-row {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 4px;
    position: relative;
    border: none;
    /* Сыртқы линияны алып тастау */
    border-radius: 50px;
    background: var(--secondary-color);
}

/* Іздеу input контейнері автотолтыру үшін */
.search-input-container {
    flex: 1;
    position: relative;
}

/* Іздеу input стилі - енді батырмасыз */
.search-input {
    width: 100%;
    padding: clamp(6px, 1.2vw, 10px) clamp(10px, 2vw, 14px);
    border: none;
    border-radius: 50px;
    font-size: clamp(14px, 3vw, 16px);
    background-color: transparent;
    color: var(--primary-color);
    transition: var(--transition);
    position: relative;
    z-index: 2;
}

.search-input:focus {
    outline: none;
}

/* Inline Autocomplete Suggestion */
.inline-suggestion {
    position: absolute;
    top: 50%;
    left: 0;
    /* JavaScript-те динамикалық өзгереді */
    transform: translateY(-50%);
    font-size: clamp(14px, 3vw, 16px);
    color: rgba(var(--primary-color-rgb), 0.4);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    z-index: 1;
    font-family: inherit;
    line-height: 1;
}

.search-input::placeholder {
    color: #999;
}

/* Автотолтыру ұсыныстары */
.search-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: var(--hover-color);
}

.suggestion-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.suggestion-meta {
    font-size: 12px;
    color: var(--primary-color);
    opacity: 0.6;
}

/* Іздеу батырмасы - енді екінші қатарда */
.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(36px, 7vw, 42px);
    height: clamp(36px, 7vw, 42px);
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    /* Тек қажетті transition-дар */
    opacity: 0.3;
    /* Бастапқыда прозрачный */
    pointer-events: none;
    /* Басылмайтын етіп қою */
}

/* Мәтін бар кезде іздеу батырмасы белсенді */
.search-btn.active {
    opacity: 1;
    pointer-events: auto;
}

.search-btn.active:hover {
    opacity: 0.9;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Фильтрлер қатары */
.search-filters-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 6px 2px 6px;
    /* Екінші қатарға көбірек padding, фигура бұрышынан алыстау */
}

/* Фильтрлер тобы */
.search-filters-row .custom-select {
    min-width: auto;
    /* Минималды кеністі алып тастау */
    flex: 0 0 auto;
    max-width: none;
    /* Максималды кеністі шектеуін алып тастау */
    width: auto;
    /* Кеністі мазмұнға бейімдеу */
}

/* Іздеу батырмасы оң жаққа */
.search-btn {
    margin-left: auto;
    flex-shrink: 0;
}

.search-container.searching .search-box {
    position: fixed;
    bottom: clamp(10px, 2vh, 20px);
    left: clamp(10px, 2vw, 20px);
    right: clamp(10px, 2vw, 20px);
    transform: none;
    z-index: 998;
    background-color: var(--secondary-color);
    padding: 6px;
    /* Бастапқы кездегідей кішкентай padding */
    border-radius: clamp(12px, 3vw, 20px);
    /* Сәл үлкен border-radius */
    border: 1px solid var(--border-color);
    margin: 0 auto;
    max-width: min(700px, 90vw);
    /* Бастапқы кездегідей кенірек */
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Dark theme үшін фон */
[data-theme="dark"] .search-container.searching .search-box {
    background-color: var(--secondary-color);
}

.search-results {
    width: 100%;
    max-width: 800px;
    margin-top: 0;
    transition: var(--transition);
}

.search-container.searching .search-results {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Search Results Enhancements */
.search-container.searching {
    grid-template-columns: 1fr;
}

.search-container.searching .search-box {
    margin-bottom: 30px;
    /* Dropdown-дарды қырқып тастамау үшін */
    overflow: visible;
}

#searchResults {
    margin-top: 20px;
}

/* Navigation buttons styling - updated */
#searchResults button {
    transition: all 0.3s ease;
    font-family: inherit;
}

#searchResults button:not([disabled]):hover {
    background-color: var(--primary-color) !important;
    color: var(--secondary-color) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color) !important;
}

#searchResults button[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--border-color) !important;
    color: var(--primary-color) !important;
}

#searchResults button[disabled]:hover {
    transform: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* Highlight styles for search results - updated with underline styling */
#searchResults mark,
#searchResults span[style*="text-decoration: underline"] {
    background-color: transparent !important;
    color: inherit !important;
    font-weight: normal !important;
    text-decoration: underline !important;
    text-underline-offset: 5px !important;
    text-decoration-thickness: 2px !important;
    padding: 0;
    border-radius: 0;
}

[data-theme="dark"] #searchResults mark,
[data-theme="dark"] #searchResults span[style*="text-decoration: underline"] {
    background-color: transparent !important;
    color: inherit !important;
    text-underline-offset: 5px !important;
    text-decoration-thickness: 2px !important;
}

/* Search navigation info */
.search-navigation {
    background: linear-gradient(135deg, var(--hover-color), var(--secondary-color));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Search result card */
.search-result-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    background: var(--secondary-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    font-weight: 400;
    /* Жұмқарақ етіп орнату */
}

.search-result-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Book info tags */
.book-tags {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.book-tag {
    background: linear-gradient(135deg, var(--hover-color), var(--accent-color));
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Content highlight box */
.content-highlight {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
    position: relative;
    overflow: hidden;
    font-weight: 400;
    /* Жұқарақ етіп орнату */
    line-height: 1.6;
    /* Жолдар арасын кеңейту */
}

.content-highlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--accent-color), transparent);
}

/* Button group styling */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.nav-button {
    padding: 10px 16px;
    background: var(--secondary-color);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    /* 8px-тен 20px-ке өзгертіп дөңгелектеттім */
    color: var(--primary-color);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.nav-button:not([disabled]):hover::before {
    left: 100%;
}

.nav-button:not([disabled]):hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-button[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--hover-color);
}

/* Loading and empty states */
.search-loading,
.search-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--primary-color);
}

.search-loading {
    position: relative;
}

.search-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
    display: block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}





/* Жылтырау анимациясы */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    50% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Ескі градиент анимациясы */
@keyframes titleGradient {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.search-empty-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 15px;
}

/* Responsive improvements for search results */
@media (max-width: 768px) {

    /* Header layout for mobile */
    .header {
        padding: 0 15px;
        height: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .logo {
        font-size: 28px;
    }

    .header-nav {
        order: 2;
        width: 100%;
        gap: 10px;
        background: var(--secondary-color);
        /* Біртұтас фон */
        padding: 10px 15px;
        overflow-x: auto;
        display: flex;
        justify-content: flex-start;
        position: relative;
        /* border-top линиясын алып тастау */
    }

    /* Мобильде scroll кезінде nav */
    .header.scrolled .header-nav {
        background: var(--secondary-color);
        /* Біртұтас фон сақталады */
        /* border-top линиясын алып тастау */
    }

    .header-nav::-webkit-scrollbar {
        display: none;
    }

    .header-nav-item {
        padding: 8px 16px;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        font-size: 15px;
        font-weight: 400;
        /* Inter Regular қалыңдық */
        white-space: nowrap;
        min-width: auto;
        border-radius: 0;
        /* Дөңгелек жиектерді алып тастау */
        margin: 0;
        letter-spacing: 0.2px;
        /* Inter Regular үшін жұмсақ әрiптер арасындағы кеңістік */
        /* Астыңғы сызықты алып тастаймыз */
        transition: all 0.3s ease;
    }

    .header-nav-item:hover {
        color: rgba(var(--current-subject-color-rgb), 1);
    }

    .header-nav-item.active {
        font-weight: 400;
        /* Inter Regular қалыңдық - біріңғай стиль */
        /* Актив күйдегі астыңғы сызықты алып тастаймыз */
    }

    .header-nav-item.active:hover {
        color: var(--primary-color);
    }

    /* Мобильде навигация индикаторы */
    .nav-indicator {
        bottom: 8px;
        height: 2px;
    }

    .header-right {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
    }

    /* Hide theme toggle in mobile */
    .theme-toggle {
        display: none;
    }

    /* Show mobile menu toggle in mobile */
    .mobile-menu-toggle {
        display: flex;
    }

    /* Hide top navigation on mobile */
    .top-nav {
        display: none !important;
    }

    .search-container {
        /* Центрируем search-box по вертикали на мобильных */
        padding: 0 15px 30px 15px;
        /* убрали верхний лишний отступ */
        justify-content: center;
        /* вертикальное центрирование */
        min-height: calc(100vh - 60px);
        /* учитывать высоту header */
        padding-top: 0;
        /* явное обнуление */
    }

    /* Мобильде search-box стилі */
    .search-box {
        padding: 4px;
        border-radius: 16px;
    }

    .search-input-row {
        margin-bottom: 3px;
    }

    /* Мобильде іздеу жолағының текст өлшемін ұлғайту */
    .search-input {
        font-size: clamp(16px, 4vw, 18px);
    }

    .search-filters-row {
        gap: 6px;
        flex-direction: row;
        align-items: center;
        padding: 8px 4px 2px 4px;
        /* Мобильде сәл көбірек padding, фигура бұрышынан алыстау */
    }

    .search-filters-row .custom-select {
        width: auto;
        /* Кеністі мазмұнға бейімдеу */
        min-width: auto;
        /* Минималды кеністі алып тастау */
        max-width: none;
        /* Максималды кеністі шектеуін алып тастау */
        flex: 0 0 auto;
        /* Өз мөлшерінде қалу */
    }

    /* Мобильде іздеу батырмасын домалақ ету */
    .search-btn {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        margin-left: auto;
        margin-top: 0;
        flex-shrink: 0;
        opacity: 0.3;
        /* Бастапқыда прозрачный */
        pointer-events: none;
    }

    /* Мобильде белсенді іздеу батырмасы */
    .search-btn.active {
        opacity: 1;
        pointer-events: auto;
    }


    .search-title {
        margin-top: 0;
        margin-bottom: 25px;
    }

    .search-container.searching .search-box {
        margin-bottom: 20px;
        padding: 4px;
        /* Мобильде де кішкентай padding */
        max-width: min(700px, 90vw);
        /* Мобильде де кенірек */
    }

    /* Desktop фильтры теперь отображаются на всех устройствах */
    .search-filters-row .custom-select[data-type="grade"],
    .search-filters-row .custom-select[data-type="publisher"] {
        display: flex;
    }
}

@media (max-width: 768px) {

    /* Компактные круглые кнопки для мобильных устройств */
    .search-filters-row .custom-select[data-type="grade"] .select-text,
    .search-filters-row .custom-select[data-type="publisher"] .select-text {
        display: none;
    }

    .search-filters-row .custom-select[data-type="grade"] .select-trigger::before {
        content: "С";
        font-weight: 600;
        font-size: 16px;
        color: var(--primary-color);
    }

    .search-filters-row .custom-select[data-type="publisher"] .select-trigger::before {
        content: "Б";
        font-weight: 600;
        font-size: 16px;
        color: var(--primary-color);
    }

    .search-filters-row .custom-select[data-type="grade"] .select-trigger,
    .search-filters-row .custom-select[data-type="publisher"] .select-trigger {
        width: 40px;
        height: 40px;
        min-width: 40px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    .search-filters-row .custom-select[data-type="grade"] .select-arrow,
    .search-filters-row .custom-select[data-type="publisher"] .select-arrow {
        display: none;
    }

    .search-result-card {
        padding: 20px;
    }

    .content-highlight {
        padding: 15px;
    }

    .main-content {
        margin-left: 0;
        margin-top: 60px;
        min-height: calc(var(--app-height, 100vh) - 60px);
    }

    /* Header improvements for mobile */
    .header {
        padding: 0 15px;
        height: 55px;
    }

    .header-right {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
    }

    /* Hide theme toggle in mobile */
    .theme-toggle {
        display: none;
    }

    /* Show mobile menu toggle in mobile */
    .mobile-menu-toggle {
        display: flex;
    }

    .logo {
        font-size: 28px;
    }

    /* Мобильдегі select dropdown бейімдеу */
    .select-dropdown {
        left: 50%;
        /* Ортаға орналастыру */
        transform: translateX(-50%);
        /* Тек орталау, анимация жоқ */
        width: max-content;
        /* Мазмұнға сай кеністі */
        min-width: 200px;
        /* Минимум кеністі арттыру */
        max-width: calc(100vw - 40px);
        /* Экран шегінен шықпау */
    }

    .custom-select.active .select-dropdown {
        transform: translateX(-50%);
        /* Тек орталау сақталады */
    }
}

/* Animation for search results appearance */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.search-result-card {
    animation: fadeInUp 0.5s ease;
}

/* Context expansion buttons styling */
#searchResults button[id^="expand"] {
    transition: all 0.3s ease !important;
}

#searchResults button[id^="expand"]:not([disabled]):hover {
    background-color: var(--primary-color) !important;
    color: var(--secondary-color) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    border-color: var(--primary-color) !important;
}

#searchResults button[id^="expand"][disabled] {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

#searchResults button[id^="expand"][disabled]:hover {
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    background-color: var(--secondary-color) !important;
}

/* Context sentences styling */
.context-sentence {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--primary-color);
    opacity: 0.7;
    padding: 12px;
    border-left: 3px solid var(--border-color);
    background-color: var(--hover-color);
    border-radius: 6px;
    margin: 8px 0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.context-sentence::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color), var(--border-color));
    opacity: 0.6;
}

.context-sentence:hover {
    opacity: 0.9;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Mobile responsive for context expansion */
@media (max-width: 768px) {

    /* Context expansion layout for mobile */
    #searchResults .context-expansion-container {
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Мобильді көріністе expand батырмаларын жоғарғы бөлікке орналастыру */
    #searchResults div[style*="display: flex; gap: 16px"] {
        flex-direction: column !important;
        gap: 12px !important;
    }

    /* Батырмалар контейнерін жоғарғы бөлікке орналастыру */
    #searchResults div[style*="display: flex; flex-direction: column; gap: 8px"] {
        order: -1 !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 20px !important;
        margin-bottom: 16px !important;
    }

    /* Context buttons row on mobile */
    #searchResults .context-buttons {
        flex-direction: row !important;
        justify-content: center !important;
        gap: 20px !important;
        order: -1;
        /* Show buttons above content on mobile */
    }

    #searchResults button[id^="expand"] {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }

    /* Main result content full width on mobile */
    #searchResults .main-result-content {
        flex: none !important;
        width: 100% !important;
    }

    /* Негізгі нәтиже контейнерін толық енімен орналастыру */
    #searchResults div[style*="flex: 1"] {
        flex: none !important;
        width: 100% !important;
    }

    /* Негізгі сөйлем фонының енін search-box енiмен сәйкестендiру: сыртқы обертка padding-ын алып тастау */
    #searchResults div[style*="padding: 16px;"] {
        padding: 0 !important;
    }

    /* Контейнердің max-width-ы search-box-пен бірдей, ортасына туралау */
    #mainResultContainer {
        width: 100% !important;
        max-width: min(700px, 90vw) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Icon states for each navigation item */
.nav-item[data-page="search"] .search-icon-default {
    display: block;
}

.nav-item[data-page="search"] .search-icon-active {
    display: none !important;
}

.nav-item[data-page="reading"] .reading-icon-default {
    display: block;
}

.nav-item[data-page="reading"] .reading-icon-active {
    display: none !important;
}

.nav-item[data-page="learn"] .learn-icon-default {
    display: block;
}

.nav-item[data-page="learn"] .learn-icon-active {
    display: none !important;
}

.nav-item[data-page="test"] .test-icon-default {
    display: block;
}

.nav-item[data-page="test"] .test-icon-active {
    display: none !important;
}

.nav-item[data-page="about"] .about-icon-default {
    display: block;
}

.nav-item[data-page="about"] .about-icon-active {
    display: none !important;
}

/* Mobile Menu Styles */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    transition: all 0.3s ease;
}

.burger-line {
    width: 20px;
    height: 2px;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active .burger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .burger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .burger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Sidebar */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--secondary-color);
    z-index: 999;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mobile-sidebar.active {
    transform: translateY(0);
}

/* Мобильді менюді жапқанда анимацияны қайта қою */
.mobile-sidebar:not(.active) .mobile-nav-item,
.mobile-sidebar:not(.active) .mobile-theme-toggle {
    animation: none;
    transform: translateY(-12px);
    opacity: 0;
}

.mobile-sidebar-content {
    padding: calc(70px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header-дің астындағы жұқа линия */
.mobile-sidebar-content::before {
    content: "";
    position: absolute;
    top: 0;
    /* контенттің басы — хедерден кейін */
    left: env(safe-area-inset-left);
    right: env(safe-area-inset-right);
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .mobile-sidebar-content::before {
    background: rgba(255, 255, 255, 0.12);
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* бөлгіш сызықтармен үйлесімді */
}

.mobile-nav-item {
    text-decoration: none;
    color: var(--primary-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 18px;
    /* үйлесімді, оқуға жеңіл */
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: 0.1px;
    padding: 14px 14px;
    /* симметриялы паддинг, сызықсыз таза */
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.25s ease, background-color 0.25s ease;
    position: relative;
    transform: translateY(-12px);
    opacity: 0;
}

/* Тармақтар арасындағы толық емес жұқа бөлгіштер */
.mobile-nav-item::after {
    content: "";
    position: absolute;
    left: 18px;
    /* толық емес болу үшін аздап ішке */
    right: 28px;
    /* оң жақта көбірек демалу */
    bottom: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    transform: scaleX(1);
}

.mobile-nav-item:last-child::after {
    display: none;
}

[data-theme="dark"] .mobile-nav-item::after {
    background: rgba(255, 255, 255, 0.1);
}

/* Анимация тек active sidebar-да іске қосылады (жоғарыдан төмен) */
.mobile-sidebar.active .mobile-nav-item {
    animation: slideDownFade 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.mobile-sidebar.active .mobile-nav-item:nth-child(1) {
    animation-delay: 0.1s;
}

.mobile-sidebar.active .mobile-nav-item:nth-child(2) {
    animation-delay: 0.15s;
}

.mobile-sidebar.active .mobile-nav-item:nth-child(3) {
    animation-delay: 0.2s;
}

.mobile-sidebar.active .mobile-nav-item:nth-child(4) {
    animation-delay: 0.25s;
}

.mobile-sidebar.active .mobile-nav-item:nth-child(5) {
    animation-delay: 0.3s;
}

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

.mobile-nav-item:hover,
.mobile-nav-item:focus-visible {
    color: rgba(var(--current-subject-color-rgb), 1);
    background: var(--hover-color);
    outline: none;
}

/* Dark theme үшін hover фонды жұмсарту */
[data-theme="dark"] .mobile-nav-item:hover,
[data-theme="dark"] .mobile-nav-item:focus-visible {
    background: rgba(255, 255, 255, 0.06);
}

.mobile-nav-item.active {
    color: rgba(var(--current-subject-color-rgb), 1);
    font-weight: 500;
}

/* Mobile Theme Toggle */
.mobile-theme-toggle {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 0;
    transform: translateX(-20px);
    opacity: 0;
}

/* Анимация тек active sidebar-да іске қосылады */
.mobile-sidebar.active .mobile-theme-toggle {
    animation: slideDownFade 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    animation-delay: 0.4s;
}

.mobile-theme-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    color: var(--primary-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    padding: 12px 0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    width: 44px;
    /* иконканы орталау үшін бекітілген өлшем */
    height: 44px;
    justify-content: center;
    border-radius: 12px;
    position: relative;
}

/* Hover кезінде фон өзгермейді, түс те сол күйі қалады */
.mobile-theme-btn:hover {
    background: transparent;
    color: inherit;
    opacity: 1;
}

.mobile-theme-btn:active {
    transform: scale(0.96);
}

/* Иконкаларды қабаттап, жұмсақ ауысу анимациясы (desktop сияқты) */
.mobile-theme-btn svg {
    position: absolute;
    width: 22px;
    height: 22px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-theme-btn .mobile-sun-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0.8);
}

.mobile-theme-btn .mobile-moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Тақырып dark болса — күн иконкасы көрінеді, ай жоғалады */
[data-theme="dark"] .mobile-theme-btn .mobile-sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="dark"] .mobile-theme-btn .mobile-moon-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0.8);
}

/* JS қосатын .hidden анимацияны бұзбасын деп, кнопка ішінде оны бейтараптандырамыз */
.mobile-theme-btn .hidden {
    display: block !important;
}

.mobile-theme-text {
    display: none;
}

.mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Dark theme үшін overlay түсін жақсарту */
[data-theme="dark"] .mobile-sidebar-overlay {
    background: rgba(0, 0, 0, 0.3);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        margin-left: 15px;
    }

    .header {
        padding: 0 15px;
        height: 60px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0;
    }

    .header-nav {
        display: none;
    }

    .header-right {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .header-left {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 0;
        width: auto;
    }

    /* Мобильдегі меню тармақтарының заманауи шрифті және аздап үлкен өлшемі */
    .mobile-nav-item {
        font-family: "SF Pro Text", "SF Pro Display", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        font-size: 20px;
        font-weight: 500;
        /* сәл қанығырақ — оқылымдылық үшін */
    }

    .logo-link {
        gap: 6px;
    }

    .logo {
        font-size: 28px;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 15px;
        height: 55px;
    }

    .main-content {
        margin-top: 55px;
        min-height: calc(var(--app-height, 100vh) - 55px);
    }

    .mobile-sidebar {
        width: 100vw;
        left: 0;
        transform: translateY(-100%);
    }

    .logo {
        font-size: 26px;
    }

    .logo-icon {
        width: 22px;
        height: 22px;
    }
}