/* --- CSS 变量配置 --- */
:root {
    --overlay-opacity: 0;
    --text-color: #333;
    --search-bg-idle: rgba(255, 255, 255, 0.25); 
    --search-bg-active: rgba(255, 255, 255, 0.95);
    --dropdown-bg: rgba(255, 255, 255, 0.8);
    --card-bg: rgba(255, 255, 255, 0.7);
    --modal-bg: #ffffff;
    --input-border: #ddd;
    --accent-color: #007bff;
    /* 动画缓动曲线 */
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
    --overlay-opacity: 1; 
    --text-color: #eee;
    --search-bg-idle: rgba(0, 0, 0, 0.3);
    --search-bg-active: rgba(40, 40, 40, 0.95);
    --dropdown-bg: rgba(50, 50, 50, 0.8);
    --card-bg: rgba(50, 50, 50, 0.6);
    --modal-bg: #2b2b2b;
    --input-border: #444;
    --accent-color: #4da3ff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    height: 100vh; overflow: hidden;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    position: relative; color: var(--text-color); user-select: none;
    -webkit-font-smoothing: antialiased; /* 字体抗锯齿 */
}

/* --- 背景系统 --- */
#bg-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -2; overflow: hidden; }

/* 开启 GPU 加速，防止卡顿 */
#bg-image, #bg-video { 
    width: 100%; height: 100%; object-fit: cover; display: block; 
    will-change: transform, filter; transform: translateZ(0);
    transition: transform 0.6s var(--ease-smooth), filter 0.6s var(--ease-smooth);
}
#bg-video { display: none; } /* 默认隐藏视频 */

/* 书签页时的背景特效：放大 + 模糊 */
.zoomed { transform: scale(1.1) translateZ(0) !important; filter: blur(12px); }

/* 黑夜模式遮罩 */
#bg-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; pointer-events: none;
    background: radial-gradient(circle at center, rgba(0,0,0,0) 20%, rgba(0,0,0,0.9) 100%);
    opacity: var(--overlay-opacity); transition: opacity 0.5s ease-in-out;
}

/* --- 顶部工具栏 --- */
.toolbar { position: absolute; top: 20px; right: 20px; z-index: 20; display: flex; gap: 12px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.2); cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    font-size: 20px; transition: all 0.3s; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3); position: relative;
}
.icon-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); }
/* 悬停提示 Tooltip */
.icon-btn::after {
    content: attr(data-title); position: absolute; top: 110%; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.7); color: #fff; padding: 4px 8px; font-size: 12px;
    border-radius: 4px; pointer-events: none; opacity: 0; transition: opacity 0.2s; white-space: nowrap;
}
.icon-btn:hover::after { opacity: 1; }

/* --- 时钟 --- */
#clock {
    font-size: 4rem; font-weight: 300; margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3); color: #fff; z-index: 10;
    font-variant-numeric: tabular-nums; letter-spacing: 2px;
}

/* --- 主容器 --- */
.main-container { width: 100%; max-width: 680px; position: relative; z-index: 10; height: 520px; }

/* 视图层通用样式 (搜索/书签) */
.view-section {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center;
    opacity: 0; transform: scale(0.95) translateY(10px);
    visibility: hidden;
    will-change: opacity, transform;
    transition: opacity 0.4s var(--ease-smooth), transform 0.4s var(--ease-smooth), visibility 0.4s;
    pointer-events: none;
}
.view-section.active { opacity: 1; transform: scale(1) translateY(0); visibility: visible; pointer-events: auto; }

/* --- 搜索框 --- */
.search-box {
    width: 100%; display: flex; height: 54px;
    background: var(--search-bg-idle);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 27px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1); backdrop-filter: blur(15px);
    transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    position: relative; z-index: 50;
}
.search-box:hover, .search-box.focused {
    background: var(--search-bg-active);
    box-shadow: 0 8px 30px rgba(0,0,0,0.2); transform: translateY(-1px);
}

/* 自定义下拉菜单 */
.custom-select { position: relative; width: 110px; height: 100%; border-right: 1px solid rgba(128,128,128,0.15); }
.select-trigger {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-color); font-size: 15px; font-weight: 500; gap: 5px;
}
.select-trigger:hover { color: var(--accent-color); }
.arrow { font-size: 10px; opacity: 0.6; transition: transform 0.3s; }
.custom-select.open .arrow { transform: rotate(180deg); }
.options-list {
    position: absolute; top: 60px; left: 0; width: 100%;
    background: var(--dropdown-bg); border-radius: 12px;
    backdrop-filter: blur(20px); box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    overflow: hidden; display: none; animation: fadeIn 0.2s ease;
}
.custom-select.open .options-list { display: block; }
.option-item {
    padding: 12px 0; text-align: center; cursor: pointer;
    font-size: 14px; color: var(--text-color); transition: background 0.2s;
}
.option-item:hover { background: rgba(128,128,128,0.15); color: var(--accent-color); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 输入框 & 按钮 */
#search-input { flex: 1; border: none; background: transparent; padding: 0 20px; font-size: 18px; color: var(--text-color); outline: none; }
#search-input::placeholder { color: var(--text-color); opacity: 0.5; }
#search-btn {
    border: none; background: transparent; padding-right: 25px; cursor: pointer;
    color: var(--text-color); font-size: 18px; border-radius: 0 27px 27px 0;
    transition: color 0.2s; opacity: 0.7;
}
#search-btn:hover { color: var(--accent-color); opacity: 1; }

/* 联想词 */
.suggestions {
    width: 100%; margin-top: 15px; background: var(--search-bg-active);
    border-radius: 16px; list-style: none; overflow: hidden; display: none;
    backdrop-filter: blur(20px); box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}
.suggestions li { padding: 12px 20px; cursor: pointer; color: var(--text-color); font-size: 15px; }
.suggestions li:hover { background: rgba(128,128,128,0.1); color: var(--accent-color); }

.hint-text { margin-top: 15px; font-size: 13px; opacity: 0.6; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }

/* --- 每日一言 (下沉布局) --- */
#quote-box {
    position: absolute; bottom: -120px; 
    text-align: center; color: #fff; width: 100%;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6); cursor: pointer;
    transition: opacity 0.3s; opacity: 0.9; padding: 15px 0;
}
#quote-box:hover { opacity: 1; }
#quote-text { font-size: 16px; font-weight: 500; margin-bottom: 5px; letter-spacing: 1px; line-height: 1.5; }
#quote-author { font-size: 12px; opacity: 0.8; }

/* --- 书签网格 --- */
#bookmark-view {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 20px; width: 100%; align-content: start;
}
.bookmark-card {
    background: var(--card-bg); backdrop-filter: blur(10px);
    border-radius: 16px; padding: 15px; text-align: center; cursor: pointer;
    transition: transform 0.3s, background 0.3s, box-shadow 0.3s;
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    height: 110px; position: relative; border: 1px solid rgba(255,255,255,0.1);
}
.bookmark-card:hover { transform: translateY(-5px); background: var(--search-bg-active); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.bookmark-icon {
    width: 48px; height: 48px; margin-bottom: 10px;
    background: #fff; border-radius: 50%; 
    display: flex; justify-content: center; align-items: center; overflow: hidden;
    font-size: 28px; line-height: 48px;
}
.bookmark-icon img { width: 100%; height: 100%; object-fit: cover; }
.bookmark-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.add-bookmark-btn { border: 2px dashed var(--text-color); opacity: 0.4; background: transparent; }
.add-bookmark-btn:hover { opacity: 0.8; border-color: var(--accent-color); color: var(--accent-color); }
.add-bookmark-btn .bookmark-icon { background: rgba(255,255,255,0.2); color: var(--text-color); }

.del-btn {
    position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
    background: #ff4d4f; color: white; border-radius: 50%; text-align: center;
    line-height: 22px; font-size: 14px; display: none; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.bookmark-card:hover .del-btn { display: block; }

/* --- 模态框通用样式 --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4); z-index: 1000;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(5px); opacity: 0; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; }
.modal-box {
    background: var(--modal-bg); width: 90%; max-width: 380px;
    padding: 30px; border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    transform: scale(0.9); transition: transform 0.3s var(--ease-out-back);
    color: var(--text-color); position: relative;
}
.modal-overlay.open .modal-box { transform: scale(1); }
.modal-close {
    position: absolute; top: 15px; right: 20px; font-size: 24px; color: #999;
    cursor: pointer; line-height: 1; transition: color 0.2s;
}
.modal-close:hover { color: var(--text-color); }
.modal-title { font-size: 20px; font-weight: bold; margin-bottom: 25px; text-align: center; }
.modal-input {
    width: 100%; padding: 12px 15px; margin-bottom: 15px;
    border: 1px solid var(--input-border); border-radius: 10px;
    background: rgba(128,128,128,0.05); color: var(--text-color); font-size: 16px; outline: none;
    transition: border 0.2s, background 0.2s;
}
.modal-input:focus { border-color: var(--accent-color); background: transparent; }

/* 美化文件上传按钮 */
.upload-hint { font-size:13px; color:#888; margin-bottom:15px; text-align:center; position: relative; }
.custom-file-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; padding: 20px; margin-bottom: 20px;
    border: 2px dashed var(--input-border); border-radius: 10px;
    background: rgba(128,128,128,0.05); color: var(--text-color);
    cursor: pointer; transition: all 0.2s; font-size: 15px; font-weight: 500;
}
.custom-file-btn:hover { border-color: var(--accent-color); color: var(--accent-color); background: rgba(0,123,255,0.05); }

/* --- 核心修改：居中且全宽的确定按钮 --- */
.modal-btns { 
    display: flex; 
    justify-content: center; /* 居中 */
    margin-top: 20px; 
}
.m-btn { 
    padding: 12px 0; border: none; border-radius: 10px; cursor: pointer; 
    font-size: 16px; font-weight: 500; transition: 0.2s; 
}
.m-btn-confirm { 
    width: 100%; /* 全宽 */
    background: var(--accent-color); color: #fff; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); 
}
.m-btn-confirm:hover { 
    filter: brightness(1.1); transform: translateY(-1px); 
    box-shadow: 0 6px 15px rgba(0,0,0,0.3); 
}

/* --- 页脚 --- */
#global-footer {
    position: absolute; bottom: 10px; width: 100%;
    text-align: center; color: rgba(255,255,255,0.7);
    font-size: 12px; z-index: 10;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
#global-footer a { color: inherit; text-decoration: none; transition: color 0.2s; }
#global-footer a:hover { color: #fff; }