/* ===== 《老登日记》- 响应式样式 ===== */
:root {
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --text: #2c2c2c;
    --text-secondary: #666;
    --text-muted: #999;
    --border: #e8e4de;
    --accent: #b8860b;
    --accent-light: #d4a843;
    --header-bg: rgba(250, 248, 245, 0.92);
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --radius: 12px;
    --font-size: 17px;
    --line-height: 1.9;
    --max-width: 680px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --bg-card: #252525;
        --text: #e0ddd8;
        --text-secondary: #aaa7a0;
        --text-muted: #777570;
        --border: #333;
        --accent: #d4a843;
        --accent-light: #e8c86a;
        --header-bg: rgba(26, 26, 26, 0.92);
        --shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
}

body.dark-mode {
    --bg: #1a1a1a;
    --bg-card: #252525;
    --text: #e0ddd8;
    --text-secondary: #aaa7a0;
    --text-muted: #777570;
    --border: #333;
    --accent: #d4a843;
    --accent-light: #e8c86a;
    --header-bg: rgba(26, 26, 26, 0.92);
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: var(--line-height);
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

.header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; height: 52px;
}

@supports (padding: max(0px)) {
    .header { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

.header-title { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: 0.5px; }
.header-btn {
    width: 40px; height: 40px; border: none; background: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text);
}
.header-btn:active { background: var(--border); }
.header-btn svg { width: 22px; height: 22px; }

.cover-section { padding: 72px 20px 32px; text-align: center; }
.cover-icon { font-size: 64px; margin-bottom: 16px; display: block; line-height: 1; }
.cover-title { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: 2px; }
.cover-author { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.cover-desc { font-size: 15px; color: var(--text-secondary); max-width: var(--max-width); margin: 0 auto 24px; line-height: 1.7; }
.cover-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 14px 36px; background: var(--accent); color: #fff;
    border: none; border-radius: 40px; font-size: 16px; font-weight: 500;
    cursor: pointer; text-decoration: none; letter-spacing: 1px;
}
.cover-btn:active { transform: scale(0.97); background: var(--accent-light); }

.chapter-section { padding: 8px 16px 80px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-muted); letter-spacing: 2px; margin-bottom: 12px; padding: 0 4px; }
.chapter-list { display: flex; flex-direction: column; gap: 8px; }
.chapter-item {
    display: block; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 20px; text-decoration: none; color: var(--text);
    box-shadow: var(--shadow); min-height: 60px;
}
.chapter-item:active { transform: scale(0.98); border-color: var(--accent); }
.chapter-item-date { font-size: 13px; color: var(--accent); font-weight: 500; margin-bottom: 4px; }
.chapter-item-title { font-size: 16px; font-weight: 600; color: var(--text); }
.chapter-item-preview { font-size: 13px; color: var(--text-muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chapter-page { padding: 72px 20px 60px; max-width: var(--max-width); margin: 0 auto; }
@supports (padding: max(0px)) {
    .chapter-page { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
}
.chapter-header { text-align: center; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.chapter-date { font-size: 13px; color: var(--accent); font-weight: 500; margin-bottom: 8px; }
.chapter-title { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: 1px; }
.chapter-body { font-size: var(--font-size); line-height: var(--line-height); color: var(--text); }
.chapter-body p { margin-bottom: 1.4em; text-indent: 2em; word-break: break-word; }

.chapter-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.nav-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 12px 20px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 40px; color: var(--text); font-size: 14px; font-weight: 500;
    cursor: pointer; text-decoration: none; min-width: 80px; min-height: 44px;
}
.nav-btn:active { transform: scale(0.96); border-color: var(--accent); color: var(--accent); }
.nav-btn.disabled { opacity: 0.3; pointer-events: none; }
.nav-center { font-size: 13px; color: var(--text-muted); }
.nav-back { text-align: center; margin-top: 16px; }
.back-home-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 24px; background: none; border: none; color: var(--text-secondary); font-size: 14px; cursor: pointer; text-decoration: none; }
.back-home-btn:active { color: var(--accent); }

/* ===== 字体大小工具栏 ===== */
.font-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 6px 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    z-index: 50;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.font-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
}
.font-btn:active {
    background: var(--border);
}
.font-btn.reset {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}
.font-btn.small { font-size: 13px; }
.font-btn.large { font-size: 17px; }

.footer { text-align: center; padding: 20px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 40px; }

@media (max-width: 480px) {
    .cover-title { font-size: 24px; }
    .chapter-title { font-size: 21px; }
    .chapter-page { padding: 68px 16px 50px; }
    .nav-btn { flex: 1; max-width: 140px; }
}
@media (max-width: 360px) {
    .cover-title { font-size: 22px; }
    :root { --font-size: 15px; }
    .chapter-item { padding: 14px 16px; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== 日记配图样式 ===== */
.diary-image-wrapper {
    margin: 20px 0;
    text-align: center;
}
.diary-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* ===== 新闻热点样式 =====
.news-section {
    padding: 8px 16px 0;
    margin-bottom: 8px;
}
.news-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.news-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
}
.news-rank {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: #999;
    margin-top: 1px;
}
.news-rank.top3 {
    background: #e74c3c;
}
.news-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    word-break: break-word;
    flex: 1;
}

/* ===== 评论区样式（手机优化） ===== */
.comments-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px 40px;
}
.comments-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}
.comment-input,
.comment-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    box-sizing: border-box;
}
.comment-input:focus,
.comment-textarea:focus {
    border-color: var(--accent);
}
.comment-textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}
.comment-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.comment-char-count {
    font-size: 12px;
    color: var(--text-muted);
}
.comment-submit {
    padding: 10px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 40px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    min-height: 40px;
    -webkit-appearance: none;
}
.comment-submit:active {
    opacity: 0.8;
}
.comment-submit:disabled {
    opacity: 0.5;
}
.comment-status {
    font-size: 14px;
    padding: 4px 0;
    text-align: center;
}
.comment-status.success { color: #27ae60; }
.comment-status.error { color: #e74c3c; }
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.comments-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.comments-loading,
.comments-empty,
.comments-error {
    text-align: center;
    padding: 20px;
    font-size: 14px;
    color: var(--text-muted);
}
.comment-item {
    display: flex;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.comment-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}
.comment-body {
    flex: 1;
    min-width: 0;
}
.comment-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}
.comment-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    word-break: break-word;
}
.comment-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
@media (max-width: 480px) {
    .comments-section { padding-left: 16px; padding-right: 16px; }
    .comment-submit { font-size: 14px; padding: 10px 22px; }
}
