* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'MS Sans Serif', 'Microsoft Sans Serif', Arial, sans-serif;
    background: #008080;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,.05) 10px, rgba(0,0,0,.05) 20px),
        linear-gradient(to bottom, #008080, #006666);
    background-size: 200% 200%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin: 0;
    position: relative;
    overflow: hidden;
    animation: subtleShift 20s ease infinite;
}

@keyframes subtleShift {
    0%, 100% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
}

body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: floatingLight 15s ease-in-out infinite;
    pointer-events: none;
}

@keyframes floatingLight {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30%, 20%) scale(1.2); }
    66% { transform: translate(-20%, 30%) scale(0.9); }
}

.window {
    background: #c0c0c0;
    width: 700px;
    height: 500px;
    display: flex;
    flex-direction: column;
    box-shadow: 
        inset 1px 1px 0 #ffffff,
        inset 2px 2px 0 #dfdfdf,
        inset -1px -1px 0 #000000,
        inset -2px -2px 0 #808080,
        4px 4px 0 rgba(0,0,0,0.3);
    border: none;
    overflow: hidden;
    position: relative;
    animation: windowAppear 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55), windowFloat 4s ease-in-out infinite 0.6s;
}

@keyframes windowAppear {
    0% { 
        transform: scale(0) rotate(5deg) translateY(-100px);
        opacity: 0;
        filter: blur(10px);
    }
    60% {
        transform: scale(1.05) rotate(-2deg) translateY(0);
        filter: blur(0px);
    }
    100% { 
        transform: scale(1) rotate(0deg) translateY(0);
        opacity: 1;
        filter: blur(0px);
    }
}

@keyframes windowFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(0.5deg); }
    50% { transform: translateY(0px) rotate(0deg); }
    75% { transform: translateY(-5px) rotate(-0.5deg); }
}

.header-bar {
    background: linear-gradient(to right, #000080, #1084d0);
    border-bottom: 2px solid #c0c0c0;
    padding: 3px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 28px;
    position: relative;
    overflow: hidden;
}

.header-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: titleBarShine 3s ease-in-out infinite;
}

@keyframes titleBarShine {
    0% { left: -100%; }
    50%, 100% { left: 200%; }
}

.header-start,
.header-end {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    background: #c0c0c0;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    min-width: 24px;
    min-height: 24px;
    box-shadow: 
        inset 1px 1px 0 #ffffff,
        inset 2px 2px 0 #dfdfdf,
        inset -1px -1px 0 #000000,
        inset -2px -2px 0 #808080;
    transition: all 0.15s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

.icon-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.icon-button:hover {
    background: #dfdfdf;
    transform: translateY(-2px) scale(1.1);
    box-shadow: 
        inset 1px 1px 0 #ffffff,
        inset 2px 2px 0 #dfdfdf,
        inset -1px -1px 0 #000000,
        inset -2px -2px 0 #808080,
        0 4px 8px rgba(0,0,0,0.2);
    animation: buttonWobble 0.5s ease;
}

.icon-button:hover::before {
    width: 100px;
    height: 100px;
}

@keyframes buttonWobble {
    0%, 100% { transform: translateY(-2px) scale(1.1) rotate(0deg); }
    25% { transform: translateY(-2px) scale(1.1) rotate(-5deg); }
    75% { transform: translateY(-2px) scale(1.1) rotate(5deg); }
}

.icon-button:active {
    box-shadow: 
        inset -1px -1px 0 #ffffff,
        inset -2px -2px 0 #dfdfdf,
        inset 1px 1px 0 #000000,
        inset 2px 2px 0 #808080;
    transform: translate(1px, 1px) scale(0.95);
    animation: buttonPress 0.1s ease;
}

@keyframes buttonPress {
    0% { transform: scale(1.1); }
    100% { transform: translate(1px, 1px) scale(0.95); }
}

.mode-button {
    background: #c0c0c0;
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    color: #000000;
    font-weight: 700;
    font-size: 11px;
    box-shadow: 
        inset 1px 1px 0 #ffffff,
        inset 2px 2px 0 #dfdfdf,
        inset -1px -1px 0 #000000,
        inset -2px -2px 0 #808080;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
    animation: modeButtonGlow 3s ease-in-out infinite;
}

@keyframes modeButtonGlow {
    0%, 100% { 
        filter: brightness(1);
        box-shadow: 
            inset 1px 1px 0 #ffffff,
            inset 2px 2px 0 #dfdfdf,
            inset -1px -1px 0 #000000,
            inset -2px -2px 0 #808080;
    }
    50% { 
        filter: brightness(1.15);
        box-shadow: 
            inset 1px 1px 0 #ffffff,
            inset 2px 2px 0 #dfdfdf,
            inset -1px -1px 0 #000000,
            inset -2px -2px 0 #808080,
            0 0 10px rgba(16, 132, 208, 0.5);
    }
}

.mode-button::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(45deg);
    animation: modeButtonShimmer 3s linear infinite;
}

@keyframes modeButtonShimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.mode-button:hover {
    background: #dfdfdf;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        inset 1px 1px 0 #ffffff,
        inset 2px 2px 0 #dfdfdf,
        inset -1px -1px 0 #000000,
        inset -2px -2px 0 #808080,
        0 6px 12px rgba(0,0,0,0.3);
    animation: buttonBounce 0.6s ease;
}

@keyframes buttonBounce {
    0%, 100% { transform: translateY(-3px) scale(1.05); }
    25% { transform: translateY(-5px) scale(1.08) rotate(-3deg); }
    50% { transform: translateY(-3px) scale(1.05) rotate(0deg); }
    75% { transform: translateY(-5px) scale(1.08) rotate(3deg); }
}

.mode-button:active {
    box-shadow: 
        inset -1px -1px 0 #ffffff,
        inset -2px -2px 0 #dfdfdf,
        inset 1px 1px 0 #000000,
        inset 2px 2px 0 #808080;
    transform: translate(1px, 1px) scale(0.98);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #c0c0c0;
    border-top-color: #000080;
    border-right-color: #1084d0;
    border-radius: 50%;
    position: relative;
    animation: spin 0.8s linear infinite, spinnerPulse 1.5s ease-in-out infinite;
}

.spinner::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid transparent;
    border-top-color: rgba(16, 132, 208, 0.3);
    border-radius: 50%;
    animation: spinReverse 1.2s linear infinite;
}

.spinner::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes spinReverse {
    to { transform: rotate(-360deg); }
}

@keyframes spinnerPulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.content {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    margin: 2px;
    position: relative;
    animation: contentFadeIn 0.8s ease;
}

.content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(16, 132, 208, 0.05) 0%, transparent 70%);
    animation: contentGlow 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes contentFadeIn {
    0% { 
        opacity: 0; 
        transform: translateY(20px);
        filter: blur(5px);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0);
        filter: blur(0px);
    }
}

@keyframes contentGlow {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
    50% { transform: translate(20%, 20%) scale(1.2); opacity: 0.8; }
}

.image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border: 2px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    animation: imageSlideIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: transform 0.3s ease;
}

.image-container img:hover {
    transform: scale(1.02);
    animation: imageFloat 2s ease-in-out infinite;
}

@keyframes imageSlideIn {
    0% { 
        opacity: 0;
        transform: scale(0.3) rotate(-15deg) translateY(50px);
        filter: blur(10px);
    }
    50% {
        transform: scale(1.05) rotate(2deg) translateY(-10px);
        filter: blur(0px);
    }
    70% {
        transform: scale(0.98) rotate(-1deg) translateY(5px);
    }
    100% { 
        opacity: 1;
        transform: scale(1) rotate(0deg) translateY(0);
        filter: blur(0px);
    }
}

@keyframes imageFloat {
    0%, 100% { transform: scale(1.02) translateY(0px); }
    50% { transform: scale(1.02) translateY(-5px); }
}

@keyframes imageZoomOut {
    0% { 
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: blur(0px);
    }
    100% { 
        opacity: 0;
        transform: scale(0.3) rotate(15deg);
        filter: blur(10px);
    }
}

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog {
    background: #c0c0c0;
    min-width: 420px;
    max-width: 90%;
    box-shadow: 
        inset 1px 1px 0 #ffffff,
        inset 2px 2px 0 #dfdfdf,
        inset -1px -1px 0 #000000,
        inset -2px -2px 0 #808080,
        4px 4px 0 rgba(0,0,0,0.5);
    animation: dialogBounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55), dialogFloat 3s ease-in-out infinite 0.6s;
}

@keyframes dialogBounceIn {
    0% { 
        transform: scale(0) translateY(-200px) rotate(-10deg);
        opacity: 0;
        filter: blur(10px);
    }
    50% {
        transform: scale(1.15) translateY(20px) rotate(5deg);
        filter: blur(0px);
    }
    70% {
        transform: scale(0.95) translateY(-10px) rotate(-2deg);
    }
    85% {
        transform: scale(1.05) translateY(5px) rotate(1deg);
    }
    100% { 
        transform: scale(1) translateY(0) rotate(0deg);
        opacity: 1;
        filter: blur(0px);
    }
}

@keyframes dialogFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.dialog-header {
    padding: 3px 4px;
    border-bottom: 2px solid #c0c0c0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, #000080, #1084d0);
    position: relative;
    overflow: hidden;
}

.dialog-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: headerShimmer 2.5s ease-in-out infinite;
}

@keyframes headerShimmer {
    0% { left: -100%; }
    50%, 100% { left: 200%; }
}

.dialog-header h2 {
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

.dialog-content {
    padding: 12px;
    animation: contentSlideIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s both;
}

@keyframes contentSlideIn {
    0% { 
        opacity: 0;
        transform: translateX(-50px) scale(0.9);
        filter: blur(5px);
    }
    60% {
        transform: translateX(10px) scale(1.02);
        filter: blur(0px);
    }
    100% { 
        opacity: 1;
        transform: translateX(0) scale(1);
        filter: blur(0px);
    }
}

.preference-group {
    margin-bottom: 20px;
}

.preference-group:last-child {
    margin-bottom: 0;
}

.preference-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #000000;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 400;
    color: #000000;
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    animation: labelBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes labelBounce {
    0%, 100% { transform: translateX(0) scale(1); }
    25% { transform: translateX(5px) scale(1.02); }
    50% { transform: translateX(-2px) scale(1.01); }
    75% { transform: translateX(3px) scale(1.02); }
}

.checkbox {
    width: 13px;
    height: 13px;
    cursor: pointer;
    accent-color: #000080;
}

.select-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    font-weight: 400;
    color: #000000;
}

.select {
    width: 100%;
    padding: 3px 4px;
    border: 2px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    font-size: 11px;
    font-weight: 400;
    background: #ffffff;
    color: #000000;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.select:hover {
    transform: scale(1.02) translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    animation: selectWiggle 0.5s ease;
}

@keyframes selectWiggle {
    0%, 100% { transform: scale(1.02) translateY(-2px) rotate(0deg); }
    25% { transform: scale(1.02) translateY(-2px) rotate(-1deg); }
    75% { transform: scale(1.02) translateY(-2px) rotate(1deg); }
}

.select:focus {
    outline: 1px dotted #000000;
    outline-offset: -3px;
    background: #ffffff;
    animation: selectFocus 0.3s ease;
}

@keyframes selectFocus {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@media (max-width: 768px) {
    .window {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .dialog {
        min-width: 90%;
    }
}

/* Дополнительные анимации для элементов */
.preference-group {
    animation: groupSlideIn 0.4s ease backwards;
}

.preference-group:nth-child(1) { animation-delay: 0.1s; }
.preference-group:nth-child(2) { animation-delay: 0.2s; }
.preference-group:nth-child(3) { animation-delay: 0.3s; }

@keyframes groupSlideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Анимация для чекбокса */
.checkbox {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.checkbox:checked {
    animation: checkboxPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkboxPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Эффект ряби при клике */
.icon-button, .mode-button {
    position: relative;
    overflow: hidden;
}

.icon-button::after, .mode-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.icon-button:active::after, .mode-button:active::after {
    width: 200px;
    height: 200px;
}

/* Анимация для header-start и header-end */
.header-start, .header-end {
    animation: headerItemsSlide 0.5s ease backwards;
}

.header-start {
    animation-delay: 0.3s;
}

.header-end {
    animation-delay: 0.4s;
}

@keyframes headerItemsSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Пульсация для disabled кнопки */
.icon-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    animation: disabledPulse 2s ease-in-out infinite;
}

@keyframes disabledPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.4; }
}

/* Анимация для image-container */
.image-container {
    position: relative;
}

.image-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    background-size: 200% 200%;
    animation: shimmerEffect 3s ease-in-out infinite;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.image-container:hover::before {
    opacity: 1;
}

@keyframes shimmerEffect {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 200%; }
}

/* Эффект свечения для окна */
.window::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #1084d0, #000080, #1084d0);
    background-size: 300% 300%;
    animation: borderGlow 4s ease-in-out infinite;
    z-index: -1;
    opacity: 0.3;
    filter: blur(8px);
}

@keyframes borderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
