/* Основные стили в стиле Apple */
:root {
    /* Цветовая палитра Apple */
    --apple-white: #f5f5f7;
    --apple-light-gray: #e8e8ed;
    --apple-gray: #8e8e93;
    --apple-dark-gray: #1d1d1f;
    --apple-blue: #007aff;
    --apple-light-blue: #5ac8fa;
    --apple-purple: #af52de;
    --apple-pink: #ff2d55;
    --apple-orange: #ff9500;
    --apple-yellow: #ffcc00;
    --apple-green: #34c759;
    
    /* Градиенты Apple */
    --gradient-primary: linear-gradient(135deg, var(--apple-blue) 0%, var(--apple-light-blue) 100%);
    --gradient-secondary: linear-gradient(135deg, var(--apple-purple) 0%, var(--apple-pink) 100%);
    --gradient-success: linear-gradient(135deg, var(--apple-green) 0%, #30d158 100%);
    --gradient-warning: linear-gradient(135deg, var(--apple-orange) 0%, var(--apple-yellow) 100%);
    
    /* Тени Apple */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.2);
    --shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    
    /* Скругления Apple */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 999px;
    
    /* Анимации */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Размеры */
    --header-height: 60px;
    --bottom-nav-height: 70px;
    --container-max-width: 1200px;
}

/* Сброс стилей */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Основные стили */
body.apple-theme {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--apple-white);
    color: var(--apple-dark-gray);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Фоновые элементы */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.floating-circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.1) 0%, rgba(90, 200, 250, 0.1) 100%);
    animation: float 20s ease-in-out infinite;
    animation-delay: var(--delay);
}

.apple-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
    opacity: 0.3;
    pointer-events: none;
}

/* Основной контейнер */
.apple-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

/* Навигация */
.apple-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    height: var(--header-height);
    display: flex;
    align-items: center;
}

.apple-nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 20px;
}

.apple-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
    color: var(--apple-dark-gray);
    text-decoration: none;
}

.apple-logo i {
    font-size: 24px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.apple-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
}

.hamburger span {
    display: block;
    height: 2px;
    background: var(--apple-dark-gray);
    border-radius: 1px;
    transition: var(--transition-normal);
}

.apple-nav-links {
    display: flex;
    gap: 2px;
    align-items: center;
}

.apple-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--apple-gray);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition-normal);
    position: relative;
}

.apple-nav-link:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--apple-dark-gray);
}

.apple-nav-link.active {
    color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.1);
}

.link-indicator {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--apple-blue);
    opacity: 0;
    transition: var(--transition-normal);
}

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

/* Основной контент */
.apple-main-content {
    min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
    padding: 24px 0;
}

.apple-page {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.apple-page.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 0 20px;
}

.apple-title {
    font-size: 40px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.2;
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.apple-subtitle {
    font-size: 18px;
    color: var(--apple-gray);
    max-width: 600px;
    margin: 0 auto;
}

/* Карточки */
.apple-card {
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-normal);
    height: 100%;
}

.glass-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-md);
}

.apple-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.card-header.with-icon {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.gradient-bg {
    background: var(--gradient-primary);
}

.header-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 14px;
    color: var(--apple-gray);
}

.card-body {
    padding: 24px;
}

/* Сетка контента */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 0 20px;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Формы */
.form-group {
    position: relative;
    margin-bottom: 20px;
}

.floating-label {
    position: relative;
}

.floating-label label {
    position: absolute;
    top: 18px;
    left: 16px;
    font-size: 16px;
    color: var(--apple-gray);
    pointer-events: none;
    transition: var(--transition-normal);
    transform-origin: left top;
}

.floating-label textarea:focus ~ label,
.floating-label textarea:not(:placeholder-shown) ~ label {
    transform: translateY(-24px) scale(0.85);
    color: var(--apple-blue);
}

.apple-input {
    width: 100%;
    padding: 18px 16px;
    font-size: 16px;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    transition: var(--transition-normal);
    resize: vertical;
}

.apple-input:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.input-hint {
    font-size: 12px;
    color: var(--apple-gray);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.char-counter {
    text-align: right;
    font-size: 14px;
    color: var(--apple-gray);
    margin-bottom: 20px;
}

/* Кнопки */
.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.apple-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    font-family: inherit;
}

.primary-button {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.secondary-button {
    background: rgba(0, 0, 0, 0.05);
    color: var(--apple-dark-gray);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.secondary-button:hover {
    background: rgba(0, 0, 0, 0.1);
}

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

.primary-button:hover .button-shine {
    left: 100%;
}

/* Отображение мантры */
.mantra-display {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    text-align: center;
    font-size: 18px;
    line-height: 1.6;
    position: relative;
}

.mantra-placeholder {
    color: var(--apple-gray);
}

.mantra-placeholder i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.mantra-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .mantra-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

.action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    font-size: 12px;
    color: var(--apple-dark-gray);
}

.action-button:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.action-button i {
    font-size: 18px;
    margin-bottom: 4px;
}

.analysis-section {
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
}

.analysis-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.analysis-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--apple-gray);
}

.analysis-value {
    font-weight: 500;
    color: var(--apple-dark-gray);
}

/* Примеры */
.examples-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.example-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    border: 1px solid transparent;
}

.example-item:hover {
    background: rgba(0, 122, 255, 0.05);
    border-color: rgba(0, 122, 255, 0.2);
    transform: translateX(4px);
}

.example-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.example-content {
    flex: 1;
}

.example-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.example-content p {
    font-size: 12px;
    color: var(--apple-gray);
}

.example-arrow {
    color: var(--apple-gray);
    opacity: 0;
    transition: var(--transition-normal);
}

.example-item:hover .example-arrow {
    opacity: 1;
}

/* Принципы */
.principles-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.principle-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.02);
    transition: var(--transition-normal);
}

.principle-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(4px);
}

.principle-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.principle-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.principle-content {
    flex: 1;
}

.principle-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.principle-content p {
    font-size: 12px;
    color: var(--apple-gray);
}

/* Аудиоплеер */
.audio-player {
    padding: 16px;
}

.track-info {
    margin-bottom: 20px;
    text-align: center;
}

.track-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.track-subtitle {
    font-size: 14px;
    color: var(--apple-gray);
}

.player-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.player-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--apple-dark-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-normal);
}

.player-button:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.play-button {
    width: 56px;
    height: 56px;
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.volume-control i {
    color: var(--apple-gray);
}

.volume-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--apple-blue);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Методология */
.methodology-content {
    padding: 0 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    text-align: center;
    padding: 24px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 16px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 14px;
    color: var(--apple-gray);
}

.methodology-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .methodology-grid {
        grid-template-columns: 1fr;
    }
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Диаграмма */
.diagram-container {
    margin: 24px 0;
}

.diagram {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.diagram-item {
    flex: 1;
    min-width: 120px;
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    background: rgba(0, 0, 0, 0.02);
}

.diagram-item.input {
    border: 2px solid var(--apple-blue);
}

.diagram-item.filter {
    border: 2px solid var(--apple-purple);
}

.diagram-item.output {
    border: 2px solid var(--apple-green);
}

.diagram-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.diagram-item.input .diagram-icon {
    background: var(--apple-blue);
}

.diagram-item.filter .diagram-icon {
    background: var(--apple-purple);
}

.diagram-item.output .diagram-icon {
    background: var(--apple-green);
}

.diagram-arrow {
    color: var(--apple-gray);
    font-size: 20px;
}

/* Блок кода */
.apple-code {
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 20px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.apple-code pre {
    margin: 0;
}

.apple-code code {
    color: var(--apple-dark-gray);
}

/* Карточка инсайта */
.insight-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(0, 122, 255, 0.05);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--apple-blue);
    margin-top: 20px;
}

.insight-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--apple-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.insight-content h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.insight-content p {
    font-size: 14px;
    color: var(--apple-dark-gray);
}

/* Примеры */
.examples-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.example-item.negative {
    border-left: 4px solid var(--apple-pink);
}

.example-item.positive {
    border-left: 4px solid var(--apple-green);
}

.example-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.example-item.negative .example-header {
    color: var(--apple-pink);
}

.example-item.positive .example-header {
    color: var(--apple-green);
}

.example-text {
    font-size: 14px;
    color: var(--apple-dark-gray);
}

.example-arrow {
    text-align: center;
    color: var(--apple-gray);
    font-size: 20px;
}

/* Практикум */
.practice-content {
    padding: 0 20px;
}

.stages-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    .stages-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stages-container {
        grid-template-columns: 1fr;
    }
}

.stage-card {
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-normal);
}

.stage-card:hover {
    transform: translateY(-8px) scale(1.02);
}

.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.stage-number {
    font-size: 32px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.3;
}

.stage-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stage-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stage-content > p {
    font-size: 14px;
    color: var(--apple-gray);
    margin-bottom: 12px;
}

.stage-details {
    font-size: 13px;
    color: var(--apple-dark-gray);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: var(--transition-normal);
}

.stage-card:hover .stage-details {
    opacity: 1;
    max-height: 100px;
}

.practice-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .practice-grid {
        grid-template-columns: 1fr;
    }
}

/* Тренажер перепрошивки */
.reprogrammer-interface {
    padding: 20px 0;
}

.input-section {
    margin-bottom: 32px;
}

.reprogram-button {
    margin-top: 16px;
    width: 100%;
}

.output-section {
    margin-bottom: 32px;
}

.result-card {
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.old-program {
    background: rgba(255, 45, 85, 0.05);
    border: 1px solid rgba(255, 45, 85, 0.2);
}

.new-program {
    background: rgba(52, 199, 89, 0.05);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

.old-program .result-header {
    color: var(--apple-pink);
}

.new-program .result-header {
    color: var(--apple-green);
}

.result-content {
    font-size: 16px;
    line-height: 1.6;
    color: var(--apple-dark-gray);
}

.transformation-arrow {
    text-align: center;
    margin: 12px 0;
    color: var(--apple-gray);
    font-size: 24px;
}

.instructions {
    padding: 20px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
}

.instructions h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 16px;
}

.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    color: var(--apple-dark-gray);
}

/* Техники */
.techniques-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.technique-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.02);
    transition: var(--transition-normal);
}

.technique-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(4px);
}

.technique-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.technique-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.technique-content p {
    font-size: 13px;
    color: var(--apple-gray);
}

/* Упражнение */
.exercise-content {
    text-align: center;
}

.day-counter {
    margin-bottom: 20px;
}

.day-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.exercise-title {
    font-size: 14px;
    color: var(--apple-gray);
}

.exercise-task {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
}

.exercise-task h4 {
    font-size: 16px;
    margin-bottom: 8px;
}

.exercise-task p {
    font-size: 14px;
    color: var(--apple-dark-gray);
}

.start-exercise {
    width: 100%;
}

/* Библиотека */
.library-content {
    padding: 0 20px;
}

.library-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--apple-gray);
}

.search-input {
    padding-left: 44px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-button {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
    font-size: 14px;
    color: var(--apple-dark-gray);
    cursor: pointer;
    transition: var(--transition-normal);
}

.filter-button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.filter-button.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    min-height: 400px;
}

@media (max-width: 768px) {
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 24px;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--apple-gray);
    margin-bottom: 24px;
}

.mantra-item {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    cursor: pointer;
}

.mantra-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.mantra-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.mantra-category {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: white;
}

.mantra-date {
    font-size: 12px;
    color: var(--apple-gray);
}

.mantra-content {
    margin-bottom: 20px;
}

.mantra-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--apple-dark-gray);
    margin-bottom: 12px;
}

.mantra-query {
    font-size: 14px;
    color: var(--apple-gray);
    font-style: italic;
}

.mantra-actions-mini {
    display: flex;
    gap: 8px;
}

.mantra-action-button {
    flex: 1;
    padding: 8px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--apple-dark-gray);
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.mantra-action-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Нижняя навигация */
.apple-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
}

@media (max-width: 768px) {
    .apple-bottom-nav {
        display: flex;
    }
    
    .apple-main-content {
        min-height: calc(100vh - var(--header-height));
        padding-bottom: calc(var(--bottom-nav-height) + 24px);
    }
}

.bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--apple-gray);
    font-size: 12px;
    transition: var(--transition-normal);
}

.bottom-nav-link.active {
    color: var(--apple-blue);
}

.bottom-nav-link i {
    font-size: 20px;
    margin-bottom: 4px;
}

/* Уведомления */
.apple-notification {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px);
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition-normal);
    z-index: 1001;
    max-width: 400px;
}

.apple-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--apple-dark-gray);
}

.notification-content i {
    color: var(--apple-green);
    font-size: 20px;
}

/* Модальное окно */
.apple-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    backdrop-filter: blur(10px);
}

.apple-modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--apple-dark-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 24px;
}

.help-content h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--apple-dark-gray);
}

.help-content ol,
.help-content ul {
    margin-bottom: 24px;
    padding-left: 24px;
}

.help-content li {
    margin-bottom: 8px;
    color: var(--apple-dark-gray);
}

.help-content kbd {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .apple-nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow-lg);
    }
    
    .apple-nav-links.active {
        display: flex;
    }
    
    .apple-menu-toggle {
        display: block;
    }
    
    .apple-title {
        font-size: 32px;
    }
    
    .apple-subtitle {
        font-size: 16px;
    }
    
    .content-left,
    .content-right {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .apple-container {
        padding: 0 16px;
    }
    
    .apple-title {
        font-size: 28px;
    }
    
    .card-body {
        padding: 20px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .apple-button {
        width: 100%;
    }
}
/* Аккордеон */
.accordion-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.accordion-item {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.6);
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.02);
    transition: var(--transition-normal);
    user-select: none;
}

.accordion-header:hover {
    background: rgba(0, 0, 0, 0.05);
}

.accordion-header i:first-child {
    color: var(--apple-blue);
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.accordion-header span {
    flex: 1;
    font-weight: 500;
    color: var(--apple-dark-gray);
}

.accordion-header i:last-child {
    color: var(--apple-gray);
    transition: var(--transition-normal);
}

.accordion-header.active i:last-child {
    transform: rotate(180deg);
    color: var(--apple-blue);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.accordion-scroll-content {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
}

.accordion-scroll-content::-webkit-scrollbar {
    width: 6px;
}

.accordion-scroll-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.accordion-scroll-content::-webkit-scrollbar-thumb {
    background: var(--apple-gray);
    border-radius: 3px;
}

.accordion-scroll-content::-webkit-scrollbar-thumb:hover {
    background: var(--apple-dark-gray);
}

.accordion-content h4 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--apple-dark-gray);
}

/* Хайлайт блоки */
.highlight-block {
    padding: 16px;
    border-radius: var(--radius-md);
    margin: 16px 0;
    background: rgba(0, 122, 255, 0.05);
    border-left: 4px solid var(--apple-blue);
}

.highlight-block.success {
    background: rgba(52, 199, 89, 0.05);
    border-left-color: var(--apple-green);
}

.highlight-block.warning {
    background: rgba(255, 149, 0, 0.05);
    border-left-color: var(--apple-orange);
}

.highlight-content p {
    margin: 4px 0;
    color: var(--apple-dark-gray);
}

.highlight-content strong {
    color: var(--apple-blue);
}

.highlight-block.success .highlight-content strong {
    color: var(--apple-green);
}

.highlight-block.warning .highlight-content strong {
    color: var(--apple-orange);
}

/* Детали примеров */
.example-details {
    font-size: 12px;
    color: var(--apple-gray);
    margin-top: 8px;
    font-style: italic;
}

/* Цикл работы */
.cycle-card .apple-code {
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-md);
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.8;
    color: var(--apple-dark-gray);
}

.cycle-card .mt-3 {
    margin-top: 12px;
}
[file content end]

[file name]: constructor.js
[file content begin]
// Функционал конструктора мантр

// DOM элементы конструктора
const constructorElements = {
    userQuery: document.getElementById('userQuery'),
    generateBtn: document.getElementById('generateBtn'),
    clearBtn: document.getElementById('clearBtn'),
    saveBtn: document.getElementById('saveBtn'),
    copyBtn: document.getElementById('copyBtn'),
    speakBtn: document.getElementById('speakBtn'),
    shareBtn: document.getElementById('shareBtn'),
    mantraDisplay: document.getElementById('mantraDisplay'),
    themeText: document.getElementById('themeText'),
    typeText: document.getElementById('typeText'),
    charCount: document.getElementById('charCount')
};

// Текущая сгенерированная мантра
let currentMantra = null;

// Инициализация конструктора
function initConstructor() {
    if (!constructorElements.userQuery) return;
    
    // Обработчики событий
    constructorElements.generateBtn?.addEventListener('click', generateMantra);
    constructorElements.clearBtn?.addEventListener('click', clearForm);
    constructorElements.saveBtn?.addEventListener('click', saveCurrentMantra);
    constructorElements.copyBtn?.addEventListener('click', copyCurrentMantra);
    constructorElements.speakBtn?.addEventListener('click', speakCurrentMantra);
    constructorElements.shareBtn?.addEventListener('click', shareCurrentMantra);
    
    // Отслеживание ввода
    constructorElements.userQuery?.addEventListener('input', updateCharCount);
    
    // Загрузка последней мантры
    loadLastMantra();
    
    // Инициализация счетчика символов
    updateCharCount();
}

// Обновление счетчика символов
function updateCharCount() {
    if (!constructorElements.charCount || !constructorElements.userQuery) return;
    
    const length = constructorElements.userQuery.value.length;
    constructorElements.charCount.textContent = `${length}/500`;
    
    if (length > 500) {
        constructorElements.charCount.style.color = 'var(--apple-pink)';
        constructorElements.generateBtn.disabled = true;
        constructorElements.generateBtn.style.opacity = '0.5';
    } else if (length > 400) {
        constructorElements.charCount.style.color = 'var(--apple-orange)';
        constructorElements.generateBtn.disabled = false;
        constructorElements.generateBtn.style.opacity = '1';
    } else {
        constructorElements.charCount.style.color = 'var(--apple-green)';
        constructorElements.generateBtn.disabled = false;
        constructorElements.generateBtn.style.opacity = '1';
    }
}

// Загрузка примера
window.loadExample = function(index) {
    if (!constructorElements.userQuery || index < 0 || index >= examples.length) return;
    
    constructorElements.userQuery.value = examples[index];
    updateCharCount();
    
    // Анимация примера
    const exampleItems = document.querySelectorAll('.example-item');
    if (exampleItems[index]) {
        exampleItems[index].classList.add('example-appear');
        setTimeout(() => {
            exampleItems[index].classList.remove('example-appear');
        }, 1000);
    }
    
    showNotification(`Загружен пример #${index + 1}`, 'success');
}

// Генерация мантры
function generateMantra() {
    const query = constructorElements.userQuery.value.trim();
    
    if (!query) {
        showNotification('Введите ваш запрос', 'error');
        constructorElements.userQuery.focus();
        return;
    }
    
    if (query.length > 500) {
        showNotification('Запрос слишком длинный (максимум 500 символов)', 'error');
        return;
    }
    
    // Показать состояние загрузки
    const originalBtnHTML = constructorElements.generateBtn.innerHTML;
    constructorElements.generateBtn.innerHTML = `
        <div class="loading-spinner" style="width: 20px; height: 20px; margin-right: 8px;"></div>
        Генерация...
    `;
    constructorElements.generateBtn.disabled = true;
    constructorElements.generateBtn.style.opacity = '0.7';
    
    // Имитация работы ИИ (в реальном приложении - запрос к API)
    setTimeout(() => {
        try {
            const result = analyzeAndGenerateMantra(query);
            displayMantra(result.mantra, result.theme, result.type);
            currentMantra = result;
            
            showNotification('Мантра успешно создана!', 'success');
            
            // Анимация появления
            const mantraDisplay = constructorElements.mantraDisplay;
            mantraDisplay.classList.add('transform-appear');
            setTimeout(() => {
                mantraDisplay.classList.remove('transform-appear');
            }, 600);
        } catch (error) {
            console.error('Ошибка генерации:', error);
            showNotification('Ошибка при создании мантры', 'error');
        } finally {
            constructorElements.generateBtn.innerHTML = originalBtnHTML;
            constructorElements.generateBtn.disabled = false;
            constructorElements.generateBtn.style.opacity = '1';
        }
    }, 1500 + Math.random() * 1000); // Добавляем случайность для реалистичности
}

// Анализ запроса и генерация мантры
function analyzeAndGenerateMantra(query) {
    // Определение тематики
    let theme = 'Личностный рост';
    let type = 'Развитие';
    const queryLower = query.toLowerCase();
    
    if (queryLower.includes('работа') || queryLower.includes('карьер') || queryLower.includes('професси')) {
        theme = 'Профессиональное развитие';
        type = 'Карьера';
    } else if (queryLower.includes('отношен') || queryLower.includes('общен') || queryLower.includes('любов')) {
        theme = 'Отношения';
        type = 'Коммуникация';
    } else if (queryLower.includes('здоров') || queryLower.includes('спорт') || queryLower.includes('тело')) {
        theme = 'Здоровье';
        type = 'Энергия';
    } else if (queryLower.includes('финанс') || queryLower.includes('деньг') || queryLower.includes('богат')) {
        theme = 'Финансы';
        type = 'Изобилие';
    } else if (queryLower.includes('страх') || queryLower.includes('тревог') || queryLower.includes('стресс')) {
        theme = 'Эмоциональное состояние';
        type = 'Спокойствие';
    } else if (queryLower.includes('уверен') || queryLower.includes('уверенно')) {
        theme = 'Уверенность в себе';
        type = 'Самооценка';
    } else if (queryLower.includes('фокус') || queryLower.includes('продуктив') || queryLower.includes('вниман')) {
        theme = 'Продуктивность';
        type = 'Концентрация';
    }
    
    // База шаблонов мантр
    const mantraTemplates = {
        'Личностный рост': [
            `Я с легкостью ${extractAction(query)} и наслаждаюсь процессом развития, зная что каждый шаг ведет меня к гармонии и успеху.`,
            `С каждым днем я становлюсь более ${extractQuality(query)}, открывая для себя новые возможности и радости самореализации.`,
            `Мое сознание естественно настраивается на волну ${extractState(query)}, привлекая в мою жизнь все необходимое для счастья и реализации.`
        ],
        'Профессиональное развитие': [
            `Я уверенно ${extractAction(query)} в профессиональной сфере, создавая ценность и достигая выдающихся результатов.`,
            `Мои профессиональные навыки постоянно развиваются, и я с легкостью ${extractAction(query)}, находя оптимальные решения.`,
            `Я привлекаю прекрасные профессиональные возможности, где могу полностью реализовать свой потенциал через ${extractAction(query)}.`
        ],
        'Отношения': [
            `Я создаю гармоничные и поддерживающие отношения, легко ${extractAction(query)} с пониманием и уважением.`,
            `Мое общение с другими наполнено искренностью и легкостью, я естественно ${extractAction(query)} в любых ситуациях.`,
            `Я привлекаю в свою жизнь людей, с которыми могу разделять радость и ${extractAction(query)} в полной гармонии.`
        ],
        'Здоровье': [
            `Мое тело наполняется энергией и жизненной силой, я с радостью ${extractAction(query)} каждый день.`,
            `Я выбираю здоровые привычки, которые поддерживают мое тело в состоянии ${extractState(query)} и гармонии.`,
            `С каждым днем я становлюсь более энергичным и здоровым, легко ${extractAction(query)} и наслаждаясь жизнью.`
        ],
        'Финансы': [
            `Деньги текут ко мне легко и изобильно, я с благодарностью ${extractAction(query)} и создаю финансовое процветание.`,
            `Я привлекаю финансовые возможности и с легкостью ${extractAction(query)}, создавая устойчивое изобилие в своей жизни.`,
            `Вселенная поддерживает меня в моем финансовом росте, и я с радостью ${extractAction(query)}, зная что достоин процветания.`
        ],
        'Эмоциональное состояние': [
            `Я нахожусь в состоянии внутреннего покоя и гармонии, легко ${extractAction(query)} в любой ситуации.`,
            `Мои эмоции находятся в равновесии, и я с уверенностью ${extractAction(query)}, сохраняя душевный покой.`,
            `Я выбираю состояние ${extractState(query)} и с легкостью ${extractAction(query)}, наслаждаясь каждым моментом жизни.`
        ],
        'Уверенность в себе': [
            `Я доверяю себе и своим решениям, уверенно ${extractAction(query)} в любой ситуации.`,
            `Моя уверенность растет с каждым днем, и я легко ${extractAction(query)}, зная что все получится.`,
            `Я действую уверенно и решительно, ${extractAction(query)} с полной верой в себя и свои способности.`
        ],
        'Продуктивность': [
            `Я легко нахожу фокус и концентрацию, эффективно ${extractAction(query)} и достигаю поставленных целей.`,
            `Моя продуктивность находится на высоком уровне, я с легкостью ${extractAction(query)} и завершаю задачи вовремя.`,
            `Я наслаждаюсь процессом работы, сохраняя энергию и концентрацию для ${extractAction(query)} с максимальной эффективностью.`
        ]
    };
    
    // Выбор случайного шаблона для тематики
    const templates = mantraTemplates[theme] || mantraTemplates['Личностный рост'];
    const mantra = templates[Math.floor(Math.random() * templates.length)];
    
    return {
        mantra: mantra,
        theme: theme,
        type: type,
        original: query,
        timestamp: new Date().toISOString()
    };
}

// Вспомогательные функции для генерации
function extractAction(query) {
    const actions = [
        'действую', 'создаю', 'достигаю', 'развиваюсь', 'расту', 'меняюсь', 
        'учусь', 'исследую', 'применяю', 'реализую', 'воплощаю', 'творю',
        'общаюсь', 'делюсь', 'поддерживаю', 'вдохновляю', 'мотивирую'
    ];
    return actions[Math.floor(Math.random() * actions.length)];
}

function extractQuality(query) {
    const qualities = [
        'уверенным', 'осознанным', 'гармоничным', 'успешным', 'радостным', 
        'энергичным', 'сбалансированным', 'наполненным', 'вдохновленным',
        'мотивированным', 'целеустремленным', 'решительным', 'спокойным'
    ];
    return qualities[Math.floor(Math.random() * qualities.length)];
}

function extractState(query) {
    const states = [
        'изобилия', 'радости', 'успеха', 'гармонии', 'любви', 'процветания',
        'благополучия', 'мира', 'спокойствия', 'удовлетворения', 'удовольствия',
        'вдохновения', 'мотивации', 'целостности', 'баланса'
    ];
    return states[Math.floor(Math.random() * states.length)];
}

// Отображение мантры
function displayMantra(mantra, theme, type) {
    if (!constructorElements.mantraDisplay) return;
    
    constructorElements.mantraDisplay.innerHTML = `
        <div class="mantra-content animate__animated animate__fadeIn">
            <i class="fas fa-quote-left" style="opacity: 0.3; font-size: 24px; margin-bottom: 16px;"></i>
            <p style="font-size: 18px; line-height: 1.6;">${mantra}</p>
            <i class="fas fa-quote-right" style="opacity: 0.3; font-size: 24px; margin-top: 16px;"></i>
        </div>
    `;
    
    if (constructorElements.themeText) {
        constructorElements.themeText.textContent = theme;
    }
    
    if (constructorElements.typeText) {
        constructorElements.typeText.textContent = type;
    }
    
    // Активировать кнопки действий
    activateActionButtons(true);
}

// Загрузка последней мантры
function loadLastMantra() {
    const lastMantra = localStorage.getItem('lastMantra');
    if (lastMantra) {
        try {
            const data = JSON.parse(lastMantra);
            currentMantra = data;
            displayMantra(data.mantra, data.theme, data.type);
        } catch (e) {
            console.error('Ошибка загрузки последней мантры:', e);
        }
    }
}

// Очистка формы
function clearForm() {
    if (!constructorElements.userQuery) return;
    
    constructorElements.userQuery.value = '';
    constructorElements.mantraDisplay.innerHTML = `
        <div class="mantra-placeholder">
            <i class="fas fa-quote-left"></i>
            <p>Введите запрос и создайте свою мантру</p>
        </div>
    `;
    
    if (constructorElements.themeText) {
        constructorElements.themeText.textContent = '—';
    }
    
    if (constructorElements.typeText) {
        constructorElements.typeText.textContent = '—';
    }
    
    updateCharCount();
    activateActionButtons(false);
    currentMantra = null;
    
    showNotification('Форма очищена', 'info');
}

// Активация кнопок действий
function activateActionButtons(active) {
    const actionButtons = [
        constructorElements.copyBtn,
        constructorElements.speakBtn,
        constructorElements.saveBtn,
        constructorElements.shareBtn
    ];
    
    actionButtons.forEach(button => {
        if (button) {
            button.disabled = !active;
            button.style.opacity = active ? '1' : '0.5';
            button.style.cursor = active ? 'pointer' : 'not-allowed';
        }
    });
}

// Копирование текущей мантры
function copyCurrentMantra() {
    if (!currentMantra) {
        showNotification('Нет мантры для копирования', 'error');
        return;
    }
    copyToClipboard(currentMantra.mantra);
}

// Озвучивание текущей мантры
function speakCurrentMantra() {
    if (!currentMantra) {
        showNotification('Нет мантры для озвучивания', 'error');
        return;
    }
    speakMantra(currentMantra.mantra);
}

// Сохранение текущей мантры
function saveCurrentMantra() {
    if (!currentMantra) {
        showNotification('Нет мантры для сохранения', 'error');
        return;
    }
    
    saveMantraToHistory(currentMantra);
    showNotification('Мантра сохранена в библиотеку', 'success');
}

// Поделиться текущей мантрой
function shareCurrentMantra() {
    if (!currentMantra) {
        showNotification('Нет мантры для публикации', 'error');
        return;
    }
    shareMantra(currentMantra.mantra, currentMantra.theme);
}

// Инициализация при загрузке
document.addEventListener('DOMContentLoaded', function() {
    initConstructor();
});

// Экспорт функций
window.generateMantra = generateMantra;
window.saveCurrentMantra = saveCurrentMantra;
window.displayMantra = displayMantra;