body {
    font-family: "Microsoft JhengHei", "Heiti TC", sans-serif;
    margin: 0;
    padding: 0;
    background-color: #FFFFCC;
    color: #333;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: #fff;
    min-height: 100vh;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

header {
    background-color: #FFCC99;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    border-bottom: 2px solid #CC9966;
}

header h1 {
    margin: 0;
    color: #663300;
    font-size: 1.5rem;
    line-height: 1.3;
    text-align: center;
    max-width: 100%;
}

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

.usage-btn {
    padding: 6px 15px;
    border-radius: 20px;
    border: 1px solid #CC9966;
    background: #FFF5EE;
    color: #663300;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.usage-btn:hover {
    background: #FFCC99;
}

/* language switch in header */
.lang-switch {
    position: static;
}

.lang-switch select {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #CC9966;
    background: #fff;
    color: #663300;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    font-weight: bold;
}

.main-content {
    display: flex;
    min-height: calc(100vh - 120px);
}

.sidebar {
    width: 260px;
    background-color: #FFFF99;
    padding: 20px;
    border-right: 1px solid #CC9966;
}

@media (max-width: 768px) {
    header {
        padding: 15px;
    }
    header h1 {
        font-size: 1.2rem;
    }
    .main-content {
        flex-direction: column;
    }
    .sidebar {
        width: auto;
        border-right: none;
        border-bottom: 1px solid #CC9966;
        padding: 15px;
    }
    .content-area {
        padding: 20px 15px;
    }
    .initials-grid {
        grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    }
    .tone-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

.tabs {
    display: flex;
    margin-bottom: 20px;
    background: rgba(204, 153, 102, 0.2);
    border-radius: 8px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #663300;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: #FFCC99;
    color: #663300;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sidebar h3 {
    color: #663300;
    font-size: 1rem;
    margin-bottom: 15px;
    margin-top: 0;
}

.initials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.initial-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    background-color: #fff;
    border: 1px solid #CC9966;
    text-decoration: none;
    color: #663300;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.initial-btn:hover, .initial-btn.active {
    background-color: #FFCC99;
    border-color: #CC9966;
    color: #663300;
    font-weight: bold;
}

.tone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
}

.tone-card {
    background-color: #FFF;
    border: 1px solid #CC9966;
    border-radius: 8px;
    text-align: center;
    padding: 12px 4px;
    font-weight: 600;
    color: #663300;
    cursor: pointer;
    transition: all 0.2s;
}

.tone-card:hover, .tone-card.active {
    background-color: #FFCC99;
    border-color: #CC9966;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tone-card span {
    display: block;
    font-weight: normal;
    font-size: 0.8rem;
    color: #AA6633;
    margin-top: 2px;
}

.char-search {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.char-search input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #CC9966;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}

.char-search button {
    padding: 10px 16px;
    background: #FFCC99;
    border: 1px solid #CC9966;
    color: #663300;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.direction-switch select {
    width: 100%;
    padding: 10px;
    border: 1px solid #CC9966;
    border-radius: 8px;
    background-color: #fff;
    color: #663300;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
}

.content-area {
    flex: 1;
    padding: 30px;
    background-color: #fff;
}

.welcome-message {
    color: #663300;
    font-size: 1.1rem;
    text-align: center;
    margin-top: 50px;
    opacity: 0.7;
}

.correspondence-group {
    margin-bottom: 30px;
    border: 1px solid #FFCC99;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.mandarin-initial-header {
    background-color: #FFF5EE;
    padding: 12px 20px;
    font-size: 1.1rem;
    color: #663300;
    font-weight: bold;
    border-bottom: 1px solid #FFCC99;
}

.char-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 20px;
}

.char-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: #fff;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    transition: all 0.2s;
}

.char-item:hover {
    border-color: #FFCC99;
    background-color: #FFF9F5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.char-symbol {
    font-size: 1.2rem;
    color: #333;
    cursor: pointer;
    flex: 1;
}

.audio-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    color: #666;
}

.audio-btn:hover {
    background-color: #EEE;
    color: #333;
}

.stats {
    padding: 8px 20px;
    background-color: #F5F5F5;
    font-size: 0.85rem;
    color: #888;
    border-top: 1px solid #EEE;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fff;
    margin: 15vh auto;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-content.wide {
    max-width: 650px;
    text-align: left;
}

.usage-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0 10px 20px 0;
    color: #444;
    font-size: 1rem;
    line-height: 1.8;
}

.usage-content h1 { 
    font-size: 1.8rem; 
    margin: 0 0 1.5rem 0; 
    color: #663300; 
    text-align: center;
    border-bottom: 3px solid #FFCC99;
    padding-bottom: 15px;
}

.usage-content h2 { 
    font-size: 1.3rem; 
    margin: 2rem 0 1rem 0; 
    color: #884400; 
    background: #FFF5EE;
    padding: 8px 15px;
    border-left: 5px solid #FFCC99;
    border-radius: 4px;
}

.usage-content h3 { 
    font-size: 1.1rem; 
    margin: 1.5rem 0 0.8rem 0; 
    color: #AA6633;
    font-weight: bold;
}

.usage-content p { 
    margin-bottom: 1.2rem; 
}

.usage-content ul, .usage-content ol { 
    padding-left: 1.5rem; 
    margin-bottom: 1.5rem; 
}

.usage-content li { 
    margin-bottom: 10px; 
    position: relative;
}

.usage-content strong {
    color: #AA3333;
    background: #FFF9F5;
    padding: 2px 4px;
    border-radius: 3px;
}

.usage-content a { 
    color: #0066CC; 
    text-decoration: none; 
    border-bottom: 1px dashed #0066CC;
}

.usage-content a:hover { 
    color: #AA3333;
    border-bottom-style: solid;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

.detail-char {
    font-size: 4rem;
    color: #663300;
    margin-bottom: 20px;
}

.detail-info {
    font-size: 1.1rem;
    margin: 10px 0;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.modal-audio-btn {
    background: #FFCC99;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .char-list {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        padding: 15px;
        gap: 8px;
    }
    .content-area {
        padding: 15px;
    }
}
