/* ============================================================
   慧海法藏 - 主样式表（含朗读模块）
   ============================================================ */

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

body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: #f8f5f0;
    color: #3a322c;
    line-height: 1.8;
    transition: background 0.3s, color 0.3s;
    padding-top: 70px;
}

a {
    color: #7a5a3a;
    text-decoration: none;
    transition: color 0.2s;
}
a:hover {
    color: #b8863a;
    text-decoration: underline;
}

/* ---------- 容器 ---------- */
.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- 头部 ---------- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 248, 240, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(180, 150, 120, 0.2);
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    transition: background 0.3s, border-color 0.3s;
}

.header-inner {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    flex-shrink: 0;
}
.logo a {
    display: flex;
    align-items: center;
    font-size: 22px;
    font-weight: 700;
    color: #5a3d2e;
    letter-spacing: 2px;
    text-decoration: none;
    gap: 10px;
}
.logo i {
    color: #b8863a;
    font-size: 24px;
    flex-shrink: 0;
}
.logo span {
    white-space: nowrap;
    transition: font-size 0.2s;
}

.translated-english .logo span,
html[lang="en"] .logo span {
    font-size: 18px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.font-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #6a5a4a;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}
.font-btn:hover {
    background: rgba(180, 150, 120, 0.15);
}
.font-btn.active {
    background: #b8863a;
    color: #fff;
}

.theme-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #b09580;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}
.theme-btn:hover {
    background: rgba(180, 150, 120, 0.15);
}

.language-switcher {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.language-switcher button {
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: #6a5a4a;
    font-size: 13px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
}
.language-switcher button:hover {
    background: rgba(180, 150, 120, 0.12);
}
.language-switcher button.active {
    background: #b8863a;
    color: #fff;
}

/* ---------- 主内容 ---------- */
.main {
    min-height: calc(100vh - 180px);
    padding: 15px 0 0px;
}

.breadcrumb {
    font-size: 14px;
    color: #8a7a6a;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(180, 150, 120, 0.15);
}
.breadcrumb a {
    color: #7a5a3a;
}
.breadcrumb a:hover {
    color: #b8863a;
    text-decoration: none;
}
.breadcrumb .separator {
    margin: 0 6px;
    color: #bba89a;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #3a2a1a;
    margin-bottom: 24px;
    line-height: 1.3;
    text-align: center;
    word-break: break-word;
}

.content-body {
    font-size: 17px;
    line-height: 2;
    color: #3a322c;
    padding: 20px 0;
    text-align: justify;
    word-break: break-word;
}
.content-body p {
    margin-bottom: 0.6em;
    text-indent: 2em;
}
.content-body p.verse {
    text-indent: 0;
    padding-left: 2em;
    font-family: "KaiTi", "楷体", "STKaiti", serif;
}

.download-link {
    margin: 30px 0 20px;
    padding: 16px 20px;
    background: #f0ebe5;
    border-radius: 8px;
    border-left: 4px solid #b8863a;
    transition: background 0.3s;
}
.download-link a {
    color: #5a3d2e;
    font-weight: 500;
    font-size: 15px;
}
.download-link a i {
    margin-right: 8px;
    color: #b8863a;
}
.download-link a:hover {
    color: #b8863a;
    text-decoration: none;
}

/* ---------- 相关阅读 ---------- */
.related-section {
    margin: 40px 0 20px;
    padding: 20px 24px;
    background: #f5f0ea;
    border-radius: 8px;
    border: 1px solid rgba(180, 150, 120, 0.15);
    transition: background 0.3s, border-color 0.3s;
}
.related-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #5a3d2e;
    margin-bottom: 12px;
    position: relative;
    padding-left: 14px;
}
.related-section h3::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: #b8863a;
    border-radius: 2px;
}
.related-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}
.related-section ul li {
    font-size: 14px;
}
.related-section ul li a {
    color: #6a5a4a;
    padding: 2px 0;
    display: inline-block;
}
.related-section ul li a:hover {
    color: #b8863a;
    text-decoration: none;
}

/* ---------- 页脚 ---------- */
.footer {
    background: #2a221c;
    color: #b0a090;
    padding: 30px 0 24px;
    margin-top: 40px;
}
.footer a {
    color: #c0b0a0;
}
.footer a:hover {
    color: #e8d5c0;
    text-decoration: none;
}
.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 24px 40px;
    margin-bottom: 16px;
    font-size: 14px;
}
.footer-links a i {
    margin-right: 6px;
}
.copyright {
    text-align: center;
    font-size: 13px;
    color: #7a6a5a;
}
.copyright i {
    margin-right: 4px;
}

/* ---------- 返回顶部 ---------- */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #b8863a;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.2s, background 0.3s;
    box-shadow: 0 4px 12px rgba(184, 134, 58, 0.3);
    z-index: 999;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}
.back-to-top:hover {
    background: #a07030;
    transform: translateY(-2px);
}

/* ---------- 暗色模式 ---------- */
body.dark {
    background: #1a1614;
    color: #d0c8c0;
}
body.dark .header {
    background: rgba(26, 22, 20, 0.92);
    border-bottom-color: rgba(120, 100, 80, 0.25);
}
body.dark .logo a {
    color: #d0c0b0;
}
body.dark .font-btn {
    color: #b0a090;
}
body.dark .font-btn.active {
    background: #b8863a;
    color: #fff;
}
body.dark .theme-btn {
    color: #b0a090;
}
body.dark .language-switcher button {
    color: #b0a090;
}
body.dark .language-switcher button.active {
    background: #b8863a;
    color: #fff;
}
body.dark .page-title {
    color: #e0d0c0;
}
body.dark .content-body {
    color: #c8c0b8;
}
body.dark .breadcrumb {
    color: #9a8a7a;
    border-bottom-color: rgba(120, 100, 80, 0.2);
}
body.dark .breadcrumb a {
    color: #c0a888;
}
body.dark .download-link {
    background: #2a221c;
    border-left-color: #b8863a;
}
body.dark .download-link a {
    color: #d0c0b0;
}
body.dark .related-section {
    background: #221e1a;
    border-color: rgba(120, 100, 80, 0.2);
}
body.dark .related-section h3 {
    color: #d0c0b0;
}
body.dark .related-section ul li a {
    color: #b0a090;
}
body.dark .related-section ul li a:hover {
    color: #d4b080;
}
body.dark .footer {
    background: #120e0c;
}
body.dark .footer a {
    color: #8a7a6a;
}
body.dark .footer a:hover {
    color: #c0b0a0;
}
body.dark .copyright {
    color: #6a5a4a;
}
body.dark .back-to-top {
    background: #8a6a3a;
}
body.dark .back-to-top:hover {
    background: #a07030;
}

/* ============================================================
   ★ 朗读模块（浏览器 TTS）
   ============================================================ */

.simple-tts-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 0 0 24px;
    padding: 0;
    background: none;
    border: none;
}

.simple-tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px;
    background: none;
    color: #6a5a4a;
    border: none;
    font-size: 15px;
    cursor: pointer;
    transition: color 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    letter-spacing: 1px;
}
.simple-tts-btn:hover {
    color: #b8863a;
}
.simple-tts-btn i {
    font-size: 15px;
}

.simple-tts-btn[data-action="play"] {
    color: #b8863a;
    font-weight: 500;
}
.simple-tts-btn[data-action="play"]:hover {
    color: #a07030;
}

.simple-tts-speed {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: none;
    border: none;
    font-size: 13px;
    color: #8a7a6a;
}
.simple-tts-speed i {
    color: #b8863a;
    font-size: 13px;
    opacity: 0.8;
}
.simple-tts-speed input[type="range"] {
    width: 90px;
    height: 4px;
    accent-color: #b8863a;
    cursor: pointer;
    background: transparent;
}
.simple-tts-speed span {
    min-width: 38px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #8a7a6a;
    font-size: 13px;
}

.content-body p.simple-tts-active {
    background: rgba(184, 134, 58, 0.08);
    border-radius: 4px;
    transition: background 0.3s ease;
}

body.dark .simple-tts-btn {
    color: #b0a090;
}
body.dark .simple-tts-btn:hover {
    color: #d4b080;
}
body.dark .simple-tts-btn[data-action="play"] {
    color: #d4b080;
}
body.dark .simple-tts-btn[data-action="play"]:hover {
    color: #e8d5c0;
}
body.dark .simple-tts-speed {
    color: #8a7a6a;
}
body.dark .simple-tts-speed i {
    color: #d4b080;
}
body.dark .simple-tts-speed span {
    color: #8a7a6a;
}
body.dark .content-body p.simple-tts-active {
    background: rgba(212, 176, 128, 0.1);
}

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }
    .header {
        height: 56px;
        padding: 0 14px;
    }
    .logo a {
        font-size: 18px;
        gap: 6px;
    }
    .logo i {
        font-size: 18px;
    }
    .logo span {
        font-size: 14px;
    }
    .header-right {
        gap: 8px;
    }
    .font-btn {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }
    .theme-btn {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }
    .language-switcher button {
        font-size: 11px;
        padding: 3px 6px;
    }
    .container {
        padding: 0 16px;
    }
    .page-title {
        font-size: 24px;
    }
    .content-body {
        font-size: 16px;
    }

    /* 朗读模块移动端 */
    .simple-tts-bar {
        gap: 16px;
        margin-bottom: 18px;
    }
    .simple-tts-btn {
        font-size: 14px;
    }
    .simple-tts-speed {
        font-size: 12px;
    }
    .simple-tts-speed input[type="range"] {
        width: 70px;
    }
    .simple-tts-speed span {
        min-width: 34px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 54px;
    }
    .header {
        height: 50px;
        padding: 0 8px;
    }
    .logo a {
        font-size: 15px;
        gap: 4px;
    }
    .logo i {
        font-size: 15px;
    }
    .logo span {
        font-size: 12px;
    }
    .translated-english .logo span,
    html[lang="en"] .logo span {
        font-size: 10px;
    }
    .header-right {
        gap: 4px;
    }
    .font-btn {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }
    .theme-btn {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    .language-switcher button {
        font-size: 9px;
        padding: 2px 4px;
    }
    .container {
        padding: 0 12px;
    }
    .page-title {
        font-size: 20px;
        margin-bottom: 16px;
    }
    .content-body {
        font-size: 15px;
        padding: 12px 0;
    }
    .content-body p {
        text-indent: 1.8em;
    }
    .breadcrumb {
        font-size: 12px;
        line-height: 1.6;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
    .breadcrumb .separator {
        margin: 0 4px;
    }
    .download-link {
        padding: 12px 16px;
        margin: 20px 0 16px;
    }
    .download-link a {
        font-size: 13px;
    }
    .related-section {
        padding: 16px;
        margin: 30px 0 16px;
    }
    .related-section ul {
        gap: 4px 12px;
    }
    .related-section ul li {
        font-size: 13px;
    }
    .footer {
        padding: 20px 0 16px;
        margin-top: 30px;
    }
    .footer-links {
        gap: 10px 16px;
        font-size: 12px;
    }
    .copyright {
        font-size: 11px;
    }
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
}

@media (max-width: 360px) {
    .logo a {
        font-size: 13px;
        gap: 3px;
    }
    .logo i {
        font-size: 13px;
    }
    .logo span {
        font-size: 10px;
    }
    .translated-english .logo span,
    html[lang="en"] .logo span {
        font-size: 8px;
    }
    .language-switcher button {
        font-size: 8px;
        padding: 1px 3px;
    }
}