/**
 * FRACK OFF v3.8.0 — Complete Styles
 * Бюро изящных отказов
 * powered by dev4rev
 * 
 * 🎠 Auto-slider: fade-only, 2s interval, no manual controls
 * 🖥️ Desktop: smaller slider, original letter sizes preserved
 */

:root {
    /* === Цвета === */
    --bg-primary: #0a0a0d;
    --bg-secondary: #121218;
    --text-primary: #f5f5f7;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b7b;
    
    --accent-gold: #d4af37;
    --accent-gold-light: #e6c06b;
    --accent-gold-dim: rgba(212, 175, 55, 0.15);
    --accent-gold-glow: rgba(212, 175, 55, 0.4);
    
    --seal-burgundy: #6b1f3a;
    --seal-burgundy-light: #8b2a4a;
    
    --envelope-cream: #f8f4e9;
    --envelope-cream-dark: #e8e0d0;
    --envelope-cream-darker: #d9c9a8;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(212, 175, 55, 0.3);
    --border-light: rgba(0, 0, 0, 0.1);
    
    /* === Шрифты === */
    --font-title: 'Playfair Display', serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-script: 'Great Vibes', cursive;
    
    /* === Размеры === */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* === Анимации === */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* === Тени === */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 25px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 15px 50px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-gold-glow);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 50%;
}

/* === Сброс === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* Скрытие элементов для скринридеров */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Фон с шумом === */
.noise-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* === Контейнер === */
.container {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* === Header === */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown var(--transition-slow) forwards;
    padding: 0 var(--spacing-sm);
}

.title {
    font-family: var(--font-title);
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--accent-gold);
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-gold-dim);
    margin-bottom: var(--spacing-xs);
    position: relative;
    display: inline-block;
    line-height: 1.1;
}

.title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

.subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2.5vw, 1.25rem);
    font-weight: 400;
    font-style: italic;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    margin-top: var(--spacing-sm);
    line-height: 1.4;
}

/* === Cards Section === */
.cards-section {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
    margin: var(--spacing-md) 0;
}

/* === СЛАЙДЕР — AUTO FADE ONLY (2s, NO CONTROLS) === */
.cards-slider {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 3/4;
    margin: var(--spacing-md) 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
    /* Отключаем все интерактивы — только авто-плей */
    pointer-events: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.card-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    /* Только fade-переход */
    transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out;
    pointer-events: none;
    z-index: 1;
}

.card-slide.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* Изображение карты */
.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    filter: sepia(25%) contrast(105%) brightness(0.92);
    display: block;
    will-change: transform;
}

/* Свечение — только для активного слайда */
.card-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, 
        rgba(212, 175, 55, 0.3) 0%, 
        rgba(212, 175, 55, 0.1) 40%, 
        transparent 70%);
    filter: blur(20px);
    animation: glowPulse 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

.card-slide:not(.active) .card-glow {
    display: none;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* Частицы — только для активного слайда */
.card-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.card-slide:not(.active) .card-particles {
    display: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-gold);
    border-radius: var(--radius-full);
    opacity: 0;
    animation: particleFloat 4s ease-in-out infinite;
    box-shadow: 0 0 10px var(--accent-gold-glow);
}

@keyframes particleFloat {
    0% { opacity: 0; transform: translateY(100%) scale(0); }
    20% { opacity: 1; transform: translateY(80%) scale(1); }
    80% { opacity: 1; transform: translateY(20%) scale(1); }
    100% { opacity: 0; transform: translateY(0%) scale(0); }
}

/* Индикаторы — скрыты (авто-слайдер без управления) */
.slider-indicators {
    display: none;
}

/* === Controls === */
.controls {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    z-index: 20;
    width: 100%;
    margin-top: var(--spacing-lg);
}

.cta-button {
    position: relative;
    background: transparent;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: var(--spacing-sm) var(--spacing-xl);
    font-family: var(--font-title);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition-normal);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 220px;
}

.cta-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-gold-dim), transparent);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.cta-button:hover {
    color: var(--bg-primary);
    background: var(--accent-gold);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.cta-button:hover::before { opacity: 1; }
.cta-button:active { transform: translateY(0); }

.settings-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: var(--spacing-sm);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    min-width: 44px;
    min-height: 44px;
}

.settings-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: var(--accent-gold-dim);
    transform: rotate(15deg);
}

.settings-btn:active { transform: rotate(0) scale(0.95); }

/* === Envelope === */
.envelope-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: min(85%, 320px);
    height: auto;
    aspect-ratio: 5/4;
    cursor: pointer;
    z-index: 15;
    transition: transform var(--transition-slow);
    opacity: 0;
    pointer-events: none;
}

.envelope-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.envelope-container.open {
    transform: translate(-50%, -50%) scale(1);
    z-index: 30;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, var(--envelope-cream), var(--envelope-cream-dark));
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, #ebe3d3, var(--envelope-cream-darker));
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    transform-origin: top;
    transition: transform 0.5s ease 0.1s, z-index 0.1s;
    z-index: 3;
}

.envelope-container.open .flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(0deg, #c9b898, var(--envelope-cream-darker));
    clip-path: polygon(0 100%, 50% 0, 100% 100%);
    z-index: 2;
}

.wax-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: radial-gradient(circle at 35% 35%, var(--seal-burgundy-light), var(--seal-burgundy));
    border-radius: var(--radius-full);
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255, 255, 255, 0.9);
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 2px 6px rgba(255, 255, 255, 0.2);
    z-index: 4;
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 2px solid rgba(0, 0, 0, 0.1);
    user-select: none;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 2px 6px rgba(255, 255, 255, 0.2); }
    50% { box-shadow: 0 4px 20px rgba(212, 175, 55, 0.6), inset 0 2px 6px rgba(255, 255, 255, 0.2); }
}

.wax-seal::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 1px dashed rgba(212, 175, 55, 0.4);
}

.wax-seal:focus { outline: 2px solid var(--accent-gold); outline-offset: 2px; }
.wax-seal:focus:not(:focus-visible) { outline: none; }
.wax-seal:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; }

.envelope-container.open .wax-seal {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4);
    pointer-events: none;
}

/* === Letter === */
.letter-content {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: min(95%, 450px);
    max-width: 600px;
    background: var(--envelope-cream);
    color: #1a1a1a;
    padding: var(--spacing-lg);
    border-radius: var(--radius-sm);
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: all 0.4s ease 0.3s;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.envelope-container.open .letter-content {
    transform: translateX(-50%) translateY(-80px);
    opacity: 1;
    z-index: 10;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.letter-content::-webkit-scrollbar { width: 5px; }
.letter-content::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); border-radius: 3px; }
.letter-content::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 3px; }
.letter-content::-webkit-scrollbar-thumb:hover { background: var(--accent-gold-light); }

.letter-header {
    text-align: right;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.letter-date {
    font-family: var(--font-body);
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.letter-body {
    flex-grow: 1;
    margin-bottom: var(--spacing-md);
    min-height: 0;
}

.letter-text {
    font-family: var(--font-body), var(--font-title), serif;
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 1.8;
    color: #1a1a1a;
    margin-bottom: var(--spacing-lg);
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
    letter-spacing: 0.01em;
}

.letter-text::first-letter {
    font-family: var(--font-title), serif;
    font-size: 3em;
    color: var(--accent-gold);
    float: left;
    line-height: 0.8;
    margin-right: 0.15em;
    margin-top: 0.1em;
    font-weight: 500;
}

.letter-signature {
    font-family: var(--font-title), var(--font-script), serif;
    font-style: italic;
    font-weight: 500;
    text-align: right;
    color: #4a4a4a;
    border-top: 1px solid var(--border-light);
    padding-top: var(--spacing-md);
    font-size: 1rem;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

/* === Letter Actions === */
.letter-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    align-items: center;
    padding-top: var(--spacing-sm);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.close-btn, .share-btn, .action-btn {
    background: transparent;
    border: none;
    color: #3a3a3a;
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: var(--spacing-xs) var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn { border-bottom: 1px solid transparent; }
.close-btn:hover { color: var(--seal-burgundy); border-bottom-color: var(--seal-burgundy); }

.share-btn, .action-btn {
    padding: var(--spacing-xs);
    border-radius: var(--radius-full);
    opacity: 0.8;
    min-width: 40px;
    min-height: 40px;
}

.share-btn:hover, .action-btn:hover {
    color: var(--accent-gold);
    opacity: 1;
    background: var(--accent-gold-dim);
    transform: scale(1.1);
}

.share-btn svg, .action-btn svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

.share-btn:hover svg, .action-btn:hover svg { transform: scale(1.1); }

/* === Footer === */
.footer {
    margin-top: auto;
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-xl);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    width: 100%;
}

.footer-main { margin-bottom: var(--spacing-sm); }
.footer-divider { margin: 0 var(--spacing-sm); opacity: 0.5; }

.footer-link {
    color: var(--accent-gold);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
    position: relative;
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--accent-gold);
    transform: scaleX(0);
    transition: transform var(--transition-fast);
}

.footer-link:hover { color: var(--accent-gold-light); }
.footer-link:hover::after { transform: scaleX(1); }
.footer-link:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; border-radius: var(--radius-sm); }

.footer-disclaimer {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.7;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

.disclaimer-icon { color: var(--accent-gold); margin: 0 var(--spacing-sm); }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 600px;
    position: relative;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(20px);
    transition: transform var(--transition-normal);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: var(--border-subtle); }
.modal-content::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 3px; }

.close-modal {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover { color: var(--text-primary); background: var(--border-subtle); }
.close-modal:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; }

.modal-title {
    font-family: var(--font-title);
    font-size: 1.75rem;
    color: var(--accent-gold);
    text-align: center;
    margin-bottom: var(--spacing-xs);
    line-height: 1.2;
}

.modal-desc {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    font-style: italic;
    font-size: 1rem;
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: var(--font-title);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn.active { color: var(--accent-gold); border-bottom-color: var(--accent-gold); }
.tab-btn:hover:not(.active) { color: var(--text-primary); }
.tab-btn:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: -2px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeInUp var(--transition-normal); }

/* === Preset List === */
.preset-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    max-height: 400px;
    overflow-y: auto;
    padding-right: var(--spacing-sm);
}

.preset-list::-webkit-scrollbar { width: 6px; }
.preset-list::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
.preset-list::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }

.preset-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.preset-item:hover {
    border-color: var(--accent-gold);
    background: var(--accent-gold-dim);
    transform: translateX(4px);
}

.preset-item:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-dim);
}

.preset-item h4 {
    font-family: var(--font-title);
    color: var(--accent-gold);
    margin-bottom: var(--spacing-xs);
    font-size: 1rem;
    line-height: 1.3;
}

.preset-item p {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === Form === */
.form-group { margin-bottom: var(--spacing-lg); }

.form-group label {
    display: block;
    color: var(--accent-gold);
    margin-bottom: var(--spacing-sm);
    font-family: var(--font-title);
    font-size: 0.95rem;
}

.form-group textarea,
.form-group input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: var(--font-body);
    font-size: 1rem;
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 100px;
}

.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-dim);
}

.form-group textarea { white-space: pre-wrap; font-family: var(--font-body); }

.char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
    transition: color var(--transition-fast);
}

.char-count.warning { color: #f59e0b; }
.char-count.error { color: #ef4444; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.btn-primary, .btn-secondary {
    padding: var(--spacing-sm) var(--spacing-lg);
    cursor: pointer;
    font-family: var(--font-title);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    font-weight: 600;
}

.btn-primary:hover { background: var(--accent-gold-light); box-shadow: var(--shadow-glow); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: 2px solid var(--bg-primary); outline-offset: 2px; }

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn-secondary:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; }

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-md);
    pointer-events: none;
    max-width: calc(100% - var(--spacing-lg) * 2);
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-primary);
    font-size: 0.95rem;
    box-shadow: var(--shadow-md);
    animation: toastIn var(--transition-normal) forwards, toastOut var(--transition-normal) 4s forwards;
    max-width: 400px;
    text-align: center;
    pointer-events: auto;
}

.toast.success { border-color: #22c55e; box-shadow: 0 8px 25px rgba(34, 197, 94, 0.2); }
.toast.error { border-color: #ef4444; box-shadow: 0 8px 25px rgba(239, 68, 68, 0.2); }
.toast.info { border-color: var(--accent-gold); box-shadow: 0 8px 25px var(--accent-gold-dim); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

@keyframes fadeInDown { from { opacity: 0; transform: translateY(-15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* === Mobile === */
@media (max-width: 768px) {
    .container { padding: var(--spacing-md); }
    .cards-slider { max-width: 100%; aspect-ratio: 3/4; }
    .controls { width: 100%; flex-direction: column; }
    .cta-button { width: 100%; max-width: 300px; }
    .modal-content { padding: var(--spacing-lg); margin: var(--spacing-sm); }
    .tabs { flex-direction: column; }
    .tab-btn { padding: var(--spacing-md); }
    .preset-list { max-height: 300px; }
    
    .envelope-container { width: min(85%, 300px); height: auto; aspect-ratio: 5/4; }
    .letter-content { width: min(95%, 400px); padding: var(--spacing-md); top: 8px; }
    .envelope-container.open .letter-content { transform: translateX(-50%) translateY(-60px); max-height: calc(100vh - 150px); }
    
    .letter-text { font-size: 1.05rem; line-height: 1.7; text-align: left; hyphens: none; }
    .letter-text::first-letter { font-size: 2.5em; }
    .letter-signature { font-size: 0.95rem; }
    .wax-seal { width: 44px; height: 44px; font-size: 1.2rem; }
    .action-btn, .share-btn { min-width: 36px; min-height: 36px; padding: 6px; }
    .action-btn svg, .share-btn svg { width: 16px; height: 16px; }
}

@media (max-width: 480px) {
    .title { font-size: 2.5rem; letter-spacing: 0.1em; }
    .subtitle { font-size: 0.95rem; }
    .card-image { border-radius: var(--radius-md); }
    .letter-text { font-size: 1rem; line-height: 1.7; padding: 0 var(--spacing-sm); }
    .letter-content { padding: var(--spacing-md); }
    .letter-signature { font-size: 0.95rem; }
    .modal-title { font-size: 1.5rem; }
    .modal-actions { flex-direction: column-reverse; }
    .btn-primary, .btn-secondary { width: 100%; }
}

@media (max-width: 360px) {
    .envelope-container { width: 85%; max-width: 280px; }
    .letter-content { width: min(95%, 340px); padding: 12px; }
    .letter-text { font-size: 1rem; }
    .cards-slider { border-radius: var(--radius-md); }
    .card-glow { inset: -10px; }
}

/* === Desktop: УМЕНЬШЕННЫЙ СЛАЙДЕР, ОРИГИНАЛЬНЫЕ РАЗМЕРЫ ПИСЬМА === */
@media (min-width: 769px) {
    
    /* === СЛАЙДЕР — УМЕНЬШЕННЫЙ (единственное изменение!) === */
    .cards-slider {
        max-width: 320px;  /* ← ИЗМЕНЕНО: было 480px → стало 320px */
    }
    
    /* === ВСЁ ОСТАЛЬНОЕ — КАК В ОРИГИНАЛЕ === */
    .envelope-container { width: 320px; height: 256px; aspect-ratio: 5/4; }
    .letter-content { width: 595px; max-width: 70vw; padding: 32px; }
    .letter-text { font-size: 1.1rem; line-height: 1.8; }
    .letter-signature { font-size: 1.05rem; }
    .envelope-container.open .letter-content { transform: translateX(-50%) translateY(-100px); }
    .letter-text::first-letter {
        font-family: var(--font-title);
        font-size: 3em;
        color: var(--accent-gold);
        float: left;
        line-height: 0.8;
        margin-right: 0.1em;
        margin-top: 0.1em;
    }
}

/* === Large Desktop: только слайдер меньше, письмо — оригинал === */
@media (min-width: 1200px) {
    .envelope-container { width: 360px; height: 288px; }
    .letter-content { width: 650px; max-width: 60vw; }
    .letter-text { font-size: 1.15rem; line-height: 1.9; }
    .modal-content { max-width: 700px; padding: var(--spacing-xl); }
    .modal-title { font-size: 2rem; }
    
    /* === СЛАЙДЕР — УМЕНЬШЕННЫЙ (единственное изменение!) === */
    .cards-slider {
        max-width: 320px;  /* ← ИЗМЕНЕНО: было 520px → стало 320px */
    }
}

/* === Высокие экраны === */
@media (min-height: 900px) {
    .container { padding: var(--spacing-xl); }
    .header { margin-bottom: var(--spacing-xl); }
    .footer { padding: var(--spacing-xl) var(--spacing-md) var(--spacing-xl); }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .card-slide { transition: none !important; }
    .card-glow { animation: none; }
    .particle { animation: none; }
    .envelope-container { transition: none; }
    .modal-overlay, .modal-content { transition: none; }
    .wax-seal { animation: none; }
}

/* === Dark mode === */
@media (prefers-color-scheme: dark) {
    :root { color-scheme: dark; }
}

/* === Focus === */
:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; }
button:focus:not(:focus-visible), [tabindex]:focus:not(:focus-visible) { outline: none; }

/* === Print === */
@media print {
    body { background: white; color: black; }
    .noise-overlay, .controls, .footer, .modal-overlay, .toast-container,
    .settings-btn, .letter-actions, .cards-section { display: none !important; }
    .envelope-container {
        position: static; transform: none !important; opacity: 1 !important;
        width: 100%; max-width: 600px; margin: 0 auto;
    }
    .envelope, .flap, .pocket, .wax-seal { display: none; }
    .letter-content {
        position: static; transform: none !important; background: white;
        color: black; padding: 2rem; box-shadow: none; max-height: none; overflow: visible;
    }
    .letter-text { font-size: 14pt; color: black; }
    .letter-signature { color: black; }
}

/* === High DPI === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card-image { image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
}

/* === Old browser fallback === */
@supports not (backdrop-filter: blur(8px)) {
    .modal-overlay { background: rgba(10, 10, 15, 0.95); }
}