:root {
    --primary-color: #4a90e2;
    --secondary-color: #2c7bd0;
    --bg-color: #f4f4f4;
    --text-color: #333;
    --radius-control: 12px;
    --radius-panel: 16px;
    --radius-round: 50%;
}

#background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/img/back01.png');
    background-size: cover;
    background-position: center;
    z-index: -1;
    transition: filter 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Helvetica Neue', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    perspective: 1000px; /* 3D 视差效果 */
    overflow-x: hidden;
}

.container {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-panel);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    text-align: center;
    max-width: 800px;
    width: 90%;
    transform-style: preserve-3d;
    transform: rotateX(10deg);
    transition: all 0.3s ease;
    position: relative;
}
.container:hover {
    transform: rotateX(0) scale(1.02);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}
.logo {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-round);
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 10px 20px rgba(74, 144, 226, 0.3);
}
.logo i {
    color: #fff; font-size: 40px;
}
.logo-text {
    font-size: 12px;
    color: var(--text-color);
    margin-top: 8px;
    opacity: 0.7;
}

.search-container {
    display: flex;
    margin-bottom: 30px;
    position: relative;
}
.search-select, .search-input {
    padding: 12px; font-size: 16px;
    border: 1px solid #ddd; outline: none;
}
.search-select {
    border-right: none;
    border-top-left-radius: var(--radius-control);
    border-bottom-left-radius: var(--radius-control);
    background-color: #f8f9fa;
}
.search-input {
    flex-grow: 1;
    border-left: none;
    min-width: 0;
}
.search-btn {
    background-color: var(--primary-color);
    color: white; border: none;
    padding: 12px 24px;
    border-top-right-radius: var(--radius-control);
    border-bottom-right-radius: var(--radius-control);
    cursor: pointer;
    transition: all 0.3s ease;
}
.search-btn:hover {
    background-color: var(--secondary-color);
}

.quick-links {
    display: flex; justify-content: center; gap: 15px;
    margin-bottom: 30px; flex-wrap: wrap;
}
.quick-link {
    text-decoration: none; color: #fff;
    background-color: var(--primary-color);
    padding: 10px 20px; border-radius: var(--radius-control);
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(74, 144, 226, 0.2);
}
.quick-link:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(74, 144, 226, 0.3);
}

.menu {
    display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; position: relative;
}
.menu-item {
    position: relative; margin: 5px;
}
.menu-title {
    cursor: pointer; padding: 10px 20px;
    background-color: #f1f3f5; border-radius: var(--radius-control);
    transition: all 0.3s ease;
}
.menu-title:hover {
    background-color: var(--primary-color); color: #fff;
}
.submenu {
    display: none; position: absolute;
    background-color: #fff; min-width: 200px;
    border: 1px solid rgba(74, 144, 226, 0.3);
    border-color: color-mix(in srgb, var(--primary-color) 32%, transparent);
    box-shadow: 0 8px 22px rgba(0,0,0,0.14);
    border-radius: var(--radius-control); z-index: 10;
    top: 100%; left: 50%; transform: translateX(-50%);
    padding: 5px 0;
}
.menu-item:hover > .submenu {
    display: block;
}
.menu > .menu-item > .submenu {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}
.submenu a {
    color: var(--text-color); text-decoration: none;
    display: block; padding: 10px 20px;
    transition: all 0.3s ease;
}
.submenu a:hover {
    background-color: #f1f3f5;
    color: var(--primary-color);
}

/* 三级菜单 */
.submenu .menu-item {
    position: relative;
}
.submenu .submenu {
    display: none; position: absolute; left: 100%; top: 0;
    transform: translateX(-50%); /* 向左回压半宽，保留层叠菜单的半遮挡效果 */
    background-color: #fff; min-width: 200px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.14);
    border-radius: var(--radius-control);
    border: 1px solid rgba(74, 144, 226, 0.3);
    border-color: color-mix(in srgb, var(--primary-color) 32%, transparent);
    z-index: 11; padding: 5px 0;
}
.submenu .menu-item:hover > .submenu {
    display: block;
}
.submenu .menu-item > a {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px;
}
.submenu .menu-item > a::after {
    content: '►'; font-size: 12px; margin-left: 10px; opacity: 0.5;
}

.spacer { height: 10px; }

.footer {
    margin-top: 10px;
    text-align: center;
    font-size: 10px; color: var(--text-color);
}
.footer a {
    color: var(--primary-color); text-decoration: none;
    margin: 0 10px; transition: color 0.3s ease;
}
.footer a:hover {
    color: var(--secondary-color); text-decoration: underline;
}

#bg-settings-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-round);
    background: rgba(255, 255, 255, 0.88);
    color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease,
                opacity 0.2s ease, visibility 0.2s ease;
}

body.settings-open #bg-settings-btn {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px) scale(0.92);
}

#bg-settings-btn i {
    font-size: 21px;
    transition: transform 0.35s ease;
}

#bg-settings-btn:hover {
    transform: translateY(-2px);
    background: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

#bg-settings-btn:hover i {
    transform: rotate(90deg);
}

#bg-settings-btn:focus-visible {
    outline: 3px solid rgba(74, 144, 226, 0.35);
    outline-offset: 3px;
}

.settings-modal {
    display: none;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1001;
    width: min(380px, calc(100vw - 40px));
    max-height: calc(100dvh - 104px);
    padding: 24px;
    overflow-y: auto;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(74, 144, 226, 0.24);
    border-color: color-mix(in srgb, var(--primary-color) 26%, transparent);
    border-radius: var(--radius-panel);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
    backdrop-filter: blur(18px);
    animation: settingsPanelIn 0.2s ease-out;
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.settings-header h2 {
    font-size: 20px;
    line-height: 1.35;
}

.settings-header p {
    margin-top: 4px;
    color: #6b7280;
    font-size: 13px;
}

.settings-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-round);
    color: #6b7280;
    background: #f3f4f6;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.settings-close:hover {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    transform: rotate(90deg);
}

.settings-close:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary-color) 28%, transparent);
    outline-offset: 2px;
}

.settings-section {
    overflow: hidden;
    margin-bottom: 14px;
    border: 1px solid rgba(74, 144, 226, 0.18);
    border-color: color-mix(in srgb, var(--primary-color) 20%, transparent);
    border-radius: var(--radius-control);
    background: rgba(248, 250, 252, 0.82);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 14px;
    cursor: pointer;
}

.settings-row + .settings-row {
    border-top: 1px solid #e5e7eb;
}

.settings-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    text-align: left;
}

.settings-copy strong {
    font-size: 14px;
    line-height: 1.4;
}

.settings-copy small {
    margin-top: 2px;
    color: #6b7280;
    font-size: 12px;
    line-height: 1.45;
}

.settings-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
}

.settings-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.settings-switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background-color 0.2s ease;
}

.settings-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-round);
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
    transition: transform 0.2s ease;
}

.settings-switch input:checked + .settings-switch-track {
    background: var(--primary-color);
}

.settings-switch input:checked + .settings-switch-track::after {
    transform: translateX(18px);
}

.settings-switch input:focus-visible + .settings-switch-track {
    outline: 3px solid color-mix(in srgb, var(--primary-color) 28%, transparent);
    outline-offset: 2px;
}

.settings-background-section {
    padding: 14px;
    overflow: visible;
}

.settings-field-label {
    display: block;
    margin-bottom: 8px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
}

.settings-select,
#custom-bg-input {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-control);
    outline: none;
    background: #fff;
    color: var(--text-color);
    font: inherit;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-select:focus,
#custom-bg-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}

.custom-bg-container {
    display: none;
    margin-top: 10px;
}

.performance-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 13px;
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--primary-color) 9%, transparent);
    color: var(--text-color);
    font-size: 12px;
    line-height: 1.5;
}

.performance-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: var(--radius-round);
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

@keyframes settingsPanelIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 警告浮层写在最外层，确保 z-index 最大，能点到 */
.warning-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
    display: none; /* 默认隐藏 */
    justify-content: center; align-items: center;
    padding: 20px;
    z-index: 10001; /* 高于mobile-modal */
}
.warning-box {
    width: min(100%, 440px);
    background: rgba(255, 255, 255, 0.98);
    padding: 32px;
    border: 1px solid rgba(74, 144, 226, 0.16);
    border-radius: var(--radius-panel);
    text-align: center;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}
.warning-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border-radius: var(--radius-round);
    background: rgba(245, 158, 11, 0.14);
    color: #d97706;
    font-size: 22px;
}
.warning-title {
    color: var(--text-color);
    margin-bottom: 12px;
    font-size: 22px;
    line-height: 1.35;
}
.warning-message {
    margin-bottom: 24px;
}
.warning-text {
    color: var(--text-color);
    font-size: 15px;
    line-height: 1.75;
}
.warning-note {
    margin-top: 8px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.6;
}
.warning-actions {
    display: flex;
    gap: 12px;
}
.btn {
    flex: 1;
    min-height: 44px;
    padding: 10px 20px;
    margin: 0;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn-agree {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 6px 14px rgba(74, 144, 226, 0.22);
}
.btn-agree:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}
.btn-cancel {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #e5e7eb;
}
.btn-cancel:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}
.btn:focus-visible {
    outline: 3px solid rgba(74, 144, 226, 0.3);
    outline-offset: 2px;
}

#clock {
    text-align: center;
    margin-bottom: 20px;
    cursor: pointer;
}

#time {
    font-size: 80px;
    color: var(--text-color);
    font-weight: bold;
    letter-spacing: 2px;
}

#date {
    font-size: 20px;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 5px;
}

.clock-fullscreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10020;
    background: #080c14;
    color: #fff;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 20px;
}

.clock-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: var(--radius-control);
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#fullscreen-time {
    font-size: clamp(48px, 12vw, 128px);
    font-weight: bold;
    letter-spacing: 3px;
}

#fullscreen-date {
    margin-top: 16px;
    font-size: clamp(18px, 4vw, 36px);
    opacity: 0.85;
}

/* 响应式 */
@media (max-width: 600px) {
    body {
        perspective: none;
    }
    .settings-modal {
        right: 16px;
        bottom: max(16px, env(safe-area-inset-bottom));
        width: calc(100vw - 32px);
        max-height: calc(100dvh - 32px);
        padding: 20px;
    }
    .container {
        margin: 20px; padding: 20px; width: calc(100% - 40px);
    }
    .menu { flex-direction: column; align-items: stretch; } /* 改为 stretch 以占满宽度 */
    .menu-item { width: 100%; } /* 确保每个项目占满宽度 */
    .menu-title {
        display: block;
        width: 100%;
        text-align: center; /* 文本居中对齐 */
        box-sizing: border-box;
    }
    .search-container {
        display: flex;
        align-items: stretch;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    .search-select, .search-input, .search-btn {
        box-sizing: border-box;
    }
    .search-select {
        flex: 0 0 86px;
        min-width: 0;
        font-size: 14px;
    }
    .search-input {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 14px;
    }
    .search-btn {
        flex: 0 0 56px;
        padding: 12px 0;
        white-space: nowrap;
        font-size: 14px;
    }
            .submenu {
                display: none; /* 手机端隐藏下拉菜单 */
            }
            .menu-item:hover > .submenu,
            .submenu .menu-item:hover > .submenu {
                display: none; /* 手机端只允许点击打开菜单 */
            }
            .footer { font-size: 12px; }
    .footer a { display: block; margin: 5px 0; }
    #time {
        font-size: 50px;
    }
    #date {
        font-size: 16px;
    }
    .clock-close-btn {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
    .warning-box {
        padding: 26px 22px 22px;
    }
    .warning-title {
        font-size: 20px;
    }
    .warning-text {
        font-size: 14px;
    }
    .btn {
        padding: 11px 16px;
        font-size: 14px;
    }
}

/* 手机端对话框样式 */
.mobile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
             max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    animation: modalFadeIn 0.3s ease-out;
}
.mobile-modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-panel);
    padding: 44px 20px 20px;
    width: 90%;
    max-width: 520px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease-out;
}
.mobile-modal-back,
.mobile-modal-close {
    position: absolute;
    top: 8px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-round);
    appearance: none;
    cursor: pointer;
    color: var(--text-color);
    background: transparent;
    z-index: 2;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}
.mobile-modal-back {
    display: none;
    left: 8px;
    font-size: 16px;
}
.mobile-modal-close {
    display: inline-flex;
    right: 8px;
    font-size: 26px;
    line-height: 1;
}
.mobile-modal-back:hover,
.mobile-modal-close:hover {
    color: var(--primary-color);
    background: rgba(74, 144, 226, 0.12);
}
.mobile-modal-back:active,
.mobile-modal-close:active {
    transform: scale(0.92);
}
.mobile-modal-back:focus-visible,
.mobile-modal-close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}
/* 手机端选项按钮样式 */
.mobile-modal-content a {
    display: block;
    width: 100%;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--radius-control);
    border: 1px solid rgba(74, 144, 226, 0.24);
    border-color: color-mix(in srgb, var(--primary-color) 26%, transparent);
    transition: all 0.3s ease;
    text-align: center; /* 文本居中对齐 */
    font-weight: 500;
    box-sizing: border-box; /* 确保宽度计算正确 */
}
.mobile-modal-content a:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.3);
}
.mobile-modal-content .menu-item > a::after {
    content: '▶';
    float: right;
    opacity: 0.7;
    margin-left: 10px;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalScaleIn {
    from { transform: scale(0.9); }
    to { transform: scale(1); }
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #e5e7eb;
    }

    body {
        background: linear-gradient(135deg, #0b1220 0%, #121a2b 100%);
        color: var(--text-color);
    }

    #background {
        filter: brightness(0.65) saturate(0.9);
    }

    .container {
        background-color: rgba(17, 24, 39, 0.88);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    }

    .search-select,
    .search-input {
        background-color: #0f172a;
        border-color: #374151;
        color: var(--text-color);
    }

    .menu-title {
        background-color: #1f2937;
        color: var(--text-color);
    }

    .submenu,
    .submenu .submenu {
        background-color: #111827;
        border-color: color-mix(in srgb, var(--primary-color) 45%, transparent);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    }

    .menu > .menu-item > .submenu {
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    }

    .submenu a:hover {
        background-color: #1f2937;
    }

    .warning-box {
        background: #111827;
        border-color: #374151;
    }

    .warning-text {
        color: var(--text-color);
    }

    .warning-note {
        color: #9ca3af;
    }

    .btn-cancel {
        background: #1f2937;
        color: var(--text-color);
        border-color: #374151;
    }

    .btn-cancel:hover {
        background: #273449;
    }

    .mobile-modal-content {
        background: rgba(17, 24, 39, 0.95);
    }

    .mobile-modal-content a {
        background: linear-gradient(135deg, #111827, #1f2937);
        border-color: #374151;
    }

    #bg-settings-btn {
        background: rgba(17, 24, 39, 0.9);
        color: var(--text-color);
        border: 1px solid #374151;
    }

    #bg-settings-btn:hover {
        background: #1f2937;
    }

    #bg-settings-modal {
        background: rgba(17, 24, 39, 0.96);
        color: var(--text-color);
        border-color: color-mix(in srgb, var(--primary-color) 42%, transparent);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }

    .settings-header p,
    .settings-copy small {
        color: #9ca3af;
    }

    .settings-section {
        background: rgba(15, 23, 42, 0.78);
        border-color: color-mix(in srgb, var(--primary-color) 32%, transparent);
    }

    .settings-row + .settings-row {
        border-color: #374151;
    }

    .settings-close {
        background: #1f2937;
        color: #d1d5db;
    }

    .settings-select,
    #custom-bg-input {
        background: #0f172a;
        color: var(--text-color);
        border: 1px solid #374151;
    }
}
