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

:root {
    --bg-primary: white;
    --bg-secondary: #f8f9fa;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.3);
    --accent-color: #667eea;
    --accent-hover: #5568d3;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --button-bg: #f5f5f5;
    --button-hover: #e0e0e0;
    --input-bg: #fafafa;
    --success-color: #4caf50;
    --error-color: #f44336;
}

/* Default Light Theme */
body[data-theme="default"] {
    --bg-primary: white;
    --bg-secondary: #f8f9fa;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.3);
    --accent-color: #667eea;
    --accent-hover: #5568d3;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --button-bg: #f5f5f5;
    --button-hover: #e0e0e0;
    --input-bg: #fafafa;
}

/* Default Dark Theme */
body.dark-theme[data-theme="default"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --shadow: rgba(0, 0, 0, 0.6);
    --accent-color: #5b9bd5;
    --accent-hover: #4a8bc5;
    --gradient-start: #4a5568;
    --gradient-end: #2d3748;
    --button-bg: #2d2d2d;
    --button-hover: #3d3d3d;
    --input-bg: #252525;
}

/* Purple Light */
body[data-theme="purple"] {
    --bg-primary: white;
    --bg-secondary: #f3e5f5;
    --text-primary: #4a148c;
    --text-secondary: #7b1fa2;
    --border-color: #ce93d8;
    --accent-color: #9c27b0;
    --accent-hover: #7b1fa2;
    --gradient-start: #9c27b0;
    --gradient-end: #7b1fa2;
    --button-bg: #f3e5f5;
    --button-hover: #e1bee7;
    --input-bg: #fafafa;
}

/* Purple Dark */
body.dark-theme[data-theme="purple"] {
    --bg-primary: #1a0d20;
    --bg-secondary: #2d1b3d;
    --text-primary: #e1bee7;
    --text-secondary: #ce93d8;
    --border-color: #6a1b9a;
    --accent-color: #ba68c8;
    --accent-hover: #ab47bc;
    --gradient-start: #6a1b9a;
    --gradient-end: #4a148c;
    --button-bg: #2d1b3d;
    --button-hover: #3d2750;
    --input-bg: #251530;
}

/* Green Light */
body[data-theme="green"] {
    --bg-primary: white;
    --bg-secondary: #e8f5e9;
    --text-primary: #1b5e20;
    --text-secondary: #388e3c;
    --border-color: #a5d6a7;
    --accent-color: #4caf50;
    --accent-hover: #43a047;
    --gradient-start: #4caf50;
    --gradient-end: #388e3c;
    --button-bg: #e8f5e9;
    --button-hover: #c8e6c9;
    --input-bg: #fafafa;
}

/* Green Dark */
body.dark-theme[data-theme="green"] {
    --bg-primary: #0d1f0f;
    --bg-secondary: #1b2e1d;
    --text-primary: #c8e6c9;
    --text-secondary: #a5d6a7;
    --border-color: #388e3c;
    --accent-color: #66bb6a;
    --accent-hover: #4caf50;
    --gradient-start: #388e3c;
    --gradient-end: #2e7d32;
    --button-bg: #1b2e1d;
    --button-hover: #2a3f2d;
    --input-bg: #152518;
}

/* Yellow Light */
body[data-theme="yellow"] {
    --bg-primary: white;
    --bg-secondary: #fffde7;
    --text-primary: #5d4037;
    --text-secondary: #f57f17;
    --border-color: #fff59d;
    --accent-color: #ffc107;
    --accent-hover: #ffb300;
    --gradient-start: #ffc107;
    --gradient-end: #ffb300;
    --button-bg: #fffde7;
    --button-hover: #fff9c4;
    --input-bg: #fafafa;
}

/* Yellow Dark */
body.dark-theme[data-theme="yellow"] {
    --bg-primary: #1f1a0d;
    --bg-secondary: #2e2818;
    --text-primary: #fff9c4;
    --text-secondary: #fff59d;
    --border-color: #f57f17;
    --accent-color: #ffd54f;
    --accent-hover: #ffc107;
    --gradient-start: #f57f17;
    --gradient-end: #f9a825;
    --button-bg: #2e2818;
    --button-hover: #3d3525;
    --input-bg: #252015;
}

/* Blue Light */
body[data-theme="blue"] {
    --bg-primary: white;
    --bg-secondary: #e3f2fd;
    --text-primary: #0d47a1;
    --text-secondary: #1976d2;
    --border-color: #90caf9;
    --accent-color: #2196f3;
    --accent-hover: #1976d2;
    --gradient-start: #2196f3;
    --gradient-end: #1976d2;
    --button-bg: #e3f2fd;
    --button-hover: #bbdefb;
    --input-bg: #fafafa;
}

/* Blue Dark */
body.dark-theme[data-theme="blue"] {
    --bg-primary: #0d1b2e;
    --bg-secondary: #1a2e4a;
    --text-primary: #bbdefb;
    --text-secondary: #90caf9;
    --border-color: #1976d2;
    --accent-color: #64b5f6;
    --accent-hover: #42a5f5;
    --gradient-start: #1976d2;
    --gradient-end: #1565c0;
    --button-bg: #1a2e4a;
    --button-hover: #254461;
    --input-bg: #152637;
}

/* Cyan Light */
body[data-theme="cyan"] {
    --bg-primary: white;
    --bg-secondary: #e0f7fa;
    --text-primary: #006064;
    --text-secondary: #00838f;
    --border-color: #80deea;
    --accent-color: #00bcd4;
    --accent-hover: #0097a7;
    --gradient-start: #00bcd4;
    --gradient-end: #0097a7;
    --button-bg: #e0f7fa;
    --button-hover: #b2ebf2;
    --input-bg: #fafafa;
}

/* Cyan Dark */
body.dark-theme[data-theme="cyan"] {
    --bg-primary: #0d1f22;
    --bg-secondary: #1a2e33;
    --text-primary: #b2ebf2;
    --text-secondary: #80deea;
    --border-color: #00838f;
    --accent-color: #4dd0e1;
    --accent-hover: #26c6da;
    --gradient-start: #00838f;
    --gradient-end: #006064;
    --button-bg: #1a2e33;
    --button-hover: #273d44;
    --input-bg: #152225;
}

body {
    margin: 0;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-attachment: fixed;
    overflow-x: hidden;
    transition: background 0.3s ease;
}

.container {
    max-width: 900px;
    width: 100%;
    background: var(--bg-primary);
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow);
    padding: 40px;
    animation: fadeIn 0.5s ease-in;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 15px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle-btn {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 40px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

header h1 {
    font-size: 2.5em;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    transition: color 0.3s ease;
}

.interface-language-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
    min-height: 40px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
}

body.dark-theme .interface-language-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.interface-language-select:hover {
    border-color: var(--accent-color);
}

.interface-language-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95em;
    transition: color 0.3s ease;
}

.translation-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.lang-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

select {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    min-height: 44px;
}

select:hover {
    border-color: var(--accent-color);
}

select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.swap-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    min-width: 50px;
    min-height: 44px;
    touch-action: manipulation;
}

.swap-btn:hover {
    background: var(--accent-hover);
    transform: rotate(180deg);
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 10px;
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Textarea wrapper for clear button */
.textarea-wrapper {
    position: relative;
    width: 100%;
}

.textarea-wrapper textarea {
    padding-right: 40px;
}

.textarea-wrapper .translated-text {
    padding-right: 40px;
    position: relative;
}

/* Clear button */
.clear-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0.7;
    z-index: 10;
    min-width: 32px;
    min-height: 32px;
    touch-action: manipulation;
}

.clear-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    opacity: 1;
    transform: scale(1.1);
}

.clear-btn:active {
    transform: scale(0.95);
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Export select */
.export-select {
    background: var(--button-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
    color: var(--text-primary);
}

body.dark-theme .export-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.export-select:hover {
    background-color: var(--button-hover);
    border-color: var(--accent-color);
}

.export-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.export-btn {
    background: var(--button-bg);
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    min-width: 100px;
    min-height: 44px;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-primary);
}

.export-btn:hover {
    background: var(--button-hover);
}

.translated-text {
    min-height: 150px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    background: var(--input-bg);
    word-wrap: break-word;
    line-height: 1.6;
    color: var(--text-primary);
}

.placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 10px;
    color: var(--accent-color);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.translate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-height: 52px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.translate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.translate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.icon {
    font-size: 20px;
}

.status {
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    min-height: 20px;
}

.status.success {
    color: var(--success-color);
}

.status.error {
    color: var(--error-color);
}

/* Chat Section */
.chat-section {
    margin-top: 25px;
    border-top: 2px solid var(--border-color);
    padding-top: 20px;
}

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

.chat-header h3 {
    font-size: 1.2em;
    color: var(--text-primary);
    margin: 0;
}

.toggle-chat-btn {
    background: var(--button-bg);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    min-width: 36px;
    min-height: 36px;
    touch-action: manipulation;
    color: var(--text-primary);
}

.toggle-chat-btn:hover {
    background: var(--button-hover);
}

.chat-content {
    display: block;
}

.chat-content.hidden {
    display: none;
}

.chat-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.chat-setting-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.chat-model-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 120px;
}

.chat-model-select {
    flex: 1;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
    color: var(--text-primary);
}

body.dark-theme .chat-model-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.chat-model-select:hover {
    border-color: var(--accent-color);
}

.chat-model-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
}

.user-message .message-avatar {
    background: var(--border-color);
}

.message-text {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message .message-text {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.user-message .message-text {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
    max-height: 120px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    min-width: 50px;
    min-height: 50px;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Tablet styles */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .translation-box {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .container {
        padding: 25px;
        border-radius: 15px;
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .lang-selector {
        gap: 8px;
        margin-bottom: 12px;
    }

    .translated-text {
        min-height: 120px;
    }
}

/* Mobile styles */
@media (max-width: 480px) {
    body {
        padding: 10px;
        align-items: flex-start;
        padding-top: 10px;
        padding-bottom: 20px;
    }

    .container {
        padding: 15px;
        border-radius: 12px;
        max-width: 100%;
        margin: 0 auto;
    }

    header {
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.75em;
        margin-bottom: 5px;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .translation-box {
        gap: 12px;
        margin-bottom: 15px;
    }

    .lang-selector {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
    }

    .swap-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }

    select {
        width: 100%;
        font-size: 16px;
        padding: 14px 15px;
    }

    textarea {
        font-size: 16px;
        padding: 12px;
        min-height: 120px;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 8px;
    }
    
    /* Улучшение для мобильных клавиатур */
    textarea:focus {
        outline: none;
        border-color: var(--accent-color);
    }
    
    /* Предотвращение масштабирования при фокусе на iOS */
    @supports (-webkit-touch-callout: none) {
        textarea {
            font-size: 16px !important;
        }
        
        select {
            font-size: 16px !important;
        }
        
        input {
            font-size: 16px !important;
        }
    }

    .translated-text {
        min-height: 100px;
        padding: 12px;
        font-size: 16px;
    }

    .translate-btn {
        padding: 16px;
        font-size: 16px;
        min-height: 52px;
        width: 100%;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* Улучшение для всех кнопок на мобильных */
    button {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        min-height: 44px;
        min-width: 44px;
    }

    .char-count {
        font-size: 11px;
    }

    .status {
        font-size: 13px;
        margin-top: 10px;
    }

    .loading {
        padding: 15px;
        font-size: 14px;
    }

    .spinner {
        width: 35px;
        height: 35px;
    }
}

/* Specific mobile optimization for 455x888 */
@media (max-width: 455px) and (max-height: 888px) {
    body {
        padding: 8px;
        align-items: flex-start;
        padding-top: 5px;
        padding-bottom: 15px;
        min-height: 100vh;
        height: auto;
    }

    .container {
        padding: 12px;
        border-radius: 12px;
        max-width: 100%;
        margin: 0;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    }

    header {
        margin-bottom: 12px;
    }

    header h1 {
        font-size: 1.6em;
        margin-bottom: 4px;
        line-height: 1.2;
    }

    .subtitle {
        font-size: 0.8em;
        line-height: 1.3;
    }

    .translation-box {
        gap: 10px;
        margin-bottom: 12px;
    }

    .lang-selector {
        flex-direction: column;
        gap: 6px;
        margin-bottom: 10px;
    }

    .swap-btn {
        width: 100%;
        padding: 10px;
        font-size: 16px;
        min-height: 44px;
        border-radius: 8px;
    }

    select {
        width: 100%;
        font-size: 16px;
        padding: 12px 14px;
        min-height: 44px;
        border-radius: 8px;
    }

    textarea {
        font-size: 16px;
        padding: 11px;
        min-height: 100px;
        border-radius: 8px;
        line-height: 1.5;
    }

    .translated-text {
        min-height: 90px;
        padding: 11px;
        font-size: 15px;
        line-height: 1.5;
        border-radius: 8px;
    }

    .translate-btn {
        padding: 14px;
        font-size: 16px;
        min-height: 48px;
        border-radius: 10px;
        margin-top: 0;
    }

    .translate-btn .icon {
        font-size: 18px;
    }

    .result-header {
        margin-bottom: 10px;
        font-size: 14px;
    }

    .result-header span {
        font-size: 14px;
    }

    .input-actions {
        margin-top: 6px;
    }

    .char-count {
        font-size: 11px;
    }

    .status {
        font-size: 12px;
        margin-top: 8px;
        min-height: 18px;
    }

    .loading {
        padding: 12px;
        font-size: 13px;
        gap: 8px;
    }

    .loading span {
        font-size: 13px;
    }

    .spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }

    .input-section {
        margin-bottom: 0;
    }

    .output-section {
        margin-top: 0;
    }

    .container {
        max-height: calc(100vh - 16px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
}

/* Additional optimization for 455px width specifically */
@media (max-width: 455px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.8em;
    }

    .translation-box {
        gap: 10px;
    }

    .lang-selector {
        gap: 6px;
    }

    select {
        padding: 12px 14px;
    }

    textarea {
        padding: 11px;
        min-height: 100px;
    }

    .translated-text {
        padding: 11px;
        min-height: 90px;
    }

    .translate-btn {
        padding: 14px;
    }
}

/* Улучшение для очень маленьких экранов */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.8em;
    }
    
    .translate-btn {
        padding: 14px;
        font-size: 15px;
    }
}

/* Улучшение для мобильных устройств - общие правила */
@media (max-width: 768px) {
    /* Улучшение прокрутки */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Улучшение кликабельности */
    a, button, select, textarea {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Улучшение производительности на мобильных */
    .container {
        will-change: transform;
        transform: translateZ(0);
    }
    
    /* Улучшение для клавиатуры */
    textarea:focus,
    input:focus {
        transform: translateY(-10px);
        transition: transform 0.3s ease;
    }
}

/* Улучшение для очень маленьких экранов (360px и меньше) */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.4em;
    }

    .subtitle {
        font-size: 0.75em;
    }

    select {
        font-size: 15px;
        padding: 12px;
    }

    textarea {
        font-size: 16px;
        padding: 10px;
    }

    .translate-btn {
        padding: 14px;
        font-size: 15px;
        min-height: 48px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 10px;
        align-items: center;
    }

    .container {
        max-width: 700px;
        padding: 20px;
    }

    .translation-box {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .translated-text {
        min-height: 80px;
    }
}

/* Sponsor Footer */
.sponsor-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
    text-align: center;
}

.sponsor-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.sponsor-icon {
    font-size: 2em;
    margin-bottom: 5px;
}

.sponsor-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sponsor-title {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.sponsor-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
    min-height: 44px;
    touch-action: manipulation;
}

.sponsor-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
    background: linear-gradient(135deg, #0099dd 0%, #0077bb 100%);
}

.sponsor-link:active {
    transform: translateY(0);
}

.telegram-icon {
    font-size: 18px;
}

.sponsor-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
    max-width: 300px;
}

/* Contact Section */
.contact-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.telegram-channel-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 136, 204, 0.3);
    min-height: 48px;
    touch-action: manipulation;
}

.telegram-channel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 136, 204, 0.4);
    background: linear-gradient(135deg, #0099dd 0%, #0077bb 100%);
}

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

.thank-you-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
    margin: 0;
    max-width: 500px;
    padding: 0 15px;
}

/* Documentation Link Section */
.documentation-link-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.documentation-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    min-height: 48px;
    touch-action: manipulation;
}

.documentation-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.documentation-link:active {
    transform: translateY(0);
}

/* Documentation Page Styles */
.documentation-section-full {
    margin-top: 20px;
}

.docs-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.doc-item {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.doc-item h4 {
    font-size: 1.1em;
    color: var(--accent-color);
    margin-bottom: 12px;
    margin-top: 0;
    font-weight: 600;
}

.doc-item h5 {
    font-size: 1em;
    color: var(--text-primary);
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.doc-item p {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.doc-item ul,
.doc-item ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

.doc-item li {
    margin-bottom: 8px;
}

.doc-item li strong {
    color: var(--text-primary);
}

.doc-item code {
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
}

.doc-item pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.5;
}

.doc-item pre code {
    background: transparent;
    padding: 0;
    color: var(--text-primary);
    font-size: 1em;
}

.doc-item a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.doc-item a:hover {
    text-decoration: underline;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--button-bg);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    border: 2px solid var(--border-color);
}

.back-btn:hover {
    background: var(--button-hover);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Mobile styles for sponsor footer */
@media (max-width: 480px) {
    .sponsor-footer {
        margin-top: 15px;
        padding-top: 15px;
    }

    .sponsor-icon {
        font-size: 1.8em;
    }

    .sponsor-title {
        font-size: 12px;
    }

    .sponsor-link {
        padding: 10px 18px;
        font-size: 14px;
        min-height: 44px;
    }

    .sponsor-subtitle {
        font-size: 11px;
        max-width: 100%;
        padding: 0 10px;
    }

    .contact-section {
        margin-top: 15px;
        padding-top: 15px;
    }

    .telegram-channel-btn {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 44px;
    }

    .thank-you-text {
        font-size: 12px;
        padding: 0 10px;
    }

    .documentation-link-section {
        margin-top: 15px;
        padding-top: 15px;
    }

    .documentation-link {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 44px;
    }

    .documentation-section-full {
        margin-top: 15px;
    }

    .docs-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .doc-item {
        padding: 15px;
    }

    .doc-item h4 {
        font-size: 1em;
    }
}

/* Specific mobile optimization for 455x888 */
@media (max-width: 455px) and (max-height: 888px) {
    .sponsor-icon {
        font-size: 1.6em;
        margin-bottom: 3px;
    }

    .sponsor-content {
        gap: 8px;
    }

    .sponsor-text {
        gap: 6px;
    }

    .sponsor-title {
        font-size: 11px;
    }

    .sponsor-link {
        padding: 9px 16px;
        font-size: 13px;
        min-height: 42px;
        border-radius: 20px;
    }

    .telegram-icon {
        font-size: 16px;
    }

    .sponsor-subtitle {
        font-size: 10px;
        padding: 0 5px;
        line-height: 1.3;
    }

    .export-select {
        min-width: 90px;
        font-size: 12px;
        padding: 7px 28px 7px 8px;
        min-height: 40px;
    }

    .export-btn {
        min-width: 75px;
        font-size: 12px;
        padding: 7px 10px;
        min-height: 40px;
    }

    .chat-settings {
        padding: 8px;
        margin-bottom: 12px;
    }

    .chat-model-label {
        font-size: 12px;
    }

    .chat-model-select {
        font-size: 12px;
        padding: 7px 30px 7px 10px;
        min-height: 40px;
    }
}
