/* Modern CSS Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --text-mode-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --text-mode-color: #10b981;
    --text-mode-dark: #059669;
    --pinyin-mode-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --pinyin-mode-color: #f59e0b;
    --pinyin-mode-dark: #d97706;
    --pinyin-writer-mode-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --pinyin-writer-mode-color: #8b5cf6;
    --pinyin-writer-mode-dark: #7c3aed;
    --success-color: #10b981;
    --error-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-white: #ffffff;
    --bg-gray-50: #f9fafb;
    --bg-gray-100: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Ensure proper text rendering for all languages */
    text-rendering: optimizeLegibility;
    /* Support for Chinese characters */
    word-break: break-word;
    overflow-wrap: break-word;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
}

.logo-section {
    text-align: center;
    flex: 1;
}

.app-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.language-selector-wrapper {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.language-selector {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.language-selector:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

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

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0 4rem;
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.mode-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: var(--bg-gray-100);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.converter-card.text-mode .mode-btn.active {
    background: var(--text-mode-gradient);
    border-color: var(--text-mode-color);
}

.converter-card.pinyin-mode .mode-btn.active {
    background: var(--pinyin-mode-gradient);
    border-color: var(--pinyin-mode-color);
}

.converter-card.pinyin-writer-mode .mode-btn.active {
    background: var(--pinyin-writer-mode-gradient);
    border-color: var(--pinyin-writer-mode-color);
}

.mode-icon {
    font-size: 1.25rem;
}

/* Converter Card */
.converter-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    margin-bottom: 2rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform 0.3s, box-shadow 0.3s;
}

.converter-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

/* Text Mode Styling */
.converter-card.text-mode .card-header-modern {
    background: var(--text-mode-gradient);
}

.converter-card.text-mode .btn-convert {
    background: var(--text-mode-gradient);
}

.converter-card.text-mode .btn-convert:hover:not(:disabled) {
    box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.3);
}

.converter-card.text-mode .form-select-modern:focus {
    border-color: var(--text-mode-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.converter-card.text-mode .form-select-modern:hover {
    border-color: var(--text-mode-color);
}

/* Pinyin Mode Styling */
.converter-card.pinyin-mode .card-header-modern {
    background: var(--pinyin-mode-gradient);
}

.converter-card.pinyin-mode .btn-convert {
    background: var(--pinyin-mode-gradient);
}

.converter-card.pinyin-mode .btn-convert:hover:not(:disabled) {
    box-shadow: 0 10px 20px -5px rgba(245, 158, 11, 0.3);
}

.converter-card.pinyin-mode .text-input-area:focus,
.converter-card.pinyin-mode .text-output-area:focus {
    border-color: var(--pinyin-mode-color);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* Pinyin Writer Mode Styling */
.converter-card.pinyin-writer-mode .card-header-modern {
    background: var(--pinyin-writer-mode-gradient);
}

.converter-card.pinyin-writer-mode .text-input-area:focus,
.converter-card.pinyin-writer-mode .text-output-area:focus {
    border-color: var(--pinyin-writer-mode-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.converter-card.pinyin-writer-mode .btn-action:hover {
    border-color: var(--pinyin-writer-mode-color);
    background: rgba(139, 92, 246, 0.05);
}

/* Sub-mode Switcher (inside Pinyin Mode) */
.sub-mode-switcher {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.sub-mode-btn {
    flex: 1;
    padding: 0.625rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.sub-mode-btn:hover:not(.active) {
    background: var(--bg-gray-100);
    color: var(--text-primary);
}

.sub-mode-btn.active {
    background: var(--pinyin-mode-gradient);
    color: white;
    border-color: var(--pinyin-mode-color);
    box-shadow: var(--shadow-sm);
}

.sub-mode-icon {
    font-size: 1rem;
}

.pinyin-sub-mode-content {
    animation: fadeIn 0.3s;
}

/* Pinyin Status Area */
.pinyin-status-area {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.status-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    text-align: center;
}

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

.card-header-modern {
    background: var(--primary-gradient);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
}

.header-icon {
    font-size: 2rem;
    line-height: 1;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.card-body-modern {
    padding: 2.5rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.file-input-wrapper-modern {
    position: relative;
    margin-bottom: 1rem;
}

.file-input-hidden {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.file-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-gray-50);
    cursor: pointer;
    transition: all 0.3s;
    min-height: 180px;
    text-align: center;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-2px);
}

.file-upload-area.has-file {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.upload-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-main-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-sub-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.supported-formats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.formats-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.format-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.format-badge {
    padding: 0.375rem 0.75rem;
    background: var(--bg-gray-100);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

/* Conversion Section */
.conversion-section {
    margin-bottom: 2rem;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.label-icon {
    font-size: 1.25rem;
}

.form-select-modern {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.2s;
    cursor: pointer;
}

.form-select-modern:hover {
    border-color: var(--primary-color);
}

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

/* Convert Button */
.btn-convert {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    box-shadow: var(--shadow-md);
}

.btn-convert:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-convert:active:not(:disabled) {
    transform: translateY(0);
}

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

/* Privacy Statement */
.privacy-statement {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--radius-md);
    text-align: center;
}

.privacy-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.privacy-text::before {
    content: '🔒 ';
    margin-right: 0.25rem;
}

.btn-icon {
    font-size: 1.25rem;
}

/* Progress Section */
.progress-section {
    margin-top: 2rem;
    animation: fadeIn 0.3s;
}

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

.progress-wrapper {
    background: var(--bg-gray-100);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-percentage {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
    background: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    min-width: 60px;
    text-align: center;
}

.progress-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-bar-modern {
    width: 100%;
    height: 14px;
    background: var(--bg-gray-100);
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 1rem;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 7px;
    transition: width 0.3s ease;
    width: 0%;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    text-align: center;
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.progress-messages {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.progress-messages::-webkit-scrollbar {
    width: 6px;
}

.progress-messages::-webkit-scrollbar-track {
    background: var(--bg-gray-100);
    border-radius: 3px;
}

.progress-messages::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.progress-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.progress-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: fadeInMessage 0.3s;
}

.progress-message::before {
    content: '→';
    color: var(--primary-color);
    font-weight: bold;
}

.progress-message.success {
    color: var(--success-color);
}

.progress-message.success::before {
    content: '✓';
}

.progress-message.error {
    color: var(--error-color);
}

.progress-message.error::before {
    content: '✗';
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Alert Container */
.alert-container {
    margin-top: 1.5rem;
}

.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 1rem 1.25rem;
    animation: slideDown 0.3s;
}

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

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-left: 4px solid var(--error-color);
}

/* Features Card */
.features-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.features-header {
    background: var(--bg-gray-50);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.features-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
}

.feature-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.feature-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.feature-content {
    flex: 1;
}

.feature-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.feature-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem 0;
    }
    
    .header-content {
        flex-direction: column;
        align-items: center;
        position: relative;
    }
    
    .logo-section {
        text-align: center;
        width: 100%;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .app-subtitle {
        font-size: 0.8125rem;
    }
    
    .language-selector-wrapper {
        position: static;
        transform: none;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .language-selector {
        width: 100%;
        max-width: 200px;
    }
    
    .main-content {
        padding: 1rem 0 2rem;
    }
    
    .card-body-modern {
        padding: 1.5rem;
    }
    
    .card-header-modern {
        padding: 1.5rem;
    }
    
    .file-upload-area {
        padding: 2rem 1.5rem;
        min-height: 150px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        padding: 1.5rem;
    }
    
    .btn-convert {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* Google Ads Placeholders */
.ad-placeholder {
    background: var(--bg-gray-100);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.ad-placeholder:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.ad-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.ad-content {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.ad-banner {
    width: 100%;
    min-height: 90px;
    padding: 1.5rem;
}

.ad-sidebar {
    width: 100%;
    min-height: 600px;
    padding: 2rem 1rem;
    position: sticky;
    top: 100px;
}

.ad-footer {
    width: 100%;
    min-height: 90px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Footer */
.app-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    padding: 2rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    text-align: center;
    margin-top: 1rem;
}

.footer-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Responsive Ad Display */
@media (max-width: 1200px) {
    .ad-sidebar {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .ad-banner {
        min-height: 70px;
        padding: 1rem;
    }
    
    .ad-content {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.25rem;
    }
    
    .card-title {
        font-size: 1.25rem;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .upload-main-text {
        font-size: 1rem;
    }
    
    .ad-banner {
        min-height: 50px;
        padding: 0.75rem;
    }
    
    .ad-label {
        font-size: 0.625rem;
    }
    
    .ad-content {
        font-size: 0.625rem;
    }
}

/* Pinyin HTML Output Window */
.pinyin-html-output {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-white);
    border: 2px solid var(--pinyin-mode-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.pinyin-html-content {
    min-height: 100px;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

.pinyin-html-content::-webkit-scrollbar {
    width: 8px;
}

.pinyin-html-content::-webkit-scrollbar-track {
    background: var(--bg-gray-100);
    border-radius: 4px;
}

.pinyin-html-content::-webkit-scrollbar-thumb {
    background: var(--pinyin-mode-color);
    border-radius: 4px;
}

.pinyin-html-content::-webkit-scrollbar-thumb:hover {
    background: var(--pinyin-mode-dark);
}

/* Text Input/Output Styles */
.text-input-section,
.text-output-section {
    margin-bottom: 2rem;
}

.text-input-area,
.text-output-area {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-size: 1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s;
}

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

.converter-card.text-mode .text-input-area:focus {
    border-color: var(--text-mode-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.text-output-area {
    background: var(--bg-gray-50);
    cursor: text;
}

.text-output-area:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.converter-card.text-mode .text-output-area:focus {
    border-color: var(--text-mode-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Output Actions */
.output-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.btn-action {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-action:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-1px);
}

.converter-card.text-mode .btn-action:hover {
    border-color: var(--text-mode-color);
    background: rgba(16, 185, 129, 0.05);
}

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

.btn-clear {
    border-color: var(--error-color);
    color: var(--error-color);
}

.btn-clear:hover {
    background: rgba(239, 68, 68, 0.05);
    border-color: var(--error-color);
}

.mode-content {
    animation: fadeIn 0.3s;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   Mobile GUI Principles:
   - Larger touch targets (min 44x44px)
   - Increased spacing between elements
   - Full-width buttons
   - Larger fonts for readability
   - Vertical stacking
   - Better padding/margins
   ============================================ */

/* Mobile breakpoint: tablets and below (768px) */
@media (max-width: 768px) {
    /* Touch-friendly spacing */
    body {
        font-size: 16px; /* Prevent iOS zoom on input focus */
    }
    
    /* Header adjustments for mobile */
    .app-header {
        padding: 1rem 0;
    }
    
    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        position: relative;
    }
    
    .logo-section {
        text-align: center;
        width: 100%;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .app-subtitle {
        font-size: 0.8125rem;
    }
    
    .language-selector-wrapper {
        position: static;
        transform: none;
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 0.5rem;
    }
    
    .language-selector {
        width: 100%;
        max-width: 200px;
        padding: 0.75rem 1rem; /* Larger touch target */
        font-size: 1rem; /* Larger text */
    }
    
    /* Main content spacing */
    .main-content {
        padding: 1rem 0 2rem;
    }
    
    /* Mode switcher - stack vertically or larger buttons */
    .mode-switcher {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .mode-btn {
        padding: 1rem 1.5rem; /* Larger touch target (min 44px height) */
        font-size: 1rem;
        min-height: 48px; /* Ensure minimum touch target size */
    }
    
    .mode-icon {
        font-size: 1.5rem; /* Larger icons for mobile */
    }
    
    /* Card adjustments */
    .card-body-modern {
        padding: 1.5rem;
    }
    
    .card-header-modern {
        padding: 1.5rem;
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .header-icon {
        font-size: 2.5rem; /* Larger icons */
    }
    
    .card-title {
        font-size: 1.25rem;
    }
    
    /* File upload area - larger touch target */
    .file-upload-area {
        padding: 2.5rem 1.5rem;
        min-height: 180px;
    }
    
    .upload-icon {
        font-size: 3.5rem; /* Larger icon */
        margin-bottom: 1.25rem;
    }
    
    .upload-main-text {
        font-size: 1.125rem;
    }
    
    .upload-sub-text {
        font-size: 0.9375rem;
    }
    
    /* Form elements - larger touch targets */
    .form-select-modern {
        padding: 1rem 1.25rem; /* Larger padding */
        font-size: 1rem;
        min-height: 48px; /* Minimum touch target */
    }
    
    /* Buttons - full width and larger */
    .btn-convert {
        padding: 1.125rem 2rem; /* Larger padding */
        font-size: 1.125rem;
        min-height: 52px; /* Larger touch target */
        width: 100%;
    }
    
    /* Text areas - better spacing */
    .text-input-area,
    .text-output-area {
        padding: 1.125rem;
        font-size: 1rem; /* Prevent zoom on iOS */
        min-height: 120px; /* Better for mobile typing */
        line-height: 1.6;
    }
    
    /* Output actions - full width buttons */
    .output-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn-action {
        width: 100%;
        padding: 1rem 1.5rem; /* Larger touch target */
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Sub-mode switcher */
    .sub-mode-switcher {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .sub-mode-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }
    
    .sub-mode-icon {
        font-size: 1.25rem;
    }
    
    /* Section labels */
    .section-label {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
    
    .label-icon {
        font-size: 1.5rem;
    }
    
    /* Progress section */
    .progress-wrapper {
        padding: 1.25rem;
    }
    
    .progress-percentage {
        font-size: 1.25rem;
        padding: 0.5rem 1rem;
    }
    
    .progress-status {
        font-size: 1rem;
    }
    
    /* Alerts */
    .alert {
        padding: 1.25rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Features grid - single column */
    .features-grid {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        gap: 1.5rem;
    }
    
    .feature-item {
        gap: 1.25rem;
    }
    
    .feature-icon {
        font-size: 2.5rem;
    }
    
    .feature-title {
        font-size: 1.125rem;
    }
    
    .feature-desc {
        font-size: 0.9375rem;
    }
    
    /* Privacy statement */
    .privacy-statement {
        padding: 1.25rem;
        font-size: 0.9375rem;
    }
    
    /* Remove hover effects on mobile (not applicable) */
    .mode-btn:hover,
    .btn-action:hover,
    .btn-convert:hover:not(:disabled),
    .file-upload-area:hover,
    .form-select-modern:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    .converter-card:hover {
        transform: none;
    }
}

/* Small mobile devices (480px and below) */
@media (max-width: 480px) {
    /* Even more compact for small screens */
    .app-title {
        font-size: 1.25rem;
    }
    
    .app-subtitle {
        font-size: 0.75rem;
    }
    
    .card-header-modern {
        padding: 1.25rem;
    }
    
    .card-body-modern {
        padding: 1.25rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    .header-icon {
        font-size: 2rem;
    }
    
    .mode-btn {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }
    
    .file-upload-area {
        padding: 2rem 1.25rem;
        min-height: 160px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .upload-main-text {
        font-size: 1rem;
    }
    
    .btn-convert {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
    
    .text-input-area,
    .text-output-area {
        padding: 1rem;
        font-size: 16px; /* Critical: prevent iOS zoom */
    }
    
    .btn-action {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }
    
    .form-select-modern {
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    .language-selector {
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    /* Compact mode switcher */
    .mode-switcher {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    /* Smaller gaps in general */
    .output-actions {
        gap: 0.5rem;
    }
    
    .sub-mode-switcher {
        gap: 0.5rem;
    }
}

/* Language-specific mobile optimizations */
/* Chinese text handling (Simplified and Traditional) */
[lang="zh-CN"],
[lang="zh-TW"],
html[lang="zh-CN"] *,
html[lang="zh-TW"] * {
    /* Better font rendering for Chinese characters */
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Noto Sans SC', 'Source Han Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Mobile optimizations for Chinese text */
@media (max-width: 768px) {
    /* Chinese text needs slightly different spacing */
    [lang="zh-CN"] .mode-btn,
    [lang="zh-TW"] .mode-btn,
    html[lang="zh-CN"] .mode-btn,
    html[lang="zh-TW"] .mode-btn {
        /* Slightly more padding for Chinese characters which can be wider */
        padding: 1rem 1.25rem;
        font-size: 0.9375rem; /* Slightly smaller to fit better */
        letter-spacing: 0.02em; /* Tighter letter spacing for Chinese */
    }
    
    /* Chinese text in buttons - ensure proper wrapping */
    [lang="zh-CN"] .btn-action,
    [lang="zh-TW"] .btn-action,
    html[lang="zh-CN"] .btn-action,
    html[lang="zh-TW"] .btn-action {
        white-space: normal;
        word-break: keep-all; /* Keep Chinese words together */
        line-height: 1.4;
        padding: 1rem 1.25rem;
    }
    
    /* Chinese text in card titles */
    [lang="zh-CN"] .card-title,
    [lang="zh-TW"] .card-title,
    html[lang="zh-CN"] .card-title,
    html[lang="zh-TW"] .card-title {
        font-size: 1.125rem; /* Slightly smaller for better fit */
        line-height: 1.5;
    }
    
    /* Chinese text in textareas - better line height */
    [lang="zh-CN"] .text-input-area,
    [lang="zh-TW"] .text-input-area,
    [lang="zh-CN"] .text-output-area,
    [lang="zh-TW"] .text-output-area,
    html[lang="zh-CN"] .text-input-area,
    html[lang="zh-TW"] .text-input-area,
    html[lang="zh-CN"] .text-output-area,
    html[lang="zh-TW"] .text-output-area {
        line-height: 1.8; /* Better line spacing for Chinese characters */
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    /* Chinese text in labels and small text */
    [lang="zh-CN"] .section-label,
    [lang="zh-TW"] .section-label,
    [lang="zh-CN"] .upload-sub-text,
    [lang="zh-TW"] .upload-sub-text,
    html[lang="zh-CN"] .section-label,
    html[lang="zh-TW"] .section-label,
    html[lang="zh-CN"] .upload-sub-text,
    html[lang="zh-TW"] .upload-sub-text {
        line-height: 1.6;
    }
}

/* Small mobile devices - additional Chinese text optimizations */
@media (max-width: 480px) {
    [lang="zh-CN"] .mode-btn,
    [lang="zh-TW"] .mode-btn,
    html[lang="zh-CN"] .mode-btn,
    html[lang="zh-TW"] .mode-btn {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    [lang="zh-CN"] .card-title,
    [lang="zh-TW"] .card-title,
    html[lang="zh-CN"] .card-title,
    html[lang="zh-TW"] .card-title {
        font-size: 1rem;
    }
}

/* Touch device optimizations (any touch device) */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .mode-btn:hover,
    .btn-action:hover,
    .btn-convert:hover:not(:disabled),
    .file-upload-area:hover,
    .form-select-modern:hover,
    .language-selector:hover {
        background: inherit;
        border-color: inherit;
        box-shadow: inherit;
        transform: none;
    }
    
    .converter-card:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    /* Increase active state visibility */
    .mode-btn:active,
    .btn-action:active,
    .btn-convert:active:not(:disabled) {
        opacity: 0.8;
        transform: scale(0.98);
    }
    
    /* Better focus states for touch */
    .mode-btn:focus,
    .btn-action:focus,
    .btn-convert:focus:not(:disabled),
    .form-select-modern:focus,
    .text-input-area:focus,
    .text-output-area:focus {
        outline: 3px solid rgba(102, 126, 234, 0.3);
        outline-offset: 2px;
    }
}

/* Text overflow and wrapping for all languages */
.mode-btn,
.btn-action,
.btn-convert,
.card-title,
.section-label {
    /* Ensure text wraps properly in all languages */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Chinese-specific text wrapping rules */
[lang="zh-CN"] *,
[lang="zh-TW"] *,
html[lang="zh-CN"] *,
html[lang="zh-TW"] * {
    /* Chinese text should not break in the middle of words */
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* Mobile: Ensure buttons accommodate longer text in all languages */
@media (max-width: 768px) {
    .mode-btn,
    .btn-action,
    .sub-mode-btn {
        /* Allow text to wrap if needed */
        white-space: normal;
        text-align: center;
        /* Ensure minimum height even with wrapped text */
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Multi-line button text support */
    .mode-btn span,
    .btn-action span,
    .sub-mode-btn span {
        display: inline-block;
        text-align: center;
    }
}

/* Ensure proper text rendering for mixed language content */
.text-input-area,
.text-output-area {
    /* Support mixed English and Chinese text */
    font-family: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', -apple-system, BlinkMacSystemFont, sans-serif;
    /* Better line spacing for mixed content */
    line-height: 1.7;
}

/* Mobile: Better spacing for mixed language content */
@media (max-width: 768px) {
    .text-input-area,
    .text-output-area {
        line-height: 1.8; /* More spacing for readability */
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .app-header {
        padding: 0.75rem 0;
    }
    
    .main-content {
        padding: 0.75rem 0 1.5rem;
    }
    
    .card-body-modern {
        padding: 1.25rem;
    }
    
    /* Reduce vertical spacing in landscape */
    .text-input-section,
    .text-output-section {
        margin-bottom: 1.5rem;
    }
}
