/* 历史页面主容器（保持原有合适样式） */
.history-container {
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 15px; /* 缩小间距，避免页面过散 */
}

/* 历史头部（核心修改：手机端横向并排，避免挤压） */
.history-header {
    display: flex;
    flex-direction: row; /* 改为横向排列，满足并排需求 */
    justify-content: space-between; /* 两端对齐，标题左、按钮右，不挤压 */
    align-items: center; /* 垂直居中，视觉更规整 */
    gap: 10px; /* 横向间距，防止标题和按钮紧贴 */
    width: 100%; /* 占满容器宽度，确保两端对齐生效 */
}
.history-title {
    font-size: 22px; /* 手机端缩小标题字体 */
    font-weight: bold;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 1; /* 允许标题轻微收缩（必要时） */
    min-width: 0; /* 允许标题容器收缩，防止溢出 */
    white-space: nowrap; /* 标题不换行 */
    overflow: hidden; /* 极端情况标题过长时隐藏溢出部分 */
    text-overflow: ellipsis; /* 标题过长显示省略号，不挤压按钮 */
}
.history-title::before {
    content: "📜";
    font-size: 20px;
    flex-shrink: 0; /* 图标不收缩，保持固定大小 */
}
.clear-history-btn {
    padding: 6px 12px; /* 手机端缩小按钮内边距 */
    border-radius: 6px;
    border: 1px solid #f87171;
    background: #fff;
    color: #f87171;
    cursor: pointer;
    font-size: 12px; /* 手机端缩小按钮字体 */
    transition: all 0.3s ease;
    flex-shrink: 0; /* 按钮不收缩，防止变形 */
    min-width: 100px; /* 按钮最小宽度，确保文字完整显示 */
    max-width: 120px; /* 限制按钮最大宽度，不占用过多空间 */
    white-space: nowrap; /* 按钮文字不换行 */
}
.clear-history-btn:hover {
    background: #fef2f2;
    transform: translateY(-1px);
}

/* 历史列表容器（保持原有合适样式） */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px; /* 缩小条目间距，适配小屏 */
    width: 100%;
}

/* 历史条目卡片（保留之前修复的继续阅读按钮不挤压样式） */
.history-item {
    padding: 12px 15px; /* 保持原有合适内边距 */
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    border-radius: 8px; /* 保持原有合适圆角 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px; /* 轻微增大内部间距，避免按钮挤压 */
    transition: all 0.2s ease;
    flex-wrap: wrap; /* 极端小屏允许换行，避免错乱 */
}
.history-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.history-item-info {
    flex: 1; /* 占满剩余宽度，确保按钮不挤压文字 */
    min-width: 0; /* 关键：允许文字容器收缩，防止溢出 */
    max-width: calc(100% - 110px); /* 限制文字区最大宽度，给操作区预留空间 */
}
.history-chapter-name {
    font-size: 14px; /* 保持原有合适字体 */
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 文字溢出时显示省略号，不换行 */
}
.history-read-time {
    font-size: 12px; /* 保持原有合适字体 */
    color: #64748b;
}
.history-item-actions {
    display: flex;
    gap: 10px; /* 增大操作区按钮间距，解决继续阅读和删除按钮挤压 */
    align-items: center;
    flex-shrink: 0; /* 按钮容器不收缩，防止错位 */
    min-width: 100px; /* 给操作区设置最小宽度，预留固定空间 */
    justify-content: flex-end; /* 操作区右对齐，视觉更规整 */
}
.goto-read-btn {
    padding: 4px 10px; /* 微调内边距，保持按钮小巧但不拥挤 */
    border-radius: 6px;
    border: none;
    background: linear-gradient(135deg, #e879f9, #6366f1);
    color: #fff;
    cursor: pointer;
    font-size: 12px; /* 保持原有合适字体 */
    transition: all 0.3s ease;
    white-space: nowrap; /* 按钮文字不换行 */
    min-width: 70px; /* 给继续阅读按钮设置最小宽度，防止被压缩变形 */
    text-align: center;
}
.goto-read-btn:hover {
    background: linear-gradient(135deg, #d946ef, #4f46e5);
}
.delete-history-btn {
    padding: 4px; /* 保持原有合适内边距 */
    border-radius: 6px;
    border: none;
    background: #f8fafc;
    color: #f87171;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* 固定删除按钮宽度，防止错乱 */
    height: 24px;
    flex-shrink: 0;
}
.delete-history-btn:hover {
    background: #fef2f2;
}

/* 空历史状态（保持原有合适样式） */
.empty-history {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 15px; /* 手机端减少上下padding，避免页面过长 */
    text-align: center;
    gap: 12px;
    color: #64748b;
}
.empty-history-icon {
    font-size: 50px; /* 手机端缩小图标 */
}
.empty-history-text {
    font-size: 14px; /* 手机端缩小文字 */
}
.empty-history-tip {
    font-size: 12px; /* 手机端缩小提示文字 */
    opacity: 0.8;
    max-width: 280px; /* 限制提示文字宽度，避免换行混乱 */
}

/* 大屏适配（768px以上，保持原有样式） */
@media (min-width: 768px) {
    /* 历史头部大屏样式：保持横向，优化尺寸 */
    .history-header {
        gap: 20px;
    }
    .history-title {
        font-size: 22px;
        overflow: visible; /* 大屏标题不隐藏溢出 */
        text-overflow: unset;
    }
    .clear-history-btn {
        padding: 8px 16px;
        font-size: 14px;
        min-width: 120px;
        max-width: none;
    }

    /* 历史条目大屏样式 */
    .history-container {
        margin: 20px auto;
        padding: 0 15px;
        gap: 20px;
    }
    .history-list {
        gap: 12px;
    }
    .history-item {
        padding: 20px 25px;
        border-radius: 10px;
        gap: 15px;
    }
    .history-item-info {
        max-width: none; /* 大屏取消文字区最大宽度限制 */
    }
    .history-chapter-name {
        font-size: 16px;
    }
    .history-read-time {
        font-size: 13px;
    }
    .history-item-actions {
        gap: 10px;
        min-width: auto; /* 大屏取消操作区最小宽度限制 */
    }
    .goto-read-btn {
        padding: 6px 12px;
        font-size: 13px;
        min-width: auto; /* 大屏取消按钮最小宽度限制 */
    }
    .delete-history-btn {
        padding: 6px;
        width: 28px;
        height: 28px;
    }

    /* 空状态大屏样式 */
    .empty-history {
        padding: 60px 20px;
        gap: 15px;
    }
    .empty-history-icon {
        font-size: 60px;
    }
    .empty-history-text {
        font-size: 16px;
    }
    .empty-history-tip {
        font-size: 14px;
    }
}

/* 超大屏适配（1200px以上） */
@media (min-width: 1200px) {
    .history-list {
        max-width: 800px;
        margin: 0 auto;
    }
}