:root {
    --primary-color: #c92a2a;
    --secondary-color: #e9b104;
    --background-color: #f8f9fa;
    --text-color: #343a40;
    --white-color: #ffffff;
    --border-radius: 12px;
    --special-key-color: #adb5bd;
    --key-background-color: var(--white-color);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --key-shadow: 0 4px 6px var(--shadow-color);
    --key-hover-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
    --transition-speed: 0.2s;
}

[data-theme="dark"] {
    --primary-color: #e74c3c;
    --secondary-color: #f1c40f;
    --background-color: #2c3e50;
    --text-color: #ecf0f1;
    --white-color: #34495e;
    --special-key-color: #95a5a6;
    --key-background-color: #3b5268;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --key-shadow: 0 4px 6px var(--shadow-color);
    --key-hover-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

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

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

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.bounce-in {
    animation: bounceIn 0.6s ease forwards;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.main-content {
    flex: 1;
    max-width: 950px;
    margin: 0 auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.8s ease-out;
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0;
    animation: fadeIn 0.6s ease-out;
    position: relative;
}

.header-center {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.header-content {
    text-align: center;
    flex-grow: 1;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.logo {
    width: 70px;
    height: 70px;
    object-fit: contain;
}
.header-content:hover {
    transform: scale(1.02);
}

header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    transition: color 0.3s ease;
    margin: 0;
    padding: 0;
    width: 100%;
}

header h1:hover {
    color: var(--secondary-color);
}

header p {
    color: var(--secondary-color);
    font-size: 1.1rem;
    margin: 6px 0 0 0;
    padding: 0;
}

.header-content h1, .header-content p {
    text-align: center;
    width: 100%;
}

.theme-button {
    position: absolute;
    top: 10px;
    right: 0;
    z-index: 10;
    padding: 8px 12px;
    font-size: 0.9rem;
}

#theme-toggle {
    padding: 10px 15px;
    border: 1px solid var(--text-color);
    background-color: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px; /* Minimum touch target size for accessibility */
}

#theme-toggle:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#theme-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.8rem;
    position: relative;
    padding-bottom: 10px;
}

section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--secondary-color);
    border-radius: 3px;
}

#text-input {
    width: 100%;
    height: 180px;
    padding: 20px;
    border: 2px solid #ced4da;
    border-radius: var(--border-radius);
    font-size: 1.3rem;
    font-family: 'Noto Sans SC', sans-serif;
    resize: vertical;
    margin-bottom: 5px;
    background-color: var(--key-background-color);
    color: var(--text-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    animation: fadeIn 0.7s ease-out;
}

#text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 2px 15px rgba(201, 42, 42, 0.2);
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-buttons button, .button-link {
    padding: 12px 25px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    background-color: var(--primary-color);
    color: #ffffff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px; /* Minimum touch target size for accessibility */
}

.action-buttons button:hover, .button-link:hover {
    background-color: #a62323;
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.action-buttons button:active, .button-link:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#keyboard, #secondary-keyboard {
    width: 100%;
    background-color: var(--white-color);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.9s ease-out;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#secondary-keyboard {
    margin-top: 20px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
    min-width: fit-content;
}

.keyboard-row:last-child {
    margin-bottom: 0;
}

.keyboard-row:nth-child(1) .key {
    animation-delay: 0.1s;
}

.keyboard-row:nth-child(2) .key {
    animation-delay: 0.2s;
}

.keyboard-row:nth-child(3) .key {
    animation-delay: 0.3s;
}

.key {
    width: 60px;
    height: 60px;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--key-background-color);
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    box-shadow: var(--key-shadow);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
    padding: 2px;
}

.key:hover {
    background-color: #f1f3f5;
    box-shadow: var(--key-hover-shadow);
    transform: translateY(-3px);
    z-index: 2;
}

.key:active {
    transform: translateY(1px);
    box-shadow: 0 2px 3px var(--shadow-color);
    background-color: #e9ecef;
}

.key-special:hover {
    background-color: #868e96;
    transform: translateY(-3px);
}

.key-special:active {
    transform: translateY(1px);
    background-color: #6c757d;
}

.key-special {
    background-color: var(--special-key-color);
    color: #ffffff;
    font-weight: bold;
    text-transform: uppercase;
}

.key-enter {
    flex-grow: 1.5;
}

.english-char {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 2px;
    line-height: 1.2;
}

.pinyin-char {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 2px;
    line-height: 1.2;
}

.chinese-char {
    font-size: 1.4rem;
    color: var(--text-color);
    font-weight: 500;
    line-height: 1.2;
}

#description-section {
    width: 100%;
    background-color: var(--white-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    animation: fadeIn 1s ease-out;
}

#description-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.8rem;
}

#description-section h3 {
    color: var(--secondary-color);
    margin: 25px 0 15px 0;
    font-size: 1.4rem;
}

#description-section p {
    margin-bottom: 15px;
    line-height: 1.7;
    font-size: 1.1rem;
}

#description-section ul {
    margin: 15px 0 20px 20px;
    line-height: 1.7;
}

#description-section li {
    margin-bottom: 10px;
}



footer {
    width: 100%;
    text-align: center;
    padding: 25px 0;
    background-color: var(--white-color);
    margin-top: auto;
    font-size: 1.1rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.footer-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

@media (max-width: 1200px) {
    .main-content {
        margin: 0 20px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    header p {
        font-size: 1rem;
    }
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    .action-buttons button, .button-link {
        width: 100%;
        padding: 15px;
        font-size: 1.1rem;
    }
    .key {
        width: 50px;
        height: 50px;
        min-width: 50px;
        padding: 2px;
    }
    .english-char {
        font-size: 1.1rem;
    }
    .pinyin-char {
        font-size: 0.95rem;
    }
    .chinese-char {
        font-size: 1.2rem;
    }
    #text-input {
        height: 150px;
        padding: 15px;
        font-size: 1.1rem;
    }
    #keyboard, #secondary-keyboard {
        padding: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .keyboard-row {
        gap: 8px;
        margin-bottom: 8px;
        min-width: fit-content;
    }
    #description-section {
        padding: 20px;
    }
    #description-section h2 {
        font-size: 1.5rem;
    }
    #description-section h3 {
        font-size: 1.2rem;
    }
    #description-section p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 15px 10px;
    }
    
    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        height: auto;
        padding: 10px 0;
    }
    
    .header-content {
        flex-direction: column;
        height: auto;
    }
    
    .logo {
        width: 40px;
        height: 40px;
        margin-bottom: 5px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    #theme-toggle {
        align-self: center;
        padding: 5px 10px;
        font-size: 0.8rem;
        height: auto;
    }
    
    .key {
        width: 30px;
        height: 30px;
        min-width: 30px;
        padding: 1px;
    }
    
    .english-char {
        font-size: 0.7rem;
    }
    
    .pinyin-char {
        font-size: 0.6rem;
    }
    
    .chinese-char {
        font-size: 0.8rem;
    }
    
    #keyboard, #secondary-keyboard {
        padding: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .keyboard-row {
        gap: 3px;
        margin-bottom: 3px;
        min-width: fit-content;
    }
    
    #text-input {
        height: 120px;
        padding: 10px;
        font-size: 1rem;
    }
    
    .action-buttons {
        gap: 10px;
    }
    
    .action-buttons button, .button-link {
        padding: 12px;
        font-size: 1rem;
    }
    
    #description-section {
        padding: 15px;
    }
    
    #description-section h2 {
        font-size: 1.3rem;
    }
    
    #description-section h3 {
        font-size: 1.1rem;
    }
    
    #description-section p {
        font-size: 0.9rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .footer-logo {
        width: 35px;
        height: 35px;
    }
    
    footer {
        padding: 20px 0;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .key {
        width: 28px;
        height: 28px;
        min-width: 28px;
        padding: 1px;
    }
    
    .english-char {
        font-size: 0.6rem;
    }
    
    .pinyin-char {
        font-size: 0.55rem;
    }
    
    .chinese-char {
        font-size: 0.75rem;
    }
    
    .keyboard-row {
        gap: 2px;
        margin-bottom: 2px;
        min-width: fit-content;
    }
    
    #text-input {
        height: 100px;
        padding: 8px;
        font-size: 0.9rem;
    }
    
    .action-buttons button, .button-link {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    #keyboard, #secondary-keyboard {
        padding: 5px;
    }
}
