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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    text-align: center;
    padding: 30px 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.translator {
    padding: 40px 30px;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.language-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.language-option label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

select {
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

select:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.swap-btn {
    background: #4facfe;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.swap-btn:hover {
    background: #2196f3;
    transform: rotate(180deg);
}

.translation-area {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.input-section, .output-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-section label, .output-section label {
    font-weight: 600;
    color: #555;
    font-size: 1rem;
}

textarea,
.source-area {
    padding: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    background: #fafbfc;
}

.source-area {
    min-height: 150px;
    overflow-y: auto;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.source-area:empty::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    pointer-events: none;
}

textarea:focus,
.source-area:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
    background: white;
}

.char-count {
    text-align: right;
    font-size: 0.85rem;
    color: #888;
    margin-top: -5px;
}

.translate-btn-container {
    text-align: center;
    margin: 20px 0;
}

.translate-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.translate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.4);
}

.translate-btn:active {
    transform: translateY(0);
}

.translate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.result-area {
    min-height: 150px;
    padding: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    background: #fafbfc;
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.result-area.has-content {
    background: white;
    border-color: #4facfe;
}

.placeholder {
    color: #999;
    font-style: italic;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.action-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 20px 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #c33;
    margin: 20px 0;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-content h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #333;
}

.modal-hint {
    font-size: 0.85rem;
    color: #888;
    margin: 0;
}

.modal-hint code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.modal-content label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    margin-top: 4px;
}

.modal-content textarea {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: monospace;
    resize: vertical;
    background: #fafbfc;
    transition: border-color 0.3s;
}

.modal-content textarea:focus {
    outline: none;
    border-color: #4facfe;
    background: white;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}

footer {
    background: #f8f9fa;
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .translator {
        padding: 20px 15px;
    }
    
    .language-selector {
        flex-direction: column;
        gap: 15px;
    }
    
    .swap-btn {
        margin-top: 0;
        transform: rotate(90deg);
    }
    
    .swap-btn:hover {
        transform: rotate(270deg);
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .translate-btn {
        padding: 14px 30px;
        font-size: 1rem;
    }
}

@media (min-width: 769px) {
    .translation-area {
        grid-template-columns: 1fr auto 1fr;
        align-items: start;
    }
    
    .translate-btn-container {
        display: flex;
        align-items: center;
        margin: 0;
        padding-top: 30px;
    }
    
    .translate-btn {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        padding: 20px 16px;
    }
}