:root {
    --primary-color: #4A90E2;
    --bg-color: #F5F7FA;
    --box-bg: #FFFFFF;
    --text-color: #333333;
    --header-bg: linear-gradient(135deg, #4A90E2, #357ABD);
}
body {
    font-family: 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    box-sizing: border-box;
}

header {
    background: var(--header-bg);
    color: white;
    text-align: center;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex: 0 0 auto;
}
header h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: 1px;
}
header h1 i {
    margin-right: 8px;
}
header p {
    margin: 5px 0 0 0;
    font-size: 14px;
    opacity: 0.9;
}

footer {
    background-color: #E6EBEF;
    color: #666;
    text-align: center;
    padding: 12px 20px;
    font-size: 13px;
    border-top: 1px solid #DFE5EC;
    flex: 0 0 auto;
    line-height: 1.6;
    width: 100%;
    box-sizing: border-box;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: #357ABD;
    text-decoration: underline;
}

main {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 2vh 4vw;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
}

.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    background: var(--box-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    justify-content: space-between;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    flex: 1 1 calc((100% - (15px * 3)) / 4); 
    min-width: 160px; 
    white-space: nowrap; 
}

.control-item label {
    white-space: nowrap;
    flex-shrink: 0;
}

.control-item input[type="range"], 
.control-item select {
    flex: 1;
    min-width: 0; 
    max-width: 100%; 
    padding: 4px;
    text-overflow: ellipsis;
}
.section {
    background: var(--box-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 15px;
    display: flex;
    flex-direction: column;
}

#top-section {
    position: relative;
    flex: 1; 
    min-height: 170px; 
    padding-top: 40px;
}

#top-section::before {
    content: "\f303  內容輸入區";
    font-family: 'Font Awesome 7 Free';
    font-weight: 900;
    position: absolute;
    top: 12px;
    left: 15px;
    color: var(--primary-color);
    letter-spacing: 1px;
}

textarea {
    width: 100%;
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px;
    font-size: 16px;
    resize: none;
    box-sizing: border-box;
    field-sizing: content;
}

.quick-examples {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.quick-examples.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    height: 0;
    margin-top: 0;
}

.example-label {
    font-size: 13px;
    color: #7F8C8D;
}

.chip {
    background-color: #E6EBEF;
    color: #333;
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: auto;
    max-width: none;
    display: inline-block;
}

.chip:hover {
    background-color: #D5DBE0;
}

.chip:active {
    transform: scale(0.95);
}

#middle-section {
    background-color: transparent;
    box-shadow: none;
    align-items: center;
    justify-content: center;
    padding: 10px;
    flex: 0 0 auto;
}
button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    width: 100%;
    max-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
button:hover { background-color: #357ABD; }
button:active { transform: scale(0.98); }
button:disabled { background-color: #A0C4E8; cursor: not-allowed; }

.action-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 360px;
    justify-content: center;
}

.action-buttons button {
    max-width: none;
}

#playBtn {
    flex: 1;
    background-color: #27AE60;
}
#playBtn:hover { 
    background-color: #219653; 
}

#stopBtn {
    flex: 1;
    background-color: #E74C3C;
}
#stopBtn:hover {
    background-color: #C0392B;
}

#shareBtn {
    flex: 0 0 auto;
    width: auto;
    padding: 12px 20px;
    background-color: #F39C12;
    color: #FFFFFF;
}

#shareBtn:hover {
    background-color: #D68910;
}

#shareBtn:active { 
    transform: scale(0.95); 
}

#voiceInfo {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
}

#bottom-section {
    flex: 2;
    overflow-y: auto;
    line-height: 2.2;
    font-size: 22px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #95A5A6;
    text-align: center;
    user-select: none;
}
.empty-icon {
    font-size: 48px;
    margin-top: 5px;
    margin-bottom: 15px;
    color: #BDC3C7;
}
.empty-title {
    font-size: 20px;
    font-weight: bold;
    margin: 0 0 5px 0;
    color: #7F8C8D;
}
.empty-subtitle {
    font-size: 15px;
    margin: 0;
}

ruby, .punct-text, .normal-text, .space-mark {
    margin-right: 2px;
    display: inline-flex;
    flex-direction: column-reverse;
    align-items: center;
    min-width: 2.2em;
    vertical-align: bottom;
}
rt {
    font-size: 0.6em;
    color: #666;
    line-height: 1.2;
    margin-bottom: 2px;
}

#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: rgba(51, 51, 51, 0.9);
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s, visibility 0.3s;
}

#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

#faq-section {
    margin-top: 5px;
}
#faq-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #E6EBEF;
    padding-bottom: 10px;
}
.faq-item {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.faq-question {
    display: flex;
    gap: 6px;
    margin: 0;
}
.faq-question h4 {
    margin: 0;
    font-size: 15px;
    color: var(--text-color);
    line-height: 1.5;
}
.faq-answer {
    display: flex;
    gap: 6px;
    margin: 0;
    padding-left: 18px;
}
.faq-answer-content {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    flex: 1;
}
.faq-answer-content p {
    margin: 0 0 10px 0;
}
.faq-answer-content p:last-child {
    margin-bottom: 0;
}
.faq-item ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
    font-size: 14px;
    color: #555;
    line-height: 1.8;
}
.faq-item li {
    margin-bottom: 8px;
}
.faq-item li:last-child {
    margin-bottom: 0;
}

#terms-section {
    margin-top: 5px;
}
#terms-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #E6EBEF;
    padding-bottom: 10px;
}
.terms-content {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}
.terms-content p {
    margin: 0 0 12px 0;
}
.terms-content p:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    header { padding: 12px 15px; }
    header h1 { font-size: 20px; }
    header p { font-size: 12px; }
    main { padding: 12px; gap: 12px; }
    
    .controls {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    .control-item { 
        display: flex; 
        width: 100%; 
        flex: none;
        white-space: nowrap;
    }
    .control-item input[type="range"], 
    .control-item select { max-width: 100%; width: 100%; }
    .control-item span { white-space: nowrap; margin-left: 5px; min-width: 25px; text-align: center; }
    
    #bottom-section { font-size: 18px; line-height: 2; }
    
    #toast { min-width: 200px; font-size: 14px; padding: 12px; }
    
    .faq-answer { padding-left: 15px; }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

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

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