* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 强制思源黑体（Google Fonts 名：Noto Sans SC）；未加载时落到系统无衬线 */
    --font-sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    --font-mono: "Source Code Pro", Menlo, Monaco, Consolas, "Courier New", monospace;
    --primary-color: #ea580c;
    --primary-rgb: 234, 88, 12;
    --secondary-color: #c2410c;
    --accent-warm: #fb923c;
    --success-color: #16a34a;
    --dark-color: #1e293b;
    --light-color: #fff7ed;
    --gray-color: #64748b;
    --border-radius: 8px;
    --box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
    --transition: all 0.2s ease;
}

body {
    font-family: var(--font-sans);
    background: transparent;
    color: var(--dark-color);
    line-height: 1.5;
    padding: 12px;
    min-height: 100vh;
}

/* 暖色底放在 html：若 body 带渐变背景，会盖住固定 .site-bg，随机图会「看不见」 */
html {
    min-height: 100%;
    background: linear-gradient(145deg, #fff7ed 0%, #ffedd5 45%, #fed7aa 100%);
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#root {
    position: relative;
    z-index: 1;
}

code,
kbd,
samp,
pre {
    font-family: var(--font-mono);
}

/* 全屏背景：由 SITE_RANDOM_BG_API 注入；模糊与暖色罩层减轻「AI 人像 + 强玻璃」感 */
.site-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(var(--site-bg-blur, 0px));
    opacity: 0.72;
}

.site-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        165deg,
        rgba(255, 247, 237, 0.45) 0%,
        rgba(255, 237, 213, 0.5) 55%,
        rgba(254, 215, 170, 0.55) 100%
    );
    pointer-events: none;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 16px;
    padding: 10px 0;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 0;
    margin-bottom: 16px;
}

.main-header h1 {
    margin: 0;
    text-align: center;
}

.site-logo-mark {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    line-height: 0;
    -webkit-tap-highlight-color: transparent;
}

.site-logo-mark img {
    display: block;
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.site-logo-mark:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 连点 logo 后的管理入口弹层 */
.admin-unlock-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.admin-unlock-modal.is-open {
    display: flex;
}

.admin-unlock-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.admin-unlock-dialog {
    position: relative;
    width: 100%;
    max-width: 360px;
    padding: 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.admin-unlock-dialog h3 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    color: var(--dark-color);
}

.admin-unlock-hint {
    margin: 0 0 12px;
    font-size: 0.875rem;
    color: var(--gray-color);
}

.admin-unlock-hint code {
    font-size: 0.8em;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

.admin-unlock-error {
    margin: 0 0 10px;
    font-size: 0.875rem;
    color: #dc2626;
}

.admin-unlock-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.admin-unlock-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.22);
}

.admin-unlock-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-unlock-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: var(--dark-color);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
}

.admin-unlock-btn.primary {
    background: var(--primary-color);
    color: #fff;
    border-color: transparent;
}

.admin-unlock-btn:hover {
    filter: brightness(0.97);
}

/* 左上角固定「分类」按钮：不随页面滚动 */
.category-toggle-fixed {
    position: fixed;
    left: 16px;
    top: 16px;
    z-index: 998;
}

body.category-sidebar-open .category-toggle-fixed {
    z-index: 997;
}

.category-toggle-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(var(--primary-rgb), 0.35);
    background: #fff;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 6px rgba(var(--primary-rgb), 0.12);
}

.category-toggle-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.22);
}

/* 分类侧边栏：固定不随页面滚动 */
.category-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

body.category-sidebar-open .category-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

.category-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}

body.category-sidebar-open .category-sidebar {
    transform: translateX(0);
}

body.category-sidebar-open {
    overflow: hidden;
}

.category-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.category-sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark-color);
    margin: 0;
}

.category-sidebar-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--gray-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.category-sidebar-close:hover {
    background: #e2e8f0;
    color: var(--dark-color);
}

.category-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-sidebar-list .category-filter {
    display: block;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    border-radius: 8px;
    font-size: 0.9rem;
}

.category-sidebar-list .category-filter:hover:not(.active) {
    background: #f8fafc;
}


/* 隐藏整个页面的滚动条 */
/* 隐藏Chrome/Safari/Opera滚动条 */
html::-webkit-scrollbar {
    display: none;
}

/* 确保滚动功能正常 */
body {
    /* 允许滚动 */
    overflow-y: scroll;
    /* 防止内容抖动，保持滚动条空间 */
    overflow-x: hidden;
    /* 兼容WebKit内核浏览器 */
    -webkit-overflow-scrolling: touch;
}




h1 {
    font-size: 2.1rem;
    margin-bottom: 6px;
    background: linear-gradient(120deg, var(--secondary-color) 0%, var(--primary-color) 55%, var(--accent-warm) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.subtitle {
    display: none;
}

.web-search-box {
    background: rgba(255, 255, 255, var(--site-glass-opacity, 0.92));
    border-radius: 10px;
    padding: 20px 22px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(var(--primary-rgb), 0.18);
}

#web-search-form {
    width: 100%;
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

#web-search-input {
    flex: 1;
    min-width: 0;
    padding: 14px 16px 14px 44px;
    border: 1px solid rgba(var(--primary-rgb), 0.28);
    border-radius: 10px;
    font-size: 1.05rem;
    transition: var(--transition);
    background: #fffefb;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

#web-search-input::placeholder {
    color: var(--gray-color);
}

#web-search-input:hover {
    border-color: rgba(var(--primary-rgb), 0.45);
    background: #fff;
}

#web-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
    background: #fff;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 18px;
    font-size: 1.35rem;
    color: var(--primary-color);
    opacity: 0.95;
}

.search-select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 0.82rem;
    transition: var(--transition);
    font-weight: 500;
    flex-shrink: 0;
    max-width: 100px;
}

.search-select:hover {
    border-color: var(--primary-color);
}

.search-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

@media (max-width: 768px) {
    .web-search-box {
        padding: 16px 14px;
        margin-bottom: 16px;
    }

    /* 移动端：搜索框与搜索引擎下拉并排同一行（并排 = side-by-side） */
    .search-wrapper {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    #web-search-input {
        flex: 1;
        min-width: 0;
        width: auto;
        padding: 14px 12px 14px 42px;
        font-size: 1rem;
    }

    .search-wrapper .search-icon {
        left: 14px;
        font-size: 1.2rem;
    }

    .search-select {
        width: auto;
        min-width: 72px;
        max-width: 36%;
        padding: 8px 8px;
        font-size: 0.78rem;
    }
}

.add-site-btn {
    background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border: none;
    padding: 9px 18px;
    font-size: 0.95rem;
    border-radius: 10px;
    cursor: pointer;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
    transition: var(--transition);
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.add-site-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.28);
}

.add-site-btn:active {
    transform: translateY(0);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    width: 92%;
    max-width: 560px;
    box-shadow: var(--box-shadow);
    animation: modalOpen 0.35s ease-out;
    overflow: hidden;
}

@keyframes modalOpen {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-modal:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 18px 20px 20px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
}

.form-group textarea {
    min-height: 70px;
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.submit-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 11px 18px;
    font-size: 0.98rem;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: var(--transition);
    margin-top: 6px;
}

.submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.22);
}

.categories-container {
    display: grid;
    gap: 16px;
}

.category-section {
    background: transparent;
    border-radius: var(--border-radius);
    padding: 16px;
    transition: var(--transition);
}

.category-section:hover {
    transform: translateY(-1px);
}

/*
 * 首页 #categories-container 专用：外层 section 已无底色，站内链接卡若仍近乎实白会像「一大条白底板」；
 * Admin 预览区同名 class 无该 id，不会套用。
 */
#categories-container .site-card {
    background: rgba(255, 255, 255, 0.5);
}

#categories-container .site-card:hover {
    background: rgba(255, 255, 255, 0.62);
}

.category-title {
    font-size: 1.2rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    color: var(--dark-color);
    font-weight: 700;
}

.category-title::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 4px;
    margin-right: 10px;
}

.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.site-card {
    background: rgba(255, 255, 255, var(--site-glass-opacity, 0.92));
    border-radius: 8px;
    padding: 14px 10px;
    text-align: center;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 140px;
    text-decoration: none;
    color: var(--dark-color);
    position: relative;
}

/* 卡片右上角点击次数，可与内容重叠 */
.site-card-clicks {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    line-height: 1;
    color: #94a3b8;
    z-index: 2;
    pointer-events: none;
}

/* 图标固定在最上方 */
.site-icon {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.site-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* 中间区域：网站名称+描述，弹性占据剩余空间 */
.site-card-body {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.site-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    flex-shrink: 0;
}

.site-description {
    font-size: 0.75rem;
    color: var(--gray-color);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    flex: 1;
    min-height: 0;
}

/* 标签固定在最下方，不受名称和描述影响 */
.site-tags {
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    justify-content: center;
    overflow: hidden;
}

.site-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    border-color: rgba(var(--primary-rgb), 0.22);
}

.tag {
    background: #ffedd5;
    color: var(--secondary-color);
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--gray-color);
}

.empty-state p {
    margin-top: 8px;
    font-size: 1rem;
}

.empty-state button {
    margin-top: 12px;
}

.top-bar {
    background: rgba(255, 255, 255, var(--site-glass-opacity, 0.92));
    border-radius: var(--border-radius);
    padding: 8px 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--box-shadow);
}

.stats-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.search-container {
    max-width: 560px;
    margin: 0 auto 16px;
    position: relative;
}

.search-container.compact {
    margin: 0;
    max-width: 500px;
    flex: 1;
}

.search-container input {
    width: 100%;
    padding: 9px 16px 9px 36px;
    border-radius: 10px;
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    font-size: 0.93rem;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: var(--transition);
    background: #fffefb;
}

.search-container input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.16);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
    font-size: 1.1rem;
}



.stats-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.stats-item span {
    font-weight: 700;
    color: var(--primary-color);
}

@media (max-width: 1024px) {
    .sites-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.85rem;
    }

    .sites-grid {
        grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .top-bar {
        flex-direction: column;
        gap: 10px;
    }

    .stats-group {
        width: 100%;
        justify-content: space-around;
        flex-wrap: wrap;
        gap: 8px;
    }

    .search-container.compact {
        width: 100%;
        max-width: none;
    }

    .add-site-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sites-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }

    .site-card {
        padding: 10px 6px;
        min-height: 120px;
    }

    .site-icon {
        width: 48px;
        height: 48px;
    }

    .site-icon img {
        width: 36px;
        height: 36px;
    }

    .site-name {
        font-size: 0.85rem;
    }
    
    .site-description {
        font-size: 0.7rem;
    }
    
    .favicon-placeholder {
        font-size: 1.1rem;
    }

    .modal-content {
        width: 96%;
        margin: 16px;
    }

    .add-site-btn {
        padding: 8px 16px;
        font-size: 0.92rem;
    }
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    color: var(--dark-color);
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    transform: translateX(320px);
    transition: transform 0.25s ease;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid #f72585;
}

.toast-icon {
    font-size: 1.2rem;
}

.category-selector {
    display: none;
}

.category-filter {
    padding: 5px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(var(--primary-rgb), 0.18);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.85rem;
}

.category-filter.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.category-filter:hover:not(.active) {
    background: #f8fafc;
    border-color: var(--primary-color);
}

.no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--gray-color);
    grid-column: 1 / -1;
}

.no-results p {
    font-size: 1.05rem;
    margin-top: 12px;
}

.favicon-placeholder {
    background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: bold;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
