/* ================= 明亮清新色系 ================= */
:root {
    --base-font-size: 20px;
    --primary-color: #00897B; 
    --primary-light: #4DB6AC; 
    --primary-dark: #00695C;  
    --accent-color: #FF7043;  
    --bg-color: #F4F7F6;      
    --text-main: #2C3E50;     
    --text-muted: #7F8C8D;
    --border-radius: 8px;
}

body {
    font-size: var(--base-font-size);
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.8;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ================= 頂部導覽列 ================= */
.main-header {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; }
.main-header h1 { 
    font-size: 1.25rem; margin: 0 0 0 5px; font-weight: normal; 
    letter-spacing: 1px; cursor: pointer;
}

.icon-btn {
    background: none; border: none; color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 6px; border-radius: 50%; transition: background 0.2s;
}
.icon-btn:active { background: rgba(255,255,255,0.2); }

.search-wrapper {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.2); border-radius: 20px; padding-right: 5px;
}
.search-input {
    width: 0; opacity: 0; border: none; background: transparent;
    color: white; font-family: inherit; font-size: 0.9rem; padding: 0;
    transition: all 0.3s ease;
}
.search-input::placeholder { color: rgba(255,255,255,0.9); }
.search-input:focus { outline: none; }
.search-input.active { width: 130px; opacity: 1; padding: 6px 10px; }

/* ================= 側邊欄 ================= */
.sidebar {
    position: fixed; top: 0; left: -280px; width: 260px; height: 100vh;
    background-color: white; box-shadow: 2px 0 12px rgba(0,0,0,0.08);
    z-index: 1000; transition: left 0.3s ease; display: flex; flex-direction: column;
}
.sidebar.open { left: 0; }
.sidebar-header {
    background-color: var(--primary-light); color: white; padding: 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.sidebar-header h2 { margin: 0; font-size: 1.1rem; font-weight: normal; }

.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li {
    padding: 10px 20px;
    cursor: pointer; color: var(--text-main); font-size: 1rem;
    display: flex; align-items: center; gap: 10px; transition: 0.2s;
}
.sidebar-menu li:hover { background-color: #F4F7F6; color: var(--primary-color); }

.sidebar-divider { height: 1px; background-color: #F0F0F0; margin: 0 15px; }

.sidebar-list { flex: 1; overflow-y: auto; list-style: none; padding: 0; margin: 0; }
.sidebar-list::-webkit-scrollbar { width: 6px; }
.sidebar-list::-webkit-scrollbar-thumb { background-color: #DDDDDD; border-radius: 4px; }
.sidebar-list li {
    padding: 10px 20px;
    border-bottom: 1px solid #FAFAFA;
    cursor: pointer; color: var(--text-main); font-size: 1rem;
    display: flex; align-items: center; gap: 10px; transition: 0.2s;
}
.sidebar-list li:hover { background-color: #F4F7F6; color: var(--primary-color); }
.sidebar-static-link { color: var(--primary-color) !important; font-weight: bold; }

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 999; display: none;
}

/* ================= 滿版橫幅 ================= */
.full-width-banner {
    width: 100%; height: 220px; background-color: #E0E0E0;
    background-image: url('https://picsum.photos/1200/400?nature'); 
    background-size: cover; background-position: center; position: relative;
}

/* ================= 內容區塊 ================= */
.view-section { 
    padding: 30px 20px; max-width: 800px; margin: 0 auto; 
    flex: 1; width: 100%; box-sizing: border-box;
}

.directory-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px;
}

.card {
    position: relative; 
    background: white; border-radius: var(--border-radius);
    box-shadow: 0 2px 15px rgba(0,0,0,0.05); padding: 25px 15px;
    text-align: center; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #EEEEEE;
}
.card:active { transform: scale(0.97); }

.card-number {
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--primary-light);
    opacity: 0.5;
    font-family: monospace;
    letter-spacing: 1px;
}

.card-icon { font-size: 2.5rem; margin-bottom: 10px; }
.card-title { font-weight: bold; font-size: 1.1rem; color: var(--primary-color); }
.card-level { font-size: 0.8rem; color: var(--accent-color); margin-top: 5px;}

/* ================= 文章排版 ================= */
.article-header {
    margin-bottom: 20px; border-bottom: 1px solid #EBEBEB; padding-bottom: 15px;
}
.article-header-flex {
    position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 0 60px; min-height: 40px;
}
.article-header h2 { margin: 0; font-size: 1.8rem; color: var(--primary-color); font-weight: bold; text-align: center; }
.article-stars { 
    position: absolute; right: 0; top: 50%; transform: translateY(-50%); 
    color: var(--accent-color); font-size: 1rem; letter-spacing: 2px; 
}

/* 左側的返回按鈕 */
.back-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    background: rgba(0, 137, 123, 0.1); /* 淡淡的青色圓底 */
    width: 36px;
    height: 36px;
}
.back-btn:active { background: rgba(0, 137, 123, 0.25); }

@media (max-width: 400px) {
    .article-header-flex { padding: 0; padding-bottom: 25px; }
    .article-stars { top: auto; bottom: 0; transform: none; right: 0; }
    .back-btn { top: auto; bottom: -5px; transform: none; left: 0; }
}

/* ★ 新增：文章專屬的工具列 (放在文章內部，樣式改為適合白底) ★ */
.article-tools {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.toggle-ruby-btn {
    background: transparent; 
    border: 1px solid var(--primary-color); 
    color: var(--primary-color);
    padding: 4px 16px; 
    border-radius: 16px; 
    font-size: 0.9rem; 
    cursor: pointer;
    transition: all 0.2s ease; 
    font-family: inherit; 
}
.toggle-ruby-btn.active {
    background: var(--primary-color); 
    color: white; 
    font-weight: bold;
}


.toggle-ruby-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.font-controls { display: flex; align-items: center; gap: 8px; }

.tool-btn {
    background: rgba(0, 137, 123, 0.1);
    color: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.tool-btn:active { background: rgba(0, 137, 123, 0.25); }
.tool-btn .material-icons { font-size: 18px; }

/* 圖片與內文 */
.article-hero-image {
    width: 100%; max-height: 400px; object-fit: cover;
    border-radius: var(--border-radius); margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.article-content p {
    text-indent: 2.5em; margin: 0 0 1.5em 0; line-height: 2.6;
    text-align: left; letter-spacing: 0.05em; 
}
.article-content h3 { color: var(--primary-color); margin-top: 30px; font-weight: bold;}


/* ================= 拼音排版 ================= */
ruby { 
    display: inline-flex;
    flex-direction: column-reverse; 
    vertical-align: text-bottom;
    text-align: center;
    margin: 0 0.1em;
}
rb {
    display: inline;
    line-height: 1.2;
    text-align: center;
}
rt { 
    color: var(--primary-dark); 
    font-size: 0.71em; 
    line-height: 1;
    white-space: nowrap;
    text-align: center;
    display: block;
    margin-bottom: 0.1em; 
	letter-spacing: -0.3px;
}



/* 模式 1：漢字模式 */
.mode-hanzi-only ruby {
    line-height: 1.4;
    margin: 0;
    display: inline;
}
.mode-hanzi-only rt { display: none; }



/* 模式 2：拼音模式 (只顯示拼音與無標音文字) */
.mode-pinyin-only rb { 
    visibility: hidden; /* 佔用空間但看不見，完美維持標點與拼音位置 */
}



/* ================= 檢視模式排版 (段落 / 斷句) ================= */
.sentence-block {
    display: inline; 
}
.sentence-block::before {
    display: none; 
}

.mode-sentence p {
    margin-bottom: 2.5em; 
    border-bottom: 1px dashed #E0E0E0; 
    padding-bottom: 1.5em;
    text-indent: 0 !important; 
}
.mode-sentence p:last-child {
    border-bottom: none;
}

.mode-sentence .sentence-block {
    display: block;       
    position: relative;
    padding-left: 34px;   
    margin-bottom: 15px;  
}

/* 預設精緻編號徽章 */
.mode-sentence .sentence-block::before {
    content: attr(data-label);
    display: block;       
    position: absolute;
    left: 0;
    top: 0.25em;          
    font-size: 0.7rem;    
    font-weight: bold;
    font-family: monospace;
    text-align: center;   
    width: 26px;          
    padding: 3px 0;       
    border-radius: 6px;   
    background-color: #F0F4F8;
    color: #546E7A;
}


/* 第 1 段循環 (A, G...)：淺青色 */
.mode-sentence .sentence-block[data-label^="A"]::before,
.mode-sentence .sentence-block[data-label^="G"]::before,
.mode-sentence .sentence-block[data-label^="M"]::before{
    background-color: #E0F2F1; color: #00695C;
}

/* 第 2 段循環 (B, H...)：淺藍色 */
.mode-sentence .sentence-block[data-label^="B"]::before,
.mode-sentence .sentence-block[data-label^="H"]::before,
.mode-sentence .sentence-block[data-label^="N"]::before{
    background-color: #E3F2FD; color: #1565C0;
}

/* 第 3 段循環 (C, I...)：淺橘色 */
.mode-sentence .sentence-block[data-label^="C"]::before,
.mode-sentence .sentence-block[data-label^="I"]::before,
.mode-sentence .sentence-block[data-label^="O"]::before{
    background-color: #FFF3E0; color: #E65100;
}

/* 第 4 段循環 (D, J...)：淺紫色 */
.mode-sentence .sentence-block[data-label^="D"]::before,
.mode-sentence .sentence-block[data-label^="J"]::before,
.mode-sentence .sentence-block[data-label^="P"]::before{
    background-color: #F3E5F5; color: #6A1B9A;
}

/* 第 5 段循環 (E, K...)：淺綠色 */
.mode-sentence .sentence-block[data-label^="E"]::before,
.mode-sentence .sentence-block[data-label^="K"]::before,
.mode-sentence .sentence-block[data-label^="Q"]::before{
    background-color: #E8F5E9; color: #2E7D32;
}

/* 第 6 段循環 (F, L...)：淺櫻花紅 */
.mode-sentence .sentence-block[data-label^="F"]::before,
.mode-sentence .sentence-block[data-label^="L"]::before,
.mode-sentence .sentence-block[data-label^="R"]::before{
    background-color: #FFEBEE; color: #C62828;
}

/* ================= 詞彙學習 ================= */
.vocabulary-section {
    margin-top: 50px; background: white; padding: 30px;
    border-radius: var(--border-radius); box-shadow: 0 2px 15px rgba(0,0,0,0.04);
    border-top: 4px solid var(--primary-light);
}
.vocabulary-section h3 { margin-top: 0; color: var(--primary-color); font-weight: bold;}
.vocabulary-section ol { padding-left: 20px; margin-bottom: 0; color: var(--text-main); }
.vocabulary-section li { margin-bottom: 10px; line-height: 1.6; }

/* ================= 頁尾 ================= */
.site-footer {
    background-color: transparent; color: #C0C0C0; text-align: center; 
    padding: 8px; font-size: 0.8rem; margin-top: 20px;
}
.site-footer p { margin: 0; letter-spacing: 1px;}

/* ================= 毛玻璃底部播放器 ================= */
.audio-player-compact {
    position: fixed; bottom: 20px; left: 5%; width: 90%;
    background-color: rgba(255, 255, 255, 0.55); 
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px; box-shadow: 0 6px 30px rgba(0,0,0,0.08);
    padding: 10px 15px 10px 20px; box-sizing: border-box;
    display: flex; align-items: center; gap: 15px; z-index: 100;
}
.progress-bar { flex: 1; accent-color: var(--primary-color); }
.player-controls { display: flex; align-items: center; gap: 8px; }

.player-action, .track-btn, .close-player {
    height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; border: none; cursor: pointer; box-sizing: border-box;
    background: rgba(0, 137, 123, 0.12); color: var(--primary-color);
    transition: all 0.2s ease;
}
.player-action { width: 40px; }
.track-btn { padding: 0 14px; font-size: 0.9rem; font-weight: bold; font-family: inherit; }
.close-player { width: 40px; background: transparent; color: #9AA5A6; }
.player-action:active, .track-btn:active { background: rgba(0, 137, 123, 0.25); }

.fab {
    position: fixed; bottom: 20px; right: 20px;
    background-color: var(--accent-color); color: white;
    border: none; width: 50px; height: 50px; border-radius: 50%;
    box-shadow: 0 4px 15px rgba(255, 112, 67, 0.4);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 90; transition: transform 0.2s;
}
.fab:active { transform: scale(0.9); }


/* ================= 搜尋高亮樣式覆寫 ================= */
mark {
    background-color: transparent;
    color: var(--accent-color);    /* 使用主題的強調色 (橘紅色 #FF7043) */
    font-weight: bold;
}



/* 單句翻譯 */
.mode-sentence .sentence-block::before {
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
}

.mode-sentence .sentence-block.is-translated::before {
    background-color: #00897B !important;
    color: #FFFFFF !important; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}



/* ================= 頁尾 ================= */
.site-footer {
    background-color: #eee; color: #C0C0C0; text-align: center; 
    padding: 8px; font-size: 0.8rem; margin-top: 20px;
}
.site-footer p { margin: 0; letter-spacing: 1px;}


.site-footer a {
    color: #C0C0C0;
    text-decoration: none;
    transition: color 0.2s;
}
.site-footer a:hover {
    color: var(--primary-light);
    text-decoration: none;
}