/* ==========================================================
   全局变量 (昼/夜) & 背景图控制
   ========================================================== */
:root {
    --site-bg-image: url('https://images.unsplash.com/photo-1477346611705-65d1883cee1e?q=80&w=2070&auto=format&fit=crop');
    /* --site-bg-image: none; */
    --bg-gradient-start: #f7f9fc;
    --bg-gradient-end: #eef1f7;
    --app-bg: rgba(255, 255, 255, 0.35);
    --page-bg: rgba(255, 255, 255, 0.25);
    --app-shadow: 0 30px 50px -20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
    --menu-bg: rgba(255, 255, 255, 0.5);
    --menu-border: rgba(255, 255, 255, 0.8);
    --menu-hover-bg: rgba(255, 255, 255, 0.85);
    --menu-active-bg: linear-gradient(135deg, #ffffff, #f9fbff);
    --menu-active-shadow: 0 18px 30px -10px rgba(80, 100, 180, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    --text-primary: #1e293b;
    --text-secondary: #2c3a5e;
    --text-muted: #334155;
    --heading-color: #0f1a30;
    --icon-color: #5b6b8c;
    --icon-active-color: #3a5c9e;
    --page-border: rgba(255, 255, 255, 0.6);
    --page-shadow: 0 8px 22px -10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
    --toggle-bg: rgba(255, 255, 255, 0.6);
    --toggle-border: rgba(255, 255, 255, 0.9);
    --toggle-icon: #4a6fa5;
    --scroll-thumb: rgba(100, 116, 139, 0.3);
    --link-bg: rgba(255, 255, 255, 0.55);
    --link-hover-bg: rgba(255, 255, 255, 0.9);
    --link-border: rgba(255, 255, 255, 0.8);
    --link-icon-bg: rgba(80, 100, 180, 0.1);
    --link-icon-color: #4a6fa5;
}

body.dark-mode {
    --bg-gradient-start: #0b0f1a;
    --bg-gradient-end: #141a26;
    --app-bg: rgba(20, 28, 40, 0.45);
    --page-bg: rgba(28, 38, 55, 0.35);
    --app-shadow: 0 30px 50px -20px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    --menu-bg: rgba(35, 45, 65, 0.6);
    --menu-border: rgba(255, 255, 255, 0.15);
    --menu-hover-bg: rgba(55, 70, 95, 0.7);
    --menu-active-bg: linear-gradient(135deg, #2a3548, #1f2a3f);
    --menu-active-shadow: 0 18px 30px -10px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted: #a0afc0;
    --heading-color: #f1f5f9;
    --icon-color: #94a3b8;
    --icon-active-color: #7aa2e0;
    --page-border: rgba(255, 255, 255, 0.1);
    --page-shadow: 0 8px 22px -10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    --toggle-bg: rgba(50, 65, 90, 0.8);
    --toggle-border: rgba(255, 255, 255, 0.2);
    --toggle-icon: #fbbf24;
    --scroll-thumb: rgba(200, 210, 230, 0.4);
    --link-bg: rgba(35, 45, 65, 0.55);
    --link-hover-bg: rgba(55, 70, 95, 0.85);
    --link-border: rgba(255, 255, 255, 0.12);
    --link-icon-bg: rgba(120, 160, 230, 0.15);
    --link-icon-color: #7aa2e0;
}

/* 全局重置 & 背景 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Helvetica, Arial, sans-serif;
    background-image: var(--site-bg-image);
    background-color: var(--bg-gradient-start);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    margin: 0;
    line-height: 1.5;
    color: var(--text-primary);
    transition: background-color 0.4s ease, color 0.3s ease;
}

body.dark-mode {
    background-image: linear-gradient(rgba(11, 15, 26, 0.7), rgba(20, 26, 38, 0.7)), var(--site-bg-image);
    background-color: var(--bg-gradient-end);
}

/* 主布局容器 */
.app-container {
    max-width: 1100px;
    width: 100%;
    background: var(--app-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: clamp(1.5rem, 6vw, 3rem);
    box-shadow: var(--app-shadow);
    padding: clamp(1.5rem, 5vw, 2rem) clamp(1rem, 4vw, 2rem) clamp(1.8rem, 6vw, 2.5rem);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* 菜单栏 */
.menu {
    display: flex;
    justify-content: center;
    gap: clamp(0.8rem, 3vw, 1.5rem);
    margin-bottom: clamp(1.8rem, 5vw, 2.5rem);
    flex-wrap: wrap;
}

.menu-item {
    flex: 1 1 0;
    min-width: clamp(65px, 18vw, 120px);
    text-align: center;
    padding: clamp(0.8rem, 3vw, 1.25rem) clamp(0.5rem, 2vw, 1rem);
    border-radius: clamp(1.5rem, 6vw, 2.5rem);
    background: var(--menu-bg);
    border: 1px solid var(--menu-border);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1);
    font-weight: 600;
    font-size: clamp(0.85rem, 2.5vw, 1.15rem);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.2rem, 1vw, 0.5rem);
    user-select: none;
    outline: none;
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}

.menu-item i {
    font-size: clamp(1.4rem, 4.5vw, 1.9rem);
    color: var(--icon-color);
    transition: all 0.3s ease;
}

.menu-item:hover {
    background: var(--menu-hover-bg);
    box-shadow: 0 18px 28px -12px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
    border-color: var(--menu-border);
}

.menu-item:hover i {
    color: var(--icon-active-color);
    transform: scale(1.05);
}

.menu-item.active {
    background: var(--menu-active-bg);
    box-shadow: var(--menu-active-shadow);
    color: var(--heading-color);
    border-color: var(--menu-border);
    transform: translateY(-2px);
}

.menu-item.active i {
    color: var(--icon-active-color);
}

/* 内容页卡片 */
.page-content {
    position: relative;
}

.page {
    background: var(--page-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: clamp(1.2rem, 5vw, 2.5rem);
    padding: clamp(1.2rem, 5vw, 2.5rem) clamp(1rem, 5vw, 2.8rem);
    box-shadow: var(--page-shadow);
    border: 1px solid var(--page-border);
    color: var(--text-primary);
    position: relative;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page.active {
    animation: pageFadeIn 0.4s ease forwards;
}

.page h2 {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: clamp(0.6rem, 2vw, 1rem);
    color: var(--heading-color);
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
    flex-wrap: wrap;
}

.page h2 i {
    font-size: clamp(1.6rem, 4.5vw, 2.2rem);
    color: var(--icon-active-color);
    flex-shrink: 0;
}

.page>p {
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    color: var(--text-secondary);
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    font-weight: 400;
    line-height: 1.7;
    max-width: 100%;
}

.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    pointer-events: none;
}

/* 昼夜切换按钮 */
.theme-toggle {
    position: fixed;
    top: max(1.2rem, env(safe-area-inset-top, 1.2rem));
    right: max(1.5rem, env(safe-area-inset-right, 1.5rem));
    width: clamp(2.6rem, 8vw, 3.2rem);
    height: clamp(2.6rem, 8vw, 3.2rem);
    border-radius: 50%;
    background: var(--toggle-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--toggle-border);
    box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1);
    z-index: 100;
    color: var(--toggle-icon);
    outline: none;
    user-select: none;
}

.theme-toggle i {
    font-size: clamp(1.2rem, 3.8vw, 1.7rem);
    color: var(--toggle-icon);
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 12px 26px -6px rgba(0, 0, 0, 0.25);
}

.theme-toggle:active {
    transform: scale(0.96);
}

/* 页脚 */
.site-footer {
    margin-top: clamp(1.8rem, 6vw, 2.8rem);
    padding-top: clamp(1.2rem, 4vw, 1.8rem);
    border-top: 1px solid var(--link-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.9rem, 3vw, 1.3rem);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(0.5rem, 2vw, 0.9rem);
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: clamp(0.4rem, 1.6vw, 0.55rem) clamp(0.8rem, 3vw, 1.1rem);
    border-radius: 100px;
    background: var(--link-bg);
    border: 1px solid var(--link-border);
    color: var(--text-muted);
    font-size: clamp(0.75rem, 2vw, 0.88rem);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.footer-link:hover {
    background: var(--link-hover-bg);
    color: var(--icon-active-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.15);
    border-color: var(--link-border);
}

.footer-link i {
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    color: var(--link-icon-color);
    transition: transform 0.3s ease;
}

.footer-link:hover i {
    transform: scale(1.1);
}

.footer-copy {
    font-size: clamp(0.72rem, 1.9vw, 0.82rem);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
    text-align: center;
    opacity: 0.8;
}

.footer-copy i {
    color: #ef4444;
    font-size: clamp(0.7rem, 1.8vw, 0.8rem);
}

/* 顶部广告位（公共） */
.ad-container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ad-banner-wrap {
    position: relative;
    width: 100%;
    z-index: 90;
    transition: all 0.3s ease;
}

.ad-inner {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.ad-link {
    display: block;
    width: 100%;
    border-radius: clamp(1rem, 4vw, 1.5rem);
    overflow: hidden;
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ad-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.25);
}

.ad-banner-wrap img {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: cover;
    display: block;
}

.ad-close {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.ad-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1) rotate(-90deg);
}

/* 验证码弹窗 (notes.html 用，但公共里放着也行) */
.captcha-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.captcha-overlay.show {
    opacity: 1;
    visibility: visible;
}

.captcha-box {
    background: var(--app-bg);
    border: 1px solid var(--app-shadow);
    border-radius: clamp(1rem, 4vw, 1.5rem);
    padding: clamp(1.5rem, 5vw, 2rem);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.4, 1);
    color: var(--text-primary);
}

.captcha-overlay.show .captcha-box {
    transform: translateY(0) scale(1);
}

.captcha-box h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.captcha-box h3 i {
    color: var(--icon-active-color);
}

.captcha-box p {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    line-height: 1.5;
}

.captcha-question {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    color: var(--heading-color);
    background: var(--link-bg);
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid var(--link-border);
    margin-bottom: 1rem;
    letter-spacing: 2px;
    transition: color 0.2s ease;
}

.captcha-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--page-border);
    background: var(--page-bg);
    color: var(--text-primary);
    font-size: 1.1rem;
    text-align: center;
    font-weight: 600;
    outline: none;
    transition: all 0.3s ease;
    margin-bottom: 1.2rem;
    font-family: inherit;
}

.captcha-input:focus {
    border-color: var(--icon-active-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

.captcha-actions {
    display: flex;
    gap: 10px;
}

.captcha-btn {
    flex: 1;
    padding: 0.8rem;
    border-radius: 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

.captcha-btn.cancel {
    background: var(--link-bg);
    color: var(--text-muted);
    border: 1px solid var(--link-border);
}

.captcha-btn.cancel:hover {
    background: var(--link-hover-bg);
}

.captcha-btn.confirm {
    background: linear-gradient(135deg, #4a6fa5, #3a5c9e);
    color: #fff;
    box-shadow: 0 4px 12px -4px rgba(74, 111, 165, 0.5);
}

.captcha-btn.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px -6px rgba(74, 111, 165, 0.6);
    filter: brightness(1.08);
}

/* 响应式 & 滚动条 */
@media (max-width: 400px) {
    .menu-item {
        min-width: 60px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    body {
        align-items: flex-start;
        padding-top: 2rem;
    }

    .app-container {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    .page-content {
        min-height: 250px;
    }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 10px;
}

img {
    max-width: 100%;
    height: auto;
}

.menu-item,
.theme-toggle,
.copy-btn {
    -webkit-tap-highlight-color: transparent;
}