:root {
    --primary-color: #16b777;
    --bg-color: #F2F3F5;
    --text-color: #333;
    --text-muted: #666;
    --border-color: #e5e5e5;
    --card-bg: rgba(255, 255, 255, 0.8);
    --header-height: 60px;
    --sidebar-width: 120px;
}

* { box-sizing: border-box; }
html { font-size: 14px; }
body { background: var(--bg-color); margin: 0; padding: 0; min-height: 100vh; }

.iconfont { width: 1em; height: 1em; vertical-align: -0.15em; fill: currentColor; }

.wallpaper {
    position: fixed; top: 0; left: 0; z-index: -1;
    background-position: 50%;
    background-repeat: no-repeat; background-size: cover;
    width: 100%; height: 100vh;
}

header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-height); padding: 10px 15px;
    z-index: 1000; display: flex; align-items: center; justify-content: space-between;
}
.menu-toggle { display: none; font-size: 24px; cursor: pointer; color: #fff; padding: 8px; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.user-avatar-box {
    width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
    cursor: pointer; box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.user-avatar-box img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar-box.grayscale { filter: grayscale(100%); }

.container { max-width: 1020px; margin: 0 auto; padding: calc(var(--header-height) + 20px) 10px 0px; }

.search-box {
    background: var(--card-bg); border-radius: 25px; padding: 5px;
    margin-bottom: 10px; display: flex; align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.search-engine { display: flex; align-items: center; padding: 0 12px; cursor: pointer; position: relative; }
.search-engine img { width: 24px; height: 24px; }
.search-engine .arrow { margin-left: 5px; border: 5px solid transparent; border-top-color: #999; }
.search-input { flex: 1; border: none; outline: none; font-size: 16px; padding: 10px; background: transparent; }
.search-btn { background: var(--primary-color); border: none; border-radius: 20px; padding: 10px 20px; cursor: pointer; }
.search-btn img { width: 20px; height: 20px; }

.engine-list {
    display: none; position: absolute; top: 50px; left: 0; right: 0;
    background: #fff; border-radius: 10px; box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    padding: 10px; z-index: 100; flex-wrap: wrap;
}
.engine-list.show { display: flex; }
.engine-item {
    width: 9.09%; text-align: center; padding: 10px 2px; cursor: pointer; border-radius: 8px; box-sizing: border-box;
}
.engine-item:hover { background: #f5f5f5; }
.engine-item .img {
    width: 42px; height: 42px; margin: 0 auto 6px; background: #f0f0f0; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.engine-item .img img { width: 65%; height: 65%; }
.engine-item .name { font-size: 13px; color: var(--text-muted); line-height: 1.4; }

.su-list {
    display: none; position: absolute; top: 55px; left: 60px; right: 60px;
    background: #fff; border: 1px solid #ddd; border-radius: 0 0 10px 10px; z-index: 99;
}
.su-list .item { padding: 10px 15px; cursor: pointer; font-size: 14px; }
.su-list .item:hover { background: #f5f5f5; }

.top-sites { background: var(--card-bg); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.top-sites-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.site-item { 
    display: flex; align-items: center; padding: 5px 12px; border-radius: 10px; 
    cursor: pointer; text-decoration: none; position: relative;
    min-width: 0; overflow: hidden;
}
.site-item:hover { background: rgba(0,0,0,0.03); }
.site-item .icon { 
    width: 32px; height: 32px; border-radius: 8px; overflow: hidden; 
    background: #f0f0f0; display: flex; align-items: center; justify-content: center; 
    flex-shrink: 0; margin-right: 8px; order: 1;
}
.site-item .icon img { width: 100%; height: 100%; object-fit: cover; }
.site-item .name { 
    font-size: 15px; color: var(--text-color); 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
    flex: 1; order: 2; min-width: 0;
}
.site-item .site-opbtn { display: none; position: absolute; top: 5px; right: 0px; font-size: 16px; color: #bbb; padding: 4px; transform: rotate(90deg); }
.site-item:hover .site-opbtn { display: block; }

.custom-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999999;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 16px 28px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
    min-width: 120px;
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: msgFadeIn 0.2s ease;
}
.custom-msg.success { background: rgba(50, 180, 100, 0.9); }
.custom-msg.error { background: rgba(220, 70, 70, 0.9); }
.custom-msg .msg-icon {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}
@keyframes msgFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.main-layout { display: flex; gap: 10px; }

.sidebar { width: var(--sidebar-width); flex-shrink: 0; }
.sidebar-inner {
    background: var(--card-bg); border-radius: 12px; padding: 10px 0;
    position: sticky; top: calc(var(--header-height) + 20px); max-height: calc(100vh - var(--header-height) - 40px); overflow-y: auto;
}
.cate-item { display: flex; align-items: center; padding: 10px 12px; cursor: pointer; position: relative; }
.cate-item:hover { background: #f7f7f7; }
.cate-item .cateicon { margin-right: 12px; font-size: 16px; display: flex; align-items: center; flex-shrink: 0; }
.cate-item .cateicon .iconfont { width: 16px; height: 16px; }
.cate-item .catename { font-size: 15px; color: #444; flex: 1; font-weight: 500; }
.cate-item .cate-opbtn { display: none; font-size: 12px; color: #999; position: absolute; right: 8px; top: 50%; transform: translateY(-50%) rotate(90deg); padding: 2px; }
.cate-item:hover .cate-opbtn { display: block; }

.mobile-cate-item { 
    display: flex !important; 
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

.content { flex: 1; min-width: 0; }
.cate-block { background: var(--card-bg); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.cate-block .head { padding: 15px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; }
.cate-block .head .catename { font-size: 15px; font-weight: 500; color: #555; }
.cate-block .head .addSiteBtn { color: #aaa; cursor: pointer; }
.cate-block .head .addSiteBtn:hover { color: #888; }

.sites-grid { display: flex; flex-wrap: wrap; padding: 10px; gap: 8px; }
.site-card { 
    display: flex; align-items: center; padding: 5px; border-radius: 8px; 
    cursor: pointer; text-decoration: none; position: relative;
    width: calc(25% - 6px); box-sizing: border-box; 
}
.site-card:hover { background: rgba(255,255,255,0.5); }
.site-card .icon { width: 38px; height: 38px; border-radius: 8px; margin-right: 12px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.site-card .icon img { width: 100%; height: 100%; object-fit: cover; }
.site-card .info { flex: 1; min-width: 0; overflow: hidden; }
.site-card .info .name { font-size: 15px; color: var(--text-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.site-card .info .desc { font-size: 12px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.site-card .site-opbtn { display: none; position: absolute; top: 0px; right: 8px; font-size: 16px; color: #bbb; padding: 4px; }
.site-card:hover .site-opbtn { display: block; }

.layui-layer { max-width: 100% !important; }
.layui-layer-page { min-height: 410px !important; }
.layui-layer-page .layui-layer-content { padding-bottom: 15px !important; }
.resp-modal { padding: 20px 20px 25px 20px; }
.resp-modal .layui-form-item { margin-bottom: 15px; }
.resp-modal .layui-form-label { width: 70px; padding: 9px 10px; text-align: right; }
.resp-modal .layui-input-block { margin-left: 85px; }
.resp-modal .layui-input { height: 40px; line-height: 40px; }
.resp-modal .icon-grid { 
    display: grid; 
    grid-template-columns: repeat(6, 1fr); 
    gap: 8px; 
    max-height: 280px; 
    overflow-y: auto; 
    padding: 10px; 
    background: #f5f5f5; 
    border-radius: 8px; 
    border: 1px solid #e0e0e0;
}
.resp-modal .icon-item { 
    width: 100%; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center; 
    border: 2px solid transparent; border-radius: 6px; 
    cursor: pointer; background: #fff;
}
.resp-modal .icon-item:hover { border-color: #ccc; }
.resp-modal .icon-item.selected, .resp-modal .icon-item.curr { border-color: var(--primary-color); background: #e8f8f0; }
.resp-modal .icon-item .iconfont { width: 20px; height: 20px; }
.resp-modal .btn-group { display: flex; gap: 10px; justify-content: center; margin-top: 15px; }
.resp-modal .btn-group .layui-btn { min-width: 100px; height: 38px; line-height: 38px; }
@media (max-width: 500px) {
    .resp-modal { padding: 15px; }
    .resp-modal .layui-form-label { width: 60px; font-size: 13px; }
    .resp-modal .layui-input-block { margin-left: 75px; }
}

.layui-layer-page:has(.icondiv) { height: auto !important; }

.mobile-sidebar { 
    display: block; position: fixed; top: 0; left: -280px; width: 280px; height: 100%; 
    background: #fff; z-index: 2000; 
    -webkit-transition: left 0.3s ease; transition: left 0.3s ease; 
    overflow-y: auto; padding-top: 60px;
    -webkit-overflow-scrolling: touch;
}
.mobile-sidebar.open { left: 0; }
.mobile-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1999; }
.mobile-overlay.show { display: block; }

.sort-op { display: none; justify-content: center; align-items: center; position: fixed; top: 0; left: 0; width: 100%; height: 60px; background: rgba(255,255,255,0.98); z-index: 99999; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

.totop { background: rgba(255,255,255,0.9); border-radius: 50%; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; position: fixed; bottom: -60px; right: 15px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.1); transition: 0.3s; z-index: 100; }
.totop.show { bottom: 20px; }
.totop .layui-icon { font-size: 20px; color: #888; }

footer { text-align: center; padding: 20px; font-size: 12px; color: #666; }
footer a { color: var(--primary-color); }

@media (max-width: 1024px) {
    .top-sites-grid { grid-template-columns: repeat(4, 1fr); }
    .site-card { width: calc(33.33% - 6px); }
    .sidebar { width: 150px; }
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .sidebar { display: none; }
    .mobile-sidebar { display: block; }
    .top-sites-grid { grid-template-columns: repeat(2, 1fr); }
    .site-item { padding: 8px 10px; }
    .site-item .icon { width: 24px; height: 24px; margin-right: 6px; }
    .site-card { width: calc(50% - 4px); padding: 10px; }
    .site-card .icon { width: 32px; height: 32px; margin-right: 10px; }
    .site-card .info .name { font-size: 13px; }
    .site-card .info .desc { font-size: 11px; }
    .search-box { border-radius: 20px; }
    .engine-item { width: 16.66%; padding: 10px 2px; }
    .engine-item .img { width: 36px; height: 36px; }
    .engine-item .name { font-size: 11px; }
    .site-card .site-opbtn, 
    .site-item .site-opbtn, 
    .cate-item .cate-opbtn,
    .mobile-cate-item .cate-opbtn { 
        display: block !important; 
        opacity: 0.6; 
        top: 8px;
    }
    .layui-layer-page { 
        margin: 0 !important; left: 10px !important; right: 10px !important; 
        width: calc(100% - 20px) !important; max-width: calc(100% - 20px) !important; 
        border-radius: 12px 12px 0 0 !important; 
        height: auto !important;
        max-height: 70vh !important;
    }
    .layui-layer-page .layui-layer-title { padding: 12px 15px !important; font-size: 15px !important; }
    .layui-layer-page .layui-layer-content { padding: 0 !important; max-height: calc(70vh - 50px) !important; overflow-y: auto !important; }
    .resp-modal .layui-form-label { width: 60px; font-size: 13px; }
    .resp-modal .layui-input-block { margin-left: 75px; }
    .resp-modal .icon-grid { max-height: 220px !important; }
    .sort-op { 
        padding: 0 15px !important;
        height: 50px !important;
    }
    .sort-op .layui-btn { 
        height: 32px !important; 
        line-height: 32px !important; 
        padding: 0 15px !important;
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .site-card { width: calc(50% - 4px); }
    .site-card .icon { width: 28px; height: 28px; margin-right: 8px; }
    .site-card .info .name { font-size: 14px; }
    .site-card .info .desc { display: none; }
    .engine-item { width: 16.66%; padding: 8px 1px; }
    .engine-item .img { width: 32px; height: 32px; }
    .engine-item .name { font-size: 13px; }
    .site-item .icon { width: 28px; height: 28px; }
    .site-item .name { font-size: 14px; }
}

.header-spacer { flex: 1; }
.mobile-sidebar-header { padding: 15px; border-bottom: 1px solid #eee; font-weight: 500; background: #fff; }
.mobile-cate-item { display: flex; align-items: center; padding: 14px 15px; border-bottom: 1px solid #f5f5f5; background: #fff; }
.mobile-cate-item .cate-icon-wrap { margin-right: 12px; font-size: 18px; width: 24px; text-align: center; }
.mobile-cate-item .cate-icon-wrap .iconfont { width: 20px; height: 20px; }
.mobile-cate-item .cate-title { font-size: 15px; color: #333; flex: 1; }
.mobile-cate-item .cate-opbtn { padding: 5px; }
.mobile-cate-item .cate-opbtn .layui-icon { font-size: 16px; color: #999; }
.search-box { position: relative; }
.site-initial { color: #999; font-size: 12px; }
.closeSort { margin-left: 20px; }
