/* 古詩文網 V4 - 全站樣式 */
:root {
    --bg: #f5f0e8;
    --card-bg: #fff;
    --text: #333;
    --text-light: #666;
    --link: #8b3a3a;
    --link-hover: #a04545;
    --border: #e0d5c5;
    --accent: #8b3a3a;
    --accent-light: #f8f0e8;
    --tag-bg: #f0e8d8;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --font-serif: "Noto Serif TC", "Source Han Serif TC", "宋體", "SimSun", serif;
}
body.dark {
    --bg: #1a1814;
    --card-bg: #2a2620;
    --text: #d4cfc6;
    --text-light: #a09a8e;
    --link: #c08080;
    --link-hover: #d09090;
    --border: #3a352e;
    --accent: #c08080;
    --accent-light: #2a2020;
    --tag-bg: #3a3528;
    --shadow: 0 2px 8px rgba(0,0,0,0.2);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-serif);
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    font-size: 16px;
}
a { color: var(--link); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--link-hover); text-decoration: underline; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 15px; }

/* 頁頭 */
.site-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 0; border-bottom: 2px solid var(--accent);
    flex-wrap: wrap; gap: 10px;
}
.logo a { font-size: 24px; font-weight: bold; color: var(--accent); }
.main-nav { display: flex; gap: 20px; }
.main-nav a { font-size: 16px; padding: 5px 0; }
.header-tools { display: flex; align-items: center; gap: 10px; }
.search-form { display: flex; }
.search-input {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px 0 0 4px;
    background: var(--card-bg); color: var(--text); font-size: 14px; outline: none;
}
.search-btn {
    padding: 6px 16px; background: var(--accent); color: #fff;
    border: none; border-radius: 0 4px 4px 0; cursor: pointer; font-size: 14px;
}
.theme-toggle { background: none; border: none; font-size: 20px; cursor: pointer; }

/* 主內容 */
.main-content { padding: 20px 0; min-height: 60vh; }
.content-layout { display: flex; gap: 20px; }
.main-col { flex: 1; min-width: 0; }
.side-col { width: 300px; flex-shrink: 0; }

/* 區塊標題 */
.section-title { display: flex; align-items: center; justify-content: space-between; }
.section-title h2 { font-size: 20px; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 15px; flex: 1; }

/* 詩文卡片 */
.poem-card {
    background: var(--card-bg); border-radius: 8px; padding: 20px;
    margin-bottom: 15px; box-shadow: var(--shadow);
}
.poem-card-header { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.author-avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; object-fit: cover; border: 1px solid var(--border); }
.poem-card-info h3 { font-size: 18px; margin-bottom: 2px; }
.poem-meta { font-size: 14px; color: var(--text-light); }
.poem-meta .dynasty { color: var(--accent); }
.poem-content { font-size: 18px; line-height: 1.9; padding: 10px 0; white-space: pre-wrap; }
.poem-tools { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); margin-top: 8px; }
.tool-btn { font-size: 14px; color: var(--text-light); cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: all 0.2s; }
.tool-btn:hover { background: var(--accent-light); color: var(--accent); }
.poem-tags { margin-top: 8px; }
.poem-tags a, .tag {
    display: inline-block; padding: 2px 10px; margin: 2px;
    background: var(--tag-bg); border-radius: 12px; font-size: 13px;
}

/* 名句卡片 */
.mingju-card {
    background: var(--card-bg); border-radius: 8px; padding: 20px;
    margin-bottom: 15px; box-shadow: var(--shadow); display: flex; gap: 15px;
}
.mingju-img { width: 120px; height: 80px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.mingju-content { flex: 1; }
.mingju-text { font-size: 18px; line-height: 1.8; margin-bottom: 8px; }
.mingju-source { font-size: 14px; color: var(--text-light); }
.mingju-tools { margin-top: 8px; }

/* 詩文詳情 */
.poem-detail { background: var(--card-bg); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
.poem-title { font-size: 26px; text-align: center; margin-bottom: 15px; }
.poem-author { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.author-avatar-lg { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }
.poem-author-name { font-size: 16px; }
.poem-body { font-size: 20px; line-height: 2; text-align: center; padding: 20px 0; white-space: pre-wrap; }
.poem-section { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 15px; }
.section-toggle { cursor: pointer; font-size: 16px; color: var(--accent); user-select: none; }
.toggle-icon { font-size: 12px; transition: transform 0.2s; display: inline-block; }
.section-toggle.collapsed .toggle-icon { transform: rotate(-90deg); }
.section-content { padding-top: 10px; display: block; }
.section-toggle.collapsed + .section-content { display: none; }
.poem-tags-detail { margin-top: 15px; }

/* ===== 作者列表頁 ===== */
.authors-page-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.authors-page-header h2 { font-size: 20px; color: var(--accent); }
.authors-total { font-size: 13px; color: var(--text-light); }
.author-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.author-card { background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow); transition: all 0.2s; overflow: hidden; padding: 16px; }
.author-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(139,58,58,0.12); transform: translateY(-2px); }
.author-card-header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.author-card-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); flex-shrink: 0; }
.author-card:hover .author-card-avatar { border-color: var(--accent); }
.author-card-name { font-size: 15px; font-weight: 600; margin: 0; }
.author-card-name a { color: var(--text); text-decoration: none; }
.author-card-name a:hover { color: var(--accent); text-decoration: none; }
.author-card-dynasty { font-size: 12px; color: var(--accent); background: var(--accent-light); display: inline-block; padding: 1px 8px; border-radius: 10px; margin: 0; }
.author-card-bio { font-size: 12px; color: var(--text-light); line-height: 1.5; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; writing-mode: horizontal-tb; }
.author-card-count { font-size: 12px; color: var(--accent); text-decoration: none; }
.author-card-count:hover { color: var(--link-hover); text-decoration: underline; }

/* ===== 作者詩文全集頁 ===== */
.authorpoems-header { display: flex; gap: 16px; align-items: center; background: var(--card-bg); border-radius: 10px; padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.authorpoems-header .author-avatar { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--accent); flex-shrink: 0; object-fit: cover; }
.authorpoems-info h1 { font-size: 20px; margin-bottom: 4px; }
.authorpoems-meta { font-size: 13px; color: var(--text-light); }
.authorpoems-meta a { color: var(--accent); }
.authorpoems-bio { font-size: 13px; color: var(--text-light); line-height: 1.8; }

/* ===== 作者詳情頁 ===== */
.author-detail-header { display: flex; gap: 20px; align-items: center; background: var(--card-bg); border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.author-detail-info h1 { font-size: 24px; }
.author-meta { color: var(--text-light); }
.author-bio-full { background: var(--card-bg); border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.author-bio-full h3 { margin-bottom: 10px; }
.author-bio-full p { line-height: 1.9; white-space: pre-wrap; }

/* ===== 側欄作者簡介（詩文詳情頁等） ===== */
.author-bio-sidebar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.author-bio-sidebar .author-avatar { width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; }
.author-bio-sidebar > p { margin: 0; }
.author-bio-sidebar-text { flex-basis: 100%; font-size: 13px; color: var(--text-light); line-height: 1.8; }

/* 名句詳情 */
.mingju-detail { background: var(--card-bg); border-radius: 8px; padding: 30px; text-align: center; box-shadow: var(--shadow); }
.mingju-text-lg { font-size: 24px; line-height: 1.8; margin-bottom: 15px; }
.mingju-source-detail { color: var(--text-light); }

/* 古籍 */
.book-list { display: grid; grid-template-columns: 1fr; gap: 15px; }
.book-card { background: var(--card-bg); border-radius: 8px; padding: 20px; box-shadow: var(--shadow); }
.book-card h3 { font-size: 18px; margin-bottom: 5px; }
.book-meta { font-size: 14px; color: var(--text-light); margin-bottom: 8px; }
.book-desc { font-size: 14px; color: var(--text-light); }
.book-detail { background: var(--card-bg); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
.book-meta-detail { color: var(--text-light); margin-bottom: 15px; }
.book-chapters { margin: 20px 0; }
.chapter-list { list-style: none; padding-left: 0; }
.chapter-list li { padding: 5px 0; }
.book-content { margin-top: 20px; line-height: 2; white-space: pre-wrap; }
.book-tools { margin-top: 15px; }

/* 字詞 */
.zici-search-bar { margin-bottom: 20px; }
.zici-list { display: grid; gap: 15px; }
.zici-card { background: var(--card-bg); border-radius: 8px; padding: 20px; box-shadow: var(--shadow); }
.zici-title { font-size: 22px; margin-bottom: 5px; }
.zici-pinyin, .zici-radical { font-size: 14px; color: var(--text-light); margin-bottom: 5px; }
.zici-explanation { font-size: 15px; line-height: 1.8; }
.zici-examples { font-size: 14px; color: var(--text-light); margin-top: 5px; }

/* 搜尋 */
.search-bar-big { margin-bottom: 20px; }
.search-input-lg { padding: 10px 15px; border: 1px solid var(--border); border-radius: 4px 0 0 4px; width: 70%; font-size: 16px; background: var(--card-bg); color: var(--text); }
.search-btn-lg { padding: 10px 25px; background: var(--accent); color: #fff; border: none; border-radius: 0 4px 4px 0; cursor: pointer; font-size: 16px; }
.search-section { margin-bottom: 25px; }
.search-section h3 { color: var(--accent); margin-bottom: 10px; }
.search-total { text-align: center; color: var(--text-light); margin-top: 20px; }

/* 糾錯 */
.jiucuo-form { background: var(--card-bg); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
.jiucuo-target { margin-bottom: 15px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; }
.form-group textarea, .form-group input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 15px; }
.submit-btn { padding: 10px 30px; background: var(--accent); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
.success-msg { background: #d4edda; color: #155724; padding: 15px; border-radius: 4px; margin-bottom: 20px; text-align: center; }

/* 側欄 */
.side-section { background: var(--card-bg); border-radius: 8px; padding: 15px; margin-bottom: 15px; box-shadow: var(--shadow); }
.side-section h3 { font-size: 16px; margin-bottom: 10px; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.side-mingju { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.side-mingju:last-child { border: none; }
.side-mingju p { font-size: 14px; line-height: 1.6; }
.side-mingju-src { font-size: 12px; color: var(--text-light); }
.side-item { padding: 5px 0; font-size: 14px; }
.side-author-list { display: flex; flex-direction: column; gap: 8px; }
.side-author-item { display: flex; gap: 8px; align-items: center; text-decoration: none; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.side-author-item:last-child { border: none; }
.side-author-item img { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0; object-fit: cover; }
.side-author-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.side-author-name { font-size: 14px; color: var(--text); }
.side-author-item:hover .side-author-name { color: var(--accent); }
.side-author-meta { font-size: 11px; color: var(--text-light); }

/* 篩選器 */
.filter-bar { background: var(--card-bg); border-radius: 10px; padding: 14px 16px; margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filter-label { font-size: 14px; color: var(--text-light); margin-right: 5px; }
.filter-item { padding: 4px 12px; border-radius: 14px; font-size: 13px; background: var(--tag-bg); color: var(--text); transition: all 0.15s; }
.filter-item:hover { text-decoration: none; background: var(--accent-light); color: var(--accent); }
.filter-item.active { background: var(--accent); color: #fff; }

/* 分頁 */
.pagination { display: flex; justify-content: center; gap: 5px; padding: 20px 0; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px;
    background: var(--card-bg); color: var(--text); font-size: 14px;
}
.pagination a:hover { background: var(--accent-light); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 相關 */
.related-section { background: var(--card-bg); border-radius: 8px; padding: 15px; margin-top: 20px; box-shadow: var(--shadow); }
.related-section h3 { color: var(--accent); margin-bottom: 10px; }
.related-item { padding: 5px 0; }

/* 廣告 */
.ad-slot { margin-bottom: 15px; min-height: 60px; }
.ad-placeholder { background: var(--accent-light); border: 1px dashed var(--border); border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 13px; min-height: 60px; }

/* 頁腳 */
.site-footer { border-top: 2px solid var(--accent); padding: 20px 0; text-align: center; color: var(--text-light); margin-top: 30px; }
.site-footer p { margin: 3px 0; }

/* 空狀態 */
.empty { text-align: center; padding: 40px; color: var(--text-light); }

/* 響應式 */
@media (max-width: 768px) {
    .content-layout { flex-direction: column; }
    .side-col { width: 100%; }
    .main-nav { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; }
    .poem-body { font-size: 18px; }
    .poem-content { font-size: 16px; }
    .search-input { width: 120px; }
    .search-input-lg { width: 60%; }
    .mingju-card { flex-direction: column; }
    .mingju-img { width: 100%; height: 150px; }
    .author-grid { grid-template-columns: repeat(2, 1fr); }
    .author-card-inner { padding: 12px 14px; }
}
@media (max-width: 480px) {
    .poem-title { font-size: 22px; }
    .poem-body { font-size: 16px; }
    .author-grid { grid-template-columns: 1fr; }
    .author-card-inner { padding: 12px 14px; gap: 10px; }
    .author-card-avatar { width: 46px; height: 46px; }
    .poem-tools { flex-wrap: wrap; gap: 8px; }
}

/* 標籤雲 */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud .tag {
    display: inline-block; padding: 4px 12px;
    background: var(--tag-bg); border-radius: 15px;
    font-size: 14px; transition: all 0.2s;
}
.tag-cloud .tag:hover { background: var(--accent); color: #fff; }
.tag-cloud .tag.active { background: var(--accent); color: #fff; }
.tag-count {
    font-size: 11px; color: var(--text-light);
    margin-left: 4px; opacity: 0.7;
}
.tag-cloud .tag:hover .tag-count { color: #ddd; }

/* 大標籤雲 */
.tag-cloud-large { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cloud-tag {
    display: inline-block; padding: 4px 12px;
    background: var(--tag-bg); border-radius: 15px;
    transition: all 0.2s; line-height: 1.5;
}
.cloud-tag:hover { background: var(--accent); color: #fff; }
.tag-xl { font-size: 20px; font-weight: bold; }
.tag-l { font-size: 18px; }
.tag-m { font-size: 16px; }
.tag-s { font-size: 14px; }
.tag-xs { font-size: 13px; color: var(--text-light); }

/* 標籤詳情頁 */
.result-count { color: var(--text-light); font-size: 14px; margin: 5px 0 15px; }

/* 古籍章節 */
.chapter-list { list-style: none; padding: 0; }
.chapter-list li {
    padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.chapter-list li a { display: block; }
.chapter-list li a:hover { padding-left: 8px; transition: padding 0.2s; }

.side-chapter-list { list-style: none; padding: 0; max-height: 300px; overflow-y: auto; }
.side-chapter-list li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.side-chapter-list li.active a { color: var(--accent); font-weight: bold; }

.chapter-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 0; margin-top: 20px; border-top: 1px solid var(--border);
}
.chapter-prev, .chapter-next, .chapter-toc {
    padding: 8px 20px; background: var(--tag-bg);
    border-radius: 4px; transition: all 0.2s;
}
.chapter-prev:hover, .chapter-next:hover, .chapter-toc:hover {
    background: var(--accent); color: #fff;
}

/* 詩文標籤（詳情頁） */
.poem-tags-detail { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.poem-tags-detail .tag {
    display: inline-block; padding: 3px 10px;
    background: var(--tag-bg); border-radius: 12px;
    font-size: 13px;
}
.poem-tags-detail .tag:hover { background: var(--accent); color: #fff; }

/* === 古籍封面與卡片 === */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; margin: 20px 0; }

.book-card-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 15px 10px; border-radius: 8px; text-align: center;
    background: var(--card-bg); box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.book-card-item:hover { transform: translateY(-3px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

.book-cover-link { display: block; margin-bottom: 10px; }
.book-cover-img {
    width: 150px; height: 210px; border-radius: 4px;
    border: 1px solid var(--border); box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    object-fit: cover; transition: box-shadow 0.2s;
}
.book-cover-img:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

.book-card-info h3 { margin: 0 0 5px; font-size: 16px; }
.book-card-info h3 a { color: var(--text); }
.book-card-info .book-meta { font-size: 12px; color: var(--text-light); margin: 2px 0; }
.book-card-info .book-cat { font-size: 11px; color: var(--accent); background: var(--tag-bg); padding: 2px 8px; border-radius: 10px; display: inline-block; margin: 2px 0; }
.book-card-info .book-ch-count { font-size: 11px; color: var(--text-light); margin: 2px 0; }

/* === 古籍詳情頁 === */
.book-detail-header { display: flex; gap: 24px; margin-bottom: 24px; }
.book-detail-cover { flex-shrink: 0; }
.book-detail-cover img {
    width: 180px; height: 252px; border-radius: 6px;
    border: 2px solid var(--border); box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.book-detail-meta { flex: 1; padding-top: 8px; }
.book-detail-meta .book-title { margin: 0 0 8px; }
.book-detail-meta .book-meta-detail { font-size: 14px; color: var(--text-light); margin: 4px 0; }
.book-description-inline { margin-top: 12px; font-size: 13px; color: var(--text-light); line-height: 1.7; }

@media (max-width: 600px) {
    .book-detail-header { flex-direction: column; align-items: center; text-align: center; }
    .book-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .book-cover-img { width: 120px; height: 168px; }
}
@media (max-width: 400px) {
    .book-grid { grid-template-columns: 1fr; }
}

/* 側邊欄古籍封面網格 */
.side-book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0; }
.side-book-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; }
.side-book-item img { width: 80px; height: 112px; border-radius: 4px; border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.1); transition: box-shadow 0.2s; }
.side-book-item:hover img { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.side-book-item span { font-size: 11px; color: var(--text-light); margin-top: 4px; text-align: center; }

/* ===== 搜尋結果作者卡片（橫向flex佈局） ===== */
.search-author-card {
    display: flex; gap: 12px; padding: 12px;
    background: var(--card-bg); border-radius: 8px;
    margin-bottom: 10px; box-shadow: var(--shadow); align-items: flex-start;
}
.search-author-card .author-avatar { width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; }
.search-author-card-info h3 { font-size: 16px; margin-bottom: 4px; }
.search-author-card-info .author-count { font-size: 13px; color: var(--text-light); }
.search-author-card-info .author-bio-text { font-size: 13px; color: var(--text-light); margin-top: 4px; }
/* ===== Tab 切換欄 ===== */
.tab-bar { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tab-item { padding: 8px 20px; font-size: 15px; color: var(--text-light); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-item:hover { color: var(--accent); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* 名句詳情頁標籤 */
.mingju-detail .poem-tags-detail { margin-top: 12px; }
.mingju-detail .poem-tags-detail a { display: inline-block; padding: 2px 10px; margin: 2px 4px 2px 0; font-size: 13px; background: var(--tag-bg); color: var(--text); border-radius: 4px; text-decoration: none; }
.mingju-detail .poem-tags-detail a:hover { background: var(--accent); color: #fff; }