/* 全局样式 */
:root {
    --primary-color: #007bff;
    --border-color: #e9ecef;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #333;
    --text-secondary: #6c757d;
    --rank-color-1: #fe2d46;
    --rank-color-2: #f60;
    --rank-color-3: #faa90e;
    --scrollbar-color: #ccc;
    --scrollbar-bg: transparent;
    --news-color-new: #000000;
    --news-color-old: #4f4f4f;
    --news-color-clicked: #b9b9b9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", Helvetica, Tahoma, Arial, "Microsoft YaHei", 微软雅黑, 黑体, Heiti, sans-serif, SimSun, 宋体, serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

html, body {
    scrollbar-width: none; /* Firefox */
}

[hidden] {
    display: none !important;
}

.container {
    /* max-width: 1200px;*/
    margin: 0 auto;
    padding: 0 15px;
}

/* 头部样式 */
.header {
    background-color: var(--primary-color);
    color: white;
    /* 修改：减少了垂直padding */
    padding: 0.5rem 0; 
    text-align: center;
    margin-bottom: 1rem;
}

.header .container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    justify-self: start;
}

.header-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    text-decoration: none;
}

.header-right {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header h1 {
    margin: 0;
    font-size: 1.6rem; /* 适当调小标题字体大小 */
    justify-self: center;
    transform: translateY(-2px);
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    vertical-align: middle;
}

.header-logo {
    width: 32px;
    height: 32px;
    display: inline-block;
}

.header-action-btn {
    box-sizing: border-box;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-size: 1.08rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.header-action-btn .header-icon {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.user-profile {
    position: relative;
    flex-shrink: 0;
}

.user-avatar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    vertical-align: middle;
}

.user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 108px;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    overflow: hidden;
    z-index: 200;
}

.user-menu-item {
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: 0;
    background: transparent;
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
    font-size: 0.92rem;
}

.user-menu-item:hover {
    background: var(--background-color);
}

.user-menu-item:disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
}

.config-dialog {
    width: min(92vw, 560px);
    border: 0;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.config-dialog::backdrop {
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
}

.config-form {
    display: grid;
    gap: 0.9rem;
    padding: 1.25rem;
}

.config-dialog-title {
    margin: 0;
    font-size: 1.15rem;
    color: var(--text-color);
}

.config-field {
    display: grid;
    gap: 0.35rem;
    color: var(--text-color);
    font-size: 0.92rem;
}

.config-required-mark {
    color: #d92d20;
    font-weight: 700;
}

.config-field input,
.config-field select,
.config-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font: inherit;
    color: var(--text-color);
    background: #fff;
}

.config-field textarea {
    resize: vertical;
    min-height: 88px;
}

.config-subfields {
    display: grid;
    gap: 0.9rem;
    padding: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(0, 123, 255, 0.04);
}

.config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.config-btn {
    border: 0;
    border-radius: 999px;
    padding: 0.65rem 1.1rem;
    font: inherit;
    cursor: pointer;
}

.config-btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.config-btn-secondary {
    background: var(--background-color);
    color: var(--text-color);
}

.cards-editing .card-editing {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.cards-editing .card-editing .card-header {
    position: relative;
    /* padding-right: 2.4rem; */
}

.card-header-main {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
}

.card-header-main h2 {
    min-width: 0;
}

.card-title-block {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
}

.card-title-block h2 {
    flex: 1 1 auto;
    min-width: 0;
}

.card-title-link {
    color: inherit;
    text-decoration: none;
    min-width: 0;
    display: block;
}

.card-title-link:hover {
    color: var(--primary-color);
}

.card-title-text {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-update-time {
    display: inline-block;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.25;
    flex-shrink: 0;
}

.card-header-controls {
    display: flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.card-actions {
    position: relative;
    flex-shrink: 0;
}

.card-action-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    letter-spacing: -1px;
}

.card-action-handle:hover,
.card-actions.is-open .card-action-handle {
    background: rgba(0, 123, 255, 0.08);
    color: var(--primary-color);
}

.card-action-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 92px;
    display: grid;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-background);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
    z-index: 50;
}

.card-action-item {
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    padding: 0.45rem 0.65rem;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.card-action-item:hover {
    background: var(--background-color);
}

.card-action-item:disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
}

.card-action-item-danger {
    color: #c62828;
}

.cards-editing .card-editing:active {
    cursor: grabbing;
}

.card.card-dragging {
    opacity: 0.92;
    box-shadow: 0 16px 34px rgba(0,0,0,0.18);
}

.card.card-floating {
    margin: 0;
    transform: scale(1.01);
    cursor: grabbing;
    will-change: left, top;
}

.card.card-placeholder {
    border: 1px dashed rgba(0, 123, 255, 0.45);
    background: rgba(0, 123, 255, 0.07);
    box-shadow: inset 0 0 0 1px rgba(0, 123, 255, 0.08);
}

/* 主内容区域 */
#main-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* 卡片样式 */
.card {
    background-color: var(--card-background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.cards-editing .card:hover {
    transform: none;
}

.card-header {
    display: flex;
    align-items: center;
    /* 修改：减少了padding */
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header img {
    width: 20px; /* 适当调小图标 */
    height: 20px;
    margin-right: 10px;
}

.card-icon-emoji {
    font-size: 20px;
    margin-right: 10px;
    line-height: 1;
}

.card-header h2 {
    margin: 0;
    font-size: 1.1rem; /* 适当调小卡片标题字体 */
}

.card-body {
    padding: 0.5rem;
    max-height: 380px;
    overflow-y: auto;
    flex-grow: 1;
    /* 针对 Firefox */
    scrollbar-color: var(--scrollbar-bg) transparent;
    transition: scrollbar-color 0.3s;
}

.card-body:hover {
    /* 鼠标悬停时显示滚动条 - Firefox */
    scrollbar-color: var(--scrollbar-color) transparent;
}

/* 针对 WebKit 浏览器 (Chrome, Safari) */
.card-body::-webkit-scrollbar {
    width: 8px;
}

.card-body::-webkit-scrollbar-track {
    background: transparent;
}

.card-body::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 10px;
    border: 3px solid transparent;
}

.card-body:hover::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-color);
}


.hotlist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hotlist li {
    display: flex;
    align-items: center;
    /* 修改：减少了列表项的下边距 */
    margin-bottom: 0.5rem; 
    font-size: 0.95rem;
}

.hotlist a {
	line-height: 1.4;
    text-decoration: none;
    color: var(--link-color, var(--text-color));
    transition: color 0.2s, text-decoration-color 0.2s;
    white-space: normal;
}

.hotlist a.news-link-new {
    --link-color: var(--news-color-new);
    color: var(--news-color-new);
}

.hotlist a.news-link-old {
    --link-color: var(--news-color-old);
    color: var(--news-color-old);
}

.hotlist a.news-link-clicked {
    --link-color: var(--news-color-clicked);
    color: var(--news-color-clicked);
}

.hotlist a:hover {
    color: var(--primary-color);
}

.is-card-edit-mode a {
    pointer-events: none;
    cursor: default;
}

.is-card-edit-mode .hotlist a:hover {
    color: var(--link-color, var(--text-color));
}

.rank {
    font-weight: bold;
    font-style: italic;
    font-size: 1rem;
    min-width: 25px;
    text-align: center;
    margin-right: 10px;
    color: var(--text-secondary);
}

/* 前三名排名颜色 */
.rank.rank-1 { color: var(--rank-color-1); }
.rank.rank-2 { color: var(--rank-color-2); }
.rank.rank-3 { color: var(--rank-color-3); }

/* 页脚样式 */
.footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* 移动端样式 - 屏幕宽度小于768px时应用 */
@media (max-width: 768px) {
    body {
        overflow-y: hidden; /* 在移动端禁用垂直滚动 */
    }

    .container {
        padding: 0; /* 移动端不需要内边距 */
    }

    #main-content {
        display: flex; /* 使用 flexbox 进行水平布局 */
        overflow-x: auto; /* 允许水平滚动 */
        scroll-snap-type: x mandatory; /* 强制滚动捕捉 */
        height: 100vh; /* 减去头部和尾部的高度 */
        width: calc(100vw - 1rem);
        padding: 0;
        margin-top: 0.5rem; /* 为固定的头部留出空间 */
        margin-bottom: 0.5rem; /* 为固定的尾部留出空间 */
    }

    .card {
        flex: 0 0 calc(100vw - 1rem); /* 每个卡片占据整个视口宽度 */
        scroll-snap-align: start; /* 滚动时对齐到卡片的开始位置 */
    }

    .card-body {
        max-height: none; /* 移除最大高度限制，使其填充剩余空间 */
    }

    .cards-editing .card-editing {
        cursor: default;
    }
    
    .header {
        padding: 0.5rem 0;
        margin-bottom: 0;
    }

    .header .container {
        padding: 0 8px;
    }

    .user-avatar-btn {
        width: 30px;
        height: 30px;
    }

    .header-action-btn {
        height: 34px;
        min-width: 34px;
        padding: 0;
    }

    .header-logo-link {
        width: 34px;
        height: 34px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .footer {
        position: fixed; /* 固定定位 */
        bottom: 0;
        width: 100%;
        z-index: 100; /* 确保在最上层 */
    }

    .config-dialog {
        width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 2rem);
    }

    .config-form {
        padding: 1rem;
    }
}
/* 新的加载占位符样式 */
.placeholder-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem; /* 与 .hotlist li 保持一致 */
    font-size: 0.95rem;    /* 与 .hotlist li 保持一致 */
}

.rank-placeholder {
    min-width: 25px;       /* 与 .rank 保持一致 */
    height: 1rem;          /* 与 .rank 字体大小接近 */
    margin-right: 10px;    /* 与 .rank 保持一致 */
    background: linear-gradient(to right, #eef0f2 8%, #e0e4e8 18%, #eef0f2 33%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}

.line-placeholder {
    height: 1.2em; /* 与列表项的行高接近 */
    flex-grow: 1;
    background: linear-gradient(to right, #eef0f2 8%, #e0e4e8 18%, #eef0f2 33%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}

/* 为加载条设置不同的随机宽度，更显逼真 */
.placeholder-item:nth-of-type(1) .line-placeholder { width: 90%; }
.placeholder-item:nth-of-type(2) .line-placeholder { width: 95%; }
.placeholder-item:nth-of-type(3) .line-placeholder { width: 85%; }
.placeholder-item:nth-of-type(4) .line-placeholder { width: 92%; }
.placeholder-item:nth-of-type(5) .line-placeholder { width: 88%; }
.placeholder-item:nth-of-type(6) .line-placeholder { width: 93%; }
.placeholder-item:nth-of-type(7) .line-placeholder { width: 89%; }

@keyframes shimmer {
    0% {
        background-position: -600px 0;
    }
    100% {
        background-position: 600px 0;
    }
}