/* ===== CSS 变量 ===== */
    :root {
        --max-width: 900px;
        --primary-color: #d0c8ff;
        --secondary-color: #a89bff;
        --deep-space-bg: rgba(10, 12, 20, 0.65);
        --deep-space-border: rgba(255, 255, 255, 0.12);
        --deep-space-glow: rgba(255, 230, 180, 0.45);
        --deep-space-text: #f5e9d2;
    }

    /* ===== 全局 / body ===== */
    body {
        font-family: "Noto Serif SC", "Inter", serif;
        font-weight: 400;
        line-height: 1.8;
        max-width: var(--max-width);
        margin: 0 auto;
        padding: 40px 20px;
        letter-spacing: 0.3px;
        color: var(--deep-space-text);
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        background: url("../assets/background.jpg")
            no-repeat center center fixed;
        background-size: cover;
        transition: background 0.3s, color 0.3s;
    }

    /* ===== 侧边栏 ===== */
    #sidebar {
        position: fixed;
        left: 20px;
        top: 50%;
        transform: translateY(-50%);
        background: linear-gradient(
            180deg,
            rgba(60, 40, 100, 0.75),
            rgba(30, 30, 70, 0.75),
            rgba(0, 0, 0, 0.75)
        );
        backdrop-filter: blur(16px);
        padding: 15px;
        border-radius: 8px;
        border: 1px solid rgba(200, 180, 255, 0.35);
        box-shadow: 0 0 20px rgba(200, 180, 255, 0.25);
        max-height: 80vh;
        overflow-y: auto;
        width: 200px;
        z-index: 1000;
        transition: opacity 0.3s, transform 0.3s;
    }

    #search-box {
        width: 100%;
        box-sizing: border-box;
        padding: 8px;
        margin-bottom: 10px;
        border: 1px solid rgba(255,255,255,0.3);
        background: rgba(255,255,255,0.12);
        color: #ffffff;
        border-radius: 4px;
    }

    .search-scope {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 8px 0 10px;
        color: rgba(245, 233, 210, 0.82);
        font-size: 13px;
        cursor: pointer;
        user-select: none;
    }

    .search-scope input {
        width: 14px;
        height: 14px;
        accent-color: #ffe9c6;
    }

    .search-scope.is-disabled {
        cursor: not-allowed;
        opacity: 0.48;
    }

    .toc-filter {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 10px 0 12px;
        width: 100%;
        color: #f5e9d2;
        font-size: 14px;
    }

    .toc-filter label {
        white-space: nowrap;
        opacity: 0.9;
    }

    #year-filter {
        flex: 1;
        min-width: 0;
        box-sizing: border-box;
        padding: 7px 8px;
        border: 1px solid rgba(255,255,255,0.28);
        background: rgba(255,255,255,0.12);
        color: #ffffff;
        border-radius: 4px;
    }

    #year-filter option {
        color: #202020;
    }

    .toc-empty {
        padding: 8px 5px;
        color: rgba(245, 233, 210, 0.72);
        font-size: 14px;
        text-align: center;
    }

    .load-status {
        margin: 0 0 10px;
        padding: 6px 8px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 5px;
        background: rgba(255, 255, 255, 0.06);
        color: rgba(245, 233, 210, 0.76);
        font-size: 12px;
        line-height: 1.4;
    }

    .load-status[data-state="fresh"] {
        color: #d8ffe4;
        border-color: rgba(160, 255, 190, 0.22);
    }

    .load-status[data-state="cached"] {
        color: #ffe9c6;
        border-color: rgba(255, 230, 180, 0.28);
    }

    .load-status[data-state="error"] {
        color: #ffcaca;
        border-color: rgba(255, 170, 170, 0.28);
    }

    /* ===== 目录项 ===== */
    .toc-item {
        cursor: pointer;
        padding: 5px;
        margin: 3px 0;
        border-left: 3px solid transparent;
        color: #f5f5f5;
        position: relative;
        overflow: visible;
        border-radius: 6px;
        transition: background 0.25s ease, color 0.25s ease;
    }

    .toc-item:hover {
        border-color: #ffffff;
        background: rgba(255, 255, 255, 0.15);
        color: #ffe9c6;
        text-shadow: 0 0 6px rgba(255, 230, 180, 0.5);
        transition: 0.25s ease;
    }

    /* scroll spy 高亮 + 磁吸 */
    .toc-item.active {
        background: rgba(255, 255, 255, 0.12);
        color: #ffe9c6;
        text-shadow: 0 0 10px rgba(255,255,255,0.9);
        backdrop-filter: blur(4px);
    }

    .toc-month {
        margin: 10px 0 4px;
        padding: 4px 5px;
        color: rgba(255, 233, 198, 0.74);
        font-size: 12px;
        letter-spacing: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* ===== 启示录子目录 ===== */
    .toc-item.revelation-child {
        padding-left: 20px;
        font-size: 0.9em;
        opacity: 0.9;
        position: relative;
        overflow: hidden;
        color: #dcd6ff;  /* fallback */
        background: linear-gradient(90deg, #dcd6ff, #a8b8ff, #ffc8ff);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }

    .toc-item.revelation-child::before {
        content: "✧";
        position: absolute;
        left: 5px;
        color: #dcd6ff;
        font-size: 0.8em;
        opacity: 0.8;
    }

    .toc-item.revelation-child::after {
        content: "";
        position: absolute;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(120deg, transparent, rgba(255,255,255,0.6), transparent);
        transform: skewX(-20deg);
        transition: 0.5s;
    }

    .toc-item.revelation-child:hover::after {
        left: 100%;
    }

    /* ===== 启示录标题（可折叠） ===== */
    .revelation-header {
        font-weight: bold;
        color: #eae6ff;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 6px;
        text-shadow: 0 0 8px rgba(200,180,255,0.8);
        position: relative;
        overflow: visible;
    }

    .revelation-header .arrow {
        font-size: 0.9em;
        color: #dcd6ff;
    }

    .revelation-header::after {
        content: "";
        position: absolute;
        inset: -6px;
        border-radius: 8px;
        background: radial-gradient(circle, rgba(200,180,255,0.6), transparent 70%);
        opacity: 0;
        transform: scale(0.6);
        transition: opacity 0.4s ease, transform 0.4s ease;
        pointer-events: none;
    }

    .revelation-header.pulse::after {
        opacity: 1;
        transform: scale(1.2);
    }

    /* ===== 启示录子目录折叠容器 ===== */
    .revelation-children {
        overflow: hidden;
        transition: height 0.35s ease;
    }

    /* ===== 目录点击星光波纹 ===== */
    .toc-ripple {
        position: absolute;
        width: 6px;
        height: 6px;
        background: radial-gradient(circle, rgba(255,255,255,0.9), transparent 70%);
        border-radius: 50%;
        pointer-events: none;
        transform: translate(-50%, -50%) scale(0.2);
        opacity: 1;
        animation: ripple-expand 0.6s ease-out forwards;
    }

    /* ===== 移动端目录按钮 ===== */
    #mobile-toc-toggle {
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
        background: rgba(255,255,255,0.2);
        color: white;
        border: none;
        border-radius: 50%;
        box-shadow: 0 2px 5px rgba(0,0,0,0.4);
        z-index: 1003;
        display: none;
        align-items: center;
        justify-content: center;
        font-size: 1.2em;
        backdrop-filter: blur(6px);
    }

    /* ===== 内容容器 ===== */
    #diary-container {
        padding: 0 20px;
        max-width: 780px;
        margin: auto;
        background: linear-gradient(
            to right,
            rgba(0,0,0,0) 0%,
            var(--deep-space-bg) 50%,
            rgba(0,0,0,0) 100%
        );
        backdrop-filter: blur(6px);
        border-radius: 10px;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }

    .chapter-container {
        margin: 40px 0;
        padding: 30px;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(12px);
        border-radius: 12px;
        position: relative;
        border: 1px solid rgba(255,255,255,0.18);
        box-shadow:
            0 1px 4px rgba(0,0,0,0.6),
            0 10px 20px -10px rgba(0,0,0,0.8);
        color: #f8f8f8;
    }

    /* ===== 章节标题 ===== */
    .chapter-title {
        font-size: 1.8em;
        text-align: center;
        margin: 30px 0;
        font-weight: 700;
        letter-spacing: 2px;
        color: var(--deep-space-text);
        text-shadow: 0 0 10px var(--deep-space-glow);
        border-bottom: 1px solid var(--deep-space-border);
        backdrop-filter: blur(6px);
        background: rgba(20, 20, 30, 0.35);
    }

    /* ===== 日期标题 ===== */
    .date {
        margin: 40px 0 20px;
        padding: 12px 0;
        font-size: 22px;
        font-weight: bold;
        text-align: center;
        color: var(--deep-space-text);
        text-shadow: 0 0 8px var(--deep-space-glow);
        position: relative;
        font-style: italic;
        background: rgba(20, 20, 30, 0.35);
        border-top: 1px solid var(--deep-space-border);
        border-bottom: 1px solid var(--deep-space-border);
        backdrop-filter: blur(6px);
        border-radius: 6px;
    }

    .date::before {
        content: "✦";
        position: absolute;
        left: 1em;
        color: #b8aaff;
        font-size: 1.2em;
    }

    /* ===== 正文段落 ===== */
    .content {
        white-space: pre-wrap;
        margin-bottom: 20px;
        border-left: 2px solid rgba(255,255,255,0.25);
        padding-left: 1.5em;
        color: #f8f8f8;
        line-height: 1.9;
        font-size: 17px;
    }

    .content p {
        text-indent: 2em;
        line-height: 1.9;
        margin: 14px 0;
        position: relative;
    }

    .content p + p {
        margin-top: 18px;
    }

    .content p::before {
        content: "";
        position: absolute;
        left: -8px;
        top: 0;
        width: 4px;
        height: 100%;
        background: linear-gradient(
            to bottom,
            var(--deep-space-border),
            rgba(255,255,255,0)
        );
        border-radius: 2px;
        pointer-events: none;
    }

    /* ===== 补充部分 ===== */
    .supplement {
        box-sizing: border-box;
        background: rgba(255, 255, 255, 0.08);
        border-left: 4px solid rgba(200,180,255,0.6);
        margin: 1.5em 2em;
        padding: 1em 2em;
        color: #f0f0ff;
        border-radius: 0 5px 5px 0;
        box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    }

    /* ===== 启示录整体模块 ===== */
    .revelation-block {
        margin: 60px 0;
        padding: 40px 30px;
        border-radius: 18px;
        background: rgba(0,0,0,0.55);
        backdrop-filter: blur(14px);
        border: 1px solid rgba(200,180,255,0.5);
        box-shadow: 0 0 25px rgba(200,180,255,0.4);
        position: relative;
    }

    .revelation-title {
        font-size: 2.2em;
        text-align: center;
        margin-bottom: 30px;
        color: var(--deep-space-text);
        text-shadow: 0 0 10px var(--deep-space-glow);
        letter-spacing: 4px;
        backdrop-filter: blur(6px);
        background: rgba(20, 20, 30, 0.35);
        border-color: var(--deep-space-border);
    }

    .revelation-date {
        margin: 20px 0 10px;
        font-size: 1.2em;
        color: var(--deep-space-text);
        text-shadow: 0 0 8px var(--deep-space-glow);
        position: relative;
        border-bottom: 1px solid var(--deep-space-border);
    }

    .revelation-date::after {
        content: "✦";
        position: absolute;
        right: -1.2em;
        top: 0.1em;
        font-size: 0.9em;
        color: #dcd6ff;
        opacity: 0.6;
        animation: starBlink 2.8s ease-in-out infinite;
    }

    .revelation-text {
        white-space: pre-wrap;
        margin-bottom: 1.5em;
        padding-left: 1.2em;
        border-left: 2px solid rgba(200,180,255,0.4);
        color: #f8f8ff;
        line-height: 1.9;
        position: relative;
        border: 1px solid rgba(200,180,255,0.25);
        border-radius: 10px;
        padding: 16px;
        overflow: hidden;
    }

    .revelation-text::before {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 10px;
        padding: 2px;
        background: linear-gradient(
            120deg,
            rgba(200,180,255,0.6),
            rgba(120,100,200,0.4),
            rgba(80,60,160,0.3),
            rgba(200,180,255,0.6)
        );
        background-size: 300% 300%;
        animation: starflow 6s linear infinite;
        -webkit-mask: 
            linear-gradient(#fff 0 0) content-box, 
            linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
                mask-composite: exclude;
    }

    .revelation-body {
        margin-top: 20px;
    }

    /* ===== 全局 hover 统一 ===== */
    a:hover {
        color: #ffe9c6;
        text-shadow: 0 0 6px rgba(255, 230, 180, 0.5);
        transition: 0.25s ease;
    }

    /* ===== 浮动柔光标题栏 ===== */
    #floating-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        padding: 12px 20px;
        font-size: 20px;
        font-weight: bold;
        color: #ffe9c6;
        text-shadow: 0 0 6px rgba(255, 230, 180, 0.6);
        background: rgba(20, 20, 30, 0.45);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease, transform 0.3s ease;
        transform: translateY(-20px);
    }

    /* ===== 搜索相关 ===== */
    #search-controls {
        margin-top: 8px;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .search-btn {
        width: 28px;
        height: 28px;
        border-radius: 6px;
        border: 1px solid rgba(255,255,255,0.15);
        background: rgba(255,255,255,0.05);
        cursor: pointer;
        transition: 0.25s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .search-btn svg {
        width: 16px;
        height: 16px;
        fill: #ffe9c6;
        opacity: 0.85;
        transition: 0.25s ease;
    }

    .search-btn:hover {
        background: rgba(255,230,180,0.15);
        border-color: rgba(255,230,180,0.35);
        box-shadow: 0 0 8px rgba(255,230,180,0.35);
    }

    .search-btn:hover svg {
        opacity: 1;
        filter: drop-shadow(0 0 4px rgba(255,230,180,0.5));
    }

    .search-btn:active {
        transform: scale(0.92);
    }

    .search-focus {
        outline: 2px solid rgba(255, 230, 180, 0.5);
        border-radius: 4px;
        padding: 2px;
    }

    /* ===== 日记图片 ===== */
    .diary-image {
        display: block;
    }

    .diary-image-resolved {
        display: block;
        max-width: 100%;
        height: auto;
        margin: 1.5em auto;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.15);
    }

    .image-placeholder {
        display: block;
        text-align: center;
        padding: 3em 1em;
        margin: 1.5em auto;
        color: rgba(245, 233, 210, 0.5);
        font-style: italic;
        font-size: 16px;
        border: 1px dashed rgba(255, 255, 255, 0.12);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.03);
    }

    /* ===== 锁定内容 ===== */
    .date-locked {
        cursor: pointer;
        user-select: none;
    }

    .lock-badge {
        font-size: 0.7em;
        color: rgba(255, 180, 150, 0.8);
        margin-left: 0.5em;
        font-weight: normal;
        font-style: normal;
    }

    .content-locked {
        position: relative;
    }

    .content-locked > p,
    .content-locked > .supplement,
    .content-locked > .stats,
    .content-locked > .chapter-content {
        display: none;
    }

    .content-locked.unlocked > p,
    .content-locked.unlocked > .supplement,
    .content-locked.unlocked > .stats,
    .content-locked.unlocked > .chapter-content {
        display: block;
    }

    .content-locked.unlocked > .supplement {
        display: block;
        box-sizing: border-box;
        background: rgba(255, 255, 255, 0.08);
        border-left: 4px solid rgba(200,180,255,0.6);
        margin: 1.5em 2em;
        padding: 1em 2em;
        border-radius: 0 5px 5px 0;
    }

    .lock-password-ui {
        display: none;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 16px 0;
        margin-bottom: 10px;
    }

    .lock-password-ui.active {
        display: flex;
    }

    .lock-input {
        flex: 1;
        min-width: 120px;
        padding: 8px 12px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.1);
        color: #ffe9c6;
        font-size: 15px;
        outline: none;
        transition: border-color 0.25s;
    }

    .lock-input:focus {
        border-color: rgba(200, 180, 255, 0.7);
        box-shadow: 0 0 6px rgba(200, 180, 255, 0.3);
    }

    .lock-submit {
        padding: 8px 18px;
        border: 1px solid rgba(200, 180, 255, 0.4);
        border-radius: 6px;
        background: rgba(200, 180, 255, 0.2);
        color: #ffe9c6;
        cursor: pointer;
        font-size: 15px;
        transition: background 0.25s;
    }

    .lock-submit:hover {
        background: rgba(200, 180, 255, 0.35);
    }

    .lock-error {
        width: 100%;
        color: #ffb0a0;
        font-size: 14px;
        font-style: italic;
        opacity: 0;
        transition: opacity 0.3s;
        text-align: center;
    }

    .lock-error.show {
        opacity: 1;
    }

    /* ===== 动画 ===== */
    @keyframes starBlink {
        0%   { opacity: 0.2; transform: scale(0.9); }
        50%  { opacity: 1;   transform: scale(1.2); }
        100% { opacity: 0.2; transform: scale(0.9); }
    }

    @keyframes starflow {
        0%   { background-position: 0% 50%; }
        100% { background-position: 300% 50%; }
    }

    @keyframes ripple-expand {
        0% {
            opacity: 1;
            transform: translate(-50%, -50%) scale(0.2);
        }
        100% {
            opacity: 0;
            transform: translate(-50%, -50%) scale(2.5);
        }
    }

    /* ===== 移动端适配 ===== */
    @media (max-width: 840px) {
        #sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: 80vw;
            max-width: 360px;
            height: 100vh;
            background: rgba(0,0,0,0.6);
            backdrop-filter: blur(18px);
            transform: translateX(-100%);
            transition: transform 0.3s ease;
            z-index: 1002;
            padding: 20px;
            overflow-y: auto;
            border-radius: 0;
            box-shadow: 4px 0 12px rgba(0,0,0,0.4);
            pointer-events: none;
        }

        #sidebar.active {
            transform: translateX(0);
            pointer-events: auto;
        }

        #mobile-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            z-index: 1001;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
        }

        #mobile-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        #mobile-toc-toggle {
            display: flex;
        }

        .close-toc {
            position: absolute;
            top: 15px;
            right: 15px;
            background: none;
            border: none;
            font-size: 1.5em;
            color: #fff;
        }

        body.sidebar-open {
            overflow: hidden;
            touch-action: none;
        }

        .supplement {
            box-sizing: border-box;
            margin-left: 1em;
            margin-right: 1em;
            padding: 1em;
        }

        /* 移动端：启示录 TOC 子项优化 */
        .toc-item.revelation-child {
            padding-left: 14px;
            font-size: 0.85em;
            overflow: visible;
            color: #dcd6ff;
            background: none;
            -webkit-background-clip: unset;
        }

        .toc-item.revelation-child::before {
            left: 2px;
            font-size: 0.7em;
        }

        .toc-item.revelation-child::after {
            display: none;
        }

        /* 移动端：启示录日期星光不溢出 */
        .revelation-date::after {
            right: 0;
        }

        /* 移动端：简化启示录正文边框动画 */
        .revelation-text::before {
            animation: none;
            background: rgba(200,180,255,0.2);
        }
    }

    @media (max-width: 600px) {
        .content {
            font-size: 16px;
            line-height: 1.85;
        }
        .date {
            font-size: 20px;
        }

        /* 移动端：日期星号改为随文内联，随标题一同居中，不再遮挡 */
        .date::before {
            position: static;
            left: auto;
            font-size: 1em;
        }

        /* 移动端：启示录标题缩小避免折行 */
        .revelation-title {
            font-size: 1.6em;
            letter-spacing: 2px;
        }

        /* 移动端：启示录正文减少内边距 */
        .revelation-text {
            padding: 12px;
        }

        /* 移动端：日记图片占位符缩小内边距 */
        .image-placeholder {
            padding: 2em 1em;
            font-size: 15px;
        }

        /* 移动端：锁定 UI 紧凑布局 */
        .lock-password-ui {
            gap: 6px;
            padding: 12px 0;
        }

        .lock-input {
            font-size: 14px;
            padding: 6px 10px;
        }

        .lock-submit {
            font-size: 14px;
            padding: 6px 14px;
        }
    }
