/* =========================================
   ПЕРЕМЕННЫЕ ДЛЯ СВЕТЛОЙ/ТЕМНОЙ ТЕМЫ
   ========================================= */
:root {
    --bg-main: #fcfbf8;
    --text-main: #1a1a1a;
    --text-muted: #666;

    --header-bg: rgba(252, 251, 248, 0.55);
    --header-border: rgba(0, 0, 0, 0.06);

    --nav-link: #618296;
    --nav-link-hover: #d0ae8b;
    --toggle-bg: rgba(0, 0, 0, 0.05);

    --btn-primary-bg: #d0ae8b;
    --btn-primary-text: #fff;

    --hero-title: #1a1a1a;
    --hero-subtitle-bg-desk: #d0ae8b;
    --hero-subtitle-text-desk: #fff;
    --hero-subtitle-border-desk: #618296;

    --card-bg: rgba(255, 255, 255, 0.55);
    --card-border: rgba(255, 255, 255, 0.4);
    --card-shadow: rgba(97, 130, 150, 0.08);

    --heading-color: #618296;

    --btn-tg-bg: #618296;
    --btn-tg-text: #fff;
    --btn-tg-border: transparent;

    --faq-tag-bg: #fff;
    --faq-tag-text: #618296;
    --faq-tag-border: #d0ae8b;

    --footer-bg: linear-gradient(180deg, #619a8c 0%, #87beaa 100%);
    --footer-border: transparent;
    --footer-title: #fff;
    --footer-text: rgba(255, 255, 255, 0.9);

    --story-bg: linear-gradient(180deg, #F5EDE4 0%, #EDE3D8 50%, #E5D9CC 100%);
    --story-text: #1a1a1a;
    --story-heading: #618296;
    --story-para: rgba(0, 0, 0, 0.8);
    --story-tip-bg: rgba(97, 130, 150, 0.07);
    --story-tip-border: rgba(208, 174, 139, 0.5);
    --story-tip-h4: #618296;
    --story-tip-p: rgba(0, 0, 0, 0.65);
    --story-tip-shadow: rgba(0, 0, 0, 0.06);
    --story-final: #1a1a1a;
    --story-divider: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    --bg-main: #1A2A3A;
    --text-main: #fcfbf8;
    --text-muted: rgba(255, 255, 255, 0.7);

    --header-bg: rgba(15, 25, 35, 0.45);
    --header-border: rgba(255, 255, 255, 0.08);

    --nav-link: #fcfbf8;
    --toggle-bg: rgba(255, 255, 255, 0.15);

    --btn-primary-bg: #d0ae8b;
    --btn-primary-text: #1a1a1a;

    --hero-title: #fff;
    --hero-subtitle-bg-desk: #d0ae8b;
    --hero-subtitle-text-desk: #1a1a1a;
    --hero-subtitle-border-desk: transparent;

    --card-bg: rgba(255, 255, 255, 0.04);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-shadow: rgba(0, 0, 0, 0.3);

    --heading-color: #d0ae8b;

    --btn-tg-bg: rgba(208, 174, 139, 0.15);
    --btn-tg-text: #d0ae8b;
    --btn-tg-border: #d0ae8b;

    --faq-tag-bg: rgba(255, 255, 255, 0.05);
    --faq-tag-text: #fcfbf8;
    --faq-tag-border: #374151;

    --footer-bg: linear-gradient(180deg, #1A2A3A 0%, #243D52 100%);
    --footer-border: #374151;
    --footer-title: #d0ae8b;
    --footer-text: rgba(255, 255, 255, 0.8);

    --story-bg: linear-gradient(180deg, #1A2634 0%, #2B4254 50%, #405F73 100%);
    --story-text: #fff;
    --story-heading: #d0ae8b;
    --story-para: rgba(255, 255, 255, 0.95);
    --story-tip-bg: rgba(255, 255, 255, 0.08);
    --story-tip-border: rgba(208, 174, 139, 0.4);
    --story-tip-h4: #d0ae8b;
    --story-tip-p: rgba(255, 255, 255, 0.8);
    --story-tip-shadow: rgba(0, 0, 0, 0.2);
    --story-final: #fff;
    --story-divider: rgba(255, 255, 255, 0.05);
}

/* =========================================
   БАЗОВЫЕ СТИЛИ
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Шапка */
.header {
    background: transparent;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: calc(18px + env(safe-area-inset-top)) 28px 18px;
    box-shadow: none;
    transition: none;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1300px;
    background: var(--header-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--header-border);
    border-radius: 100px;
    padding: 12px 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 40px;
}

.nav {
    display: flex;
    align-items: center;
}

.nav .nav-link {
    text-decoration: none;
    color: var(--nav-link);
    margin-left: 8px;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid var(--header-border);
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.nav .nav-link:hover {
    color: var(--nav-link-hover);
    border-color: rgba(208, 174, 139, 0.4);
    background: rgba(208, 174, 139, 0.08);
}

.theme-toggle {
    cursor: pointer;
    font-size: 20px;
    margin-left: 20px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--toggle-bg);
    transition: transform 0.2s, background-color 0.4s;
    user-select: none;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Кнопки */
.btn-primary {
    background: linear-gradient(135deg, #d0ae8b 0%, #c49b74 100%);
    color: var(--btn-primary-text) !important;
    padding: 12px 26px;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.4s ease;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 20px rgba(208, 174, 139, 0.3);
    border: none;
    letter-spacing: 0.3px;
}

.btn-primary:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 30px rgba(208, 174, 139, 0.5);
}

.btn-telegram {
    background-color: var(--btn-tg-bg);
    border: 1px solid var(--btn-tg-border);
    color: var(--btn-tg-text);
    padding: 15px 25px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    width: 100%;
    text-align: center;
    margin-top: 10px;
    transition: all 0.3s;
}

.btn-telegram:hover {
    filter: brightness(1.1);
}

.btn-pulse {
    box-shadow: 0 0 0 0 rgba(208, 174, 139, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(208, 174, 139, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(208, 174, 139, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(208, 174, 139, 0);
    }
}

/* Анимации появления */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Главный экран */
.hero {
    position: relative;
    min-height: 100vh;
    text-align: center;
    padding: 60px 0;
}

.bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    opacity: 0.5;
    z-index: -1;
    transition: background-color 0.4s;
}

.hero-content {
    position: relative;
    z-index: 1;
    width: 100%;
    padding-top: 40px;
}

.hero h1 {
    font-size: 52px;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 28px;
    color: var(--hero-title);
    transition: color 0.4s;
    animation: fadeInUp 1s ease both;
    letter-spacing: -0.5px;
}

.hero .subtitle {
    font-size: 18px;
    color: var(--hero-subtitle-text-desk);
    background-color: var(--hero-subtitle-bg-desk);
    display: inline-block;
    padding: 10px 30px;
    border-radius: 50px;
    border: 1px solid var(--hero-subtitle-border-desk);
    margin-bottom: 40px;
    font-weight: 600;
    box-shadow: 0 6px 24px rgba(208, 174, 139, 0.25);
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
    animation: fadeInUp 1s ease 0.15s both;
}

.story-card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--card-border);
    padding: 44px;
    border-radius: 28px;
    box-shadow: 0 20px 60px var(--card-shadow);
    max-width: 800px;
    margin: 0 auto;
    text-align: left;
    transition: background 0.4s, border-color 0.4s;
    animation: fadeInUp 1s ease 0.3s both;
}

.family-photos {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.family-photos img {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--nav-link-hover);
    padding: 4px;
    background-color: transparent;
}

/* Разделы на главной */
section h2 {
    font-size: 36px;
    text-align: center;
    margin-bottom: 12px;
    color: var(--heading-color);
    transition: color 0.4s;
    letter-spacing: -0.3px;
}

.section-desc {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    transition: color 0.4s;
}

.diagnoses,
.faq {
    padding: 60px 0;
    position: relative;
    z-index: 10;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 28px;
    border-radius: 20px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 32px var(--card-shadow);
    transition: transform 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
    position: relative;
}

.card:hover {
    transform: translateY(-8px);
    border-color: var(--nav-link-hover);
    box-shadow: 0 20px 48px rgba(208, 174, 139, 0.18);
}

.card h3 {
    color: var(--heading-color);
    margin-bottom: 8px;
    transition: color 0.4s;
}

.animate-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-card.show {
    opacity: 1;
    transform: translateY(0);
}

.card:nth-child(2) {
    transition-delay: 0.1s;
}

.card:nth-child(3) {
    transition-delay: 0.2s;
}

.card:nth-child(4) {
    transition-delay: 0.3s;
}

.card:nth-child(5) {
    transition-delay: 0.4s;
}

.card:nth-child(6) {
    transition-delay: 0.5s;
}

.join-action {
    margin-top: 50px;
    text-align: center;
}

.join-btn-large {
    font-size: 18px;
    padding: 16px 36px;
    width: auto;
}

.faq-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.faq-tag {
    background: var(--faq-tag-bg);
    padding: 12px 20px;
    border-radius: 50px;
    text-decoration: none;
    color: var(--faq-tag-text);
    border: 1px solid var(--faq-tag-border);
    font-size: 15px;
    transition: all 0.2s;
}

.faq-tag:hover {
    background: var(--nav-link-hover);
    border-color: var(--nav-link-hover);
    color: #fff;
}

/* Подвал */
.footer {
    padding: 80px 0 40px;
    background: var(--footer-bg);
    border-top: none;
    position: relative;
    z-index: 10;
    transition: background 0.4s;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand {
    flex: 1;
    min-width: 250px;
}

.footer-logo {
    height: 45px;
    margin-bottom: 15px;
}

.footer-slogan {
    font-size: 16px;
    line-height: 1.5;
    color: var(--footer-text);
    max-width: 320px;
}

.footer-links-col h4,
.footer-contact h4 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--footer-title);
}

.footer-links-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 150px;
}

.footer-links-col a {
    text-decoration: none;
    color: var(--footer-text);
    font-size: 16px;
    transition: opacity 0.2s;
}

.footer-links-col a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.footer-contact {
    flex: 1;
    min-width: 200px;
}

.footer-contact .phone {
    font-size: 20px;
    font-weight: 600;
    color: var(--footer-title);
    text-decoration: none;
    display: block;
    margin-bottom: 5px;
}

.footer .small-text {
    font-size: 14px;
    color: var(--text-muted);
}

.footer-bottom {
    padding-top: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.footer-bottom .small-text {
    color: var(--footer-text);
    opacity: 0.8;
}

/* =========================================
   ИДЕАЛЬНАЯ АДАПТАЦИЯ ДЛЯ ТЕЛЕФОНОВ (Главная)
   ========================================= */
@media (max-width: 768px) {
    :root {
        --hero-subtitle-bg: #fcfbf8;
        --hero-subtitle-text: #618296;
        --hero-subtitle-border: #d0ae8b;
    }

    [data-theme="dark"] {
        --hero-subtitle-bg: rgba(208, 174, 139, 0.15);
        --hero-subtitle-text: #d0ae8b;
        --hero-subtitle-border: #d0ae8b;
    }

    .header {
        padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
    }

    .header-inner {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        padding: 8px 16px;
        border-radius: 60px;
    }

    .logo {
        margin-top: 3px;
    }

    .logo img {
        height: 24px;
    }

    .nav {
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
    }

    .nav .nav-link {
        display: none;
    }

    .header-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .theme-toggle {
        margin-left: 6px;
        font-size: 18px;
        width: 34px;
        height: 34px;
    }

    .hero {
        min-height: auto;
        padding: 0 0 10px;
        display: flex;
        flex-direction: column;
    }

    .bg-video {
        position: relative;
        width: 100%;
        height: calc(100vw * 9 / 16);
        object-fit: cover;
        z-index: 1;
    }

    .video-overlay {
        display: none;
    }

    .hero-content {
        padding-top: 25px;
    }

    .hero h1 {
        font-size: 21px;
        max-width: 380px;
        margin: 0 auto 15px;
        line-height: 1.3;
    }

    .hero .subtitle {
        font-size: 12px;
        white-space: nowrap;
        font-weight: 600;
        background-color: var(--hero-subtitle-bg);
        color: var(--hero-subtitle-text);
        border: 2px solid var(--hero-subtitle-border);
        padding: 6px 14px;
        border-radius: 50px;
        display: inline-block;
        margin: 0 auto 20px;
    }

    .story-card {
        padding: 18px;
        border-radius: 16px;
        margin: 0 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        border: 2px solid var(--card-border);
    }

    .family-photos {
        justify-content: space-between;
        gap: 6px;
        margin-bottom: 15px;
    }

    .family-photos img {
        width: 31%;
        height: auto;
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        border-width: 2px;
        padding: 2px;
    }

    .story-text p {
        font-size: 14px;
        line-height: 1.45;
        margin-bottom: 10px;
    }

    .btn-telegram {
        margin-top: 5px;
    }

    .diagnoses {
        padding: 20px 0 20px;
    }

    section h2 {
        font-size: 24px;
    }

    .section-desc {
        font-size: 14px;
        margin-bottom: 25px;
        padding: 0 10px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 10px;
    }

    .card {
        padding: 18px 45px 18px 20px;
        border-radius: 14px;
        box-shadow: none;
        transition: transform 0.15s ease, background-color 0.15s ease;
    }

    .card::after {
        content: '›';
        position: absolute;
        right: 18px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 28px;
        color: var(--nav-link-hover);
        font-weight: 300;
    }

    .card h3 {
        font-size: 16px;
        margin-bottom: 4px;
    }

    .card p {
        font-size: 13px;
        line-height: 1.4;
        color: var(--text-muted);
    }

    .card:active {
        transform: scale(0.97);
        border-color: var(--nav-link-hover);
    }

    .join-action {
        margin-top: 30px;
        padding: 0 10px;
    }

    .join-btn-large {
        width: 100%;
        font-size: 16px;
        padding: 14px 20px;
    }

    .faq {
        padding: 30px 0 40px;
    }

    .faq-tag {
        width: 100%;
        text-align: center;
    }

    .footer {
        padding: 40px 0 30px;
    }

    .footer-top {
        flex-direction: column;
        gap: 30px;
        margin-bottom: 30px;
    }

    .footer-brand,
    .footer-links-col,
    .footer-contact {
        text-align: left;
    }

    .footer-logo {
        height: 35px;
    }

    .footer-bottom {
        text-align: center;
    }
}

/* =========================================
   СТИЛИ ДЛЯ SCROLLYTELLING (История)
   ========================================= */

.story-page {
    background: var(--story-bg);
    color: var(--story-text);
    transition: background 0.4s ease, color 0.4s ease;
}

.story-scene {
    min-height: 90vh;
    display: flex;
    align-items: center;
    padding: 60px 20px;
    border-bottom: 1px solid var(--story-divider);
}

.scene-final {
    flex-direction: column;
    justify-content: center;
    border-bottom: none;
}

.scene-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
}

/* ВОЛШЕБНЫЙ ШРИФТ ДЛЯ ТЕКСТА ИСТОРИИ */
.scene-text h2 {
    font-size: 46px;
    font-family: 'Philosopher', sans-serif;
    color: var(--story-heading);
    margin-bottom: 25px;
    line-height: 1.2;
    transition: color 0.4s;
}

.scene-text p {
    font-size: 21px;
    font-family: 'Philosopher', sans-serif;
    line-height: 1.6;
    color: var(--story-para);
    margin-bottom: 20px;
    text-wrap: pretty;
    transition: color 0.4s;
}

/* Карточка с подсказкой */
.scene-tip {
    background: var(--story-tip-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--story-tip-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 15px 35px var(--story-tip-shadow);
    transition: background 0.4s, border-color 0.4s;
}

.tip-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.scene-tip h4 {
    font-size: 22px;
    color: var(--story-tip-h4);
    margin-bottom: 15px;
    transition: color 0.4s;
}

.scene-tip p {
    font-size: 16px;
    line-height: 1.6;
    color: var(--story-tip-p);
    transition: color 0.4s;
}

.final-message {
    font-size: 28px;
    font-family: 'Philosopher', sans-serif;
    color: var(--story-final);
    margin-bottom: 30px;
    transition: color 0.4s;
}

/* Магия плавного появления и растворения (Кинематографичный эффект) */
.animate-scroll {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
    filter: blur(8px);
    transition: opacity 1s ease-out, transform 1s ease-out, filter 1s ease-out;
}

.animate-scroll.in-view {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

.delay-1 {
    transition-delay: 0.3s;
}

.delay-2 {
    transition-delay: 0.6s;
}

/* Адаптация Скроллителлинга для телефонов */
@media (max-width: 768px) {
    .story-scene {
        min-height: auto;
        padding: 50px 10px;
    }

    .scene-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .scene-text h2 {
        font-size: 30px;
    }

    .scene-text p {
        font-size: 18px;
        text-wrap: pretty;
    }

    .scene-tip {
        padding: 25px;
        border-radius: 16px;
    }

    .tip-icon {
        font-size: 36px;
    }

    .scene-tip h4 {
        font-size: 18px;
    }

    .scene-tip p {
        font-size: 14px;
    }

    .final-message {
        font-size: 24px;
    }
}

/* =========================================
   КНОПКА АУДИОПЛЕЕРА
   ========================================= */
.audio-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #d0ae8b;
    color: #1a1a1a;
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    transition: transform 0.2s, background 0.3s, color 0.3s;
}

.audio-btn:hover {
    transform: scale(1.05);
}

.audio-btn.playing {
    background: #618296;
    color: #fff;
    box-shadow: 0 0 15px rgba(97, 130, 150, 0.6);
}

@media (max-width: 768px) {
    .audio-btn {
        bottom: 20px;
        right: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* =========================================
   ИИ ЧАТ-БОТ — ПРЕМИУМ ДИЗАЙН
   ========================================= */

/* Пульсирующее свечение кнопки */
@keyframes chatBtnGlow {
    0%, 100% { box-shadow: 0 6px 24px rgba(208, 174, 139, 0.35), 0 0 0 0 rgba(208, 174, 139, 0.4); }
    50% { box-shadow: 0 6px 32px rgba(208, 174, 139, 0.55), 0 0 0 8px rgba(208, 174, 139, 0); }
}

/* Появление окна чата */
@keyframes chatWindowIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
        filter: blur(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Мерцание точек загрузки */
@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.chat-open-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    background: linear-gradient(135deg, #d0ae8b 0%, #c49b74 50%, #618296 100%);
    color: #fff;
    border: none;
    border-radius: 60px;
    padding: 16px 28px;
    font-family: 'Philosopher', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.3px;
    animation: chatBtnGlow 3s ease-in-out infinite;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.chat-open-btn .chat-btn-icon {
    font-size: 20px;
    display: flex;
    align-items: center;
}

.chat-open-btn:hover {
    transform: scale(1.07) translateY(-2px);
    filter: brightness(1.08);
}

.chat-open-btn:active {
    transform: scale(0.97);
}

/* Когда чат открыт — кнопка меняет стиль */
.chat-open-btn.active {
    background: linear-gradient(135deg, #618296 0%, #4d6f82 100%);
    animation: none;
    box-shadow: 0 6px 20px rgba(97, 130, 150, 0.4);
}

.chat-window {
    position: fixed;
    bottom: 100px;
    left: 30px;
    width: 380px;
    height: 520px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    z-index: 2001;
    overflow: hidden;
    border: 1.5px solid rgba(208, 174, 139, 0.35);
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.28),
        0 8px 24px rgba(97, 130, 150, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: chatWindowIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Фон для светлой темы — полностью непрозрачный */
.chat-window {
    background: linear-gradient(180deg, #f7f3ee 0%, #f0ebe4 100%);
}

/* Фон для тёмной темы — полностью непрозрачный */
[data-theme="dark"] .chat-window {
    background: linear-gradient(180deg, #1e2d3d 0%, #172330 100%);
    border-color: rgba(208, 174, 139, 0.2);
}

/* Этот класс прячет чат, пока на кнопку не нажали */
.chat-window.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(30px) scale(0.92);
    filter: blur(6px);
    animation: none;
}

/* Заголовок чата — премиальный градиент */
.chat-header {
    background: linear-gradient(135deg, #618296 0%, #4d6f82 40%, #3d5f72 100%);
    color: #fff;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Декоративная полоска на заголовке */
.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #d0ae8b, #e8c4a0, #d0ae8b);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d0ae8b, #c49b74);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-family: 'Philosopher', sans-serif;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.chat-header-info .chat-status {
    font-size: 11px;
    opacity: 0.8;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7be8a4;
    display: inline-block;
    box-shadow: 0 0 6px rgba(123, 232, 164, 0.5);
    animation: pulse 2s infinite;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Кастомный скроллбар */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(208, 174, 139, 0.3);
    border-radius: 10px;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    position: relative;
}

.ai-message {
    background: linear-gradient(135deg, rgba(97, 130, 150, 0.12) 0%, rgba(97, 130, 150, 0.06) 100%);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(97, 130, 150, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .ai-message {
    background: linear-gradient(135deg, rgba(97, 130, 150, 0.2) 0%, rgba(97, 130, 150, 0.1) 100%);
    border-color: rgba(97, 130, 150, 0.2);
}

.user-message {
    background: linear-gradient(135deg, #d0ae8b 0%, #c49b74 100%);
    color: #1a1a1a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(208, 174, 139, 0.3);
}

.chat-input-area {
    display: flex;
    padding: 14px 16px;
    border-top: 1px solid rgba(208, 174, 139, 0.15);
    background: rgba(255, 255, 255, 0.5);
    gap: 10px;
    align-items: center;
}

[data-theme="dark"] .chat-input-area {
    background: rgba(0, 0, 0, 0.2);
    border-top-color: rgba(255, 255, 255, 0.06);
}

#chatInput {
    flex: 1;
    padding: 11px 18px;
    border: 1.5px solid rgba(208, 174, 139, 0.25);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-main);
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#chatInput:focus {
    border-color: #d0ae8b;
    box-shadow: 0 0 0 3px rgba(208, 174, 139, 0.15);
}

[data-theme="dark"] #chatInput {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(208, 174, 139, 0.2);
}

[data-theme="dark"] #chatInput:focus {
    border-color: #d0ae8b;
    box-shadow: 0 0 0 3px rgba(208, 174, 139, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, #618296 0%, #4d6f82 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(97, 130, 150, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(97, 130, 150, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* Брендинг внизу сообщений */
.chat-branding {
    text-align: center;
    padding: 6px 0 2px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.5;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
}

/* Настройки для телефонов */
@media (max-width: 768px) {
    .chat-open-btn {
        bottom: 20px;
        left: 20px;
        padding: 13px 20px;
        font-size: 14px;
        border-radius: 50px;
    }

    .chat-window {
        bottom: 78px;
        left: 12px;
        right: 12px;
        width: auto;
        height: 420px;
        border-radius: 20px;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-header-avatar {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .chat-messages {
        padding: 14px;
    }
}

/* =========================================
   МОБИЛЬНОЕ МЕНЮ
   ========================================= */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: background 0.2s, color 0.4s;
    line-height: 1;
}

.story-page .menu-toggle {
    color: rgba(255, 255, 255, 0.9);
}

.mobile-menu {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 42, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.mobile-menu.open {
    opacity: 1;
    pointer-events: all;
}

.mobile-menu a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 22px;
    font-weight: 600;
    font-family: 'Philosopher', sans-serif;
    padding: 20px 50px;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.2s, color 0.2s;
}

.mobile-menu a:last-child {
    border-bottom: none;
}

.mobile-menu a:active {
    background: rgba(208, 174, 139, 0.15);
    color: #d0ae8b;
}

.mobile-menu-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 28px;
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.mobile-menu-close:active {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
}

/* =========================================
   КНОПКА «НАЗАД»
   ========================================= */
.back-nav {
    padding: 20px 20px 0;
    max-width: 1100px;
    margin: 0 auto;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
}

/* =========================================
   ПОЛОСА ПРОГРЕССА ЧТЕНИЯ
   ========================================= */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #d0ae8b, #e8c4a0);
    z-index: 10001;
    width: 0%;
    border-radius: 0 2px 2px 0;
    transition: width 0.12s linear;
    pointer-events: none;
}

/* =========================================
   ДОПОЛНИТЕЛЬНЫЕ МОБИЛЬНЫЕ СТИЛИ
   ========================================= */
@media (max-width: 768px) {
    .back-nav {
        padding: 15px 16px 0;
    }

    .back-link {
        font-size: 13px;
    }

    .story-scene {
        padding: 40px 16px;
    }

    .scene-text p {
        font-size: 17px;
        line-height: 1.65;
    }

    .audio-btn {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .footer {
        padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 375px) {
    .hero h1 {
        font-size: 19px;
    }

    .scene-text h2 {
        font-size: 26px;
    }

    .scene-text p {
        font-size: 16px;
    }

    .final-message {
        font-size: 20px;
    }
}